Skip to content

COPT

What it is

COPT (Cardinal Optimizer) from Cardinal Operations is a newer commercial linear, mixed-integer, second-order cone, and semidefinite programming solver. FlexTool writes each solve's model to an MPS file and runs COPT's command-line solver copt_cmd (found on PATH or in ~/copt/bin) on it in a separate process, giving every parameter as a set <ParamName> <value> command. FlexTool never imports coptpy directly.

Official site: https://www.copt.de/ (Cardinal Operations product portal). Also https://www.shanshu.ai/ offers licensing options.

License options

  • Commercial. Cardinal Operations sells perpetual and floating-server licences directly and through resellers.
  • Academic. Free for academic users. Request through the Cardinal Operations academic programme on the official site.
  • Cloud / WLS-style token licences. Cardinal supports floating-licence servers and token discovery, similar to Gurobi's WLS model.
  • Trial / community. A free trial is typically offered; specifics change with release. Check the vendor site.

Installation

Install the Python wrapper:

pip install coptpy

For licensing:

  1. Obtain copt.lic (node-locked) or floating-licence credentials from Cardinal Operations.
  2. Place copt.lic at the path indicated by the vendor installer, or set COPT_LICENSE_DIR to the directory containing it. Refer to the vendor's installation guide for the precise discovery order [FIXME: confirm URL].
  3. Floating-licence users configure the licence server endpoint per the COPT documentation; polar-high accepts a pre-built coptpy.Envr via the env= pass-through.

HiGHS / COPT process-coexistence warning

COPT 8.x ships native code (coptpy.coptcore) that conflicts with highspy when both are loaded into the same Python interpreter: highspy.Highs.run() can segfault once coptpy has been imported.

polar-high auto-detects this situation and transparently routes COPT solves through the MPS-file fallback (HiGHS writes an MPS, the copt_cmd CLI is invoked as a subprocess) so the in-process load does not happen. This requires the standalone copt_cmd binary on PATH. If it is missing, FlexTool surfaces a clear "binary not found" error. The binary ships with the COPT distribution.

In a FlexTool scenario that uses only COPT (no HiGHS solves anywhere in the run), the in-process direct path is used.

Verification

After installing coptpy, run:

python -c "from polar_high.solvers import available_solvers; print(available_solvers)"

Expected: 'copt' appears in the list.

['gurobi', 'cplex', 'xpress', 'copt', 'highs']

To verify the licence works:

python -c "import coptpy as cp; cp.Envr().createModel('test')"

A clean exit (no CoptError) means the licence is found.

Common errors

The error messages below are what FlexTool surfaces as FlexToolUserError. polar-high's COPT adapter classifies licence errors by both numeric errno and message keywords (because the published errno table is not as cleanly documented as Gurobi's).

  • No licence file found. CoptError with errno in the provisional licence range (2, 7, 8, 9) or a message containing "license", "licence", "token", or "expired". FlexTool shows: "Solver 'copt' is installed but its license check failed. Details: ...". Fix by placing copt.lic or setting COPT_LICENSE_DIR.
  • Licence expired. Same FlexTool message family with the vendor's expiry text. Renew through the Cardinal Operations licence portal.
  • Time or node limit reached. A MIP stopped at its time or node limit with a solution is kept with a warning; an LP, or a MIP without a solution, stops the run. See Time and other limits.
  • Objective values. AbsGap is written in unscaled currency; FlexTool scales it to the objective COPT sees (see Time and other limits).
  • copt_cmd not on PATH (HiGHS-coexistence fallback). FlexTool shows: "Solver 'copt' returned an error: ..." with the cause naming the missing binary. Add the COPT distribution's bin directory to PATH, or run COPT solves from a process that does not also use HiGHS.

How to set it in FlexTool

On the solve entity:

solve_advanced.solver         = "copt"
solve_advanced.solver_mip_gap = 0.005
solve_advanced.solver_arguments:
  Presolve   = 1
  LpMethod   = 2
flextool <input_db_url> --solver-time-limit 60 --solver-mip-gap 0.001

--solver-time-limit and --solver-mip-gap reach COPT as TimeLimit 60 and RelGap 0.001, over the solve's solver_mip_gap, its solver_arguments and copt.opt (precedence in Solver selection). Parameter names match without regard to case. --threads (Threads per run in the FlexTool window) sets Threads; without it, Threads in copt.opt or solver_arguments applies. --highs-threads does not change it. BarThreads, SimplexThreads, CrossoverThreads and MipTasks are used as given. The run prints what COPT receives in a Solver args (copt): line before each solve.


Verified install on: [empty]