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

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:

(7)\[y = f \rightarrow a^{T}x \leq b\]

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 \(=\).

Second-Order-Cone constraint

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

  • CONE_QUAD : Regular cone

(8)\[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 cone

(9)\[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\}\]

Quadratic objective function

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

The mathematical form is:

(10)\[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:

(11)\[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

The solution status of an problem is called solution status, Possible solution status values are listed below:

Table 12 Solution Status

Status Codes

Description

UNSTARTED

The solving process is not started yet

OPTIMAL

Optimal values founded

INFEASIBLE

The model is infeasible

UNBOUNDED

The objective is unbounded

INF_OR_UNB

The model is infeasible or unbounded

NUMERICAL

Numerical trouble encountered

NODELIMIT

Solving process not finished within node limit

TIMEOUT

Solving process not finished within time limit

UNFINISHED

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

IMPRECISE

The solution is imprecise

INTERRUPTED

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 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 of each programming language API reference manual: