Try our new documentation site (beta).
Filter Content By
Version
Text Search
${sidebar_list_label} - Back
Filter by Language
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
, you'd do:
m.Params.timeLimit = 100.0The case of the parameter name is actually ignored, as are underscores, so you could also do:
m.Params.timelimit = 100.0...or...
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