Try our new documentation site (beta).


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
...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

Try Gurobi for Free

Choose the evaluation license that fits you best, and start working with our Expert Team for technical guidance and support.

Evaluation License
Get a free, full-featured license of the Gurobi Optimizer to experience the performance, support, benchmarking and tuning services we provide as part of our product offering.
Academic License
Gurobi supports the teaching and use of optimization within academic institutions. We offer free, full-featured copies of Gurobi for use in class, and for research.
Cloud Trial

Request free trial hours, so you can see how quickly and easily a model can be solved on the cloud.

Search

Gurobi Optimization