General Constants
There are three types of constants.
Constructing models, such as optimization directions, constraint senses or variable types.
Accessing solution results, such as API return code, basis status and LP status.
Monitoring optimization progress, such as callback context.
Version information
VERSION_MAJOR
The major version number.
VERSION_MINOR
The minor version number.
VERSION_TECHNICAL
The technical version number.
Optimization directions
For different optimization scenarios, it may be required to either maximize or minimize the objective function. There are two optimization directions:
MINIMIZE
For minimizing the objective function.
MAXIMIZE
For maximizing the objective function.
The optimization direction is automatically set when reading in a problem from file. Besides, COPT provides relevant functions, allowing user to explicitly set. Functions for different APIs are listed below:
Programming API 
Function 

C 

C++ 

C# 

Java 

Python 

NOTE: The function names, calling methods and parameter names in different programming interfaces are slightly different. For details, please refer to the API parameters of each programming language.
Infinity and Undefined Value
Infinity
In COPT, the infinite bound is represented by a large value, whose default value is also available as a constant:
INFINITY
The default value (
1e30
) of the infinite bound.
Undefined Value
In COPT, the undefined value is represented by another large value. For example, the default solution value of MIP start is set to a constant:
UNDEFINED
Undefined value(
1e40`
).
Constraint senses
Traditionally, for optimization models, constraints are defined using senses. The most common constraint senses are:
LESS_EQUAL
For constraint in the form of \(g(x) \leq b\)
GREATER_EQUAL
For constraint in the form of \(g(x) \geq b\)
EQUAL
For constraint in the form of \(g(x) = b\)
In additional, there are two less used constraint senses:
FREE
For unconstrained expression
RANGE
For constraints with both lower and upper bounds in the form of \(l \leq g(x) \leq u\).
NOTE: Using constraint senses is supported by COPT but not recommended. We recommend defining constraints using explicit lower and upper bounds.
Variable types
Variable types are used for defining whether a variable is continuous or integral.
CONTINUOUS
Noninteger continuous variables
BINARY
Binary variables
INTEGER
Integer variables
SOSconstraint types
SOS constraint (Special Ordered Set) is a kind of special constraint that places restrictions on the values that a set of variables can take. COPT currently support two types of SOS constraints:
SOS_TYPE1
SOS1 constraint
At most one variable in the constraint is allowed to take a nonzero value.
SOS_TYPE2
SOS2 constraint
At most two variables in the constraint are allowed to take nonzero value, and those nonzero variables must be contiguous.
NOTE: Variables in SOS constraints are allowed to be continuous, binary and integer.
Indicator constraint
Indicator constraint is a kind of logical constraints, is uses a binary variable \(y\) as the indicator variable, and implies whether the linear constraint \(a^{T}x \leq b\) is valid based on value of variable \(y\). The canonical form of an indicator constraint is:
Where \(f \in \{0, 1\}\). If \(y = f\), the linear constraint is valid. Otherwise if \(y \neq f\), the linear constraint is invalid (may be violated). The sense of the linear constraint can be \(\leq\), \(\geq\) and \(=\).
SecondOrderCone constraint
The SecondOrderCone (SOC) constraint is a special type of quadratic constraints. Currently, COPT supports two types of SOC constraints:
CONE_QUAD
: Regular cone
CONE_RQUAD
: Rotated cone
Quadratic objective function
Besides linear objective function, COPT also supports general convex quadratic objective function.
The mathematical form is:
Where, \(x\) is an array of variables, \(Q\) is the quadratic part of the quadratic objective funtion and \(c\) is the linear part.
Quadratic constraint
Besides the special type of quadratic constraint, SecondOrderCone (SOC) constraint, COPT also supports general convex quadratic constraint.
The mathematical form is:
Where, \(x\) is an array of variables, \(Q\) is the quadratic part of the quadratic constraint and \(c\) is the linear part.
Basis status
For an LP problem with \(n\) variables and \(m\) constraints, the constraints are treated as slack variables internally, resulting in \(n+m\) variables. When solving an LP problem using the simplex method, the simplex method fixes \(n\) variables at one of their bounds, and then computes solutions for the other \(m\) variables. The \(m\) variables with computed solution are called basic variables, and the other \(n\) variables are called nonbasic variables. The simplex progress and its final solution can be defined using the basis status of all the variables and constraints. The basis status supported by COPT are listed below:
Basis status codes 
Value 
Description 


0 
The variable is nonbasic at its lower bound 

1 
The variable is basic 

2 
The variable is nonbasic at its upper bound 

3 
The variable is nonbasic but not any of its bounds 

4 
The variable is nonbasic and fixed at its bound 
Solution status
The solution status of an problem is called solution status, Possible solution status values are listed below:
Status Codes 
Description 


The solving process is not started yet 

Optimal values founded 

The model is infeasible 

The objective is unbounded 

The model is infeasible or unbounded 

Numerical trouble encountered 

Solving process not finished within node limit 

Solving process not finished within time limit 

The solving process is stopped but solver cannot provide a solution because of numerical issues 

The solution is imprecise 

The solving process is stopped by user interrupt 
Notes
In the Python API, solution states are defined in COPT’s General Constants Class. They can be accessed via the
"COPT."
prefix orModel.status
;In the Constant class of the Java API and C# API, the constants about the solution status are defined in the
Status
class;The linear programming solution status can be obtained through the attribute
"LpStatus"
, and the integer programming solution status can be obtained through the attribute"MipStatus"
.The LPrelaxation status of the current node can be obtained through the Callback information
"NodeStatus"
. The return value is as above, except forNODELIMIT
,UNSTARTED
,INF_OR_UNB
.
Client configuration
For floating and cluster clients, user are allowed to set client configuration parameters, currently available settings are:
CLIENT_CLUSTER
IP address of cluster server.
CLIENT_FLOATING
IP address of token server.
CLIENT_PASSWORD
Password of cluster server.
CLIENT_PORT
Connection port of token server.
CLIENT_WAITTIME
Wait time of client.
Callback context
CBCONTEXT_MIPRELAX
Invokes the callback when a new LPrelaxation solution is found.
CBCONTEXT_MIPSOL
Invokes the callback when a new MIP candidate solution is found.
CBCONTEXT_MIPNODE
Invokes the callback when a MIP node is finished and LPrelaxation has been solved.
Methods for accessing constants
In different programming interfaces, the ways of accessing constants are slightly different. In the C language interface, the constant name is prefixed with "COPT_"
(like COPT_MAXIMIZE
). For details, please refer to the corresponding chapters of each programming language API reference manual:
C API: C API Reference: Constants
C++ API: C++ API Reference: Constants
Java API: Java API Reference: General Constants
Python API: Python API Reference: General Constants