C API Reference
The Cardinal Optimizer provides a C API library for advanced usage.
This section documents all the COPT constants,
API functions, parameters and attributes listed in copt.h.
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.
Optimization directions
For different optimization scenarios, it may be required to either maximize or minimize the objective function. There are two optimization directions:
COPT_MINIMIZEFor minimizing the objective function.
COPT_MAXIMIZEFor maximizing the objective function.
The optimization direction is automatically
set when reading in a problem from file.
It can also be set explicitly using COPT_SetObjSense.
Infinity
In COPT, the infinite bound is represented by a large value,
which can be set using the double parameter
COPT_DBLPARAM_INFBOUND,
whose default value is also available as a constant:
COPT_INFINITYThe 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:
COPT_UNDEFINEDUndefined value(
1e40`).
Constraint senses
NOTE: Using constraint senses is supported by COPT but not recommended. We recommend defining constraints using explicit lower and upper bounds.
Traditionally, for optimization models, constraints are defined using senses. The most common constraint senses are:
COPT_LESS_EQUALFor constraint in the form of \(g(x) \leq b\)
COPT_GREATER_EQUALFor constraint in the form of \(g(x) \geq b\)
COPT_EQUALFor constraint in the form of \(g(x) = b\)
In additional, there are two less used constraint senses:
COPT_FREEFor unconstrained expression
COPT_RANGEFor constraints with both lower and upper bounds in the form of \(l \leq g(x) \leq u\).
Please refer to documentation of
COPT_LoadProbregarding how to useCOPT_RANGEto define a constraints with both lower and upper bounds.
Variable types
Variable types are used for defining whether a variable is continuous or integral.
COPT_CONTINUOUSNon-integer continuous variables
COPT_BINARYBinary variables
COPT_INTEGERInteger 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, one is SOS1 constraint, where at most one variable in the constraint is allowed to take a non-zero value, the other is SOS2 constraint, where at most two variables in the constraint are allowed to take non-zero value, and those non-zero variables must be contiguous. Variables in SOS constraints are allowed to be continuous, binary and integer.
COPT_SOS_TYPE1SOS1 constraint
COPT_SOS_TYPE2SOS2 constraint
Indicator constraint
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:
COPT_INDICATOR_IFIf-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).
COPT_INDICATOR_ONLYIFOnly-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.
COPT_INDICATOR_IFANDONLYIFIf-and-Only-If:
The linear constraint \(a^{T}x \leq b\) and \(y=f\) must be satisfied simultaneously or not satisfied simultaneously.
SOC constraint type
The Second-Order-Cone (SOC) constraint is a special type of quadratic constraints. COPT supports two types of SOC constraints:
COPT_CONE_QUAD: Regular Second-Order-Cone
COPT_CONE_RQUAD: Rotated Second-Order-Cone
Exponential cone constraint type
COPT supports two types of exponential cone contraints:
COPT_EXPCONE_PRIMAL: Primal exponential cone
COPT_EXPCONE_DUAL: Dual exponential 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, Second-Order-Cone (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 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:
COPT_BASIS_LOWERThe variable is non-basic at its lower bound.
COPT_BASIS_BASICThe variable is basic.
COPT_BASIS_UPPERThe variable is non-basic at its upper bound.
COPT_BASIS_SUPERBASICThe variable is non-basic but not any of its bounds.
COPT_BASIS_FIXEDThe variable is non-basic and fixed at its bound.
LP solution status
The solution status of an LP problem is called LP status,
which can be obtained using integer attribute
COPT_INTATTR_LPSTATUS.
Possible LP status values are:
COPT_LPSTATUS_UNSTARTEDThe LP optimization is not started yet.
COPT_LPSTATUS_OPTIMALThe LP problem is solved to optimality.
COPT_LPSTATUS_INFEASIBLEThe LP problem is infeasible.
COPT_LPSTATUS_UNBOUNDEDThe LP problem is unbounded.
COPT_LPSTATUS_NUMERICALNumerical trouble encountered.
COPT_LPSTATUS_TIMEOUTThe LP optimization is stopped because of time limit.
COPT_LPSTATUS_UNFINISHEDThe LP optimization is stopped but the solver cannot provide a solution because of numerical difficulties.
COPT_LPSTATUS_IMPRECISEThe solution is imprecise.
COPT_LPSTATUS_INTERRUPTEDThe LP optimization is stopped by user interrupt.
COPT_LPSTATUS_ITERLIMITThe LP optimization is stopped because of iteration limit.
MIP solution status
The solution status of an MIP problem is called MIP status,
which can be obtained using integer attribute
COPT_INTATTR_MIPSTATUS.
Possible MIP status values are:
COPT_MIPSTATUS_UNSTARTEDThe MIP optimization is not started yet.
COPT_MIPSTATUS_OPTIMALThe MIP problem is solved to optimality.
COPT_MIPSTATUS_INFEASIBLEThe MIP problem is infeasible.
COPT_MIPSTATUS_UNBOUNDEDThe MIP problem is unbounded.
COPT_MIPSTATUS_INF_OR_UNBThe MIP problem is infeasible or unbounded.
COPT_MIPSTATUS_NODELIMITThe MIP optimization is stopped because of node limit.
COPT_MIPSTATUS_TIMEOUTThe MIP optimization is stopped because of time limit.
COPT_MIPSTATUS_UNFINISHEDThe MIP optimization is stopped but the solver cannot provide a solution because of numerical difficulties.
COPT_MIPSTATUS_INTERRUPTEDThe MIP optimization is stopped by user interrupt.
Callback context
CBCONTEXT_INCUMBENTInvokes the callback after a new incumbent was found.
COPT_CBCONTEXT_MIPNODEInvokes the callback after a MIP node was processed.
COPT_CBCONTEXT_MIPRELAXInvokes the callback when an LP-relaxation was solved.
COPT_CBCONTEXT_MIPSOLInvokes the callback when a new MIP candidate solution is found.
Nonlinear Expression Operators
COPT_NL_PLUSAddition operator.
COPT_NL_MINUSSubtraction operator.
COPT_NL_MULTMultiplication operator.
COPT_NL_DIVDivision operator.
COPT_NL_POWPower operator.
COPT_NL_SQRTSquare root operator.
COPT_NL_EXPExponential function operator.
COPT_NL_LOGNatural logarithm operator.
COPT_NL_LOG10Base-10 logarithm operator.
COPT_NL_NEGUnary negation operator.
COPT_NL_ABSAbsolute value operator.
COPT_NL_FLOORFloor function operator.
COPT_NL_CEILCeiling function operator.
COPT_NL_SINSine function operator.
COPT_NL_COSCosine function operator.
COPT_NL_TANTangent function operator.
COPT_NL_SINHHyperbolic sine function operator.
COPT_NL_COSHHyperbolic cosine function operator.
COPT_NL_TANHHyperbolic tangent function operator.
COPT_NL_ASINInverse sine (arcsin) function operator.
COPT_NL_ACOSInverse cosine (arccos) function operator.
COPT_NL_ATANInverse tangent (arctan) function operator.
COPT_NL_ASINHInverse hyperbolic sine (arsinh) function operator.
COPT_NL_ACOSHInverse hyperbolic cosine (arcosh) function operator.
COPT_NL_ATANHInverse hyperbolic tangent (artanh) function operator.
COPT_NL_ATAN2Two-argument inverse tangent function operator.
COPT_NL_SUMSummation operator.
COPT_NL_GETConstant retrieval operator.
API function return code
When an API function finishes, it returns an integer return code, which indicates whether the API call was finished okay or failed. In case of failure, it specifies the reason of the failure.
Possible COPT API function return codes are:
COPT_RETCODE_OKThe API call finished successfully.
COPT_RETCODE_MEMORYThe API call failed because of memory allocation failure.
COPT_RETCODE_FILEThe API call failed because of file input or output failure.
COPT_RETCODE_INVALIDThe API call failed because of invalid data.
COPT_RETCODE_LICENSEThe API call failed because of license validation failure. In this case, further information can be obtained by calling
COPT_GetLicenseMsg.COPT_RETCODE_INTERNALThe API call failed because of internal error.
COPT_RETCODE_THREADThe API call failed because of thread error.
COPT_RETCODE_SERVERThe API call failed because of remote server error.
COPT_RETCODE_NONCONVEXThe API call failed because of problem is nonconvex.
COPT_RETCODE_MEMORY_GPUThe API call failed because of GPU memory allocation failure.
Client configuration
For floating and cluster clients, users are allowed to set client configuration parameters, currently available settings are:
COPT_CLIENT_CLUSTERIP address of cluster server.
COPT_CLIENT_FLOATINGIP address of token server.
COPT_CLIENT_PASSWORDPassword of cluster server.
COPT_CLIENT_PORTConnection port of token server.
COPT_CLIENT_WAITTIMEWait time of client.
Other constants
COPT_BUFFSIZEDefines the recommended buffer size when obtaining a C-style string message from COPT library. This can be used with, for example,
COPT_GetBanner,COPT_GetRetcodeMsgetc.
Attributes
Problem information
COPT_INTATTR_COLSor"Cols"Integer attribute.
Number of variables (columns) in the problem.
COPT_INTATTR_PSDCOLSor"PSDCols"Integer attribute.
Number of PSD variables in the problem.
COPT_INTATTR_ROWSor"Rows"Integer attribute.
Number of constraints (rows) in the problem.
COPT_INTATTR_ELEMSor"Elems"Integer attribute.
Number of non-zero elements in the coefficient matrix.
COPT_INTATTR_QELEMSor"QElems"Integer attribute.
Number of non-zero quadratic elements in the quadratic objective function.
COPT_INTATTR_PSDELEMSor"PSDElems"Integer attribute.
Number of PSD terms in objective function.
COPT_INTATTR_SYMMATSor"SymMats"Integer attribute.
Number of symmetric matrices in the problem.
COPT_INTATTR_BINSor"Bins"Integer attribute.
Number of binary variables.
COPT_INTATTR_INTSor"Ints"Integer attribute.
Number of integer variables.
COPT_INTATTR_SOSSor"Soss"Integer attribute.
Number of SOS constraints.
COPT_INTATTR_CONESor"Cones"Integer attribute.
Number of Second-Order-Cone constraints.
COPT_INTATTR_EXPCONESor"ExpCones"Integer attribute.
Number of exponential cone constraints.
COPT_INTATTR_AFFINECONESor"AffineCones"Integer attribute.
Number of affine cone constraints.
COPT_INTATTR_QCONSTRSor"QConstrs"Integer attribute.
Number of quadratic constraints.
COPT_INTATTR_PSDCONSTRSor"PSDConstrs"Integer attribute.
Number of PSD constraints.
COPT_INTATTR_LMICONSTRSor"LMIConstrs"Integer attribute.
Number of LMI constraints.
COPT_INTATTR_INDICATORSor"Indicators"Integer attribute.
Number of indicator constraints.
COPT_INTATTR_OBJSENSEor"ObjSense"Integer attribute.
The optimization direction.
COPT_DBLATTR_OBJCONSTor"ObjConst"Double attribute.
The constant part of the objective function.
COPT_INTATTR_HASQOBJor"HasQObj"Integer attribute.
Whether the problem has quadratic objective function.
COPT_INTATTR_HASPSDOBJor"HasPSDObj"Integer attribute.
Whether the problem has PSD terms in objective function.
COPT_INTATTR_ISMIPor"IsMIP"Integer attribute.
Whether the problem is a MIP.
COPT_INTATTR_NLELEMSor"NLElems"Integer attribute.
The number of nonlinear expression terms in the objective of the model.
COPT_INTATTR_NLCONSTRSor"NLConstrs"Integer attribute.
The number of nonlinear expression constraints in the model.
COPT_INTATTR_HASNLOBJor"HasNLObj"Integer attribute.
Indicates whether the model has nonlinear expressions in the objective.
COPT_INTATTR_MULTIOBJSor"MultiObjs"Integer attribute.
The number of objectives in a multi-objective model.
Solution information
COPT_INTATTR_LPSTATUSor"LpStatus"Integer attribute.
The LP status. Please refer to Constants: LP solution status for possible values.
COPT_INTATTR_MIPSTATUSor"MipStatus"Integer attribute.
The MIP status. Please refer to Constants: MIP solution status for possible values.
COPT_INTATTR_SIMPLEXITERor"SimplexIter"Integer attribute.
Number of simplex iterations performed.
COPT_INTATTR_BARRIERITERor"BarrierIter"Integer attribute.
Number of barrier iterations performed.
COPT_INTATTR_NODECNTor"NodeCnt"Integer attribute.
Number of explored nodes.
COPT_INTATTR_POOLSOLSor"PoolSols"Integer attribute.
Number of solutions in solution pool.
COPT_INTATTR_TUNERESULTSor"TuneResults"Integer attribute.
Number of parameter tuning results
COPT_INTATTR_HASLPSOLor"HasLpSol"Integer attribute.
Whether LP solution is available.
COPT_INTATTR_HASBASISor"HasBasis"Integer attribute.
Whether LP basis is available.
COPT_INTATTR_HASDUALFARKASor"HasDualFarkas"Integer attribute.
Whether the dual Farkas of an infeasible LP problem is available.
COPT_INTATTR_HASPRIMALRAYor"HasPrimalRay"Integer attribute.
Whether the primal ray of an unbounded LP problem is available.
COPT_INTATTR_HASMIPSOLor"HasMipSol"Integer attribute.
Whether MIP solution is available.
COPT_INTATTR_IISCOLSor"IISCols"Integer attribute.
Number of bounds of columns in IIS.
COPT_INTATTR_IISROWSor"IISRows"Integer attribute.
Number of rows in IIS.
COPT_INTATTR_IISSOSSor"IISSOSs"Integer attribute.
Number of SOS constraints in IIS.
COPT_INTATTR_IISINDICATORSor"IISIndicators"Integer attribute.
Number of indicator constraints in IIS.
COPT_INTATTR_HASIISor"HasIIS"Integer attribute.
Whether IIS is available.
COPT_INTATTR_HASFEASRELAXSOLor"HasFeasRelaxSol"Integer attribute.
Whether feasibility LP-relaxation solution is available.
COPT_INTATTR_ISMINIISor"IsMinIIS"Integer attribute.
Whether the computed IIS is minimal.
COPT_INTATTR_HASSENSITIVITYor"HasSensitivity"Integer attribute.
Whether sensitivity analysis results are available for LP problem.
COPT_DBLATTR_LPOBJVALor"LpObjval"Double attribute.
The LP objective value.
COPT_DBLATTR_BESTOBJor"BestObj"Double attribute.
Best integer objective value for MIP.
COPT_DBLATTR_BESTBNDor"BestBnd"Double attribute.
Best bound for MIP.
COPT_DBLATTR_BESTGAPor"BestGap"Double attribute.
Best relative gap for MIP.
COPT_DBLATTR_FEASRELAXOBJorFeasRelaxObjDouble attribute.
Feasibility relaxation objective value.
COPT_DBLATTR_SOLVINGTIMEor"SolvingTime"Double attribute.
The time spent for the optimization (in seconds).
Information
Problem information
COPT_DBLINFO_OBJor"Obj"Double information.
Objective cost of columns.
COPT_DBLINFO_LBor"LB"Double information.
Lower bounds of columns or rows.
COPT_DBLINFO_UBor"UB"Double information.
Upper bounds of columns or rows.
Solution and sensitivity analysis information
COPT_DBLINFO_VALUEor"Value"Double information.
Solution of columns.
COPT_DBLINFO_SLACKor"Slack"Double information.
Solution of slack variables, also known as activities of constraints. Only available for LP problem.
COPT_DBLINFO_DUALor"Dual"Double information.
Solution of dual variables. Only available for LP problem.
COPT_DBLINFO_REDCOSTor"RedCost"Double information.
Reduced cost of columns. Only available for LP problem.
COPT_DBLINFO_SAOBJLOWor"SAObjLow"Double information.
Sensitivity analysis information of the objective coefficient.
Indicates the minimum value to which the objective coefficient of a variable can be reduced while keeping the current basis optimal.
COPT_DBLINFO_SAOBJUPor"SAObjUp"Double information.
Sensitivity analysis information of the objective coefficient.
Indicates the maximum value to which the objective coefficient of a variable can be increased while keeping the current basis optimal.
COPT_DBLINFO_SALBLOWor"SALBLow"Double information.
Sensitivity analysis information of the lower bound of the variable/constraint.
Indicates the minimum value to which the lower bound of the variable/constraint can be reduced while keeping the current basis optimal.
COPT_DBLINFO_SALBUPor"SALBUp"Double information.
Sensitivity analysis information of the lower bound of the variable/constraint.
Indicates the maximum value to which the lower bound of the variable/constraint can be increased while keeping the current basis optimal.
COPT_DBLINFO_SAUBLOWor"SAUBLow"Double information.
Sensitivity analysis information of the upper bound of the variable/constraint.
Indicates the minimum value to which the upper bound of the variable/constraint can be reduced while keeping the current basis optimal.
COPT_DBLINFO_SAUBUPor"SAUBUp"Double information.
Sensitivity analysis information of the upper bound of the variable/constraint.
Indicates the maximum value to which the upper bound of the variable/constraint can be increased while keeping the current basis optimal.
Dual Farkas and primal ray
Advanced topic. When an LP is infeasible or unbounded, the solver can return the dual Farkas or primal ray to prove it.
COPT_DBLINFO_DUALFARKASor"DualFarkas"Double information.
The dual Farkas for constraints of an infeasible LP problem. Please enable the parameter
"ReqFarkasRay"to ensure that the dual Farkas is available when the LP is infeasible.Without loss of generality, the concept of the dual Farkas can be conveniently demonstrated using an LP problem with general variable bounds and equality constraints: \(Ax = 0 \text{ and } l \leq x \leq u\). When the LP is infeasible, a dual Farkas vector \(y\) can prove that the system has conflict that \(\max y^TAx < y^T b = 0\). Computing \(\max y^TAx\): with the vector \(\hat{a} = y^TA\), choosing variable bound \(x_i = l_i\) when \(\hat{a}_i < 0\) and \(x_i = u_i\) when \(\hat{a}_i > 0\) gives the maximal possible value of \(y^TAx\) for any \(x\) within their bounds.
Some application relies on the alternate conflict \(\min \bar{y}^TAx > \bar{y}^T b = 0\). This can be achieved by negating the dual Farkas, i.e. \(\bar{y}=-y\) returned by the solver.
In very rare cases, the solver may fail to return a valid dual Farkas. For example when the LP problem slightly infeasible by tiny amount, which We recommend to study and to repair the infeasibility using FeasRelax instead.
COPT_DBLINFO_PRIMALRAYor"PrimalRay"Double information.
The primal ray for variables of an unbounded LP problem. Please enable the parameter
"ReqFarkasRay"to ensure that the primal ray is available when an LP is unbounded.For a minimization LP problem in the standard form: \(\min c^T x, Ax = b \text{ and } x \geq 0\), a primal ray vector \(r\) satisfies that \(r \geq 0, Ar = 0 \text{ and } c^T r < 0\).
Feasibility relaxation information
COPT_DBLINFO_RELAXLBor"RelaxLB"Double information.
Feasibility relaxation values for lower bounds of columns or rows.
COPT_DBLINFO_RELAXUBor"RelaxUB"Double information.
Feasibility relaxation values for upper bounds of columns or rows.
COPT_DBLINFO_RELAXVALUEor"RelaxValue"Double information.
Solutions for the original model variables (columns) in the feasibility relaxation model.
Callback information
COPT_CBINFO_BESTOBJor"BestObj"Double information.
Current best objective.
COPT_CBINFO_BESTBNDor"BestBnd"Double information.
Current best objective bound.
COPT_CBINFO_HASINCUMBENTor"HasIncumbent"Integer information.
Whether an incumbent is available.
COPT_CBINFO_INCUMBENTor"Incumbent"Double information.
Current best feasible solution.
COPT_CBINFO_MIPCANDIDATEor"MipCandidate"Double information.
Current feasible solution candidate.
COPT_CBINFO_MIPCANDOBJor"MipCandObj"Double information.
Objective value for current feasible solution candidate.
COPT_CBINFO_RELAXSOLUTIONor"RelaxSolution"Double information.
Current solution of LP-relaxation.
COPT_CBINFO_RELAXSOLOBJor"RelaxSolObj"Double information.
Current objective of LP-relaxation.
COPT_CBINFO_NODESTATUSor"NodeStatus"Integer information.
The solution status of the LP-relaxation problem at the current node.
For possible values, please refer to: General Constants Chapter: Solution Status (Part), except for
NODELIMIT,UNSTARTED,INF_OR_UNB.
Parameters
Limits and tolerances
COPT_DBLPARAM_TIMELIMITor"TimeLimit"Double parameter.
Time limit of the optimization.
Default: 1e20
Minimal: 0
Maximal: 1e20
COPT_DBLPARAM_SOLTIMELIMITor"SolTimeLimit"Double parameter.
Time limit if a primal feasible solution has been found.
Default: 1e20
Minimal: 0
Maximal: 1e20
COPT_INTPARAM_NODELIMITor"NodeLimit"Integer parameter.
Node limit of the optimization.
Default: -1
Minimal: -1
Maximal:
INT_MAXCOPT_INTPARAM_BARITERLIMITor"BarIterLimit"Integer parameter.
Iteration limit of barrier method.
Default: 500
Minimal: 0
Maximal:
INT_MAXCOPT_DBLPARAM_MATRIXTOLor"MatrixTol"Double parameter.
Input matrix coefficient tolerance.
Default: 1e-10
Minimal: 0
Maximal: 1e-7
COPT_DBLPARAM_FEASTOLor"FeasTol"Double parameter.
The feasibility tolerance.
Default: 1e-6
Minimal: 1e-9.
Maximal: 1e-4
COPT_DBLPARAM_DUALTOLor"DualTol"Double parameter.
The tolerance for dual solutions and reduced cost.
Default: 1e-6
Minimal: 1e-9
Maximal: 1e-4
COPT_DBLPARAM_INTTOLor"IntTol"Double parameter.
The integrality tolerance for variables.
Default: 1e-6
Minimal: 1e-9
Maximal: 1e-1
COPT_DBLPARAM_RELGAPor"RelGap"Double parameter.
The relative gap of optimization.
Default: 1e-4
Minimal: 0
Maximal:
DBL_MAXCOPT_DBLPARAM_ABSGAPor"AbsGap"Double parameter.
The absolute gap of optimization.
Default: 1e-6
Minimal: 0
Maximal:
DBL_MAX
Presolving and scaling
COPT_INTPARAM_PRESOLVEor"Presolve"Integer parameter.
Level of presolving before solving a model.
Default: -1
Possible values:
-1: Automatic
0: Off
1: Fast
2: Normal
3: Aggressive
COPT_INTPARAM_SCALINGor"Scaling"Integer parameter.
Whether to perform scaling before solving a problem.
Default: -1
Possible values:
-1: Choose automatically.
0: No scaling.
1: Apply scaling.
COPT_INTPARAM_DUALIZEor"Dualize"Integer parameter.
Whether to dualize a problem before solving it.
Default: -1
Possible values:
-1: Choose automatically.
0: No dualizing.
1: Dualizing the problem.
Multi-objective Optimization
COPT_DBLPARAM_MULTIOBJTIMELIMITor"MultiObjTimeLimit"Double parameter.
Time limit (in seconds) for solving a multi-objective model.
Default 1e20
Minimum 0
Maximum 1e20
COPT_INTPARAM_MULTIOBJPARAMMODEor"MultiObjParamMode"Integer parameter.
Parameter usage mode for the model of each objective in multi-objective optimization.
Default 0
Possible values
0: Use the global solver parameters for all multi-objective models
1: Use the solver parameters specific to each multi-objective model.
Other parameters
COPT_INTPARAM_LOGGINGor"Logging"Integer parameter.
Whether to print optimization logs.
Default: 1
Possible values:
0: No optimization logs.
1: Print optimization logs.
COPT_INTPARAM_LOGLEVELor"LogLevel"Integer parameter.
Controls the level of detail in the optimization logs.
Default: 2
Possible values:
2: Print basic optimization logs.
3: Print memory usage information in addition to basic optimization logs (for MIP problems).
COPT_INTPARAM_LOGTOCONSOLEor"LogToConsole"Integer parameter.
Whether to print optimization logs to console.
Default: 1
Possible values:
0: No optimization logs to console.
1: Print optimization logs to console.
API Functions
The documentations for COPT API functions are grouped by their purposes.
All the return values of COPT API functions are integers, and possible return values are documented in the constants section.
Creating the environment and problem
COPT_CreateEnvConfig
Synopsis
int COPT_CreateEnvConfig(copt_env_config **p_config)Description
Create a COPT client configuration.
Arguments
p_configOutput pointer to COPT client configuration.
COPT_DeleteEnvConfig
Synopsis
int COPT_DeleteEnvConfig(copt_env_config **p_config)Description
Delete COPT client configuration.
Arguments
p_configInput pointer to COPT client configuration.
COPT_SetEnvConfig
Synopsis
int COPT_SetEnvConfig(copt_env_config *config, const char *name, const char *value)Description
Set COPT client configuration.
Arguments
configCOPT client configuration.
nameName of configuration parameter.
valueValue of configuration parameter.
COPT_CreateEnv
Synopsis
int COPT_CreateEnv(copt_env **p_env)Description
Creates a COPT environment.
Calling this function is the first step when using the COPT library. It validates the license, and when the license is okay, the resulting environment variable will allow for creating COPT problems. When the license validation fails, more information can be obtained using
COPT_GetLicenseMsgto help identify the issue.Arguments
p_envThe output pointer to a variable holding COPT environment.
COPT_CreateEnvWithPath
Synopsis
int COPT_CreateEnvWithPath(const char *licDir, copt_env **p_env)Description
Creates a COPT environment, directory of license files is specified by argument
licDir.Calling this function is the first step when using the COPT library. It validates the license, and when the license is okay, the resulting environment variable will allow for creating COPT problems. When the license validation fails, more information can be obtained using
COPT_GetLicenseMsgto help identify the issue.Arguments
licDirDirectory of license files.
p_envOutput pointer to a variable holding COPT environment.
COPT_CreateEnvWithConfig
Synopsis
int COPT_CreateEnvWithConfig(copt_env_config *config, copt_env **p_env)Description
Creates a COPT environment, client configuration is specified by argument
config.Calling this function is the first step when using the COPT library. It validates the client configuration, and when the license is okay, the resulting environment variable will allow for creating COPT problems. When the license validation fails, more information can be obtained using
COPT_GetLicenseMsgto help identify the issue.Arguments
configClient configuration.
p_envOutput pointer to a variable holding COPT environment.
COPT_DeleteEnv
Synopsis
int COPT_DeleteEnv(copt_env **p_env)Description
Deletes the COPT environment created by
COPT_CreateEnv.Arguments
p_envInput pointer to a variable holding COPT environment.
COPT_GetLicenseMsg
Synopsis
int COPT_GetLicenseMsg(copt_env *env, char *buff, int buffSize)Description
Returns a C-style string regarding the license validation information. Please refer to this function when
COPT_CreateEnvfails.Arguments
envThe COPT environment.
buffA buffer for holding the resulting string.
buffSizeThe size of the above buffer.
COPT_CreateProb
Synopsis
int COPT_CreateProb(copt_env *env, copt_prob **p_prob)Description
Creates an empty COPT problem.
Arguments
envThe COPT environment.
p_probOutput pointer to a variable holding the COPT problem.
COPT_CreateCopy
Synopsis
int COPT_CreateCopy(copt_prob *src_prob, copt_prob **p_dst_prob)Description
Create a deep-copy of an COPT problem.
Note: The parameter settings will be copied too. To solve the copied problem with different parameters, users should reset its parameters to default by calling
COPT_ResetParamfirst, and then set parameters as needed.Arguments
src_probThe pointer to a varialbe hoding the COPT problem to be copied.
p_dst_probOutput pointer to a variable hodling the copied COPT problem.
COPT_ClearProb
Synopsis
int COPT_ClearProb(copt_prob *prob)Description
Clear COPT problem data (excluding callback function).
Arguments
probCOPT problem.
COPT_DeleteProb
Synopsis
int COPT_DeleteProb(copt_prob **p_prob)Description
Deletes the COPT problem created using
COPT_CreateProbArguments
p_probInput pointer to a variable holding the COPT problem.
Building and modifying a problem
COPT_LoadProb
Synopsis
int COPT_LoadProb(
copt_prob *prob,
int nCol,
int nRow,
int iObjSense,
double dObjConst,
const double *obj,
const int *colMatBeg,
const int *colMatCnt,
const int *colMatIdx,
const double *colMatElem,
const char *colType,
const double *colLower,
const double *colUpper,
const char *rowSense,
const double *rowBound,
const double *rowUpper,
char const *const *colNames,
char const *const *rowNames)Description
Loads a problem defined by arrays.
Arguments
probThe COPT problem.
nColNumber of variables (coefficient matrix columns).
nRowNumber of constraints (coefficient matrix rows).
iObjSenseThe optimization sense, either
COPT_MAXIMIZEorCOPT_MINIMIZE.
dObjConstThe constant part of the objective function.
objObjective coefficients of variables.
colMatBeg, colMatCnt, colMatIdxandcolMatElemDefines the coefficient matrix in compressed column storage (CCS) format. Please see other information for an example of the CCS format.
If
colMatCntisNULL,colMatBegwill need to have length ofnCol+1, and the begin and end pointers to the i-th matrix column coefficients are defined usingcolMatBeg[i]andcolMatBeg[i+1].If
colMatCntis provided, the begin and end pointers to the i-th column coefficients are defined usingcolMatBeg[i]andcolMatBeg[i] + colMatCnt[i].
colTypeTypes of variables.
If
colTypeisNULL, all variables will be continuous.
colLowerandcolUpperLower and upper bounds of variables.
If
colLowerisNULL, lower bounds will be 0.If
colUpperisNULL, upper bounds will be infinity.
rowSenseSenses of constraint.
Please refer to the list of all senses constants for all the supported types.
If
rowSenseisNULL, thenrowBoundandrowUpperwill be treated as lower and upper bounds for constraints. This is the recommended method for defining constraints.If
rowSenseis provided, thenrowBoundandrowUpperwill be treated as RHS and range for constraints. In this case,rowUpperis only required when there areCOPT_RANGEconstraints, where thelower bound is
rowBound[i] - fabs(rowUpper[i])upper bound is
rowBound[i]
rowBoundLower bounds or RHS of constraints.
rowUpperUpper bounds or range of constraints.
colNamesandrowNamesNames of variables and constraints. Can be
NULL.Other information
The compressed column storage (CCS) is a common format for storing sparse matrix. We demonstrate how to store the example matrix with 4 columns and 3 rows in the CCS format.
// Compressed column storage using colMatBeg
colMatBeg[5] = { 0, 1, 3, 5, 6};
colMatIdx[6] = { 0, 0, 1, 1, 2, 2};
colMatElem[6] = {1.1, 1.2, 2.2, 2.3, 3.3, 3.4};
// Compressed column storage using both colMatBeg and colMatCnt.
// The * in the example represents unused spaces.
colMatBeg[4] = { 0, 1, 5, 7};
colMatCnt[4] = { 1, 2, 2, 1};
colMatIdx[6] = { 0, 0, 1, 1, 2, *, *, 2};
colMatElem[6] = {1.1, 1.2, 2.2, 2.3, 3.3, *, *, 3.4};
COPT_AddCol
Synopsis
int COPT_AddCol(
copt_prob *prob,
double dColObj,
int nColMatCnt,
const int *colMatIdx,
const double *colMatElem,
char cColType,
double dColLower,
double dColUpper,
const char *colName)Description
Adds one variable (column) to the problem.
Arguments
probThe COPT problem.
dColObjThe objective coefficient of the variable.
nColMatCntNumber of non-zero elements in the column.
colMatIdxRow index of non-zero elements in the column.
colMatElemValues of non-zero elements in the column.
cColTypeThe type of the variable.
dColLoweranddColUpperThe lower and upper bounds of the variable.
colNameThe name of the variable. Can be
NULL.
COPT_AddPSDCol
Synopsis
int COPT_AddPSDCol(copt_prob *prob, int colDim, const char *name)Description
Add a PSD variable to the problem.
Arguments
probThe COPT problem.
colDimDimension of new PSD variable.
nameName of new PSD variable. Can be
NULL.
COPT_AddRow
Synopsis
int COPT_AddRow(
copt_prob *prob,
int nRowMatCnt,
const int *rowMatIdx,
const double *rowMatElem,
char cRowSense,
double dRowBound,
double dRowUpper,
const char *rowName)Description
Adds one constraint (row) to the problem.
Arguments
probThe COPT problem.
nRowMatCntNumber of non-zero elements in the row.
rowMatIdxColumn index of non-zero elements in the row.
rowMatElemValues of non-zero elements in the row.
cRowSenseThe sense of the row.
Please refer to the list of all senses constants for all the supported types.
If
cRowSenseis 0, thendRowBoundanddRowUpperwill be treated as lower and upper bounds for the constraint. This is the recommended method for defining constraints.If
cRowSenseis provided, thendRowBoundanddRowUpperwill be treated as RHS and range for the constraint. In this case,dRowUpperis only required whencRowSense = COPT_RANGE, wherelower bound is
dRowBound - dRowUpperupper bound is
dRowBound
dRowBoundLower bound or RHS of the constraint.
dRowUpperUpper bound or range of the constraint.
rowNameThe name of the constraint. Can be
NULL.
COPT_AddCols
Synopsis
int COPT_AddCols(
copt_prob *prob,
int nAddCol,
const double *colObj,
const int *colMatBeg,
const int *colMatCnt,
const int *colMatIdx,
const double *colMatElem,
const char *colType,
const double *colLower,
const double *colUpper,
char const *const *colNames)Description
Adds
nAddColvariables (columns) to the problem.Arguments
probThe COPT problem.
nAddColNumber of new variables.
colObjObjective coefficients of new variables.
colMatBeg, colMatCnt, colMatIdxandcolMatElemDefines the coefficient matrix in compressed column storage (CCS) format. Please see other information of
COPT_LoadProbfor an example of the CCS format.
colTypeTypes of new variables.
colLowerandcolUpperLower and upper bounds of new variables.
If
colLowerisNULL, lower bounds will be 0.If
colUpperisNULL, upper bounds will beCOPT_INFINITY.
colNamesNames of new variables. Can be
NULL.
COPT_AddPSDCols
Synopsis
int COPT_AddPSDCols(copt_prob *prob, int nAddCol, const int* colDims, char const *const *names)Description
Add
nAddColPSD variables to the problem.Arguments
probThe COPT problem.
nAddColNumber of new PSD variables.
colDimsDimensions of new PSD variables.
namesNames of new PSD variables. Can be
NULL.
COPT_AddRows
Synopsis
int COPT_AddRows(
copt_prob *prob,
int nAddRow,
const int *rowMatBeg,
const int *rowMatCnt,
const int *rowMatIdx,
const double *rowMatElem,
const char *rowSense,
const double *rowBound,
const double *rowUpper,
char const *const *rowNames)Description
Adds
nAddRowconstraints (rows) to the problem.Arguments
probThe COPT problem.
nAddRowNumber of new constraints.
rowMatBeg, rowMatCnt, rowMatIdxandrowMatElemDefines the coefficient matrix in compressed row storage (CRS) format. The CRS format is similar to the CCS format described in the other information of
COPT_LoadProb.
rowSenseSenses of new constraints.
Please refer to the list of all senses constants for all the supported types.
If
rowSenseisNULL, thenrowBoundandrowUpperwill be treated as lower and upper bounds for constraints. This is the recommended method for defining constraints.If
rowSenseis provided, thenrowBoundandrowUpperwill be treated as RHS and range for constraints. In this case,rowUpperis only required when there areCOPT_RANGEconstraints, where thelower bound is
rowBound[i] - fabs(rowUpper[i])upper bound is
rowBound[i]
rowBoundLower bounds or RHS of new constraints.
rowUpperUpper bounds or range of new constraints.
rowNamesNames of new constraints. Can be
NULL.
COPT_AddSOSs
Synopsis
int COPT_AddSOSs(
copt_prob *prob,
int nAddSOS,
const int *sosType,
const int *sosMatBeg,
const int *sosMatCnt,
const int *sosMatIdx,
const double *sosMatWt)Description
Add
nAddSOSSOS constraints to the problem. IfsosMatWtisNULL, then COPT will generate it internally.Note: if a problem contains SOS constraints, the problem is a MIP.
Arguments
probThe COPT problem.
nAddSOSNumber of new SOS constraints.
sosTypeTypes of SOS constraints.
sosMatBeg, sosMatCnt, sosMatIdxandsosMatWtDefines the coefficient matrix in compressed row storage (CRS) format. The CRS format is similar to the CCS format described in the other information of
COPT_LoadProb.
sosMatWtWeights of variables in SOS constraints. Can be
NULL.
COPT_AddCones
Synopsis
int COPT_AddCones(
copt_prob *prob,
int nAddCone,
const int *coneType,
const int *coneBeg,
const int *coneCnt,
const int *coneIdx)Description
Add
nAddConeSecond-Order-Cone (SOC) constraints.Arguments
probThe COPT problem.
nAddConeNumber of new SOC constraints.
coneTypeTypes of SOC constraints.
coneBeg, coneCnt, coneIdxDefines the coefficient matrix in compressed row storage (CRS) format. The CRS format is similar to the CCS format described in the other information of
COPT_LoadProb.
COPT_AddExpCones
Synopsis
int COPT_AddExpCones(
copt_prob *prob,
int nAddCone,
const int *coneType,
const int *coneIdx)Description
Add
nAddConeexponential cone constraints.Arguments
probThe COPT problem.
nAddConeNumber of new exponential cone constraints.
coneTypeTypes of exponential cone constraints.
coneIdxArray of subscripts for the variables that constitute the exponential cone constraints.
COPT_AddAffineCone
Synopsis
int COPT_AddAffineCone(
copt_prob *prob,
int coneType,
int nConeDim,
int nAlphaDim,
const double *alphaElem,
const int *psdBeg,
const int *psdCnt,
const int *psdColIdx,
const int *psdMatIdx,
const int *rowMatBeg,
const int *rowMatCnt,
const int *rowMatIdx,
const double *rowMatElem,
const double *rowConst,
const char *name)Description
Add the affine cone constraints.
Arguments
probThe COPT model.
coneTypeThe type of the affine cone. Please refer to SOC constraint types and Exponential Cone type for possible values.
nConeDimThe dimension of the affine cone.
nAlphaDimReserved parameter, currently not in use.
alphaElemReserved parameter, currently not in use.
psdBeg, psdCnt, psdColIdx, psdMatIdxRepresents the PSD terms in the affine cone.
psdBegindicates the starting position of the PSD terms in each affine cone term,psdCntspecifies the number of PSD terms,psdColIdxindicates the index of the PSD variable, andpsdMatIdxrefers to the index of the symmetric matrix.
rowMatBeg, rowMatCnt, rowMatIdx, rowMatElemRepresents the linear terms in the affine cone.
The coefficient matrix is provided in CRS-format. For detailed examples, please refer to Additional Information in
COPT_LoadProb.
rowConstThe constant terms in the affine cone.
nameThe name of the affine cone.
COPT_AddQConstr
Synopsis
int COPT_AddQConstr(
copt_prob *prob,
int nRowMatCnt,
const int *rowMatIdx,
const int *rowMatElem,
int nQMatCnt,
const int *qMatRow,
const int *qMatCol,
const double *qMatElem,
char cRowSense,
double dRowBound, const char *name)Description
Add a general quadratic constraint.
Note Only convex quadratic constraint is currently supported.
Arguments
probThe COPT problem.
nRowMatCntNumber of non-zero linear terms of the quadratic constraint (row).
rowMatIdxColumn index of non-zero linear terms of the quadratic constraint (row).
rowMatElemValues of non-zero linear terms of the quadratic constraint (row).
nQMatCntNumber of non-zero quadratic terms of the quadratic constraint (row).
qMatRowRow index of non-zero quadratic terms of the quadratic constraint (row).
qMatColColumn index of non-zero quadratic terms of the quadratic constraint (row).
qMatElemValues of non-zero quadratic terms of the quadratic constraint (row).
cRowSenseThe sense of the quadratic constraint (row).
dRowBoundRight hand side of the quadratic constraint (row).
nameName of the quadratic constraint (row).
COPT_AddPSDConstr
Synopsis
int COPT_AddPSDConstr(
copt_prob *prob,
int nRowMatCnt,
const int *rowMatIdx,
const int *rowMatElem,
int nColCnt,
const int *psdColIdx,
const int *symMatIdx,
char cRowSense,
double dRowBound,
double dRowUpper,
const char *name)Description
Add a PSD constraint.
Arguments
probThe COPT problem.
nRowMatCntNumber of non-zero linear terms of the PSD constraint.
rowMatIdxColumn index of non-zero linear terms of the PSD constraint.
rowMatElemValues of non-zero linear terms of the PSD constraint.
nColCntNumber of PSD terms of the PSD constraint.
psdColIdxPSD variable index of PSD terms of the PSD constraint.
symMatIdxSymmetric matrix index of PSD terms of the PSD constraint.
cRowSenseSenses of new PSD constraint.
Please refer to the list of all senses constants for all the supported types.
If
cRowSenseis 0, thendRowBoundanddRowUpperwill be treated as lower and upper bounds for the constraint. This is the recommended method for defining constraints.If
cRowSenseis provided, thendRowBoundanddRowUpperwill be treated as RHS and range for the constraint. In this case,dRowUpperis only required whencRowSense = COPT_RANGE, wherelower bound is
dRowBound - dRowUpperupper bound is
dRowBound
dRowBoundLower bound or RHS of the PSD constraint.
dRowUpperUpper bound or range of the PSD constraint.
nameName of the PSD constraint. Can be
NULL.
COPT_AddLMIConstr
Synopsis
int COPT_AddLMIConstr(
copt_prob *prob,
int nDim,
int nLMIMatCnt,
const int *colIdx,
const int *symMatIdx,
int constMatIdx,
const char *name)Description
Add a LMI constraint to the problem.
Arguments
probThe COPT problem.
nDimDimension of symmetric matrix in the LMI constraint.
nLMIMatCntNumber of coefficient matrix entries in the LMI constraint.
colIdxIndex of scalar variable in the LMI constraint.
symMatIdxIndex of symmetric coefficient matrix in the LMI constraint.
constMatIdxIndex of constant-term symmetric matrix in the LMI constraint.
nameName of LMI constraint. Can be
NULL.
COPT_AddIndicator
Synopsis
int COPT_AddIndicator(
copt_prob *prob,
int binColIdx,
int binColVal,
int nRowMatCnt,
const int *rowMatIdx,
const double *rowMatElem,
char cRowSense, double dRowBound)Description
Add an indicator constraint to the problem.
Arguments
probThe COPT problem.
binColIdxIndex of indicator variable (column).
binColValValue of indicator variable (column).
nRowMatCntNumber of non-zero elements in the linear constraint (row).
rowMatIdxColumn index of non-zero elements in the linear constraint (row).
rowMatElemValues of non-zero elements in the linear constraint (row).
cRowSenseThe sense of the linear constraint (row). Options are:
COPT_EQUAL,COPT_LESS_EQUALandCOPT_GREATER_EQUAL.
dRowBoundRight hand side of the linear constraint (row).
COPT_AddIndicators
Synopsis
int COPT_AddIndicators(
copt_prob *prob,
int nInd,
int *indType,
int *binColIdx,
int *binColVal,
const int *rowMatBeg,
const int *RowMatCnt,
const int *rowMatIdx,
const double *rowMatElem,
char cRowSense,
double *dRowBound,
char const *const indNames);Description
Add
nIndindicator constraints to the problem.Arguments
probThe COPT problem.
nIndNumber of indicator constraints.
indTypeType for indcator constraints. Please refer to Indicator constraint types for possible values.
binColIdxIndex of indicator variable (column).
binColValValue of indicator variable (column).
rowMatBeg, rowMatCnt, rowMatIdxandrowMatElemDefines the coefficient matrix in compressed row storage (CRS) format for linear constraint in the indcator constrsints.
Please see other information of
COPT_LoadProbfor an example of the CRS format.
cRowSenseThe sense of the linear constraint (row). Options are:
COPT_EQUAL,COPT_LESS_EQUALandCOPT_GREATER_EQUAL.
dRowBoundRight hand side of the linear constraint (row).
indNamesNames for indicator constraints.
COPT_AddSymMat
Synopsis
int COPT_AddSymMat(copt_prob *prob, int ndim, int nelem, int *rows, int *cols, double *elems)Description
Add a symmetric matrix to the problem. (Expect lower triangle part)
Arguments
probThe COPT problem.
ndimDimension of symmetric matrix.
nelemNumber of non-zeros of symmetric matrix.
rowsRow index of symmetric matrix.
colsColumn index of symmetric matrix.
elemsNonzero elements of symmetric matrix.
COPT_AddNLConstr
Synopsis
int COPT_AddNLConstr(
copt_prob *prob,
int nToken,
int nTokenElem,
const int *token,
const double *tokenElem,
int nRowMatCnt,
const int *rowMatIdx,
const double *rowMatElem,
char cRowSense,
double dRowBound,
double dRowUpper,
const char *name)Description
Add a nonlinear expression constraint. Currently, only prefix notation is supported.
Arguments
probThe COPT problem.
nTokenNumber of tokens in the expression.
nTokenElemNumber of constants in the expression.
tokenArray of expression tokens.
tokenElemArray of constants in the expression.
nRowMatCntNumber of linear terms in the constraint.
rowMatIdxIndices of linear terms in the constraint.
rowMatElemCoefficients of linear terms in the constraint.
cRowSenseConstraint type.
Refer to the constants section for the supported constraint types in COPT.
If
cRowSenseis 0, thendRowBoundanddRowUpperare treated as the lower and upper bounds of the constraint. This is the recommended way to define constraints.If
cRowSenseis a meaningful value, thendRowBoundanddRowUpperare treated as the RHS and range. In this case,dRowUpperis used only when the constraint type isCOPT_RANGE. The constraint bounds in this scenario are:Lower bound:
dRowBound - dRowUpperUpper bound:
dRowBound
dRowBoundLower bound or RHS of the constraint.
dRowUpperUpper bound or range of the constraint.
nameName of the constraint. Can be set to
NULL.
COPT_AddNLConstrs
Synopsis
int COPT_AddNLConstrs(
copt_prob *prob,
int nConstrs,
const int *tokenBeg,
const int *tokenCnt,
const int *tokenElemBeg,
const int *tokenElemCnt,
const int *token,
const double *tokenElem,
const int *rowMatBeg,
const int *rowMatCnt,
const int *rowMatIdx,
const double *rowMatElem,
const char *rowSense,
const double *rowBound,
const double *rowUpper,
char const *const *rowNames)Description
Add a set of nonlinear expression constraints. Currently, only prefix notation is supported.
Arguments
probThe COPT problem.
nConstrsNumber of constraints.
tokenBegArray of starting positions of tokens in expressions.
tokenCntArray of counts of tokens in expressions.
tokenElemBegArray of starting positions of constants in expressions.
tokenElemCntArray of counts of constants in expressions.
tokenArray of tokens in expressions.
tokenElemArray of constants in expressions.
rowMatBeg, rowMatCnt, rowMatIdxandrowMatElemProvide the coefficient matrix in a row-compressed storage format. For specific examples of sparse matrix compression storage format, refer to the Additional Information section in
COPT_LoadProb.
rowSenseConstraint types.
Refer to the constants section for supported constraint types in COPT.
If
rowSenseis not provided,rowBoundandrowUpperare treated as the lower and upper bounds of constraints. This is the recommended way to define constraints.If
rowSenseis provided,rowBoundandrowUpperare treated as the RHS and range. In this case, therowUpperarray is only used when there is aCOPT_RANGEconstraint type. The constraint bounds in this scenario are:Lower bound:
rowBound[i] - fabs(rowUpper[i])Upper bound:
rowBound[i]
rowBoundLower bound or RHS of the new constraints.
rowUpperUpper bound or range of the new constraints.
rowNamesNames of the new constraints. Can be set to
NULL.
COPT_DelCols
Synopsis
int COPT_DelCols(copt_prob *prob, int num, const int *list)Description
Deletes
numvariables (columns) from the problem.Arguments
probThe COPT problem.
numNumber of variables to be deleted.
listA list of index of variables to be deleted.
COPT_DelPSDCols
Synopsis
int COPT_DelPSDCols(copt_prob *prob, int num, const int *list)Description
Deletes
numPSD variables from the problem.Arguments
probThe COPT problem.
numNumber of PSD variables to be deleted.
listA list of index of PSD variables to be deleted.
COPT_DelRows
Synopsis
int COPT_DelRows(copt_prob *prob, int num, const int *list)Description
Deletes
numconstraints (rows) from the problem.Arguments
probThe COPT problem.
numThe number of constraints to be deleted.
listThe list of index of constraints to be deleted.
COPT_DelSOSs
Synopsis
int COPT_DelSOSs(copt_prob *prob, int num, const int *list)Description
Deletes
numSOS constraints from the problem.Arguments
probThe COPT problem.
numThe number of SOS constraints to be deleted.
listThe list of index of SOS constraints to be deleted.
COPT_DelCones
Synopsis
int COPT_DelCones(copt_prob *prob, int num, const int *list)Description
Deletes
numSecond-Order-Cone (SOC) constraints from the problem.Arguments
probThe COPT problem.
numThe number of SOC constraints to be deleted.
listThe list of index of SOC constraints to be deleted.
COPT_DelExpCones
Synopsis
int COPT_DelExpCones(copt_prob *prob, int num, const int *list)Description
Deletes
numexponential cone constraints from the problem.Arguments
probThe COPT problem.
numThe number of exponential cone constraints to be deleted.
listThe list of index of exponential cone constraints to be deleted.
COPT_DelAffineCones
Synopsis
int COPT_DelAffineCones(copt_prob *prob, int num, const int *list)Description
Deletes
numaffine cone constraints from the problem.Arguments
probThe COPT problem.
numThe number of affine cone constraints to be deleted.
listThe list of index of affine cone constraints to be deleted.
COPT_DelQConstrs
Synopsis
int COPT_DelQConstrs(copt_prob *prob, int num, const int *list)Description
Deletes
numquadratic constraints from the problem.Arguments
probThe COPT problem.
numThe number of quadratic constraints to be deleted.
listThe list of index of quadratic constraints to be deleted.
COPT_DelPSDConstrs
Synopsis
int COPT_DelPSDConstrs(copt_prob *prob, int num, const int *list)Description
Deletes
numPSD constraints from the problem.Arguments
probThe COPT problem.
numThe number of PSD constraints to be deleted.
listThe list of index of PSD constraints to be deleted.
COPT_DelLMIConstrs
Synopsis
int COPT_DelLMIConstrs(copt_prob *prob, int num, const int *list)Description
Deletes
numLMI constraints from the problem.Arguments
probThe COPT problem.
numThe number of LMI constraints to be deleted.
listThe list of index of LMI constraints to be deleted.
COPT_DelIndicators
Synopsis
int COPT_DelIndicators(copt_prob *prob, int num, const int *list)Description
Deletes
numindicator constraints from the problem.Arguments
probThe COPT problem.
numThe number of indicator constraints to be deleted.
listThe list of index of indicator constraints to be deleted.
COPT_DelNLConstrs
Synopsis
int COPT_DelNLConstrs(copt_prob *prob, int num, const int *list)Description
Delete
numnonlinear expression constraints.Arguments
probThe COPT problem.
numNumber of nonlinear expression constraints to delete.
listList of indices of nonlinear expression constraints to delete.
COPT_DelQuadObj
Synopsis
int COPT_DelQuadObj(copt_prob *prob)Description
Deletes the quadratic terms from the quadratic objective function.
Arguments
probThe COPT problem.
COPT_DelNLObj
Synopsis
int COPT_DelNLObj(copt_prob *prob)Description
Delete the nonlinear expression terms in the objective function.
Arguments
probThe COPT problem.
COPT_DelPSDObj
Synopsis
int COPT_DelPSDObj(copt_prob *prob)Description
Deletes the PSD terms from objective function.
Arguments
probThe COPT problem.
COPT_SetElem
Synopsis
int COPT_SetElem(copt_prob *prob, int iCol, int iRow, double newElem)Description
Set coefficient of specified row and column.
Note: If
newElemis smaller than or equal to parameterMatrixTol, the coefficient will be set as zero.Arguments
probThe COPT problem.
iColColumn index.
iRowRow index.
newElemNew coefficient.
COPT_SetElems
Synopsis
int COPT_SetElems(copt_prob *prob, int nelem, const int *cols, const int *rows, const double *elems)Description
Set the coefficients of the specified columns and rows in batches.
Note The index pairs of columns and rows cannot appear repeatedly.
Arguments
probThe COPT problem.
nelemThe number of new coefficients to be set.
colsColumn indexes.
rowsRow indexes.
elemsThe values of the new coefficients to be set.
COPT_SetPSDElem
Synopsis
int COPT_SetPSDElem(copt_prob *prob, int iCol, int iRow, int newIdx)Description
Set symmetric matrix index for given PSD term of PSD constraint.
Arguments
probThe COPT problem.
iColPSD variable index.
iRowPSD constraint index.
newIdxNew symmetric matrix index.
COPT_SetLMIElem
Synopsis
int COPT_SetLMIElem(copt_prob *prob, int iCol, int iRow, int newIdx)Description
Set symmetric matrix index for given term of LMI constraint.
Arguments
probThe COPT problem.
iColScalar variable index.
iRowLMI constraint index.
newIdxNew coefficient symmetric matrix index.
COPT_SetObjSense
Synopsis
int COPT_SetObjSense(copt_prob *prob, int iObjSense)Description
Change the objective function sense.
Arguments
probThe COPT problem.
iObjSenseThe optimization sense, either
COPT_MAXIMIZEorCOPT_MINIMIZE.
COPT_SetObjConst
Synopsis
int COPT_SetObjConst(copt_prob *prob, double dObjConst)Description
Set the constant term of objective function.
Arguments
probThe COPT problem.
dObjConstThe constant term of objective function.
COPT_SetColObj/Type/Lower/Upper/Names
Synopsis
int COPT_SetColObj(copt_prob *prob, int num, const int *list, const double *obj)
int COPT_SetColType(copt_prob *prob, int num, const int *list, const char *type)
int COPT_SetColLower(copt_prob *prob, int num, const int *list, const double *lower)
int COPT_SetColUpper(copt_prob *prob, int num, const int *list, const double *upper)
int COPT_SetColNames(copt_prob *prob, int num, const int *list, char const *const *names)Description
These five API functions each modifies
objective coefficients
variable types
lower bounds
upper bounds
names
of
numvariables (columns) in the problem.Arguments
probThe COPT problem.
numNumber of variables to modify.
listA list of index of variables to modify.
objNew objective coefficients for each variable in the
list.
typesNew types for each variable in the
list.
lowerNew lower bounds for each variable in the
list.
upperNew upper bounds for each variable in the
list.
namesNew names for each variable in the
list.
COPT_SetPSDColNames
Synopsis
int COPT_SetPSDColNames(copt_prob *prob, int num, const int *list, char const *const *names)Description
Modify names of
numPSD variables.Arguments
probThe COPT problem.
numNumber of PSD variables to modify.
listA list of index of PSD variables to modify.
namesNew names for each PSD variable in the
list.
COPT_SetRowLower/Upper/Names
Synopsis
int COPT_SetRowLower(copt_prob *prob, int num, const int *list, const double *lower)
int COPT_SetRowUpper(copt_prob *prob, int num, const int *list, const double *upper)
int COPT_SetRowNames(copt_prob *prob, int num, const int *list, char const *const *names)Description
These three API functions each modifies
lower bounds
upper bounds
names
of
numconstraints (rows) in the problem.Arguments
probThe COPT problem.
numNumber of constraints to modify.
listA list of index of constraints to modify.
lowerNew lower bounds for each constraint in the
list.
upperNew upper bounds for each constraint in the
list.
namesNew names for each constraint in the
list.
COPT_SetQConstrSense/Rhs/Names
Synopsis
int COPT_SetQConstrSense(copt_prob *prob, int num, const int *list, const char *sense)
int COPT_SetQConstrRhs(copt_prob *prob, int num, const int *list, const double *rhs)
int COPT_SetQConstrNames(copt_prob *prob, int num, const int *list, char const *const *names)Description
These three API functions each modifies
senses
RHS
names
of
numquadratic constraints (rows) in the problem.Arguments
probThe COPT problem.
numNumber of quadratic constraints to modify.
listA list of index of quadratic constraints to modify.
senseNew senses for each quadratic constraint in the
list.
rhsNew RHS for each quadratic constraint in the
list.
namesNew names for each quadratic constraint in the
list.
COPT_SetPSDConstrLower/Upper/Names
Synopsis
int COPT_SetPSDConstrLower(copt_prob *prob, int num, const int *list, const double *lower)
int COPT_SetPSDConstrUpper(copt_prob *prob, int num, const int *list, const double *upper)
int COPT_SetPSDConstrNames(copt_prob *prob, int num, const int *list, char const *const *names)Description
These three API functions each modifies
lower bounds
upper bounds
names
of
numPSD constraints in the problem.Arguments
probThe COPT problem.
numNumber of PSD constraints to modify.
listA list of index of PSD constraints to modify.
lowerNew lower bounds for each PSD constraint in the
list.
upperNew upper bounds for each PSD constraint in the
list.
namesNew names for each PSD constraint in the
list.
COPT_SetLMIConstrRhs
Synopsis
int COPT_SetLMIConstrRhs(copt_prob *prob, int num, const int *list, const int *newIdx)Description
Modify the constant-term symmetric matrix of
numLMI constraints.Arguments
probThe COPT problem.
numNumber of LMI constraints to modify.
listA list of index of LMI constraints to modify.
newIdxThe new index of the constant-term symmetric matrix to be set.
COPT_SetLMIConstrNames
Synopsis
int COPT_SetLMIConstrNames(copt_prob *prob, int num, const int *list, char const *const *names)Description
Modify the names of
numLMI constraints.Arguments
probThe COPT problem.
numNumber of LMI constraints to modify.
listA list of index of LMI constraints to modify.
namesNew names for each LMI constraint in the
list.
COPT_SetIndicatorNames
Synopsis
int COPT_SetIndicatorNames(copt_prob *prob, int num, const int *list, char const *const *names)Description
Modifies names of
numindicator constraints in the problem.Arguments
probThe COPT problem.
numNumber of indicator constraints to modify.
listA list of indexes of indicator constraints to modify.
namesNew names for each indicator constraint in the
list.
COPT_SetAffineConeNames
Synopsis
int COPT_SetAffineConeNames(copt_prob *prob, int num, const int *list, char const *const *names)Description
Modifies names of
numaffine cones in the problem.Arguments
probThe COPT problem.
numNumber of affine cones to modify.
listA list of indexes of affine cones to modify.
namesNew names for each affine cone in the
list.
COPT_SetNLConstrLower/Upper/Names
Synopsis
int COPT_SetNLConstrLower(copt_prob *prob, int num, const int *list,const double *lower)
int COPT_SetNLConstrUpper(copt_prob *prob, int num, const int *list,const double *upper)
int COPT_SetNLConstrNames(copt_prob *prob, int num, const int *list,char const *const *names)Description
These three functions respectively modify the following properties of
numnonlinear expression constraints:Lower bound
Upper bound
Name
Arguments
probThe COPT problem.
numNumber of nonlinear expression constraints to modify.
listList of nonlinear expression constraints to modify.
lowerNew lower bounds for the listed nonlinear expression constraints.
upperNew upper bounds for the listed nonlinear expression constraints.
namesNew names for the listed nonlinear expression constraints.
COPT_ReplaceColObj
Synopsis
int COPT_ReplaceColObj(copt_prob *prob, int num, const int *list, const double *obj)Description
Replace objective function with new objective function represented by specified objective costs.
Arguments
probThe COPT problem.
numNumber of variables to be modified.
listIndex of variables to be modified.
objObjective costs of modified variables.
COPT_ReplacePSDObj
Synopsis
int COPT_ReplacePSDObj(copt_prob *prob, int num, const int *list, const int *idx)Description
Replace PSD terms in objective function with specified PSD terms.
Arguments
probThe COPT problem.
numNumber of PSD variables to be modified.
listIndex of PSD variables to be modified.
idxSymmetric matrix index of modified PSD variables.
COPT_SetQuadObj
Synopsis
int COPT_SetQuadObj(copt_prob *prob, int num, int *qRow, int *qCol, double *qElem)Description
Set the quadratic terms of the quadratic objective function.
Arguments
probThe COPT problem.
numNumber of non-zero quadratic terms of the quadratic objective function.
qRowRow index of non-zero quadratic terms of the quadratic objective function.
qColColumn index of non-zero quadratic terms of the quadratic objective function.
qElemValues of non-zero quadratic terms of the quadratic objective function.
COPT_SetNLObj
Synopsis
int COPT_SetNLObj(copt_prob *prob, int nToken, int nTokenElem,const int *token, const double *tokenElem)Description
Set the nonlinear expression terms in the nonlinear objective function.
Arguments
probThe COPT problem.
nTokenNumber of tokens in the expression.
nTokenElemNumber of constants in the expression.
tokenArray of tokens in the expression.
tokenElemArray of constants in the expression.
COPT_SetPSDObj
Synopsis
int COPT_SetPSDObj(copt_prob *prob, int iCol, int newIdx)Description
Set PSD terms of objective function.
Arguments
probThe COPT problem.
iColPSD variable index.
newIdxSymmetric matrix index.
Reading and writing the problem
COPT_ReadMps
Synopsis
int COPT_ReadMps(copt_prob *prob, const char *mpsfilename)Description
Reads a problem from a MPS file.
Arguments
probThe COPT problem.
mpsfilenameThe path to the MPS file.
COPT_ReadLp
Synopsis
int COPT_ReadLp(copt_prob *prob, const char *lpfilename)Description
Read a problem from a LP file.
Arguments
probThe COPT problem.
lpfilenameThe path to the LP file.
COPT_ReadSDPA
Synopsis
int COPT_ReadSDPA(copt_prob *prob, const char *sdpafilename)Description
Reads a problem from SDPA format file.
Arguments
probThe COPT problem.
sdpafilenameThe path to the SDPA format file.
COPT_ReadCbf
Synopsis
int COPT_ReadCbf(copt_prob *prob, const char *cbffilename)Description
Reads a problem from CBF format file.
Arguments
probThe COPT problem.
cbffilenameThe path to the CBF format file.
COPT_ReadBin
Synopsis
int COPT_ReadBin(copt_prob *prob, const char *binfilename)Description
Reads a problem from a COPT binary format file.
Arguments
probThe COPT problem.
binfilenameThe path to the COPT binary format file.
COPT_ReadBlob
Synopsis
int COPT_ReadBlob(copt_prob *prob, void *blob, COPT_INT64 len)Description
Reads a problem from COPT serialized data.
Arguments
probThe COPT problem.
blobSerialized data.
lenLength of serialized data.
COPT_WriteMps
Synopsis
int COPT_WriteMps(copt_prob *prob, const char *mpsfilename)Description
Writes the problem to a MPS file.
Arguments
probThe COPT problem.
mpsfilenameThe path to the MPS file.
COPT_WriteMpsStr
Synopsis
int COPT_WriteMpsStr(copt_prob *prob, char *str, int nStrSize, int *pReqSize)Description
Writes the problem to a string buffer as MPS format.
Arguments
probThe COPT problem.
strString buffer of MPS-format problem.
nStrSizeThe size of string buffer.
pReqSizeMinimum space requirement of string buffer for problem.
COPT_WriteLp
Synopsis
int COPT_WriteLp(copt_prob *prob, const char *lpfilename)Description
Writes the problem to a LP file.
Arguments
probThe COPT problem.
lpfilenameThe path to the LP file.
COPT_WriteCbf
Synopsis
int COPT_WriteCbf(copt_prob *prob, const char *cbffilename)Description
Writes the problem to a CBF format file.
Arguments
probThe COPT problem.
cbffilenameThe path to the CBF format file.
COPT_WriteBin
Synopsis
int COPT_WriteBin(copt_prob *prob, const char *binfilename)Description
Writes the problem to a COPT binary format file.
Arguments
probThe COPT problem.
binfilenameThe path to the COPT binary format file.
COPT_WriteNL
Synopsis
int COPT_WriteNL(copt_prob *prob, const char *nlfilename)Description
Export the internal COPT model to an NL format file.
Arguments
probThe COPT problem.
nlfilenamePath to the NL format file.
COPT_WriteBlob
Synopsis
int COPT_WriteBlob(copt_prob *prob, int tryCompress, void **p_blob, COPT_INT64 *pLen)Description
Writes the problem to COPT serialized data.
Arguments
probThe COPT problem.
tryCompressWhether to compress data.
p_blobOutput pointer of serialized data.
pLenPointer to length of serialized data.
Solving the problem and accessing solutions
COPT_SolveLp
Synopsis
int COPT_SolveLp(copt_prob *prob)Description
Solves the LP, QP, QCP, SOCP and SDP problem.
If problem is a MIP, then integer restrictions on variables will be ignored, and SOS constraints, indicator constraints will be discarded, and the problem will be solved as a LP.
Arguments
probThe COPT problem.
COPT_Solve
Synopsis
int COPT_Solve(copt_prob *prob)Description
Solves the problem.
Arguments
probThe COPT problem.
COPT_GetSolution
Synopsis
int COPT_GetSolution(copt_prob *prob, double *colVal)Description
Obtains MIP solution.
Arguments
probThe COPT problem.
colValSolution values of variables.
COPT_GetPoolObjVal
Synopsis
int COPT_GetPoolObjVal(copt_prob *prob, int iSol, double *p_objVal)Description
Obtains the
iSol-th objective value in solution pool.Arguments
probThe COPT problem.
iSolIndex of solution.
p_objValPointer to objective value.
COPT_GetPoolSolution
Synopsis
int COPT_GetPoolSolution(copt_prob *prob, int iSol, int num, const int *list, double *colVal)Description
Obtains the
iSol-th solution.Arguments
probThe COPT problem.
iSolIndex of solution.
numNumber of columns.
listIndex of columns. Can be
NULL.
colValArray of solution.
COPT_GetLpSolution
Synopsis
int COPT_GetLpSolution(copt_prob *prob, double *value, double *slack, double *rowDual, double *redCost)Description
Obtains LP, QP, QCP, SOCP and SDP solutions.
Note: For SDP, please use
COPT_GetPSDColInfoto obtain primal/dual solution of PSD variable.Arguments
probThe COPT problem.
valueSolution values of variables. Can be
NULL.
slackSolution values of slack variables. They are also known as activities of constraints. Can be
NULL.
rowDualDual values of constraints. Can be
NULL.
redCostReduced cost of variables. Can be
NULL.
COPT_SetLpSolution
Synopsis
int COPT_SetLpSolution(copt_prob *prob, double *value, double *slack, double *rowDual, double *redCost)Description
Set LP solution.
Arguments
probThe COPT problem.
valueSolution values of variables.
slackSolution values of slack variables.
rowDualDual values of constraints.
redCostReduced cost of variables.
COPT_GetBasis
Synopsis
int COPT_GetBasis(copt_prob *prob, int *colBasis, int *rowBasis)Description
Obtains LP basis.
Arguments
probThe COPT problem.
colBasisandrowBasisThe basis status of variables and constraints. Please refer to basis constants for possible values and their meanings.
COPT_SetBasis
Synopsis
int COPT_SetBasis(copt_prob *prob, const int *colBasis, const int *rowBasis)Description
Sets LP basis. It can be used to warm-start an LP optimization.
Arguments
probThe COPT problem.
colBasisandrowBasisThe basis status of variables and constraints. Please refer to basis constants for possible values and their meanings.
COPT_SetSlackBasis
Synopsis
int COPT_SetSlackBasis(copt_prob *prob)Description
Sets a slack basis for LP. The slack basis is the default starting basis for an LP problem. This API function can be used to restore an LP problem to its starting basis.
Arguments
probThe COPT problem.
COPT_Reset
Synopsis
int COPT_Reset(copt_prob *prob, int iClearAll)Description
Reset basis and LP/MIP solution in problem, which forces next solve start from scratch. If
iClearAllis1, then clear additional information such as MIP start as well.Arguments
probThe COPT problem.
iClearAllWhether to clear additional information.
COPT_ReadSol
Synopsis
int COPT_ReadSol(copt_prob *prob, const char *solfilename)Description
Reads a MIP solution from file as MIP start information.
Note: The default solution value is 0, i.e. a partial solution will be automatically filled in with zeros.
Arguments
probThe COPT problem.
solfilenameThe path to the solution file.
COPT_ReadJsonSol
Synopsis
int COPT_ReadJsonSol(copt_prob *prob, const char *solfilename)Description
Read solution in format of JSON from file.
Arguments
probThe COPT problem.
solfilenameThe path to the solution file.
COPT_WriteSol
Synopsis
int COPT_WriteSol(copt_prob *prob, const char *solfilename)Description
Writes a LP/MIP solution to a file.
Arguments
probThe COPT problem.
solfilenameThe path to the solution file.
COPT_WriteJsonSol
Synopsis
int COPT_WriteJsonSol(copt_prob *prob, const char *solfilename)Description
Writes solution to a file of type
".json".Arguments
probThe COPT problem.
solfilenameThe path to the solution file.
COPT_WritePoolSol
Synopsis
int COPT_WritePoolSol(copt_prob *prob, int iSol, const char *solfilename)Description
Writes selected pool solution to a file.
Arguments
probThe COPT problem.
iSolIndex of pool solution.
solfilenameThe path to the solution file.
COPT_WriteBasis
Synopsis
int COPT_WriteBasis(copt_prob *prob, const char *basfilename)Description
Writes the internal LP basis to a file.
Arguments
probThe COPT problem.
basfilenameThe path to the basis file.
COPT_ReadBasis
Synopsis
int COPT_ReadBasis(copt_prob *prob, const char *basfilename)Description
Reads the LP basis from a file. It can be used to warm-start an LP optimization.
Arguments
probThe COPT problem.
basfilenameThe path to the basis file.
Accessing information of problem
COPT_GetCols
Synopsis
int COPT_GetCols(
copt_prob *prob,
int nCol,
const int *list,
int *colMatBeg,
int *colMatCnt,
int *colMatIdx,
double *colMatElem,
int nElemSize,
int *pReqSize)Description
Extract coefficient matrix by columns.
In general, users need to call this function twice to accomplish the task. Firstly, by passing
NULLto argumentscolMatBeg,colMatCnt,colMatIdxandcolMatElem, we get number of non-zeros elements bypReqSizespecified bynColandlist. Secondly, allocate sufficient memory for CCS-format matrix and call this function again to extract coefficient matrix. If the memory of coefficient matrix passed to function is not sufficient, then return the firstnElemSizenon-zero elements, and the minimal required length of non-zero elements bypReqSize. IflistisNULL, then the firstnColcolumns will be returned.Arguments
probThe COPT problem.
nColNumber of columns.
listIndex of columns. Can be
NULL.
colMatBeg, colMatCnt, colMatIdxandcolMatElemDefines the coefficient matrix in compressed column storage (CCS) format. Please see other information of
COPT_LoadProbfor an example of the CCS format.
nElemSizeLength of array for non-zero coefficients.
pReqSizePointer to minimal length of array for non-zero coefficients. Can be
NULL.
COPT_GetPSDCols
Synopsis
int COPT_GetPSDCols(copt_prob *prob, int nCol, int *list, int* colDims, int *colLens)Description
Get dimension and flattened length of
nColPSD variables.Arguments
probThe COPT problem.
nColNumber of PSD variables.
listIndex of PSD variables. Can be
NULL.
colDimsDimension of PSD variables.
colLensFlattened length of PSD variables.
COPT_GetRows
Synopsis
int COPT_GetRows(
copt_prob *prob,
int nRow,
const int *list,
int *rowMatBeg,
int *rowMatCnt,
int *rowMatIdx,
double *rowMatElem,
int nElemSize,
int *pReqSize)Description
Extract coefficient matrix by rows.
In general, users need to call this function twice to accomplish the task. Firstly, by passing
NULLto argumentsrowMatBeg,rowMatCnt,rowMatIdxandrowMatElem, we get number of non-zeros elements bypReqSizespecified bynRowandlist. Secondly, allocate sufficient memory for CRS-format matrix and call this function again to extract coefficient matrix. If the memory of coefficient matrix passed to function is not sufficient, then return the firstnElemSizenon-zero elements, and the minimal required length of non-zero elements bypReqSize. IflistisNULL, then the firstnRowrows will be returned.Arguments
probThe COPT problem.
nRowNumber of rows.
listIndex of rows. Can be
NULL.
rowMatBeg, rowMatCnt, rowMatIdxandrowMatElemDefines the coefficient matrix in compressed row storage (CRS) format. Please see other information of
COPT_LoadProbfor an example of the CRS format.
nElemSizeLength of array for non-zero coefficients.
pReqSizePointer to minimal length of array for non-zero coefficients. Can be
NULL.
COPT_GetElem
Synopsis
int COPT_GetElem(copt_prob *prob, int iCol, int iRow, double *p_elem)Description
Get coefficient of specified row and column.
Arguments
probThe COPT problem.
iColColumn index.
iRowRow index.
p_elemPointer to requested coefficient.
COPT_GetPSDElem
Synopsis
int COPT_GetPSDElem(copt_prob *prob, int iCol, int iRow, int *p_idx)Description
Get symmetric matrix index of specified PSD constraint and PSD variable.
Arguments
probThe COPT problem.
iColPSD variable index.
iRowPSD constraint index.
p_idxPointer to requested symmetric matrix index.
COPT_GetLMIElem
Synopsis
int COPT_GetLMIElem(copt_prob *prob, int iCol, int iRow, int *p_idx)Description
Get symmetric matrix index of specified LMI constraint and scalar variable.
Arguments
probThe COPT problem.
iColScalar variable index.
iRowLMI constraint index.
p_idxPointer to requested coefficient matrix index.
COPT_GetSymMat
Synopsis
int COPT_GetSymMat(
copt_prob *prob,
int iMat,
int *p_nDim,
int *p_nElem,
int *rows,
int *cols,
double *elems)Description
Get specified symmetric matrix.
In general, users need to call this function twice to accomplish the task. Firstly, by passing
NULLto argumentsrows,colsandelems, we get dimension and number of non-zeros of symmetric matrix byp_nDimandp_nElem, then allocate enough memory forrows,colsandelemsand call this function to get the data of symmetric matrix.Arguments
probThe COPT problem.
iMatSymmetric matrix index.
p_nDimPointer to dimension of symmetric matrix.
p_nElemPointer to number of nonzeros of symmetric matrix.
rowsRow index of symmetric matrix.
colsColumn index of symmetric matrix.
elemsNonzero elements of symmetric matrix.
COPT_GetQuadObj
Synopsis
int COPT_GetQuadObj(copt_prob* prob, int* p_nQElem, int* qRow, int* qCol, double* qElem)Description
Get the quadratic terms of the quadratic objective function.
Arguments
probThe COPT problem.
p_nQElemPointer to number of non-zero quadratic terms . Can be
NULL.
qRowRow index of non-zero quadratic terms of the quadratic objective function.
qColColumn index of non-zero quadratic terms of the quadratic objective function.
qElemValues of non-zero quadratic terms of the quadratic objective function.
COPT_GetPSDObj
Synopsis
int COPT_GetPSDObj(copt_prob *prob, int iCol, int *p_idx)Description
Get the specified PSD term of objective function.
Arguments
probThe COPT problem.
iColPSD variable index.
p_idxPointer to symmetric matrix index.
COPT_GetNLObj
Synopsis
int COPT_GetNLObj(
copt_prob *prob,
int *p_nToken,
int *p_nTokenElem,
int *token,
double *tokenElem)Description
Retrieve the nonlinear expression terms in the objective function.
Arguments
probThe COPT problem.
p_nTokenPointer to the number of tokens in the expression.
p_nTokenElemPointer to the number of constants in the expression.
tokenArray of tokens in the expression.
tokenElemArray of constants in the expression.
COPT_GetSOSs
Synopsis
int COPT_GetSOSs(
copt_prob *prob,
int nSos,
const int *list,
int *sosMatBeg,
int *sosMatCnt,
int *sosMatIdx,
double *sosMatWt,
int nElemSize,
int *pReqSize)Description
Get the weight matrix of SOS constraints.
In general, users need to call this function twice to accomplish the task. Firstly, by passing
NULLto argumentssosMatBeg,sosMatCnt,sosMatIdxandsosMatWt, we get number of non-zeros elements bypReqSizespecified bynSosandlist. Secondly, allocate sufficient memory for CRS-format matrix and call this function again to extract weight matrix. If the memory of weight matrix passed to function is not sufficient, then return the firstnElemSizenon-zero elements, and the minimal required length of non-zero elements bypReqSize. IflistisNULL, then the firstnSosrows will be returned.Arguments
probThe COPT problem.
nSosNumber of SOS constraints.
listIndex of SOS constraints. Can be
NULL.
sosMatBeg, sosMatCnt, sosMatIdxandsosMatWtDefines the weight matrix of SOS constraints in compressed row storage (CRS) format. Please see other information of
COPT_LoadProbfor an example of the CRS format.
nElemSizeLength of array for non-zero weights.
pReqSizePointer to minimal length of array for non-zero weights. Can be
NULL.
COPT_GetCones
Synopsis
int COPT_GetCones(
copt_prob *prob,
int nCone,
const int *list,
int *coneBeg,
int *coneCnt,
int *coneIdx,
int nElemSize,
int *pReqSize)Description
Get the matrix of Second-Order-Cone (SOC) constraints.
In general, users need to call this function twice to accomplish the task. Firstly, by passing
NULLto argumentsconeBeg,coneCntandconeIdx, we get number of subscripts of variables bypReqSizespecified bynConeandlist. Secondly, allocate sufficient memory for CRS-format matrix and call this function again to extract weight matrix. If the memory of weight matrix passed to function is not sufficient, then return the firstnElemSizesubscripts of variables, and the minimal required length of non-zero elements bypReqSize. IflistisNULL, then the firstnConerows will be returned.Arguments
probThe COPT problem.
nConeNumber of SOC constraints.
listIndex of SOC constraints. Can be
NULL.
coneBeg, coneCnt, coneIdxDefines the matrix of SOC constraints in compressed row storage (CRS) format. Please see other information of
COPT_LoadProbfor an example of the CRS format.
nElemSizeLength of array for non-zero weights.
pReqSizePointer to minimal length of array for non-zero weights. Can be
NULL.
COPT_GetExpCones
Synopsis
int COPT_GetExpCones(
copt_prob *prob,
int nCone,
const int *list,
int *coneType,
int *coneIdx,
int nElemSize,
int *pReqSize)Description
Get the array of exponential cone constraints.
In general, users need to call this function twice to accomplish the task. Firstly, by passing
NULLto argumentsconeIdx, we get number of subscripts of variables bynElemSizesspecified bynConeandlist. Secondly, allocate sufficient memory for array and call this function again to extract weight array. If the memory of weight array passed to function is not sufficient, then return the firstnElemSizesubscripts, and the minimal required length of subscripts bypReqSize. IflistisNULL, then the firstnConerows will be returned.Arguments
probThe COPT problem.
nConeNumber of exponential cone constraints.
listIndex of exponential cone constraints. Can be
NULL.
coneTypeType of exponential cone constraints. Please refer to Exponential Cone type for possible values.
coneIdxArray of subscripts of variables constituting the exponential cone constraints.
nElemSizeLength of array for subscripts of variables.
pReqSizePointer to minimal length of array for subscripts of variables. Can be
NULL.
COPT_GetAffineCone
Synopsis
int COPT_GetAffineCone(
copt_prob *prob,
int affConeIdx,
int *coneType,
int *nConeDim,
int *nAlphaDim,
double *alphaElem,
int *psdBeg,
int *psdCnt,
int *psdColIdx,
int *psdMatIdx,
int nPsdElemSize,
int *pPsdReqSize,
int *rowMatBeg,
int *rowMatCnt,
int *rowMatIdx,
double *rowMatElem,
double *rowConst,
int nElemSize,
int *pReqSize)Description
Retrieve the array of affine cone constraints from the model.
Generally, the user needs to call this function twice to complete the extraction of the affine cone constraint.
First, pass
NULLtoaffConeIdxto obtain the number of indices for the affine cone constraint array specified bynConeDimandlistthroughpReqSize. Then, allocate appropriate space for the array parameters, and call the function again to retrieve the specified affine cone constraint array.If the length of the affine cone constraint array passed in is insufficient, the function will return the first
nElemSizevariable index arrays and return the minimum required array length throughpReqSize. IflistisNULL, the function returns the affine cone constraint array corresponding to the firstnConeDimrows.Arguments
probThe COPT problem.
affConeIdxThe index of the affine cone.
coneTypeThe type of the affine cone. Please refer to SOC constraint types and Exponential Cone type for possible values.
nConeDimThe dimension of the affine cone.
nAlphaDimReserved parameter, currently not in use.
alphaElemReserved parameter, currently not in use.
psdBeg, psdCnt, psdColIdx, psdMatIdxRepresents the PSD terms in the affine cone.
psdBegindicates the starting position of the PSD terms in each affine cone term,psdCntspecifies the number of PSD terms,psdColIdxindicates the index of the PSD variable, andpsdMatIdxrefers to the index of the symmetric matrix.First, the number of PSD terms is returned via
pPsdReqSize, andnPsdElemSizerepresents the number of PSD terms to be retrieved.
rowMatBeg, rowMatCnt, rowMatIdx, rowMatElemRepresents the linear terms in the affine cone.
The coefficient matrix is provided in CRS-format. For detailed examples, please refer to Additional Information in
COPT_LoadProb.
rowConstThe constant term in the affine cone.
nElemSizeLength of array for subscripts of variables.
pReqSizePointer to minimal length of array for subscripts of variables of the affine cone. Can be
NULL.
COPT_GetQConstr
Synopsis
int COPT_GetQConstr(
copt_prob *prob,
int qConstrIdx,
int *qMatRow,
int *qMatCol,
double *qMatElem,
int nQElemSize,
int *pQReqSize,
int *rowMatIdx,
double *rowMatElem,
char *cRowSense,
double *dRowBound,
int nElemSize,
int *pReqSize)Description
Get quadratic constraint.
In general, users need to call this function twice to accomplish the task. Firstly, by passing
NULLto argumentsqMatRow,qMatCol,qMatElem,rowMatIdxandrowMatElem, we get number of non-zero quadratic terms bypQReqSizeand number of non-zero linear terms bypReqSizespecified byqConstrIdx. Secondly, allocate sufficient memory for the quadratic terms and the linear terms, and call this function again to extract the quadratic constraint. If the memory of the array of the quadratic terms passed to function is not sufficient, then return the firstnQElemSizequadratic terms, and the minimal required length of quadratic terms bypQReqSize. If the memory of the array of the linear terms passed to function is not sufficient, then return the firstnElemSizelinear terms, and the minimal required length of linear terms bypReqSize.Arguments
probThe COPT problem.
qConstrIdxIndex of the quadratic constraint.
qMatRowRow index of non-zero quadratic terms of the quadratic constraint (row).
qMatColColumn index of non-zero quadratic terms of the quadratic constraint (row).
qMatElemValues of non-zero quadratic terms of the quadratic constraint (row).
nQElemSizeLength of array for non-zero quadratic terms of the quadratic constraint (row).
pQReqSizePointer to minimal length of array for non-zero quadratic terms of the quadratic constraint (row). Can be
NULL.
rowMatIdxColumn index of non-zero linear terms of the quadratic constraint (row).
rowMatElemValues of non-zero linear terms of the quadratic constraint (row).
cRowSenseThe sense of the quadratic constraint (row).
dRowBoundRight hand side of the quadratic constraint (row).
nElemSizeLength of array for non-zero linear terms of the quadratic constraint (row).
pReqSizePointer to minimal length of array for non-zero linear terms of the quadratic constraint (row). Can be
NULL.
COPT_GetPSDConstr
Synopsis
int COPT_GetPSDConstr(
copt_prob *prob,
int psdConstrIdx,
int *psdColIdx,
int *symMatIdx,
int nColSize,
int *pColReqSize,
int *rowMatIdx,
double *rowMatElem,
double *dRowLower,
double *dRowUpper,
int nElemSize,
int *pReqSize)Description
Get PSD constraint.
In general, users need to call this function twice to accomplish the task. Fisrtly, by passing
NULLto argumentspsdColIdxandsymMatIdx, we get number of PSD terms bypColReqSizespecified bypsdConstrIdx, by passingNULLto argumentsrowMatIdxandrowMatElem, we get number of linear terms bypReqSizespecified byqConstrIdx. Secondly, allocate sufficient memory for the PSD terms and the linear terms, and call this function again to extract the PSD constraint. If the memory of the array of the PSD terms passed to function is not sufficient, then return the firstnColSizePSD terms, and the minimal required length of PSD terms bypColReqSize. If the memory of the array of the linear terms passed to function is not sufficient, then return the firstnElemSizelinear terms, and the minimal required length of linear terms bypReqSize.Arguments
probThe COPT problem.
psdConstrIdxPSD constraint index.
psdColIdxPSD variable index.
symMatIdxSymmetric matrix index.
nColSizeLength of array for PSD terms of the PSD constraint.
pColReqSizePointer to minimal length of array for PSD terms of the PSD constraint. Can be
NULL.
rowMatIdxColumn index of non-zero linear terms of the PSD constraint.
rowMatElemValues of non-zero linear terms of the PSD constraint.
dRowLowerPointer to lower bound of the PSD constraint.
dRowUpperPointer to upper bound of the PSD constraint.
nElemSizeLength of array for non-zero linear terms of the PSD constraint.
pReqSizePointer to minimal length of array for non-zero linear terms of the PSD constraint (row). Can be
NULL.
COPT_GetLMIConstr
Synopsis
int COPT_GetLMIConstr(
copt_prob *prob,
int lmiConstrIdx,
int *nDim,
int *nLMILen,
int *colIdx,
int *symMatIdx,
int *constMatIdx,
int nElemSize,
int *pReqSize)Description
Gets the LMI constraint with the specified index in the model.
Arguments
probThe COPT problem.
lmiConstrIdxLMI constraint index.
nDimPointer to the dimension of symmetric matrix in the LMI constraint.
nLMILenPointer to the flattened length of the LMI constraint.
colIdxIndex of scalar variable in the LMI constraint.
symMatIdxIndex of symmetric coefficient matrix in the LMI constraint.
constMatIdxPointer to the index of symmetric constant-term matrix in the LMI constraint.
nElemSizeLength of array for non-zero linear terms of the LMI constraint.
pReqSizePointer to minimal length of array for non-zero linear terms of the LMI constraint (row). Can be
NULL.
COPT_GetIndicator
Synopsis
int COPT_GetIndicator(
copt_prob *prob,
int rowIdx,
int *binColIdx,
int *binColVal,
int *nRowMatCnt,
int *rowMatIdx,
double *rowMatElem,
char *cRowSense,
double *dRowBound,
int nElemSize,
int *pReqSize)Description
Get the data of an indicator constraint.
In general, users need to call this function twice to accomplish the task. Firstly, by passing
NULLto argumentsnRowMatCnt,rowMatIdxandrowMatElem, we get number of non-zeros elements bypReqSizespecified byrowIdx. Secondly, allocate sufficient memory for sparse row vector and call this function again to extract data.If the memory of sparse row vector passed to function is not sufficient, then return the first
nElemSizenon-zero elements, and the minimal required length of non-zero elements bypReqSize.Arguments
probThe COPT problem.
rowIdxIndex of the indicator constraint.
binColIdxIndex of the indicator variable (column).
binColValValue of the indicator variable (column).
nRowMatCntNumber of non-zeros elements in the linear constraint (row).
rowMatIdxColumn index of non-zeros elements in the linear constraint (row).
rowMatElemValues of non-zero elements in the linear constraint (row).
cRowSenseThe sense of the linear constraint (row).
dRowBoundRight hand side of the linear constraint (row).
nElemSizeLength of array for non-zero coefficients.
pReqSizePointer to minimal length of array for non-zero coefficients. Can be
NULL.
COPT_GetIndicators
Synopsis
int COPT_GetIndicators(
copt_prob *prob,
int nInd,
int *list,
int *indType,
int *binColIdx,
int *binColVal,
int *rowMatBeg,
int *rowMatCnt,
int *rowMatIdx,
double *rowMatElem,
char *cRowSense,
double *dRowBound,
int nElemSize,
int *pReqSize)Description
Get the data of a set of indicator constraints.
In general, users need to call this function twice to accomplish the task. Firstly, by passing
NULLto argumentsrowMatBeg,rowMatCnt,rowMatIdx, we get number of non-zeros elements bypReqSizespecified bynIndandlist. Secondly, allocate sufficient memory for CRS-format matrix and call this function again to extract coefficient matrix.If the memory of coefficient matrix passed to function is not sufficient, then return the first
nElemSizenon-zero elements, and the minimal required length of non-zero elements bypReqSize. IflistisNULL, then the firstnIndrows will be returned.Arguments
probThe COPT problem.
nIndNumber of indicator constraints (rows).
listIndex of indicator constraints. Can be
NULL.
indTypeType of indicator constraints. Please refer to Indicator constraint types for possible values.
binColIdxIndex of the indicator variable (column).
binColValValue of the indicator variable (column).
rowMatBeg, rowMatCnt, rowMatIdxandrowMatElemDefines the coefficient matrix of indcator constrants in compressed row storage (CRS) format. Please see other information of
COPT_LoadProbfor an example of the CRS format.
cRowSenseThe sense of the linear constraint (row).
dRowBoundRight hand side of the linear constraint (row).
nElemSizeLength of array for non-zero coefficients.
pReqSizePointer to minimal length of array for non-zero coefficients. Can be
NULL.
COPT_GetNLConstr
Synopsis
int COPT_GetNLConstr(
copt_prob *prob,
int nlConstrIdx,
int *token,
double *tokenElem,
int nToken,
int nTokenElem,
int *pReqToken,
int *pReqTokenElem,
int *rowMatIdx,
double *rowMatElem,
double *dRowLower,
double *dRowUpper,
int nElemSize,
int *pReqElemSize)Description
Retrieve the nonlinear expression constraint at the specified index.
Arguments
probThe COPT problem.
nlConstrIdxIndex of the constraint.
tokenArray of tokens in the expression.
tokenElemArray of constants in the expression.
nTokenNumber of tokens in the expression.
nTokenElemNumber of constants in the expression.
pReqTokenPointer to the number of tokens in the expression.
pReqTokenElemPointer to the number of constants in the expression.
rowMatIdxIndices of linear terms in the constraint.
rowMatElemCoefficients of linear terms in the constraint.
dRowLowerPointer to the lower bound of the constraint.
dRowUpperPointer to the upper bound of the constraint.
nElemSizeNumber of linear terms in the constraint.
pReqElemSizePointer to the number of linear terms.
COPT_GetColIdx
Synopsis
int COPT_GetColIdx(copt_prob *prob, const char *colName, int *p_iCol)Description
Get index of column by name.
Arguments
probThe COPT problem.
colNameName of column.
p_iColPointer to index of column.
COPT_GetPSDColIdx
Synopsis
int COPT_GetPSDColIdx(copt_prob *prob, const char *psdColName, int *p_iPSDCol)Description
Get index of PSD variable by name.
Arguments
probThe COPT problem.
psdColNameName of PSD variable.
p_iPSDColPointer to index of PSD variable.
COPT_GetRowIdx
Synopsis
int COPT_GetRowIdx(copt_prob *prob, const char *rowName, int *p_iRow)Description
Get index of row by name.
Arguments
probThe COPT problem.
rowNameName of row.
p_iRowPointer to index of row.
COPT_GetQConstrIdx
Synopsis
int COPT_GetQConstrIdx(copt_prob *prob, const char *qConstrName, int *p_iQConstr)Description
Get index of quadratic constraint by name.
Arguments
probThe COPT problem.
qConstrNameName of quadratic constraint.
p_iQConstrPointer to index of quadratic constraint.
COPT_GetPSDConstrIdx
Synopsis
int COPT_GetPSDConstrIdx(copt_prob *prob, const char *psdConstrName, int *p_iPSDConstr)Description
Get index of PSD constraint by name.
Arguments
probThe COPT problem.
psdConstrNameName of PSD constraint.
p_iPSDConstrPointer to index of PSD constraint.
COPT_GetLMIConstrIdx
Synopsis
int COPT_GetLMIConstrIdx(copt_prob *prob, const char *lmiConstrName, int *p_iLMIConstr)Description
Get index of LMI constraint by name.
Arguments
probThe COPT problem.
lmiConstrNameName of LMI constraint.
p_iLMIConstrPointer to index of LMI constraint.
COPT_GetIndicatorIdx
Synopsis
int COPT_GetIndicatorIdx(copt_prob *prob, const char *indicatorName, int *p_iIndicator)Description
Get index of indicator constraint by name.
Arguments
probThe COPT problem.
indicatorNameName of indicator constraint.
p_iIndicatorPointer to index of indicator constraint.
COPT_GetAffineConeIdx
Synopsis
int COPT_GetAffineConeIdx(copt_prob *prob, const char *affConeName, int *p_iAffCone)Description
Get index of affine cone by name.
Arguments
probThe COPT problem.
affConeNameName of affine cone.
p_iAffConePointer to index of affine cone.
COPT_GetNLConstrIdx
Synopsis
int COPT_GetNLConstrIdx(copt_prob *prob, const char *nlConstrName, int *p_iNLConstr)Description
Retrieve the index of a nonlinear expression constraint by name.
Arguments
probThe COPT problem.
nlConstrNameName of the nonlinear expression constraint.
p_iNLConstrPointer to the internal index of the nonlinear expression constraint in COPT.
COPT_GetColInfo
Synopsis
int COPT_GetColInfo(copt_prob *prob, const char *infoName, int num, const int *list, double *info)Description
Get information of column. If
listisNULL, then information of the firstnumcolumns will be returned.Arguments
probThe COPT problem.
infoNameName of information. Please refer to Information for supported information.
numNumber of columns.
listIndex of columns. Can be
NULL.
infoArray of information.
COPT_GetPSDColInfo
Synopsis
int COPT_GetPSDColInfo(copt_prob *prob, const char *infoName, int iCol, double *info)Description
Get information of PSD variable.
Arguments
probThe COPT problem.
infoNameName of information. Please refer to Information for supported information.
iColIndex of PSD variable.
infoArray of information.
COPT_GetRowInfo
Synopsis
int COPT_GetRowInfo(copt_prob *prob, const char *infoName, int num, const int *list, double *info)Description
Get information of row. If
listisNULL, then information of the firstnumrows will be returned.Arguments
probThe COPT problem.
infoNameName of information. Please refer to Information for supported information.
numNumber of rows.
listIndex of rows. Can be
NULL.
infoArray of information.
COPT_GetQConstrInfo
Synopsis
int COPT_GetQConstrInfo(copt_prob *prob, const char *infoName, int num, const int *list, double *info)Description
Get information of quadratic constraints. If
listisNULL, then information of the firstnumquadratic constraints will be returned.Arguments
probThe COPT problem.
infoNameName of information. Please refer to Information for supported information.
numNumber of quadratic constraints.
listIndex of quadratic constraints. Can be
NULL.
infoArray of information.
COPT_GetPSDConstrInfo
Synopsis
int COPT_GetPSDConstrInfo(copt_prob *prob, const char *infoName, int num, const int* list, double *info)Description
Get information of PSD constraints. If
listisNULL, then information of the firstnumPSD constraints will be returned.Arguments
probThe COPT problem.
infoNameName of information. Please refer to Information for supported information.
numNumber of PSD constraints.
listIndex of PSD constraints. Can be
NULL.
infoArray of information.
COPT_GetLMIConstrInfo
Synopsis
int COPT_GetLMIConstrInfo(copt_prob *prob, const char *infoName, int iLMI, double *info)Description
Get a set of information about LMI constraints.
Arguments
probThe COPT problem.
infoNameName of information. Possible values are:
COPT_DBLINFO_SLACKandCOPT_DBLINFO_DUAL.
iLMIThe index of the LMI constraint whose information is to be retrieved.
infoArray of information.
COPT_GetNLConstrInfo
Synopsis
int COPT_GetNLConstrInfo(copt_prob *prob, const char *infoName,int num, const int *list, double *info)Description
Retrieve information about nonlinear expression constraints. If
listisNULL, the function returns information for the firstnumnonlinear expression constraints.Arguments
probThe COPT problem.
infoNameName of the information to retrieve. Currently supported nonlinear expression constraint information is:
"LB","UB"and"Slack".
numNumber of nonlinear expression constraints to retrieve information for.
listIndex list of nonlinear expression constraints to retrieve information for. Can be
NULL.
infoArray to store the retrieved information.
COPT_GetColType
Synopsis
int COPT_GetColType(copt_prob *prob, int num, const int *list, char *type)Description
Get types of columns. If
listisNULL, then types of the firstnumcolumns will be returned.Arguments
probThe COPT problem.
numNumber of columns.
listIndex of columns. Can be
NULL.
typeTypes of columns.
COPT_GetColBasis
Synopsis
int COPT_GetColBasis(copt_prob *prob, int num, const int *list, int *colBasis)Description
Get basis status of columns. If
listisNULL, then basis status of the firstnumcolumns will be returned.Arguments
probThe COPT problem.
numNumber of columns.
listIndex of columns. Can be
NULL.
colBasisBasis status of columns.
COPT_GetRowBasis
Synopsis
int COPT_GetRowBasis(copt_prob *prob, int num, const int *list, int *rowBasis)Description
Get basis status of rows. If
listisNULL, then basis status of the firstnumrows will be returned.Arguments
probThe COPT problem.
numNumber of rows.
listIndex of rows. Can be
NULL.
rowBasisBasis status of rows.
COPT_GetQConstrSense
Synopsis
int COPT_GetQConstrSense(copt_prob *prob, int num, const int *list, char *sense)Description
Get senses of quadratic constraints. If
listisNULL, then types of the firstnumquadratic constraints will be returned.Arguments
probThe COPT problem.
numNumber of quadratic constraints.
listIndex of quadratic constraints. Can be
NULL.
senseArray of senses.
COPT_GetQConstrRhs
Synopsis
int COPT_GetQConstrRhs(copt_prob *prob, int num, const int *list, double *rhs)Description
Get RHS of quadratic constraints. If
listisNULL, then types of the firstnumquadratic constraints will be returned.Arguments
probThe COPT problem.
numNumber of quadratic constraints.
listIndex of quadratic constraints. Can be
NULL.
rhsArray of RHS.
COPT_GetColName
Synopsis
int COPT_GetColName(copt_prob *prob, int iCol, char *buff, int buffSize, int *pReqSize)Description
Get name of column by index. If memory of
buffis not sufficient, then return the firstbuffSizelength of sub-string, and the length of name requested bypReqSize. IfbuffisNULL, then we can get the length of name requested bypReqSize.Arguments
probThe COPT problem.
iColIndex of column.
buffBuffer for storing name.
buffSizeLength of the buffer.
pReqSizeLength of the requested name. Can be
NULL.
COPT_GetPSDColName
Synopsis
int COPT_GetPSDColName(copt_prob *prob, int iPSDCol, char *buff, int buffSize, int *pReqSize)Description
Get name of PSD variable by index. If memory of
buffis not sufficient, then return the firstbuffSizelength of sub-string, and the length of name requested bypReqSize. IfbuffisNULL, then we can get the length of name requested bypReqSize.Arguments
probThe COPT problem.
iPSDColIndex of PSD variable.
buffBuffer for storing name.
buffSizeLength of the buffer.
pReqSizeLength of the requested name. Can be
NULL.
COPT_GetRowName
Synopsis
int COPT_GetRowName(copt_prob *prob, int iRow, char *buff, int buffSize, int *pReqSize)Description
Get name of row by index. If memory of
buffis not sufficient, then return the firstbuffSizelength of sub-string, and the length of name requested bypReqSize. IfbuffisNULL, then we can get the length of name requested bypReqSize.Arguments
probThe COPT problem.
iRowIndex of row.
buffBuffer for storing name.
buffSizeLength of the buffer.
pReqSizeLength of the requested name. Can be
NULL.
COPT_GetQConstrName
Synopsis
int COPT_GetQConstrName(copt_prob *prob, int iQConstr, char *buff, int buffSize, int *pReqSize)Description
Get name of quadratic constraint by index. If memory of
buffis not sufficient, then return the firstbuffSizelength of sub-string, and the length of name requested bypReqSize. IfbuffisNULL, then we can get the length of name requested bypReqSize.Arguments
probThe COPT problem.
iQConstr`Index of quadratic constraint.
buffBuffer for storing name.
buffSizeLength of the buffer.
pReqSizeLength of the requested name. Can be
NULL.
COPT_GetPSDConstrName
Synopsis
int COPT_GetPSDConstrName(copt_prob *prob, int iPSDConstr, char *buff, int buffSize, int *pReqSize)Description
Get name of PSD constraint by index. If memory of
buffis not sufficient, then return the firstbuffSizelength of sub-string, and the length of name requested bypReqSize. IfbuffisNULL, then we can get the length of name requested bypReqSize.Arguments
probThe COPT problem.
iPSDConstr`Index of PSD constraint.
buffBuffer for storing name.
buffSizeLength of the buffer.
pReqSizeLength of the requested name. Can be
NULL.
COPT_GetLMIConstrName
Synopsis
int COPT_CALL COPT_GetLMIConstrName(copt_prob *prob, int iLMIConstr, char *buff, int buffSize, int *pReqSize)Description
Get name of LMI constraint by index. If memory of
buffis not sufficient, then return the firstbuffSizelength of sub-string, and the length of name requested bypReqSize. IfbuffisNULL, then we can get the length of name requested bypReqSize.Arguments
probThe COPT problem.
iLMIConstrIndex of LMI constraint.
buffBuffer for storing name.
buffSizeLength of the buffer.
pReqSizeLength of the requested name. Can be
NULL.
COPT_GetIndicatorName
Synopsis
int COPT_GetIndicatorName(copt_prob *prob, int iIndicator, char *buff, int buffSize, int *pReqSize)Description
Get name of indicator constraints by index. If memory of
buffis not sufficient, then return the firstbuffSizelength of sub-string, and the length of name requested bypReqSize. IfbuffisNULL, then we can get the length of name requested bypReqSize.Arguments
probThe COPT problem.
iIndicatorIndex of indicator constraint.
buffBuffer for storing name.
buffSizeLength of the buffer.
pReqSizeLength of the requested name. Can be
NULL.
COPT_GetAffineConeName
Synopsis
int COPT_GetAffineConeName(copt_prob *prob, int iAffCone, char *buff, int buffSize, int *pReqSize)Description
Get name of affine cone by index. If memory of
buffis not sufficient, then return the firstbuffSizelength of sub-string, and the length of name requested bypReqSize. IfbuffisNULL, then we can get the length of name requested bypReqSize.Arguments
probThe COPT problem.
iAffConeIndex of affine cone.
buffBuffer for storing name.
buffSizeLength of the buffer.
pReqSizeLength of the requested name. Can be
NULL.
COPT_GetNLConstrName
Synopsis
int COPT_GetNLConstrName(copt_prob *prob, int iNLConstr, char *buff,int buffSize, int *pReqSize)Description
Retrieve the name of nonlinear constraint by index. If the provided
bufflength is insufficient, the function returns a substring of lengthbuffSize, and the full required string length is returned viapReqSize.If
buffisNULL, the function returns the required string length viapReqSize.Arguments
probThe COPT problem.
iNLConstrIndex of the nonlinear expression constraint.
buffArray to store the retrieved name string.
buffSizeSize of the provided array.
pReqSizePointer to store the minimum required string length for the full name. Can be
NULL.
COPT_GetLMIConstrRhs
Synopsis
int COPT_GetLMIConstrRhs(copt_prob *prob, int num, const int *list, int *constMatIdx)Description
Get the constant-term symmetric matrix of
numLMI constraints.Arguments
probThe COPT problem.
numNumber of LMI constraints.
listIndex of LMI constraints.
constMatIdxIndex of constant-term symmetric in the LMI constraints.
Accessing and setting parameters
COPT_SetIntParam
Synopsis
int COPT_SetIntParam(copt_prob *prob, const char *paramName, int intParam)Description
Sets an integer parameter.
Arguments
probThe COPT problem.
paramNameThe name of the integer parameter.
intParamThe value of the integer parameter.
COPT_GetIntParam, COPT_GetIntParamDef/Min/Max
Synopsis
int COPT_GetIntParam(copt_prob *prob, const char *paramName, int *p_intParam)
int COPT_GetIntParamDef(copt_prob *prob, const char *paramName, int *p_intParam)
int COPT_GetIntParamMin(copt_prob *prob, const char *paramName, int *p_intParam)
int COPT_GetIntParamMax(copt_prob *prob, const char *paramName, int *p_intParam)Description
Gets the
current
default
minimal
maximal
value of an integer parameter.
Arguments
probThe COPT problem.
paramNameThe name of the integer parameter.
p_intParamPointer to the value of the integer parameter.
COPT_SetDblParam
Synopsis
int COPT_SetDblParam(copt_prob *prob, const char *paramName, double dblParam)Description
Sets a double parameter.
Arguments
probThe COPT problem.
paramNameThe name of the double parameter.
dblParamThe value of the double parameter.
COPT_GetDblParam, COPT_GetDblParamDef/Min/Max
Synopsis
int COPT_GetDblParam(copt_prob *prob, const char *paramName, double *p_dblParam)
int COPT_GetDblParamDef(copt_prob *prob, const char *paramName, double *p_dblParam)
int COPT_GetDblParamMin(copt_prob *prob, const char *paramName, double *p_dblParam)
int COPT_GetDblParamMax(copt_prob *prob, const char *paramName, double *p_dblParam)Description
Gets the
current
default
minimal
maximal
value of a double parameter.
Arguments
probThe COPT problem.
paramNameThe name of the double parameter.
p_dblParamPointer to the value of the double parameter.
COPT_ResetParam
Synopsis
int COPT_ResetParam(copt_prob *prob)Description
Reset parameters to default settings.
Arguments
probThe COPT problem.
COPT_WriteParam
Synopsis
int COPT_WriteParam(copt_prob *prob, const char *parfilename)Description
Writes user defined parameters to a file. This API function will write out all the parameters that are different from their default values.
Arguments
probThe COPT problem.
parfilenameThe path to the parameter file.
COPT_WriteParamStr
Synopsis
int COPT_WriteParamStr(copt_prob *prob, char *str, int nStrSize, int *pReqSize)Description
Writes the modified parameters to a string buffer.
Arguments
probThe COPT problem.
strString buffer of modified parameters.
nStrSizeThe size of string buffer.
pReqSizeMinimum space requirement of string buffer for modified parameters.
COPT_ReadParam
Synopsis
int COPT_ReadParam(copt_prob *prob, const char *parfilename)Description
Reads and applies parameters settings as defined in the parameter file.
Arguments
probThe COPT problem.
parfilenameThe path to the parameter file.
COPT_ReadParamStr
Synopsis
int COPT_ReadParamStr(copt_prob *prob, const char *strParam)Description
Read parameter settings from string buffer, and set parameters in COPT.
Arguments
probThe COPT problem.
strParamString buffer of parameter settings.
Accessing attributes
COPT_GetIntAttr
Synopsis
int COPT_GetIntAttr(copt_prob *prob, const char *attrName, int *p_intAttr)Description
Gets the value of an integer attribute.
Arguments
probThe COPT problem.
attrNameThe name of the integer attribute.
p_intAttrPointer to the value of the integer attribute.
COPT_GetDblAttr
Synopsis
int COPT_GetDblAttr(copt_prob *prob, const char *attrName, int *p_dblAttr)Description
Gets the value of an double attribute.
Arguments
probThe COPT problem.
attrNameThe name of the double attribute.
p_dblAttrPointer to the value of the double attribute.
Logging utilities
COPT_SetLogFile
Synopsis
int COPT_SetLogFile(copt_prob *prob, char *logfilename)Description
Set log file for the problem.
Arguments
probThe COPT problem.
logfilenameThe path to the log file.
COPT_SetLogCallback
Synopsis
int COPT_SetLogCallback(copt_prob *prob, void (*logcb)(char *msg, void *userdata), void *userdata)Description
Set message callback for the problem.
Arguments
probThe COPT problem.
logcbCallback function for message.
userdataUser defined data. The data will be passed to the solver without modification.
MIP start utilities
COPT_AddMipStart
Synopsis
int COPT_AddMipStart(copt_prob *prob, int num, const int *list, double *colVal)Description
Add MIP start information for the problem. If
listisNULL, then information of the firstnumcolumns will be added.One MIP start information will be added for each call to this function.
Arguments
probThe COPT problem.
numNumber of variables (columns).
listIndex of variables (columns). Can be
NULL.
colValMIP start information.
COPT_ReadMst
Synopsis
int COPT_ReadMst(copt_prob *prob, const char *mstfilename)Description
Read MIP start information from file, and used as initial solution for the problem.
Arguments
probThe COPT problem.
mstfilenameThe path to the MIP start file.
COPT_WriteMst
Synopsis
int COPT_WriteMst(copt_prob *prob, const char *mstfilename)Description
Write solution or existed MIP start information in problem to file.
Arguments
probThe COPT problem.
mstfilenameThe path to the MIP start file.
Nonlinear start point utilities
COPT_SetNLPrimalStart
Synopsis
int COPT_SetNLPrimalStart(copt_prob *prob, int num, const int *list, double *colVal)Description
Set nonlinear primal start information for the problem. If
listisNULL, then information of the firstnumcolumns will be set.Arguments
probThe COPT problem.
numNumber of variables (columns).
listIndex of variables (columns). Can be
NULL.
colValNonlinear primal start information.
IIS utilities
COPT_ComputeIIS
Synopsis
int COPT_ComputeIIS(copt_prob *prob)Description
Compute IIS (Irreducible Inconsistent Subsystem) for infeasible problem.
Arguments
probThe COPT problem.
COPT_GetColLowerIIS
Synopsis
int COPT_GetColLowerIIS(copt_prob *prob, int num, const int *list, int *colLowerIIS)Description
Get IIS status of lower bounds of columns. If
listisNULL, then IIS status of the firstnumcolumns will be returned.Arguments
probThe COPT problem.
numNumber of columns.
listIndex of columns. Can be
NULL.
colLowerIISIIS status of lower bounds of columns.
COPT_GetColUpperIIS
Synopsis
int COPT_GetColUpperIIS(copt_prob *prob, int num, const int *list, int *colUpperIIS)Description
Get IIS status of upper bounds of columns. If
listisNULL, then IIS status of the firstnumcolumns will be returned.Arguments
probThe COPT problem.
numNumber of columns.
listIndex of columns. Can be
NULL.
colUpperIISIIS status of upper bounds of columns.
COPT_GetRowLowerIIS
Synopsis
int COPT_GetRowLowerIIS(copt_prob *prob, int num, const int *list, int *rowLowerIIS)Description
Get IIS status of lower bounds of rows. If
listisNULL, then IIS status of the firstnumrows will be returned.Arguments
probThe COPT problem.
numNumber of rows.
listIndex of rows. Can be
NULL.
rowLowerIISIIS status of lower bounds of rows.
COPT_GetRowUpperIIS
Synopsis
int COPT_GetRowUpperIIS(copt_prob *prob, int num, const int *list, int *rowUpperIIS)Description
Get IIS status of upper bounds of rows. If
listisNULL, then IIS status of the firstnumrows will be returned.Arguments
probThe COPT problem.
numNumber of rows.
listIndex of rows. Can be
NULL.
rowUpperIISIIS status of upper bounds of rows.
COPT_GetSOSIIS
Synopsis
int COPT_GetSOSIIS(copt_prob *prob, int num, const int *list, int *sosIIS)Description
Get IIS status of SOS constraints. If
listisNULL, then IIS status of the firstnumSOS constraints will be returned.Arguments
probThe COPT problem.
numNumber of SOS constraints.
listIndex of SOS constraints. Can be
NULL.
sosIISIIS status of SOS constraints.
COPT_GetIndicatorIIS
Synopsis
int COPT_GetIndicatorIIS(copt_prob *prob, int num, const int *list, int *indicatorIIS)Description
Get IIS status of indicator constraints. If
listisNULL, then IIS status of the firstnumindicator constraints will be returned.Arguments
probThe COPT problem.
numNumber of indicator constraints.
listIndex of indicator constraints. Can be
NULL.
indicatorIISIIS status of indicator constraints.
Feasibility relaxation utilities
COPT_FeasRelax
Synopsis
int COPT_FeasRelax(copt_prob *prob, double *colLowPen, double *colUppPen, double *rowBndPen, double *rowUppPen)Description
Compute feasibility relaxation to infeasible problem.
Arguments
probThe COPT problem.
colLowPenPenalty for lower bounds of columns. If
NULL, then no relaxation for lower bounds of columns are allowed; If penalty incolLowPenisCOPT_INFINITY, then no relaxation is allowed for corresponding bound.
colUppPenPenalty for upper bounds of columns. If
NULL, then no relaxation for upper bounds of columns are allowed; If penalty incolUppenisCOPT_INFINITY, then no relaxation is allowed for corresponding bound.
rowBndPenPenalty for bounds of rows. If
NULL, then no relaxation for bounds of rows are allowed; If penalty inrowBndPenisCOPT_INFINITY, then no relaxation is allowed for corresponding bound.
rowUppPenPenalty for upper bounds of rows. If problem has two-sided rows, and
rowUppPenis notNULL, thenrowUppPenis penalty for upper bounds of rows; If penalty inrowUppPenisCOPT_INFINITY, then no relaxation is allowed for corresponding bound.Note: Normally, just set
rowUppPentoNULL.
COPT_WriteRelax
Synopsis
int COPT_WriteRelax(copt_prob *prob, const char *relaxfilename)Description
Write feasrelax problem to file.
Arguments
probThe COPT problem.
relaxfilenameName of feasrelax problem file.
Parameter tuning utilities
COPT_Tune
Synopsis
int COPT_Tune(copt_prob *prob)Description
Parameter tuning of the model.
Arguments
probCOPT model.
COPT_LoadTuneParam
Synopsis
int COPT_LoadTuneParam(copt_prob *prob, int idx)Description
Load the parameter tuning results of the specified number into the model.
Arguments
probCOPT model.
idxThe number of the parameter tuning result.
COPT_ReadTune
Synopsis
int COPT_ReadTune(copt_prob *prob, const char *tunefilename)Description
Read the parameter combination to be tuned from the tuning file to the model.
Arguments
probCOPT model.
tunefilenameTuning file names.
COPT_WriteTuneParam
Synopsis
int COPT_WriteTuneParam(copt_prob *prob, int idx, const char *parfilename)Description
Output the parameter tuning result of the specified number to the parameter file.
Arguments
probCOPT model.
idxThe number of the parameter tuning result.
parfilenameparameter file name.
COPT_ReadOrd
Synopsis
int COPT_ReadOrd(copt_prob *prob, const char *ordfilename)Description
Read a branching order file (ORD-format) into the current model to reuse a predefined branching strategy.
Arguments
probThe COPT problem.
ordfilenameName of the branching order file.
COPT_WriteOrd
Synopsis
int COPT_WriteOrd(copt_prob *prob, const char *ordfilename)Description
Write the branching order information of the current model into an ORD-format file, so that the branching strategy can be saved and reused.
Arguments
probThe COPT problem.
ordfilenamePath of the ORD-format file.
Callback utilities
Certain callback utilities methods can only be called in certain contexts, which are listed below:
Context |
Methods |
|---|---|
COPT_CBCONTEXT_INCUMBENT |
|
COPT_CBCONTEXT_MIPSOL |
COPT_AddCallbackLazyConstr, COPT_AddCallbackLazyConstrs, COPT_AddCallbackSolution, COPT_GetCallbackInfo |
COPT_CBCONTEXT_MIPRELAX |
COPT_AddCallbackUserCut, COPT_AddCallbackUserCuts, COPT_AddCallbackSolution, COPT_GetCallbackInfo |
COPT_CBCONTEXT_MIPNODE |
COPT_AddLazyConstr
Synopsis
int COPT_AddLazyConstr(
copt_prob *prob,
int nRowMatCnt,
const int *rowMatIdx,
const double *rowMatElem,
char cRowSense,
double dRowBound,
double dRowUpper,
const char *rowName)Description
Add a lazy constraint to the MIP model.
Arguments
probThe COPT problem.
nRowMatCntNumber of non-zero elements in the lazy constraint.
rowMatIdxColumn index of non-zero elements in the lazy constraint.
rowMatElemValues of non-zero elements in the lazy constraint.
cRowSenseThe sense of the new lazy constraint.
Please refer to Constraint senses for all the supported types.
If
cRowSenseis 0, thendRowBoundanddRowUpperwill be treated as lower and upper bounds for the constraint. This is the recommended method for defining constraints.If
cRowSenseis provided, thendRowBoundanddRowUpperwill be treated as RHS and range for the constraint. In this case,dRowUpperis only required whencRowSense = COPT_RANGE, wherelower bound is
dRowBound - dRowUpperupper bound is
dRowBound
dRowBoundLower bound or RHS of the lazy constraint.
dRowUpperUpper bound or range of the lazy constraint.
rowNameThe name of the lazy constraint. Can be
NULL.
COPT_AddLazyConstrs
Synopsis
int COPT_AddLazyConstrs(
copt_prob *prob,
int nAddRow,
const int *rowMatBeg,
const int *rowMatCnt,
const int *rowMatIdx,
const double *rowMatElem,
const char *rowSense,
const double *rowBound,
const double *rowUpper,
char const *const *rowNames)Description
Add a set of lazy constraints to the MIP model.
Arguments
probThe COPT problem.
nAddRowNumber of new lazy constraints.
rowMatBeg, rowMatCnt, rowMatIdxandrowMatElemDefines the coefficient matrix in compressed row storage (CRS) format. The CRS format is similar to the CCS format described in the other information of
COPT_LoadProb.
rowSenseSenses of new lazy constraints.
Please refer to Constraint senses for all the supported types.
If
rowSenseisNULL, thenrowBoundandrowUpperwill be treated as lower and upper bounds for constraints. This is the recommended method for defining constraints.If
rowSenseis provided, thenrowBoundandrowUpperwill be treated as RHS and range for constraints. In this case,rowUpperis only required when there areCOPT_RANGEconstraints, where thelower bound is
rowBound[i] - fabs(rowUpper[i])upper bound is
rowBound[i]
rowBoundLower bounds or RHS of new lazy constraints.
rowUpperUpper bounds or range of new lazy constraints.
rowNamesNames of new lazy constraints. Can be
NULL.
COPT_AddUserCut
Synopsis
int COPT_AddUserCut(
copt_prob* prob,
int nRowMatCnt,
const int* rowMatIdx,
const double* rowMmatElem,
char cRowSense,
double dRowBound,
double dRowUpper,
const char* rowName)Description
Add a user cut to the MIP model.
Arguments
probThe COPT problem.
nRowMatCntNumber of non-zero elements in the user cut.
rowMatIdxColumn index of non-zero elements in the user cut.
rowMatElemValues of non-zero elements in the user cut.
cRowSenseThe sense of the user cut.
Please refer to Constraint senses for all the supported types.
If
cRowSenseis 0, thendRowBoundanddRowUpperwill be treated as lower and upper bounds for the constraint. This is the recommended method for defining constraints.If
cRowSenseis provided, thendRowBoundanddRowUpperwill be treated as RHS and range for the constraint. In this case,dRowUpperis only required whencRowSense = COPT_RANGE, wherelower bound is
dRowBound - dRowUpperupper bound is
dRowBound
dRowBoundLower bound or RHS of the user cut.
dRowUpperUpper bound or range of the user cut.
rowNameThe name of the user cut. Can be
NULL.
COPT_AddUserCuts
Synopsis
int COPT_CALL COPT_AddUserCuts(
copt_prob *prob,
int nAddRow,
const int *rowMatBeg,
const int *rowMatCnt,
const int *rowMatIdx,
const double *rowMatElem,
const char *rowSense,
const double *rowBound,
const double *rowUpper,
char const *const *rowNames)Description
Add a set of user cuts to the MIP model.
Arguments
probThe COPT problem.
nAddRowNumber of new user cuts.
rowMatBeg, rowMatCnt, rowMatIdxandrowMatElemDefines the coefficient matrix in compressed row storage (CRS) format. The CRS format is similar to the CCS format described in the other information of
COPT_LoadProb.
rowSenseSenses of new user cuts.
Please refer to Constraint senses for all the supported types.
If
rowSenseisNULL, thenrowBoundandrowUpperwill be treated as lower and upper bounds for constraints. This is the recommended method for defining constraints.If
rowSenseis provided, thenrowBoundandrowUpperwill be treated as RHS and range for constraints. In this case,rowUpperis only required when there areCOPT_RANGEconstraints, where thelower bound is
rowBound[i] - fabs(rowUpper[i])upper bound is
rowBound[i]
rowBoundLower bounds or RHS of new user cuts.
rowUpperUpper bounds or range of new user cuts.
rowNamesNames of new user cuts. Can be
NULL.
COPT_SetCallback
Synopsis
int COPT_SetCallback(
copt_prob *prob,
int (COPT_CALL *cb)(copt_prob *prob, void *cbdata, int cbctx, void *userdata),
int cbctx,
void *userdata)Description
Set the callback function of the model.
Arguments
probThe COPT problem.
cbCallback function.
cbctxCallback context. Please refer to Callback context .
userdataUser defined data. The data will be passed to the solver without modification.
COPT_GetCallbackInfo
Synopsis
int COPT_GetCallbackInfo(void *cbdata, const char* cbinfo, void *p_val)Description
Retrieve the value of the specified callback information.
Arguments
cbdataThe cbdata argument that was passed into the user callback by COPT. This argument must be passed unmodified from the user callback to COPT_GetCallbackInfo().
cbinfoThe name of the callback information. Please refer to Callback information for possible values.
p_valPointer to the value of the callback information.
COPT_AddCallbackSolution
Synopsis
int COPT_AddCallbackSolution(void *cbdata, const double *sol, double* p_objval)Description
Set feasible solutions for the specified variables.
Arguments
cbdataThe cbdata argument that was passed into the user callback by COPT. This argument must be passed unmodified from the user callback to COPT_AddCallbackSolution().
solThe solution vector.
p_objvalPointer to the objective value for solution.
COPT_AddCallbackUserCut
Synopsis
int COPT_AddCallbackUserCut(
void *cbdata,
int nRowMatCnt,
const int *rowMatIdx,
const double *rowMatElem,
char cRowSense,
double dRowRhs)Description
Add a user cut to the MIP model from within the callback function.
Arguments
cbdataThe cbdata argument that was passed into the user callback by COPT. This argument must be passed unmodified from the user callback to COPT_AddCallbackUserCut().
nRowMatCntNumber of non-zero elements in the user cut.
rowMatIdxColumn index of non-zero elements in the user cut.
rowMatElemValues of non-zero elements in the user cut.
cRowSenseThe sense of the new user cut. It supports for
LESS_EQUAL,GREATER_EQUAL,EQUALandFREE.The user cut added from within callback can only have a single bound.
dRowRhsRHS of the user cut.
COPT_AddCallbackUserCuts
Synopsis
int COPT_AddCallbackUserCuts(
void *cbdata,
int nAddRow,
const int *rowMatBeg,
const int *rowMatCnt,
const int *rowMatIdx,
const double *rowMatElem,
const char *rowSense,
const double *rowRhs)Description
Add a set of user cuts to the MIP model from within the callback function.
Arguments
cbdataThe cbdata argument that was passed into the user callback by COPT. This argument must be passed unmodified from the user callback to COPT_AddCallbackUserCuts().
nAddRowNumber of new user cuts.
rowMatBeg, rowMatCnt, rowMatIdxandrowMatElemDefines the coefficient matrix in compressed row storage (CRS) format. The CRS format is similar to the CCS format described in the other information of
COPT_LoadProb.
rowSenseSenses of new user cuts. It supports for
LESS_EQUAL,GREATER_EQUAL,EQUALandFREE.The user cuts added from within callback can only have single bounds.
rowRhsRHS of new user cuts.
COPT_AddCallbackLazyConstr
Synopsis
int COPT_AddCallbackLazyConstr(
void *cbdata,
int nRowMatCnt,
const int *rowMatIdx,
const double *rowMatElem,
char cRowSense,
double dRowRhs)Description
Add a lazy constraint to the MIP model from within the callback function.
Arguments
cbdataThe cbdata argument that was passed into the user callback by COPT. This argument must be passed unmodified from the user callback to COPT_AddCallbackLazyConstr().
nRowMatCntNumber of non-zero elements in the lazy constraint.
When
nRowMatCnt<=0, the MIP candidate solution will be directly rejected without adding a lazy constraint. AndrowMatIdx,rowMatElem,cRowSenseanddRowRhswill be ignored.
rowMatIdxColumn index of non-zero elements in the lazy constraint.
rowMatElemValues of non-zero elements in the lazy constraint.
cRowSenseThe sense of new lazy constraint. It supports for
LESS_EQUAL,GREATER_EQUAL,EQUALandFREE.The lazy constraint added from within callback can only have a single bound.
dRowRhsRHS of the lazy constraint.
COPT_AddCallbackLazyConstrs
Synopsis
int COPT_AddCallbackLazyConstrs(
void *cbdata,
int nAddRow,
const int *rowMatBeg,
const int *rowMatCnt,
const int *rowMatIdx,
const double *rowMatElem,
const char *rowSense,
const double *rowRhs)Description
Add a set of lazy constraints to the MIP model from within the callback function.
Arguments
cbdataThe cbdata argument that was passed into the user callback by COPT. This argument must be passed unmodified from the user callback to COPT_AddCallbackLazyConstrs().
nAddRowNumber of new lazy constraints.
When
nAddRow<=0, the MIP candidate solution will be directly rejected without adding lazy constraints.And other parameters(apart from
cbdata) will be ignored.
rowMatBeg, rowMatCnt, rowMatIdxandrowMatElemDefines the coefficient matrix in compressed row storage (CRS) format. The CRS format is similar to the CCS format described in the other information of
COPT_LoadProb.
rowSenseSenses of new lazy constraints. It supports for
LESS_EQUAL,GREATER_EQUAL,EQUALandFREE.The lazy constraints added from within callback can only have single bounds.
rowRhsRHS of new lazy constraints.
Note: If the user gives a solution to COPT in a callback, the user should ensure that this fulfills the lazy constraint callback since that won’t be called for user-provided solutions.
Other API functions
COPT_GetRetcodeMsg
Synopsis
int COPT_GetRetcodeMsg(int code, char *buff, int buffSize)Description
Obtains a C-style string which explains a return code value in plain text.
Arguments
codeThe return code from a COPT API function.
buffA buffer for holding the resulting string.
buffSizeThe size of the above buffer.
COPT_Interrupt
Synopsis
int COPT_Interrupt(copt_prob *prob)Description
Interrupt solving process of current problem.
Arguments
probThe COPT problem.
Multi-objective Model API Functions
COPT_MultiObjSetColObj
Synopsis
int COPT_MultiObjSetColObj(
copt_prob *prob,
int iObj,
int num,
const int *list,
const double *colObj)Description
Set the specified linear objective in a multi-objective model.
Note: this operation overwrites the existing objective definition.
Arguments
probCOPT problem.
iObjIndex of the objective.
numNumber of linear objective coefficients.
listIndex list of linear objective coefficients.
colObjValue list of linear objective coefficients.
COPT_MultiObjGetColObj
Synopsis
int COPT_MultiObjGetColObj(
copt_prob *prob,
int iObj,
int num,
const int *list,
double *colObj)Description
Retrieve the specified linear objective in a multi-objective model.
Arguments
probCOPT problem.
iObjIndex of the objective.
numNumber of nonzero coefficients in the linear objective.
listIndices of the nonzero coefficients in the linear objective.
colObjValues of the nonzero coefficients in the linear objective.
COPT_MultiObjDelColObj
Synopsis
int COPT_MultiObjDelColObj(
copt_prob *prob,
int iObj)Description
Delete the specified linear objective in a multi-objective model.
Arguments
probCOPT problem.
iObjIndex of the objective.
COPT_MultiObjSetObjSense
Synopsis
int COPT_MultiObjSetObjSense(
copt_prob *prob,
int iObj,
int iObjSense)Description
Set the objective sense for the specified objective in a multi-objective model.
Arguments
probCOPT problem.
iObjIndex of the objective.
iObjSenseThe optimization sense, either
COPT_MAXIMIZEorCOPT_MINIMIZE.
COPT_MultiObjSetObjConst
Synopsis
int COPT_MultiObjSetObjConst(
copt_prob *prob,
int iObj,
double dObjConst)Description
Set the objective constant for the specified objective in a multi-objective model.
Arguments
probCOPT problem.
iObjIndex of the objective.
dObjConstConstant term of the objective function.
COPT_MultiObjSetObjParam
Synopsis
int COPT_MultiObjSetObjParam(
copt_prob *prob,
int iObj,
const char *paramName,
double dblParam)Description
Set the objective parameter value for the specified objective in a multi-objective model.
Arguments
probCOPT problem.
iObjIndex of the objective.
paramNameName of the objective parameter.
Possible values:
COPT_MULTIOBJ_PRIORITY,COPT_MULTIOBJ_WEIGHT,COPT_MULTIOBJ_ABSTOL,COPT_MULTIOBJ_RELTOL.
dblParamValue to set for the objective parameter.
COPT_MultiObjGetObjParam
Synopsis
int COPT_MultiObjGetObjParam(
copt_prob *prob,
int iObj,
const char *paramName,
double *p_dblParam)Description
Retrieve the objective parameter value for the specified objective in a multi-objective model.
Arguments
probCOPT problem.
iObjIndex of the objective.
paramNameName of the objective parameter.
Possible values are:
COPT_MULTIOBJ_PRIORITY,COPT_MULTIOBJ_WEIGHT,COPT_MULTIOBJ_ABSTOL,COPT_MULTIOBJ_RELTOL.
p_dblParamPointer to store the retrieved parameter value.
COPT_MultiObjResetObjParam
Synopsis
int COPT_MultiObjResetObjParam(
copt_prob *prob,
int iObj)Description
Reset all objective parameters of the specified objective in a multi-objective model to their default values.
Arguments
probCOPT problem.
iObjIndex of the objective.
COPT_MultiObjSetIntParam
Synopsis
int COPT_MultiObjSetIntParam(
copt_prob *prob,
int iObj,
const char *paramName,
int intParam)Description
Set an integer solver parameter for the model corresponding to the specified objective in a multi-objective problem.
Arguments
probCOPT problem.
iObjIndex of the objective.
paramNameName of the parameter.
intParamInteger value of the parameter to be set.
COPT_MultiObjGetIntParam
Synopsis
int COPT_MultiObjGetIntParam(
copt_prob *prob,
int iObj,
const char *paramName,
int *p_intParam)Description
Get the integer solver parameter for the model corresponding to the specified objective in a multi-objective problem.
Arguments
probCOPT problem.
iObjIndex of the objective.
paramNameName of the parameter.
p_intParamPointer to the retrieved integer parameter value.
COPT_MultiObjSetDblParam
Synopsis
int COPT_MultiObjSetDblParam(
copt_prob *prob,
int iObj,
const char *paramName,
int dblParam)Description
Set the double solver parameter for the model corresponding to the specified objective in a multi-objective problem.
Arguments
probCOPT problem.
iObjIndex of the objective.
paramNameName of the parameter.
dblParamValue of the double parameter to set.
COPT_MultiObjGetDblParam
Synopsis
int COPT_MultiObjGetDblParam(
copt_prob *prob,
int iObj,
const char *paramName,
int *p_dblParam)Description
Get the double solver parameter of the model corresponding to the specified objective in a multi-objective problem.
Arguments
probCOPT problem.
iObjIndex of the objective.
paramNameName of the parameter.
p_dblParamPointer to store the value of the double parameter.
COPT_MultiObjResetParam
Synopsis
int COPT_MultiObjResetParam(
copt_prob *prob,
int iObj)Description
Reset all solver parameters of the model corresponding to the specified objective in a multi-objective problem to their default settings.
Arguments
probCOPT problem.
iObjIndex of the objective.
COPT_MultiObjGetIntAttr
Synopsis
int COPT_MultiObjGetIntAttr(
copt_prob *prob,
int iObj,
const char *attrName,
int *p_intAttr)Description
Retrieve an integer attribute of the specified objective in a multi-objective problem.
Arguments
probCOPT problem.
iObjIndex of the objective.
attrNameName of the attribute.
Possible values are:
COPT_DBLATTR_LPOBJVAL,COPT_DBLATTR_BESTOBJ,COPT_DBLATTR_OBJCONST.
p_intAttrPointer to the integer value of the attribute.
COPT_MultiObjGetDblAttr
Synopsis
int COPT_MultiObjGetDblAttr(
copt_prob *prob,
int iObj,
const char *attrName,
double *p_dblAttr)Description
Retrieve a double attribute of the specified objective in a multi-objective problem.
Arguments
probCOPT problem.
iObjIndex of the objective.
attrNameName of the attribute.
Possible values are:
COPT_DBLATTR_LPOBJVAL,COPT_DBLATTR_BESTOBJ,COPT_DBLATTR_OBJCONST.
p_dblAttrPointer to the double value of the attribute.
COPT_MultiObjGetPoolObjVal
Synopsis
int COPT_MultiObjGetPoolObjVal(
copt_prob *prob,
int iObj,
int iSol,
double *p_objVal)Description
Retrieve the value of the specified objective at the solution with index
iSolin the solution pool.Arguments
probCOPT problem.
iObjIndex of the objective.
iSolIndex of the solution in the solution pool.
p_objValPointer to the value of the objective.