5

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?

SecretAgentMan
  • 1,895
  • 2
  • 13
  • 39
orpanter
  • 517
  • 3
  • 10

1 Answers1

0

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!

J. Dionisio
  • 534
  • 2
  • 14