Architecture

This section contains an overview of the architecture of the solvers API on Python; the classes are similar to the cpp version (shown here) but are split in separate modules.

So far, the publicly available python packages are amplpy-gurobi and amplpy-cplex.

This diagram shows the available classes in three groups:

graph G { size="10,10" layout=fdp subgraph clusterBase { label="base" AMPLModel BaseCallback GenericCallback; } subgraph clusterGurobi { label="amplpy-gurobi" GurobiModel GurobiCallback "Gurobi C entry points" } subgraph clusterCplex { label="amplpy-cplex" CPLEXModel CPLEXCallback "CPLEX C entry points" } clusterBase -- clusterGurobi clusterBase -- clusterCplex }

both amplpy-gurobi and amplpy-cplex contain the base group and the solver-specific classes. In addition to the classes implemented in this library, the modules contain wrappers to the solvers’ native C library functions, useful when implementing a “solver native” usage.

amplpy

If amplpy is installed, importing the modules add the following functions, which help creating the solver APIs objects and, after solving them, importing them back to AMPL:

  • amplpy.AMPL.exportGurobiModel

  • amplpy.AMPL.exportCplexModel

  • amplpy.AMPL.exportModel(drivername)

  • amplpy.AMPL.importSolution(AMPLModel)