GurobiModel#

class amplpy_gurobi.GurobiModel#

Store an in-memory representation of a gurobi model, which can be constructed by loading it from an NL file. It also contains two-way mappings between solver column and row numbers and AMPL entity names. It inherits all the members from ampls.AMPLModel and adds the following:

getIntAttr(name: str)#

Get an integer model attribute (using gurobi C library name)

getDoubleAttr(name: str)#

Get a double model attribute (using gurobi C library name)

getIntAttrVector(name: str) list#

Get an integer array model attribute (using gurobi C library name)

getDoubleAttrVector(name: str)#

Get a double array model attribute (using gurobi C library name)

getIntParam(name: str)#

Get an integer parameter (using gurobi C library name)

getDoubleParam(name: str)#

Get a double parameter (using gurobi C library name)

setParam(name: str)#

Set a integer parameter (using gurobi C library name)

getGRBmodel() GRBmodel#

Get the pointer to the native C GRBmodel structure.

getGRBenv() GRBenv#

Get the pointer to the native C GRBenv structure.

GurobiCallback#

class amplpy_gurobi.GurobiModel#

Base class for Gurobi callbacks, inherit from this to declare a callback to be called at various stages of the solution process. Provides all mapping between solver-specific and generic values. To implement a callback, you should implement the run() method and set it via :py:method:`ampls.AMPLModel.setCallback` before starting the solution process via :py:method:`ampls.AMPLModel.optimize`. Depending on where the callback is called from, you can obtain various information about the progress of the optimization and can modify the behaviour of the solver.

It implements all the methods in ampls.GenericCallback and adds the following:

getCBData()#

Get CBdata, useful for calling gurobi c library functions.

getGRBModel()#

Get the underlying gurobi model pointer

terminate()#

Terminate the solution.

getInt(what: int)#

Get an integer attribute (using gurobi C library enumeration to specify what)

getDouble(what: int)#

Get a double attribute (using gurobi C library enumeration to specify what)

getDoubleArray(what: int)#

Get a double array attribute (using gurobi C library enumeration to specify what)