General Constants

There are three types of constants.

  1. Constructing models, such as optimization directions, constraint senses or variable types.

  2. Accessing solution results, such as API return code, basis status and LP status.

  3. 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:

Table 10 Functions for setting optimization directions

Programming API

Function

C

COPT_SetObjSense

C++

Model::SetObjSense()

C#

Model.SetObjSense()

Java

Model.setObjSense()

Python

Model.setObjSense()

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

    Non-integer continuous variables

  • BINARY

    Binary variables

  • INTEGER

    Integer variables

SOS constraint 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 non-zero value.

  • SOS_TYPE2

    SOS2 constraint

    At most two variables in the constraint are allowed to take non-zero value, and those non-zero variables must be contiguous.

NOTE: Variables in SOS constraints are allowed to be continuous, binary and integer.

Indicator constraint types

Indicator constraint is a kind of logical constraints in COPT, used to describe the relationship between the value of the binary variable \(y\) and whether the linear constraint \(a^{T}x \leq b\) is satisfied. Currently, COPT supports three types of indicator constraints:

  • INDICATOR_IF

    If-Then:

    If \(y=f\) , then the linear constraint \(a^{T}x \leq b\) is satisfied.

    If \(y\ne f\) , then the linear constraint \(a^{T}x \leq b\) is invalid (may be violated).

(7)\[\begin{split}y &= f \rightarrow a^{T}x \leq b\\ f &\in \{0, 1\}\end{split}\]
  • INDICATOR_ONLYIF

    Only-If:

    If the linear constraint \(a^{T}x \leq b\) is satisfied, then \(y=f\) .

    If the linear constraint \(a^{T}x \leq b\) is not satisfied, then \(y\) can be 0 or 1.

(8)\[\begin{split}a^{T}x &\leq b \rightarrow y = f\\ f &\in \{0, 1\}\end{split}\]
  • INDICATOR_IFANDONLYIF

    If-and-Only-If:

    The linear constraint \(a^{T}x \leq b\) and \(y=f\) must be satisfied simultaneously or not satisfied simultaneously.

(9)\[\begin{split}a^{T}x &\leq b \leftrightarrow y = f\\ f &\in \{0, 1\}\end{split}\]

SOC constraint types

The Second-Order-Cone (SOC) constraint is a special type of quadratic constraints. COPT supports two types of SOC constraints:

  • CONE_QUAD : Regular Second-Order-Cone

(10)\[Q^n= \left\{x\in \mathbb{R}^n\ \left|\ x_0\geq\sqrt{\sum_{i=1}^{n-1} x_i^2}, x_0\geq0 \right. \right\}\]
  • CONE_RQUAD : Rotated Second-Order-Cone

(11)\[Q^n_r= \left\{x\in \mathbb{R}^n\ \left|\ 2x_0x_1\geq\sum_{i=2}^{n-1} x_i^2, x_0\geq0, x_1\geq 0 \right. \right\}\]

Exponential Cone type

COPT supports two types of exponential cone contraints:

  • EXPCONE_PRIMAL : Primal exponential cone

(12)\[\mathrm{cl}(S_1) = S_1 \cup S_2\]
(13)\[\begin{split}\begin{aligned} S_1 &= \left\{\begin{pmatrix} t \\ s \\ r \end{pmatrix}\in \mathbb{R}^3\ |\ s > 0,\ t \geq s\ \mathrm{exp}\left(\frac{r}{s} \right) \right\}, \\ S_2 &= \left\{\begin{pmatrix} t \\ s \\ r \end{pmatrix}\in \mathbb{R}^3\ |\ s=0,\ t\geq 0,\ r\leq 0 \right\} \end{aligned}\end{split}\]
  • EXPCONE_DUAL : Dual exponential cone

(14)\[\mathrm{cl}(S_1) = S_1 \cup S_2\]
(15)\[\begin{split}\begin{aligned} S_1 &= \left\{\begin{pmatrix} t \\ s \\ r \end{pmatrix}\in \mathbb{R}^3\ |\ r < 0,\ t \geq -r\ \mathrm{exp}\left(\frac{s}{r}-1\right) \right\}, \\ S_2 &= \left\{\begin{pmatrix} t \\ s \\ r \end{pmatrix}\in \mathbb{R}^3\ |\ r = 0,\ t\geq 0,\ s\geq 0 \right\} \end{aligned}\end{split}\]

Quadratic objective function

Besides linear objective function, COPT also supports general convex quadratic objective function.

The mathematical form is:

(16)\[x^{T}Qx + c^{T}x\]

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, Second-Order-Cone (SOC) constraint, COPT also supports general convex quadratic constraint.

The mathematical form is:

(17)\[x^{T}Qx + q^{T}x \leq b\]

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 non-basic 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:

Table 11 Basis status values and descriptions

Basis status codes

Value

Description

BASIS_LOWER

0

The variable is non-basic at its lower bound

BASIS_BASIC

1

The variable is basic

BASIS_UPPER

2

The variable is non-basic at its upper bound

BASIS_SUPERBASIC

3

The variable is non-basic but not any of its bounds

BASIS_FIXED

4

The variable is non-basic and fixed at its bound

Solution status

Possible solution status values are listed below:

Table 12 Solution Status

Status Codes

Value

Description

UNSTARTED

0

The solving process is not started yet

OPTIMAL

1

Optimal values founded

INFEASIBLE

2

The model is infeasible

UNBOUNDED

3

The objective is unbounded

INF_OR_UNB

4

The model is infeasible or unbounded

NUMERICAL

5

Numerical trouble encountered

NODELIMIT

6

Solving process not finished within node limit

IMPRECISE

7

The solution is imprecise

TIMEOUT

8

Solving process not finished within time limit

UNFINISHED

9

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

INTERRUPTED

10

The solving process is stopped by user interrupt

Notes

  • In the Python API, solution status are defined in COPT’s General Constants Class. They can be accessed via the "COPT." prefix or Model.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 LP-relaxation status of the current node can be obtained through the Callback information "NodeStatus" . The return value is as above, except for NODELIMIT, 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.

Notes:

The client configuration related parameters here are only supported to be set within EnvrConfig .

Callback context

  • CBCONTEXT_INCUMBENT

    Invokes the callback after a new incumbent was found.

  • CBCONTEXT_MIPRELAX

    Invokes the callback when a new LP-relaxation 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 LP-relaxation 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 for each programming language API: