COPT#
Cardinal Optimizer (COPT) incorporates a full suite of solvers for linear, (non-)convex quadratic, second-order and exponential conic mixed-integer programming. It ranks at the top of benchmark tests on continuous linear programs, and has been fully extended to handle integer variables. The driver is built on the MP library, which reformulates logical and other expressions that the solver does not accept natively.
Product Page | Modeling guide | Features | Options | Changes
Download COPT | Start a COPT Trial Now!
How to use it#
How to install using amplpy:
# Install Python API for AMPL:
$ python -m pip install amplpy --upgrade
# Install AMPL & solver modules:
$ python -m amplpy.modules install copt # install COPT
# Activate your license (e.g., free ampl.com/ce or ampl.com/academia licenses):
$ python -m amplpy.modules activate <your-license-uuid>
How to use:
from amplpy import AMPL
ampl = AMPL()
...
ampl.solve(solver="copt", copt_options="option1=value1 option2=value2")
Learn more about what we have to offer to implement and deploy Optimization in Python.
AMPL APIs give access to AMPL from a programming language:
AMPLS (AMPL solver libraries) load an AMPL model
into the solver in C++ or Python and give direct access to the solver’s
own API, for example for callbacks. Python packages: amplpy-gurobi,
amplpy-cplex, amplpy-xpress, amplpy-copt.
ampl: option solver copt; # change the solver
ampl: option copt_options 'option1=value1 option2=value2'; # specify options
ampl: solve; # solve the problem
Resources#
Features#
Problem types and algorithms#
Problem types
LP, (non-)convex QP, (non-)convex QCP, conic programs (SOCP, exponential cones)
MILP, (non-)convex MIQP, (non-)convex MIQCP, mixed-integer conic programs
NLP (local)
MINLP (approximated)
Received natively: indicator constraints, SOS, quadratic constraints,
second-order (also rotated) and exponential cones. With acc:_expr=1, also
abs and all nonlinear functions, as expressions; by default they are
approximated piecewise-linearly.
All constructs: native constraints and expressions by driver.
LP: simplex, barrier, PDLP
alg:method: -1 automatic (default), 1 dual simplex, 2 barrier,
4 concurrent, 5 simplex or barrier, 6 first-order (PDLP). GPU for
barrier and PDLP: alg:gpumode (CUDA, Windows and Linux).
MIP and nonconvex quadratic models: branch-and-cut
Relative gap: mip:gap. For continuous nonconvex quadratic models,
alg:nonconvex: -1 default (as of COPT 8 a local search), 1 local,
2 global. Nonlinear functions other than quadratic are
approximated piecewise-linearly
by default, which allows approximate solving of MINLP.
Nonlinear models: local
With acc:_expr=1, nonlinear functions (exp, log, trigonometric,
powers, divisions) are passed to COPT natively as expressions, and its
barrier returns a locally optimal solution (solve_result solved?,
message “locally optimal solution”); on a nonconvex model, different
starting points can give different local optima. For the continuous
relaxation of an MINLP, add alg:relax=1. With the default acc:_expr=0,
these functions are approximated piecewise-linearly instead.
ampl.solve(solver="copt", copt_options="acc:_expr=1 outlev=1") # local NLP
print(ampl.solve_result, ampl.get_value("solve_message"))
ampl: option solver copt;
ampl: option copt_options 'acc:_expr=1 outlev=1'; # local NLP
ampl: solve;
Instrumentation#
For a generic summary of the options and features used most often, see Important features in the MP documentation.
For all models
Model export
Option tech:writemodel. Details
Solution export
Option tech:writesolution. Details
Feasibility relaxation
Option alg:feasrelax. Details
Irreducible inconsistent subset (IIS)
Option iis:find. Details
Method: iis:method.
Basis input and output
Option alg:basis. Details
Multiple solutions
Option sol:stub. Details
Multiple objectives
Option obj:multi. Details
Sensitivity analysis
Option alg:sens. Details
Unbounded rays and Farkas certificates
Option alg:rays. Details
Warm start
Option alg:start. Details
For MIP models
Fixed model (duals and basis for a MIP)
Option mip:basis. Details
Lazy constraints and user cuts
Option mip:lazy. Details
MIP gap
Option mip:return_gap. Details
Best dual bound
Option mip:bestbound. Details
Solver options#
Full list of solver options:
More details on solver options: MP solver options.
Retrieving solutions#
The outcome of the last optimization is stored in the AMPL parameter solve_result_num and the relative message in
solve_result.
display solve_result_num, solve_result;
COPT solve result codes can be obtained by running copt -! or ampl: shell "copt -!";:
Solve result table for COPT 8.0.6
0- 99 solved: optimal for an optimization problem,
feasible for a satisfaction problem
100-199 solved? solution candidate returned but error likely
150 solved? MP solution check failed (option sol:chk:fail)
200-299 infeasible
300-349 unbounded, feasible solution returned
350-399 unbounded, no feasible solution returned
400-449 limit, feasible: stopped, e.g., on iterations or Ctrl-C
450-469 limit, problem is either infeasible or unbounded.
Disable dual reductions or run IIS finder for definitive answer.
470-499 limit, no solution returned
500-999 failure, no solution returned
550 failure: numeric issue, no feasible solution
For general information, see MP result codes guide.
Changelog#
- COPT Changelog
- 20261029
- 20260813
- 20260624
- 20260610
- 20260609
- 20260414
- 20260322
- 20260108
- 20251210
- 20251121
- 20251021
- 20251015
- 20250814
- 20250801
- 20250617
- 20250429
- 20250424
- 20250408
- 20250407
- 20250329
- 20250308
- 20241228
- 20240724
- 20240617
- 20240604
- 20240531
- 20240529
- 20240429
- 20240410
- 20240320
- 20240115
- 20231117
- 20231103
- 20231017
- 20230919
- 20230831
- 20230817
- 20230726
- 20230724
- 20230621
- 20230616
- 20230428
- 20230424
- 20230330
- 20230207
- 20221228
- 20221222
- 20221211
- 20230207
- 20221012
- 20220928
- 20220715
- 20220615
- 20220526
- 20220511
- 20220411