5
$\begingroup$

I use pyscipopt. I know how to add constraints while branching using handlers (kind of), but now I want also to change some parameters. I imagine is similar, but couldn’t found an example.

What I want is as follows: -Every time a feasible node is found (or every 10 nodes) update a parameter.

How do I do this? Are there examples or documentation on this?

$\endgroup$

1 Answer 1

1
$\begingroup$

To do this, I believe you need to create an event handler that gets called whenever a new feasible node is found. There are many kinds of events, see here for all the SCIP_EVENTTYPE's. For the feasible node, you would want SCIP_EVENTTYPE_NODEFEASIBLE.

I don't know how to create custom events (like the every 10 nodes you mention), but you can always keep a tracker of the last time the parameter was changed and only execute the event handler whenever you want.

When executing this event, you then just change the parameters. Here is a sample code that should hopefully help you out:

from pyscipopt import Model, SCIP_EVENTTYPE, Eventhdlr

class changeParam(Eventhdlr):

    def __init__(self, model):
        self.model = model

    def eventinit(self):
        self.model.catchEvent(SCIP_EVENTTYPE.NODEFEASIBLE, self) # the LP/pseudo solution of the node was feasible

    def eventexec(self, event):
        self.model.setParams(....)

model = Model()
model.includeEventhdlr(changeParams, "Parameter changing Eventhdlr", "Event Handler for changing parameters every feasible node.") 

Let me know if this helps!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.