AMPL

class amplpy.AMPL

Represents an instance of the AMPL interpreter in the AMPLAPI for Python. When importing one of the ampls modules, the following functions are added:

exportGurobiModel(options: list = None)

Export the current model as a GurobiModel. At this stage it is possible to pass normal AMPL solver options to the solver driver, as listed by calling the AMPL solver with the `-=` parameter. Example: ampl.exportGurobiModel(["outlev=1", "return_mipgap=5"]

Parameters

options (list, optional) – A list of options as specified to the AMPL solver driver

Returns

the current model instance

Return type

amplpy_gurobi.GurobiModel

exportCplexModel(options: list = None)

Export the current model as a CPLEXModel. At this stage it is possible to pass normal AMPL solver options to the solver driver, as listed by calling the AMPL solver with the `-=` parameter. Example: ampl.exportCplexModel(["outlev=1", "return_mipgap=5"]

Parameters

options (list, optional) – A list of options as specified to the AMPL solver driver

Returns

the current model instance

Return type

amplpy_cplex.CPLEXModel

exportModel(drivername: str, options: list = None)

Export the current model as an ampls model. Currently the string can have the values gurobi or cplex, and the return type will vary accordingly.

Parameters
  • drivername (string) – The name of the solver to export the model to (gurobi or cplex)

  • options (list, optional) – A list of options as specified to the AMPL solver driver

importSolution(model: ampls.AMPLModel)

Import the solution represented by the AMPL model.