Java API Reference
The Cardinal Optimizer provides a Java API library. This chapter documents all COPT Java constants and API functions for Java applications.
Constants
There are four types of constants defined in Cardinal Optimizer. They are general constants, information constants, attributes constants and parameters constants.
General Constants
For the contents of Java general constants, see General Constants.
General constants are defined in Consts
class. User may refer general constants
with namespace, that is, copt.Consts.XXXX
.
Attributes
For the contents of Java attribute constants, see Attributes.
All COPT Java attributes are defined in DblAttr
and IntAttr
classes.
User may refer double attributes by copt.DblAttr.XXXX
, and integer
attributes by copt.IntAttr.XXXX
.
In the Java API, user can get the attribute value by specifying the attribute name. The two functions of obtaining attribute values are as follows, please refer to Java API: Model Class for details.
Model.getIntAttr()
: Get value of a COPT integer attribute.Model.getDblAttr()
: Get value of a COPT double attribute.
Information
For the content of Java information constants, see Information.
In the Java API, information constants are defined in the DblInfo
class.
Users can access information constants through the prefix copt
in the namespace (usually can be omitted) copt.DblInfo.
For instance, copt.DblInfo.Obj
is the coefficients of variables in the objective function.
Callback Information
For the content of Java API callback information class constants, see Callback Information.
In the Java API, callback-related information constants are defined in the CbInfo
class.
Users can access information constants through the prefix copt
in the namespace (usually can be omitted) copt.CbInfo.
For instance, copt.CbInfo.BestObj
is the current best objective.
Parameters
For the contents of Java parameters constants, see Parameters.
All COPT Java parameters are defined in DblParam and IntParam classes. User may refer double parameters by copt.DblParam.XXXX
, and integer parameters by copt.IntParam.XXXX
.
In the Java API, user can get and set the parameter value by specifying the parameter name. The provided functions are as follows, please refer to Java API: Model Class for details.
Get detailed information of the specified parameter (current value/max/min):
Model.getParamInfo()
Get the current value of the specified integer/double parameter:
Model.getIntParam()
/Model.getDblParam()
Set the specified integer/double parameter value:
Model.setIntParam()
/Model.setDblParam()
Java Modeling Classes
This chapter documents COPT Java interface. Users may refer to Java classes described below for details of how to construct and solve Java models.
Envr
Essentially, any Java application using Cardinal Optimizer should start with a COPT environment. COPT models are always associated with a COPT environment. User must create an environment object before populating models. User generally only need a single environment object in program.
EnvrConfig
If user connects to COPT remote services, such as floating token server or compute cluster, it is necessary to add config settings with EnvrConfig object.
Model
In general, a COPT model consists of a set of variables, a (linear) objective function on these variables, a set of constraints on there varaibles, etc. COPT model class encapsulates all required methods for constructing a COPT model.
- Model.Model()
- Model.addAffineCone()
- Model.addAffineCone()
- Model.addAffineCone()
- Model.addCone()
- Model.addCone()
- Model.addCone()
- Model.addCone()
- Model.addConstr()
- Model.addConstr()
- Model.addConstr()
- Model.addConstr()
- Model.addConstr()
- Model.addConstrs()
- Model.addConstrs()
- Model.addConstrs()
- Model.addDenseMat()
- Model.addDenseMat()
- Model.addDiagMat()
- Model.addDiagMat()
- Model.addDiagMat()
- Model.addDiagMat()
- Model.addExpCone()
- Model.addExpCone()
- Model.addExpCone()
- Model.addExpCone()
- Model.addEyeMat()
- Model.addGenConstrIndicator()
- Model.addGenConstrIndicator()
- Model.addGenConstrIndicator()
- Model.addGenConstrIndicators()
- Model.addLazyConstr()
- Model.addLazyConstr()
- Model.addLazyConstr()
- Model.addLazyConstrs()
- Model.addLmiConstr()
- Model.addOnesMat()
- Model.addPsdConstr()
- Model.addPsdConstr()
- Model.addPsdConstr()
- Model.addPsdConstr()
- Model.addPsdVar()
- Model.addPsdVars()
- Model.addQConstr()
- Model.addQConstr()
- Model.addQConstr()
- Model.addSos()
- Model.addSos()
- Model.addSos()
- Model.addSparseMat()
- Model.addSymMat()
- Model.addUserCut()
- Model.addUserCut()
- Model.addUserCut()
- Model.addUserCuts()
- Model.addVar()
- Model.addVar()
- Model.addVars()
- Model.addVars()
- Model.addVars()
- Model.addVars()
- Model.addVars()
- Model.clear()
- Model.clone()
- Model.computeIIS()
- Model.delPsdObj()
- Model.delQuadObj()
- Model.feasRelax()
- Model.feasRelax()
- Model.get()
- Model.get()
- Model.get()
- Model.get()
- Model.get()
- Model.get()
- Model.get()
- Model.get()
- Model.getAffineCone()
- Model.GetAffineConeBuilder()
- Model.GetAffineConeBuilders()
- Model.getAffineConeBuilders()
- Model.getAffineConeBuilders()
- Model.getAffineConeByName()
- Model.getAffineCones()
- Model.getCoeff()
- Model.getCol()
- Model.getColBasis()
- Model.getCone()
- Model.getConeBuilders()
- Model.getConeBuilders()
- Model.getConeBuilders()
- Model.getCones()
- Model.getConstr()
- Model.getConstrBuilder()
- Model.getConstrBuilders()
- Model.getConstrByName()
- Model.getConstrLowerIIS()
- Model.getConstrLowerIIS()
- Model.getConstrs()
- Model.getConstrUpperIIS()
- Model.getConstrUpperIIS()
- Model.getDblAttr()
- Model.getDblParam()
- Model.getDblParamInfo()
- Model.getExpCone()
- Model.getExpConeBuilders()
- Model.getExpConeBuilders()
- Model.getExpConeBuilders()
- Model.getExpCones()
- Model.getGenConstr()
- Model.getGenConstrByName()
- Model.getGenConstrIndicator()
- Model.getGenConstrIndicators()
- Model.getGenConstrs()
- Model.getIndicatorIIS()
- Model.getIndicatorIIS()
- Model.getIntAttr()
- Model.getIntParam()
- Model.getIntParamInfo()
- Model.getLmiCoeff()
- Model.getLmiConstr()
- Model.getLmiConstrByName()
- Model.getLmiConstrs()
- Model.getLmiRhs()
- Model.getLmiRow()
- Model.getLmiSolution()
- Model.getLpSolution()
- Model.getObjective()
- Model.getPoolObjVal()
- Model.getPoolSolution()
- Model.getPoolSolution()
- Model.getPsdCoeff()
- Model.getPsdConstr()
- Model.getPsdConstrBuilder()
- Model.getPsdConstrBuilders()
- Model.getPsdConstrByName()
- Model.getPsdConstrs()
- Model.getPsdObjective()
- Model.getPsdRow()
- Model.getPsdSolution()
- Model.getPsdVar()
- Model.getPsdVarByName()
- Model.getPsdVars()
- Model.getQConstr()
- Model.getQConstrBuilder()
- Model.getQConstrBuilders()
- Model.getQConstrByName()
- Model.getQConstrs()
- Model.getQuadObjective()
- Model.getQuadRow()
- Model.getRow()
- Model.getRowBasis()
- Model.getSolution()
- Model.getSos()
- Model.getSosBuilders()
- Model.getSosBuilders()
- Model.getSosBuilders()
- Model.getSOSIIS()
- Model.getSOSIIS()
- Model.getSoss()
- Model.getSymMat()
- Model.getVar()
- Model.getVarByName()
- Model.getVarLowerIIS()
- Model.getVarLowerIIS()
- Model.getVars()
- Model.getVarUpperIIS()
- Model.getVarUpperIIS()
- Model.interrupt()
- Model.loadMipStart()
- Model.loadTuneParam()
- Model.read()
- Model.readBasis()
- Model.readBin()
- Model.readCbf()
- Model.readLp()
- Model.readMps()
- Model.readMst()
- Model.readParam()
- Model.readSdpa()
- Model.readSol()
- Model.readTune()
- Model.remove()
- Model.remove()
- Model.remove()
- Model.remove()
- Model.remove()
- Model.remove()
- Model.remove()
- Model.remove()
- Model.remove()
- Model.remove()
- Model.remove()
- Model.remove()
- Model.remove()
- Model.remove()
- Model.remove()
- Model.remove()
- Model.remove()
- Model.remove()
- Model.remove()
- Model.remove()
- Model.remove()
- Model.remove()
- Model.reset()
- Model.resetAll()
- Model.resetParam()
- Model.set()
- Model.set()
- Model.set()
- Model.set()
- Model.set()
- Model.set()
- Model.setBasis()
- Model.setCallback()
- Model.setCoeff()
- Model.setCoeffs()
- Model.setCoeffs()
- Model.setDblParam()
- Model.setIntParam()
- Model.setLmiCoeff()
- Model.setLmiRhs()
- Model.setLpSolution()
- Model.setMipStart()
- Model.setMipStart()
- Model.setMipStart()
- Model.setMipStart()
- Model.setNames()
- Model.setNames()
- Model.setNames()
- Model.setNames()
- Model.setNames()
- Model.setNames()
- Model.setNames()
- Model.setNames()
- Model.setNames()
- Model.setNames()
- Model.setNames()
- Model.setNames()
- Model.setNames()
- Model.setNames()
- Model.setNames()
- Model.setObjConst()
- Model.setObjective()
- Model.setObjSense()
- Model.setPsdCoeff()
- Model.setPsdObjective()
- Model.setQuadObjective()
- Model.setSlackBasis()
- Model.setSolverLogFile()
- Model.solve()
- Model.solveLp()
- Model.tune()
- Model.write()
- Model.writeBasis()
- Model.writeBin()
- Model.writeIIS()
- Model.writeLp()
- Model.writeMps()
- Model.writeMpsStr()
- Model.writeMst()
- Model.writeParam()
- Model.writePoolSol()
- Model.writeRelax()
- Model.writeSol()
- Model.writeTuneParam()
Var
COPT variable object. Variables are always associated with a particular model. User creates a variable object by adding a variable to a model, rather than by using constructor of Var class.
VarArray
COPT variable array object. To store and access a set of Java Var objects, Cardinal Optimizer provides Java VarArray class, which defines the following methods.
Expr
COPT linear expression object. A linear expression consists of a constant term, a list of terms of variables and associated coefficients. Linear expressions are used to build constraints.
- Expr.Expr()
- Expr.Expr()
- Expr.Expr()
- Expr.Expr()
- Expr.addConstant()
- Expr.addExpr()
- Expr.addExpr()
- Expr.addTerm()
- Expr.addTerms()
- Expr.addTerms()
- Expr.addTerms()
- Expr.addTerms()
- Expr.clone()
- Expr.evaluate()
- Expr.getCoeff()
- Expr.getConstant()
- Expr.getVar()
- Expr.remove()
- Expr.remove()
- Expr.setCoeff()
- Expr.setConstant()
- Expr.size()
Constraint
COPT constraint object. Constraints are always associated with a particular model. User creates a constraint object by adding a constraint to a model, rather than by using constructor of Constraint class.
ConstrArray
COPT constraint array object. To store and access a set of Java Constraint objects, Cardinal Optimizer provides Java ConstrArray class, which defines the following methods.
ConstrBuilder
COPT constraint builder object. To help building a constraint, given a linear expression, constraint sense and right-hand side value, Cardinal Optimizer provides Java ConstrBuilder class, which defines the following methods.
ConstrBuilderArray
COPT constraint builder array object. To store and access a set of Java ConstrBuilder objects, Cardinal Optimizer provides Java ConstrBuilderArray class, which defines the following methods.
Column
COPT column object. A column consists of a list of constraints and associated coefficients. Columns are used to represent the set of constraints in which a variable participates, and the asssociated coefficents.
ColumnArray
COPT column array object. To store and access a set of Java Column objects, Cardinal Optimizer provides Java ColumnArray class, which defines the following methods.
Sos
COPT SOS constraint object. SOS constraints are always associated with a particular model. User creates an SOS constraint object by adding an SOS constraint to a model, rather than by using constructor of Sos class.
An SOS constraint can be type 1 or 2 (COPT_SOS_TYPE1
or COPT_SOS_TYPE2
).
SosArray
COPT SOS constraint array object. To store and access a set of Java Sos objects, Cardinal Optimizer provides Java SosArray class, which defines the following methods.
SosBuilder
COPT SOS constraint builder object. To help building an SOS constraint, given the SOS type, a set of variables and associated weights, Cardinal Optimizer provides Java SosBuilder class, which defines the following methods.
SosBuilderArray
COPT SOS constraint builder array object. To store and access a set of Java SosBuilder objects, Cardinal Optimizer provides Java SosBuilderArray class, which defines the following methods.
GenConstr
COPT general constraint object. General constraints are always associated with a particular model. User creates a general constraint object by adding a general constraint to a model, rather than by using constructor of GenConstr class.
GenConstrArray
COPT general constraint array object. To store and access a set of Java GenConstr objects, Cardinal Optimizer provides Java GenConstrArray class, which defines the following methods.
GenConstrBuilder
COPT general constraint builder object. To help building a general constraint, given a binary variable and associated value, a linear expression and constraint sense, Cardinal Optimizer provides Java GenConstrBuilder class, which defines the following methods.
GenConstrBuilderArray
COPT general constraint builder array object. To store and access a set of Java GenConstrBuilder objects, Cardinal Optimizer provides Java GenConstrBuilderArray class, which defines the following methods.
Cone
COPT cone constraint object. Cone constraints are always associated with a particular model. User creates a cone constraint object by adding a cone constraint to a model, rather than by using constructor of Cone class.
A cone constraint can be regular or rotated (COPT_CONE_QUAD
or COPT_CONE_RQUAD
).
ConeArray
COPT cone constraint array object. To store and access a set of Java Cone objects, Cardinal Optimizer provides Java ConeArray class, which defines the following methods.
ConeBuilder
COPT cone constraint builder object. To help building a cone constraint, given the cone type and a set of variables, Cardinal Optimizer provides Java ConeBuilder class, which defines the following methods.
ConeBuilderArray
COPT cone constraint builder array object. To store and access a set of Java ConeBuilder objects, Cardinal Optimizer provides Java ConeBuilderArray class, which defines the following methods.
ExpCone
COPT exponential cone constraint object. ExpCone constraints are always associated with a particular model. User creates an exponential cone constraint object by adding an exponential cone constraint to a model, rather than by using constructor of ExpCone class.
ExpConeArray
COPT exponential cone constraint array object. To store and access a set of Java ExpCone objects, Cardinal Optimizer provides Java ExpConeArray class, which defines the following methods.
ExpConeBuilder
COPT exponential cone constraint builder object. To help building an exponential cone constraint, given the exponential cone type and a set of variables, Cardinal Optimizer provides Java ExpConeBuilder class, which defines the following methods.
ExpConeBuilderArray
COPT exponential cone constraint builder array object. To store and access a set of Java ExpConeBuilder objects, Cardinal Optimizer provides Java ExpConeBuilderArray class, which defines the following methods.
AffineCone Class
The AffineCone class in COPT encapsulates operations related to affine cones. The following methods are provided:
AffineConeArray Class
To facilitate user operations on a group of Java AffineCone Class objects, the Java interface of COPT introduces the AffineConeArray class. The following methods are provided:
AffineConeBuilder Class
The AffineConeBuilder class in COPT encapsulates the builder for constructing affine cones. The following methods are provided:
AffineConeBuilderArray Class
To facilitate operations on a group of Java AffineConeBuilder Class objects, the Java interface of COPT introduces the AffineConeBuilderArray class. The following methods are provided:
QuadExpr
COPT quadratic expression object. A quadratic expression consists of a linear expression, a list of variable pairs and associated coefficients of quadratic terms. Quadratic expressions are used to build quadratic constraints and objectives.
- QuadExpr.QuadExpr()
- QuadExpr.QuadExpr()
- QuadExpr.QuadExpr()
- QuadExpr.QuadExpr()
- QuadExpr.QuadExpr()
- QuadExpr.QuadExpr()
- QuadExpr.QuadExpr()
- QuadExpr.addConstant()
- QuadExpr.addLinExpr()
- QuadExpr.addLinExpr()
- QuadExpr.addQuadExpr()
- QuadExpr.addQuadExpr()
- QuadExpr.addTerm()
- QuadExpr.addTerm()
- QuadExpr.addTerms()
- QuadExpr.addTerms()
- QuadExpr.addTerms()
- QuadExpr.addTerms()
- QuadExpr.addTerms()
- QuadExpr.addTerms()
- QuadExpr.clone()
- QuadExpr.evaluate()
- QuadExpr.getCoeff()
- QuadExpr.getConstant()
- QuadExpr.getLinExpr()
- QuadExpr.getVar1()
- QuadExpr.getVar2()
- QuadExpr.remove()
- QuadExpr.remove()
- QuadExpr.setCoeff()
- QuadExpr.setConstant()
- QuadExpr.size()
QConstraint
COPT quadratic constraint object. Quadratic constraints are always associated with a particular model. User creates a quadratic constraint object by adding a quadratic constraint to a model, rather than by using constructor of QConstraint class.
QConstrArray
COPT quadratic constraint array object. To store and access a set of Java QConstraint objects, Cardinal Optimizer provides Java QConstrArray class, which defines the following methods.
QConstrBuilder
COPT quadratic constraint builder object. To help building a quadratic constraint, given a quadratic expression, constraint sense and right-hand side value, Cardinal Optimizer provides Java ConeBuilder class, which defines the following methods.
QConstrBuilderArray
COPT quadratic constraint builder array object. To store and access a set of Java QConstrBuilder objects, Cardinal Optimizer provides Java QConstrBuilderArray class, which defines the following methods.
PsdVar
COPT PSD variable object. PSD variables are always associated with a particular model. User creates a PSD variable object by adding a PSD variable to model, rather than by constructor of PsdVar class.
PsdVarArray
COPT PSD variable array object. To store and access a set of PsdVar objects, Cardinal Optimizer provides PsdVarArray class, which defines the following methods.
PsdExpr
COPT PSD expression object. A PSD expression consists of a linear expression, a list of PSD variables and associated coefficient matrices of PSD terms. PSD expressions are used to build PSD constraints and objectives.
- PsdExpr.PsdExpr()
- PsdExpr.PsdExpr()
- PsdExpr.PsdExpr()
- PsdExpr.PsdExpr()
- PsdExpr.PsdExpr()
- PsdExpr.PsdExpr()
- PsdExpr.addConstant()
- PsdExpr.addLinExpr()
- PsdExpr.addLinExpr()
- PsdExpr.addPsdExpr()
- PsdExpr.addPsdExpr()
- PsdExpr.addTerm()
- PsdExpr.addTerm()
- PsdExpr.addTerm()
- PsdExpr.addTerms()
- PsdExpr.addTerms()
- PsdExpr.addTerms()
- PsdExpr.addTerms()
- PsdExpr.addTerms()
- PsdExpr.addTerms()
- PsdExpr.clone()
- PsdExpr.evaluate()
- PsdExpr.getCoeff()
- PsdExpr.getConstant()
- PsdExpr.getLinExpr()
- PsdExpr.getPsdVar()
- PsdExpr.multiply()
- PsdExpr.remove()
- PsdExpr.remove()
- PsdExpr.remove()
- PsdExpr.setCoeff()
- PsdExpr.setConstant()
- PsdExpr.size()
PsdConstraint
COPT PSD constraint object. PSD constraints are always associated with a particular model. User creates a PSD constraint object by adding a PSD constraint to model, rather than by constructor of PsdConstraint class.
PsdConstrArray
COPT PSD constraint array object. To store and access a set of PsdConstraint objects, Cardinal Optimizer provides PsdConstrArray class, which defines the following methods.
PsdConstrBuilder
COPT PSD constraint builder object. To help building a PSD constraint, given a PSD expression, constraint sense and right-hand side value, Cardinal Optimizer provides PsdConstrBuilder class, which defines the following methods.
PsdConstrBuilderArray
COPT PSD constraint builder array object. To store and access a set of PsdConstrBuilder objects, Cardinal Optimizer provides PsdConstrBuilderArray class, which defines the following methods.
LmiConstraint
COPT LMI constraint object. LMI constraints are always associated with a particular model. User creates a LMI constraint object by adding a LMI constraint to model, rather than by constructor of LmiConstraint class.
LmiConstrArray
COPT LMI constraint array object. To store and access a set of LmiConstraint objects, Cardinal Optimizer provides LmiConstrArray class, which defines the following methods.
LmiExpr
COPT LMI expression object. A LMI expression consists of a list of variables, associated coefficient matrices of LMI term, and constant matrices. LMI expressions are used to build LMI constraints.
- LmiExpr.LmiExpr()
- LmiExpr.LmiExpr()
- LmiExpr.LmiExpr()
- LmiExpr.LmiExpr()
- LmiExpr.LmiExpr()
- LmiExpr.addConstant()
- LmiExpr.addLmiExpr()
- LmiExpr.addLmiExpr()
- LmiExpr.addTerm()
- LmiExpr.addTerm()
- LmiExpr.addTerms()
- LmiExpr.addTerms()
- LmiExpr.clone()
- LmiExpr.getCoeff()
- LmiExpr.getConstant()
- LmiExpr.getVar()
- LmiExpr.multiply()
- LmiExpr.remove()
- LmiExpr.remove()
- LmiExpr.setCoeff()
- LmiExpr.setConstant()
- LmiExpr.size()
SymMatrix
COPT symmetric matrix object. Symmetric matrices are always associated with a particular model. User creates a symmetric matrix object by adding a symmetric matrix to model, rather than by constructor of SymMatrix class.
Symmetric matrices are used as coefficient matrices of PSD terms in PSD expressions, PSD constraints or PSD objectives.
SymMatrixArray
COPT symmetric matrix object. To store and access a set of SymMatrix objects, Cardinal Optimizer provides SymMatrixArray class, which defines the following methods.
SymMatExpr
COPT symmetric matrix expression object. A symmetric matrix expression is a linear combination of symmetric matrices, which is still a symmetric matrix. However, by doing so, we are able to delay computing the final matrix until setting PSD constraints or PSD objective.
- SymMatExpr.SymMatExpr()
- SymMatExpr.SymMatExpr()
- SymMatExpr.addSymMatExpr()
- SymMatExpr.addTerm()
- SymMatExpr.addTerms()
- SymMatExpr.addTerms()
- SymMatExpr.addTerms()
- SymMatExpr.clone()
- SymMatExpr.getCoeff()
- SymMatExpr.getDim()
- SymMatExpr.getSymMat()
- SymMatExpr.multiply()
- SymMatExpr.remove()
- SymMatExpr.remove()
- SymMatExpr.reserve()
- SymMatExpr.setCoeff()
- SymMatExpr.size()
CallbackBase
COPT Callback abstract base object. Users must implment its virtual method
virtual void CallbackBase::callback()
to instantiate an instance, which
pass to Model::SetCallback(CallbackBase cb, int cbctx)
as the first
parameter. Subclass of CallbackBase inherits the following member methods:
- CallbackBase.CallbackBase()
- CallbackBase.addLazyConstr()
- CallbackBase.addLazyConstr()
- CallbackBase.addLazyConstr()
- CallbackBase.addLazyConstrs()
- CallbackBase.addUserCut()
- CallbackBase.addUserCut()
- CallbackBase.addUserCut()
- CallbackBase.addUserCuts()
- CallbackBase.callback()
- CallbackBase.getDblInfo()
- CallbackBase.getIncumbent()
- CallbackBase.getIncumbent()
- CallbackBase.getIncumbent()
- CallbackBase.getIncumbent()
- CallbackBase.getIntInfo()
- CallbackBase.getRelaxSol()
- CallbackBase.getRelaxSol()
- CallbackBase.getRelaxSol()
- CallbackBase.getRelaxSol()
- CallbackBase.getSolution()
- CallbackBase.getSolution()
- CallbackBase.getSolution()
- CallbackBase.getSolution()
- CallbackBase.interrupt()
- CallbackBase.loadSolution()
- CallbackBase.setSolution()
- CallbackBase.setSolution()
- CallbackBase.setSolution()
- CallbackBase.where()
ProbBuffer
Buffer object for COPT problem. ProbBuffer object holds the (MPS) problem in string format.
CoptException
Copt exception object.