Attributes
To query and modify properties of a COPT model is through the attribute interface. A variety of different attributes are available, and they can be associated with solutions, or the model.
Problem related
Problem related attributes provide the relevant information of the model composition and description. The names and descriptions of these attributes are summarized below.
Name |
Type |
Description |
|---|---|---|
Integer |
Number of variables (columns) in the problem |
|
Integer |
Number of binary variables |
|
Integer |
Number of integer variables |
|
Integer |
Number of PSD variables in the problem |
|
Integer |
Number of constraints (rows) in the problem |
|
Integer |
Number of indicator constraints |
|
Integer |
Number of SOS constraints |
|
Integer |
Number of Second-Order-Cone constraints |
|
Integer |
Number of exponential cone constraints |
|
Integer |
Number of affine cone constraints |
|
Integer |
Number of quadratic constraints |
|
Integer |
Number of PSD constraints |
|
Integer |
Number of LMI (Linear Matrix Inequalities) constraints |
|
Integer |
Number of nonlinear expression constraints in the model |
|
Integer |
Number of non-zero elements in the coefficient matrix |
|
Integer |
Number of non-zero quadratic elements in the quadratic objective function |
|
Integer |
Number of PSD terms in objective function |
|
Integer |
Number of nonlinear expression terms in the objective of the model |
|
Integer |
Number of symmetric matrices in the problem |
|
Integer |
Number of objectives in a multi-objective model |
|
Integer |
The optimization direction |
|
Double |
The constant part of the objective function |
|
Integer |
Whether the problem has quadratic terms in its objective |
|
Integer |
Whether the problem has PSD terms in its objective |
|
Integer |
Whether the problem has nonlinear terms in its objective |
|
Integer |
Whether the problem is a MIP |
|
Double |
Minimum absolute value of the non-zero elements of the coefficient matrix in the linear constraints |
|
Double |
Maximum absolute value of the non-zero elements of the coefficient matrix in the linear constraints |
|
Double |
Minimum absolute value of the non-zero variable bounds |
|
Double |
Maximum absolute value of the non-zero variable bounds |
|
Double |
Minimum absolute value of the non-zero bounds (right-hand sides) of the linear constraints |
|
Double |
Maximum absolute value of the non-zero bounds (right-hand sides) of the linear constraints |
|
Double |
Minimum absolute value of the non-zero linear objective costs |
|
Double |
Maximum absolute value of the non-zero linear objective costs |
|
Double |
Minimum absolute value of the non-zero quadratic elements of the quadratic constraints |
|
Double |
Maximum absolute value of the non-zero quadratic elements of the quadratic constraints |
|
Double |
Minimum absolute value of the non-zero linear elements of the quadratic constraints |
|
Double |
Maximum absolute value of the non-zero linear elements of the quadratic constraints |
|
Double |
Minimum absolute value of the non-zero right-hand sides of the quadratic constraints |
|
Double |
Maximum absolute value of the non-zero right-hand sides of the quadratic constraints |
|
Double |
Minimum absolute value of the non-zero quadratic objective costs |
|
Double |
Maximum absolute value of the non-zero quadratic objective costs |
ColsInteger attribute.
Number of variables (columns) in the problem.
BinsInteger attribute.
Number of binary variables.
IntsInteger attribute.
Number of integer variables.
PSDColsInteger attribute.
Number of PSD variables in the problem.
RowsInteger attribute.
Number of constraints (rows) in the problem.
IndicatorsInteger attribute.
Number of indicator constraints.
SossInteger attribute.
Number of SOS constraints.
ConesInteger attribute.
Number of Second-Order-Cone constraints.
ExpConesInteger attribute.
Number of exponential cone constraints.
AffineConesInteger attribute.
Number of affine cone constraints.
QConstrsInteger attribute.
Number of quadratic constraints.
PSDConstrsInteger attribute.
Number of PSD constraints.
LMIConstrsInteger attribute.
Number of LMI (Linear Matrix Inequalities) constraints.
NLConstrsInteger attribute.
The number of nonlinear expression constraints in the model.
ElemsInteger attribute.
Number of non-zero elements in the coefficient matrix.
QElemsInteger attribute.
Number of non-zero quadratic elements in the quadratic objective function.
PSDElemsInteger attribute.
Number of PSD terms in objective function.
NLElemsInteger attribute.
The number of nonlinear expression terms in the objective of the model.
SymMatsInteger attribute.
Number of symmetric matrices in the problem.
MultiObjsInteger attribute.
Number of objectives in a multi-objective model.
ObjSenseInteger attribute.
The optimization direction.
ObjConstDouble attribute.
The constant part of the objective function.
HasQObjInteger attribute.
Whether the problem has quadratic terms in its objective.
HasPSDObjInteger attribute.
Whether the problem has PSD terms in its objective.
HasNLObjInteger attribute.
Whether the problem has nonlinear terms in its objective.
IsMIPInteger attribute.
Whether the problem is a MIP.
MinElemDouble attribute.
Minimum absolute value of the non-zero elements of the coefficient matrix in the linear constraints.
MaxElemDouble attribute.
Maximum absolute value of the non-zero elements of the coefficient matrix in the linear constraints.
MinBoundDouble attribute.
Minimum absolute value of the non-zero variable bounds.
Bounds equal to zero and infinite bounds are not taken into account. A bound is treated as infinite when its absolute value reaches the infinite-bound value used by COPT, which is 1e30 by default.
MaxBoundDouble attribute.
Maximum absolute value of the non-zero variable bounds.
Please refer to MinBound for details.
MinRHSDouble attribute.
Minimum absolute value of the non-zero bounds (right-hand sides) of the linear constraints.
In COPT, a linear constraint is defined by a lower and an upper bound rather than by a single right-hand side, and both bounds are taken into account. A ranged constraint therefore contributes two values, while a constraint with a single sense contributes only its finite bound. Bounds equal to zero and infinite bounds are not taken into account.
MaxRHSDouble attribute.
Maximum absolute value of the non-zero bounds (right-hand sides) of the linear constraints.
Please refer to MinRHS for details.
MinCostDouble attribute.
Minimum absolute value of the non-zero linear objective costs.
MaxCostDouble attribute.
Maximum absolute value of the non-zero linear objective costs.
MinQElem
MaxQElemDouble attribute.
Maximum absolute value of the non-zero quadratic elements of the quadratic constraints.
Please refer to MinQElem for details.
MinQLElemDouble attribute.
Minimum absolute value of the non-zero linear elements of the quadratic constraints.
MaxQLElemDouble attribute.
Maximum absolute value of the non-zero linear elements of the quadratic constraints.
MinQRHSDouble attribute.
Minimum absolute value of the non-zero right-hand sides of the quadratic constraints.
Unlike a linear constraint, a quadratic constraint is defined by a single right-hand side together with a sense. Right-hand sides equal to zero and infinite right-hand sides are not taken into account.
MaxQRHSDouble attribute.
Maximum absolute value of the non-zero right-hand sides of the quadratic constraints.
Please refer to MinQRHS for details.
MinQCostDouble attribute.
Minimum absolute value of the non-zero quadratic objective costs.
Coefficients are reported as supplied to the model, without applying any additional factor.
MaxQCostDouble attribute.
Maximum absolute value of the non-zero quadratic objective costs.
Please refer to MinQCost for details.
Note
The attributes from MinElem to MaxQCost describe the problem as it was last loaded into the solver. Because model modifications are buffered, they return 0.0 before the model is first loaded, and their previous values after any later modification. Load the model before querying them, for example by solving or updating it.
A value of 0.0 is also returned when the model contains no elements of the corresponding kind: all quadratic attributes do so for a model with neither quadratic constraints nor a quadratic objective function. Use QConstrs and HasQObj to tell the two cases apart.
These attributes are retrieved from the original problem, and will therefore generally differ from the ranges of coefficients printed in the solver log, which are those of the problem actually passed to the solver, after presolving, scaling and reformulation.
Solution related
Solution related attributes provide the relevant information of the solution composition and description. The names and descriptions of these attributes are summarized below.
Name |
Type |
Description |
|---|---|---|
Integer |
Optimization status |
|
Integer |
(deprecated) The LP status |
|
Integer |
(deprecated) The MIP status |
|
Integer |
Whether a solution is available |
|
Integer |
(deprecated) Whether LP solution is available |
|
Integer |
(deprecated) Whether MIP solution is available |
|
Integer |
Whether LP basis is available |
|
Integer |
Whether sensitivity analysis results are available for LP problem |
|
Integer |
Whether the dual Farkas of an infeasible LP problem is available |
|
Integer |
Whether the primal ray of an unbounded LP problem is available |
|
Integer |
Whether feasibility LP-relaxation solution is available |
|
Integer |
Whether IIS is available |
|
Integer |
Whether the computed IIS is minimal |
|
Integer |
Number of bounds of columns in IIS |
|
Integer |
Number of rows in IIS |
|
Integer |
Number of SOS constraints in IIS |
|
Integer |
Number of indicator constraints in IIS |
|
Integer |
Number of simplex iterations performed |
|
Integer |
Number of barrier iterations performed |
|
Integer |
Number of first-order method (PDLP) iterations performed |
|
Integer |
Number of explored nodes |
|
Integer |
Number of solutions in solution pool |
|
Integer |
Number of parameter tuning results |
|
Double |
Current best objective value |
|
Double |
Current best bound on the optimal objective value |
|
Double |
(deprecated) Optimal objective value for continuous convex optimization problem |
|
Double |
(deprecated) Current best objective value for MIP |
|
Double |
(deprecated) Current best bound for MIP |
|
Double |
Current best relative gap for MIP |
|
Double |
Feasibility relaxation objective value |
|
Double |
The time spent for the optimization (in seconds) |
|
Double |
Peak memory usage (MB) for the optimization |
StatusInteger attribute.
Optimization status.
Please refer to General Constants: Solution status for possible values.
LpStatus
MipStatus
HasSolInteger attribute.
Whether a solution is available.
HasLpSol
HasMipSol
HasBasisInteger attribute.
Whether LP basis is available.
HasSensitivityInteger attribute.
Whether sensitivity analysis results are available for LP problem.
HasDualFarkasInteger attribute.
Whether the dual Farkas of an infeasible LP problem is available.
HasPrimalRayInteger attribute.
Whether the primal ray of an unbounded LP problem is available.
HasFeasRelaxSolInteger attribute.
Whether feasibility LP-relaxation solution is available.
HasIISInteger attribute.
Whether IIS is available.
IsMinIISInteger attribute.
Whether the computed IIS is minimal.
IISColsInteger attribute.
Number of bounds of columns in IIS.
IISRowsInteger attribute.
Number of rows in IIS.
IISSOSsInteger attribute.
Number of SOS constraints in IIS.
IISIndicatorsInteger attribute.
Number of indicator constraints in IIS.
SimplexIterInteger attribute.
Number of simplex iterations performed.
BarrierIterInteger attribute.
Number of barrier iterations performed.
PDLPIterInteger attribute.
Number of first-order method (PDLP) iterations performed.
NodeCntInteger attribute.
Number of explored nodes.
PoolSolsInteger attribute.
Number of solutions in solution pool.
TuneResultsInteger attribute.
Number of parameter tuning results.
ObjValDouble attribute.
Current best objective value. When
StatusisOPTIMAL, this is the optimal objective value.
ObjBoundDouble attribute.
Current best bound on the optimal objective value.
LpObjValDouble attribute.
Optimal objective value for continuous convex optimization problem.
Deprecated. Use ObjVal instead.
BestObj
BestBnd
BestGapDouble attribute.
Current best relative gap for MIP.
FeasRelaxObjDouble attribute.
Feasibility relaxation objective value.
SolvingTimeDouble attribute.
The time spent for the optimization (in seconds).
MemPeakDouble attribute.
Peak memory usage (MB) for the optimization.
Note
It is recommended to use Status, HasSol, ObjVal and ObjBound instead of the attributes marked (deprecated) above,
as they provide a unified interface for querying the solution status, whether a solution is available,
and optimal objective value across all supported problem types, including linear programming, integer programming, and convex/non-convex optimization problems.
Methods for accessing attributes
In different programming interfaces, the ways to access attributes are slightly different. For details, please refer to the corresponding chapters for each programming language API:
C++ API: C++ API Reference: Attributes
C# API: C# API Reference: Attributes
Java API: Java API Reference: Attributes
Python API: Python API Reference: Attributes