CONOPT
|
Enumerations | |
enum class | ConoptConstraintType { ConoptConstraintType::Eq = 0 , ConoptConstraintType::GtEq , ConoptConstraintType::LtEq , ConoptConstraintType::Free } |
the constraint type More... | |
enum class | ConoptObjectiveElement { ConoptObjectiveElement::Variable = 0 , ConoptObjectiveElement::Constraint } |
the element that is used for the objective function More... | |
enum class | ConoptSense { ConoptSense::Minimize = -1 , ConoptSense::Maximize = 1 } |
the objective sense More... | |
Functions | |
virtual int | ConoptModelData::readMatrix (double lower[], double curr[], double upper[], int vsta[], int type[], double rhs[], int esta[], int colsta[], int rowno[], double value[], int nlflag[], int numvar, int numcon, int numnz) |
loads the structure of the model into CONOPT. | |
void | ConoptModelData::setProblemDimension (unsigned int numvar, unsigned int numcons, unsigned int numnz, unsigned int numnlnz) |
sets the problem dimension. This is called if the user wants to implement a custom readMatrix() method. | |
int | ConoptModelData::addConstraint (ConoptConstraintType constype, double rhs, int slackstatus=-1) |
adds a constraint to the problem. The non-zero coefficients are added later | |
int | ConoptModelData::addConstraint (ConoptConstraintType constype, double rhs, const std::vector< int > &varindex, const std::vector< double > &value, const std::vector< int > &nlflag, int slackstatus=-1) |
adds a constraint to the problem. The matrix non-zeros are added based on the supplied variables | |
int | ConoptModelData::addVariable (double lower, double upper, double curr=0, int varstatus=-1) |
adds a variable to the model. The non-zero coefficients are added later. | |
int | ConoptModelData::addVariable (double lower, double upper, const std::vector< int > &consindex, const std::vector< double > &value, const std::vector< int > &nlflag, double curr=0, int varstatus=-1) |
adds a variable to the problem. The matrix non-zeros are added based on the supplied constraints. | |
void | ConoptModelData::setObjectiveElement (ConoptObjectiveElement elem, int elemindex) |
sets the index for the objective variable or constraint | |
void | ConoptModelData::setOptimizationSense (ConoptSense sense) |
sets the optimisation direction. | |
void | ConoptModelData::setInitialStatusOption (int inistat) |
the setting to indicate how the initial status of the variables and slack variables will be handled. | |
Methods that are used to define the model to be solved by CONOPT.
There are two ways to define the model:
Either method achieves the same result of defining the model. However, the latter calls an internally defined readMatrix method. As such, there is a small memory and processing overhead.
|
strong |
the constraint type
This is supplied when adding constraints using the ConoptModelData::addConstraint() methods.
|
strong |
the element that is used for the objective function
This can be either a single variable or a constraint. If the objective function is a constraint, then the constraint must be added with the type ConoptConstraintType::Free.
Enumerator | |
---|---|
Variable | the objective is given by a single variable |
Constraint | the objective is given by the value of an equation |
|
strong |
|
virtual |
loads the structure of the model into CONOPT.
Using the C++ interface, there are two ways to load the model into CONOPT. The first method follows the process used for the Fortran and C interfaces. This involves:
The second method makes use of the convenience functions included in the C++ interface. Within the ConoptModelData the methods addConstraint() and addVariable() are provided. As such, to load the model into CONOPT, you must:
where:
LOWER
: Vector of lower bounds on the variables. CONOPT will fill the vector with a special internal value that represent minus infinity or no lower bound before issuing the callback.CURR
: Vector of initial values of the variables. CONOPT will fill the vector with the default initial value of zero before issuing the callback.UPPER
: Vector of upper bounds on the variables. CONOPT will fill the vector with a special internal value that represent plus infinity or no upper bound before issuing the callback.VSTA
: Vector of initial status values for the variable. VSTA
is only used if ConoptModelData::setInitialStatusOption was called with IniStat = 1 or 2
.
If `IniStat = 1` the value of `VSTA` must be defined as: - <b>0:</b> The variable is initialized non-basic (if `CURR = LOWER` or `CURR = UPPER`) or super-basic, and - <b>1:</b> The variable is initialized basic and if `IniStat = 2` the value of `VSTA` must be defined as: - <b>0:</b> The variable is initialized at lower bound - <b>1:</b> The variable is initialized at upper bound - <b>2:</b> The variable is initialized basic, and - <b>3:</b> The variable is initialized superbasic.
IniStat = 1
is simple to implement by hand, while IniStat = 2
is consistent with the output status defined in the Solution
callback method. Note that if the numerical value in CURR
are inconsistent with the status value, the numerical values will be used.
If IniStat = 0 (the default value) CONOPT will not use VSTA
and you do not have to define it.
TYPE
: Vector of equation types. The values of TYPE have the following meaning:
There is no default value for TYPE
so it must be defined for all constraints. Note that CONOPT does not accept ranges.
RHS
: Vector of right hand sides values. The default value is zero.ESTA
: Vector of initial status values for the slacks in the constraints. ESTA
is only used if ConoptModelData::setInitialStatusOption was called with IniStat = 1 or 2
.
If `IniStat = 1` the value of `ESTA` must be defined as: - <b>0:</b> The slack is initialized non-basic (if the constraint is binding in the initial point) or super-basic, and - <b>1:</b> The slack is initialized basic and if `IniStat = 2` the value of `ESTA` must be defined as: - <b>0:</b> The slack is initialized at lower bound. - <b>1:</b> The slack is initialized at upper bound. - <b>2:</b> The slack is initialized basic, and - <b>3:</b> The slack is initialized superbasic.
Again, IniStat = 1
is simple to implement by hand, while IniStat = 2
is consistent with the output status defined in Solution
callback method.
If IniStat = 0
(the default value) then CONOPT will not use ESTA
.
COLSTA
: Vector of start of column pointers. All non-zero Jacobian elements must be sorted by column, i.e. all elements in column i
comes before all elements in column i+1
. COLSTA
points to the first element in each column. If you have selected Base = 1
(Fortran conventions) then COLSTA
must therefore satisfy: COLSTA(1) = 1
and COLSTA(N+1) = NZ+1
. If you have selected Base = 0
(C conventions) then COLSTA
must therefore satisfy: COLSTA[0] = 0
and COLSTA[N] = NZ
. COLSTA
must in both cases be increasing.ROWNO
: Vector of row or equation numbers of the non-zeros. The numbers must be in the range 1 through M inclusive if you have defined Base = 1
(Fortran conventions) and in the range 0 to M-1 inclusive if you have defined Base = 0
(C conventions). Although the columns are sorted, the rows do not have to be sorted within each column.VALUE
: Vector of values of the Jacobian elements. VALUE
must be defined for all constant Jacobian elements, i.e. elements for which the following NLFLAG = 0
. VALUE
does not have to be defined for varying Jacobian elements.NLFLAG
: Vector of nonlinearity flags:
NLFLAG
is not read if the model is linear, i.e. if NLNZ = 0
, otherwise it must be defined. Note that if you have an LP model, you should probably select a specialized LP algorithm instead of CONOPT.
N
: Number of variables as defined in ConoptModelData::setProblemDimension.M
: Number of constraints as defined in ConoptModelData::setProblemDimension.NZ
: Number of Jacobian elements as defined in ConoptModelData::setProblemDimension.The lower bounds in LOWER
must be less than or equal to the upper bounds in UPPER
. Some of the bounds may be -INF
or +INF
, which are the bounds CONOPT assigns by default. If a bound is infinite, the user should normally not change the corresponding entry in LOWER
or UPPER
. If it is more convenient for the modeler to assign a value representing infinity it should be done using the values that are present in LOWER
and UPPER
when ReadMatrix
is called, for example taken from the first element before any assignments are done. As an alternative, you may define the numerical value of Infinity to be used by the solution algorithm in option RTMAXV
and store the same value in UPPER
and -RTMAXV
in LOWER
.
The values in CURR
, both those defined by the modeler and those defined by default, are without warning moved to the nearest bound if they are outside the bounds.
LOWER
and UPPER
. void ConoptModelData::setProblemDimension | ( | unsigned int | numvar, |
unsigned int | numcons, | ||
unsigned int | numnz, | ||
unsigned int | numnlnz ) |
sets the problem dimension. This is called if the user wants to implement a custom readMatrix() method.
NOTE: it is not possible to call setProblemDimension() and addConstraint() or addVariable(). The latter functions can only be used if the problem dimension is not set and the default readMatrix() method is used.
numvar | the number of variables in the problem |
numcons | the number of constraints in the problem |
numnz | the number of non-zeros in the constraint matrix |
numnlnz | the number of nonlinear non-zeros in the constraint matrix |
int ConoptModelData::addConstraint | ( | ConoptConstraintType | constype, |
double | rhs, | ||
int | slackstatus = -1 ) |
adds a constraint to the problem. The non-zero coefficients are added later
constype | the type of constraint, 0: ==, 1: >=, 2: <=, 3: free |
rhs | the right hand side |
slackstatus | initial status of the slack variables, see IniStat |
int ConoptModelData::addConstraint | ( | ConoptConstraintType | constype, |
double | rhs, | ||
const std::vector< int > & | varindex, | ||
const std::vector< double > & | value, | ||
const std::vector< int > & | nlflag, | ||
int | slackstatus = -1 ) |
adds a constraint to the problem. The matrix non-zeros are added based on the supplied variables
constype | the type of constraint, 0: ==, 1: >=, 2: <=, 3: free |
rhs | the right hand side |
varindex | the variables this constraint has non-zero coefficients |
value | the non-zero of the variable |
nlflag | flag to set whether the variable belongs to a non-linear term |
slackstatus | initial status of the slack variables, see IniStat |
int ConoptModelData::addVariable | ( | double | lower, |
double | upper, | ||
double | curr = 0, | ||
int | varstatus = -1 ) |
adds a variable to the model. The non-zero coefficients are added later.
lower | lower bound for the variable |
upper | upper bound for the variable |
curr | initial value of the variable, can be set to 0 |
varstatus | initial status of the variable, see IniStat |
int ConoptModelData::addVariable | ( | double | lower, |
double | upper, | ||
const std::vector< int > & | consindex, | ||
const std::vector< double > & | value, | ||
const std::vector< int > & | nlflag, | ||
double | curr = 0, | ||
int | varstatus = -1 ) |
adds a variable to the problem. The matrix non-zeros are added based on the supplied constraints.
lower | lower bound for the variable |
upper | upper bound for the variable |
consindex | the constraints this variable has non-zero coefficients |
value | the non-zero of the variable |
nlflag | flag to set whether the variable belongs to a non-linear term |
curr | initial value of the variable, can be set to 0 |
varstatus | initial status of the variable, see IniStat |
void ConoptModelData::setObjectiveElement | ( | ConoptObjectiveElement | elem, |
int | elemindex ) |
sets the index for the objective variable or constraint
void ConoptModelData::setOptimizationSense | ( | ConoptSense | sense | ) |
sets the optimisation direction.
void ConoptModelData::setInitialStatusOption | ( | int | inistat | ) |
the setting to indicate how the initial status of the variables and slack variables will be handled.
The initial status is set in the addVariable() and addConstraint() methods, or in the readMatrix() method if the classical model input approach is used. By default, the value of inistat is 0, which means that the variable and slack status is ignored.
If inistat == 1: The variable status has the following behaviour:
If inistat == 2: The variable status has the following behaviour: