Python Parameter Examples

Python Parameter Examples

In the Python interface, parameters are listed as constants within the GRB.Param class. You would refer to the Threads parameter as GRB.Param.Threads.

To modify a parameter, you can set the appropriate member of Model.params. To set the time limit for model <span>$</span>m<span>$</span>, you'd do:

  m.params.timeLimit = 100.0
The case of the parameter name is actually ignored, as are underscores, so you could also do:
  m.params.timelimit = 100.0
  m.params.TIME_LIMIT = 100.0

You can also use the Model.setParam method:

  m.setParam(GRB.Param.TimeLimit, 100.0)

If you'd prefer to use a string for the parameter name, you can also do:

  m.setParam("TimeLimit", 100.0);

To query the current value of a parameter, use:

  currentlimit = m.params.timeLimit