Modeling overview and implemented solvers#

Solvers built with AMPL’s MP library (ampl/mp) accept a much wider range of model expressions than a solver’s own API: you write the model the way you think about it, and MP passes each construct to the solver natively where the solver supports it, and reformulates it otherwise.

What MP handles, with details in Expressions supported:

  • conditional and logical constraints: if-then-else, ==>, or, and, exists, forall;

  • counting and constraint-programming constructs: count, atmost, atleast, exactly, numberof, alldiff, !=;

  • piecewise-linear functions, abs, min, max;

  • rounding and integer division: floor, ceil, round, trunc, div, mod;

  • nonlinear functions and products, second-order and exponential cones;

  • complementarity (complements) and set membership (in; being reworked, see Set membership operator);

  • multiple objectives (Multiple objectives).

Solver classes. What happens to a construct depends on the solver:

Class

MP-based drivers

What MP does

Linear and mixed-integer

Gurobi, CPLEX, Xpress, COPT, HiGHS, SCIP, MOSEK, CBC, GCG, cuOpt

Logic becomes indicator or general constraints where the solver has them, big-M rows otherwise; other nonlinear functions are approximated piecewise-linearly.

Conic

MOSEK, COPT, Gurobi, Xpress, CPLEX, SCIP

Recognizes second-order and exponential cones from their algebraic form (Second-order cone programming (SOCP)).

Global nonlinear

Gurobi, Xpress, SCIP, BARON (baronmp); COPT solves nonlinear models locally (acc:_expr=1)

Passes nonlinear functions as expression trees (Flat constraints vs expression trees).

Constraint programming

CP-SAT (integer models)

Receives logic, counting, alldiff, products, div and mod natively. The same AMPL constructs are reformulated for MIP solvers, so a constraint-programming model can also be solved by any MIP solver.

Any NL solver

MP2NL (e.g. Knitro, Ipopt, Couenne, BARON)

Applies MP’s reformulations, then calls the NL solver.

Each solver’s page on AMPL Development (linked above) summarizes the problem types and expressions it receives natively, its algorithms and options. The exact list for an installed driver is in its acceptance options (<solver> -=acc:), and compared across drivers in native constructs by driver; other features are compared in Support by solvers. Binaries are available through the AMPL Portal.

Where to read next: Choosing between formulations (choosing between formulations), Efficiency considerations and Numerical accuracy (writing models that solve well), Tools & details (reformulation options, exploring what the solver receives, solution check, MP2NL), and Troubleshooting. Small modeling tasks are covered in the MP Modeling Series.