CONOPT
Loading...
Searching...
No Matches
pyconopt.ConoptModelData Class Reference

The Model Data class. More...

Public Member Functions

 __init__ (self)
 Constructor.
 
 readMatrix (self, lower, curr, upper, vsta, type, rhs, esta, colsta, rowno, value, nlflag, numvar, numcon, numnz)
 loads the structure of the model into CONOPT.
 
 setProblemDimension (self, numvar, numcons, numnz, numnlnz)
 sets the problem dimension.
 
 addConstraint (self, *args)
 Overload 1: adds a constraint to the problem.
 
 addVariable (self, *args)
 Overload 1: adds a variable to the model.
 
 setObjectiveElement (self, elem, elemindex)
 sets the index for the objective variable or constraint
 
 setOptimizationSense (self, sense)
 sets the optimisation direction.
 
 setInitialStatusOption (self, inistat)
 the setting to indicate how the initial status of the variables and slack variables will be handled.
 
 numVar (self)
 returns the number of variables in the model
 
 numCons (self)
 returns the number of constraints in the model
 
 numHessianNonzeros (self)
 returns the number of non-zeros in the Hessian
 
 getVariable (self, index)
 returns a reference to the variable object
 
 getConstraint (self, index)
 returns a reference to the constraint object
 
 setSDEvaluationType (self, sdevaltype)
 informs CONOPT of the method for evaluating the second derivative
 
 setSDLagrangianStructure (self, rownum, colnum)
 sets the structure of the second derivatives of the Lagrangian
 
 getSDLagrangianRowNumbers (self)
 returns the row numbers in the second derivative of the lagrangian structure
 
 getSDLagrangianColumnNumbers (self)
 returns the column numbers in the second derivative of the lagrangian structure
 
 __disown__ (self)
 

Properties

 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
 

Detailed Description

The Model Data class.

Definition at line 1951 of file pyconopt.py.

Constructor & Destructor Documentation

◆ __init__()

pyconopt.ConoptModelData.__init__ ( self)

Constructor.

Definition at line 1957 of file pyconopt.py.

Member Function Documentation

◆ readMatrix()

pyconopt.ConoptModelData.readMatrix ( self,
lower,
curr,
upper,
vsta,
type,
rhs,
esta,
colsta,
rowno,
value,
nlflag,
numvar,
numcon,
numnz )

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:

  1. setting the problem dimension by calling setProblemDimension().
  2. set the objective element (constraint or variable) by calling setObjectiveElement().
  3. set the optimisation sense by calling setOptimizationSense().
  4. implementing a readMatrix() method that loads the model using a column-oriented sparse matrix format. For more details regarding the parameters of the readMatrix() method, please see 'API_DEFINING_THE_MODEL_F90'

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:

  1. write a member function for building the model.
  2. in the build model function, call addVariable() for each variable to be added to the problem.
  3. in the build model function, call addConstraint() for each constraint to be added to the problem. When adding a constraint, you should specify the variables (by index), coefficients and non-linear flags (for all nonlinear terms).
  4. set the objective element (constraint or variable) by calling setObjectiveElement().
  5. set the optimisation sense by calling setOptimizationSense(). When the solve method is called, the default readMatrix() method will be called, which will load the model into CONOPT as specified by the calls to addVariable() and addConstraint().

Definition at line 1966 of file pyconopt.py.

◆ setProblemDimension()

pyconopt.ConoptModelData.setProblemDimension ( self,
numvar,
numcons,
numnz,
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.

Parameters
numvarthe number of variables in the problem
numconsthe number of constraints in the problem
numnzthe number of non-zeros in the constraint matrix
numnlnzthe number of nonlinear non-zeros in the constraint matrix

Reimplemented in pyconopt.ModelData.

Definition at line 1995 of file pyconopt.py.

◆ addConstraint()

pyconopt.ConoptModelData.addConstraint ( self,
* args )

Overload 1: adds a constraint to the problem.

The non-zero coefficients are added later

Parameters
constypethe type of constraint, 0: ==, 1: >=, 2: <=, 3: free
rhsthe right hand side
slackstatusinitial status of the slack variables, see IniStat

|

Overload 2: adds a constraint to the problem. The matrix non-zeros are added based on the supplied variables

Parameters
constypethe type of constraint, 0: ==, 1: >=, 2: <=, 3: free
rhsthe right hand side
varindexthe variables this constraint has non-zero coefficients
valuethe non-zero of the variable
nlflagflag to set whether the variable belongs to a non-linear term
slackstatusinitial status of the slack variables, see IniStat

|

Overload 3: adds a constraint to the problem. The matrix non-zeros are added based on the supplied variables

Parameters
constypethe type of constraint, 0: ==, 1: >=, 2: <=, 3: free
rhsthe right hand side
varindexthe variables this constraint has non-zero coefficients
valuethe non-zero of the variable
nlflagflag to set whether the variable belongs to a non-linear term
slackstatusinitial status of the slack variables, see IniStat

Reimplemented in pyconopt.ModelData.

Definition at line 2011 of file pyconopt.py.

◆ addVariable()

pyconopt.ConoptModelData.addVariable ( self,
* args )

Overload 1: adds a variable to the model.

The non-zero coefficients are added later.

Parameters
lowerlower bound for the variable
upperupper bound for the variable
currinitial value of the variable, can be set to 0
varstatusinitial status of the variable, see IniStat

|

Overload 2: adds a variable to the problem. The matrix non-zeros are added based on the supplied constraints.

Parameters
lowerlower bound for the variable
upperupper bound for the variable
consindexthe constraints this variable has non-zero coefficients
valuethe non-zero of the variable
nlflagflag to set whether the variable belongs to a non-linear term
currinitial value of the variable, can be set to 0
varstatusinitial status of the variable, see IniStat

|

Overload 3: adds a variable to the problem. The matrix non-zeros are added based on the supplied constraints.

Parameters
lowerlower bound for the variable
upperupper bound for the variable
consindexthe constraints this variable has non-zero coefficients
valuethe non-zero of the variable
nlflagflag to set whether the variable belongs to a non-linear term
currinitial value of the variable, can be set to 0
varstatusinitial status of the variable, see IniStat

|

Overload 4: adds a variable to the problem. The matrix non-zeros are added based on the supplied constraints.

Parameters
lowerlower bound for the variable
upperupper bound for the variable
consindexthe constraints this variable has non-zero coefficients
valuethe non-zero of the variable
nlflagflag to set whether the variable belongs to a non-linear term
currinitial value of the variable, can be set to 0
varstatusinitial status of the variable, see IniStat

Reimplemented in pyconopt.ModelData.

Definition at line 2052 of file pyconopt.py.

◆ setObjectiveElement()

pyconopt.ConoptModelData.setObjectiveElement ( self,
elem,
elemindex )

sets the index for the objective variable or constraint

Reimplemented in pyconopt.ModelData.

Definition at line 2111 of file pyconopt.py.

◆ setOptimizationSense()

pyconopt.ConoptModelData.setOptimizationSense ( self,
sense )

sets the optimisation direction.

Reimplemented in pyconopt.ModelData.

Definition at line 2119 of file pyconopt.py.

◆ setInitialStatusOption()

pyconopt.ConoptModelData.setInitialStatusOption ( self,
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:

  • 0: The variable is initialized non-basic (if curr = lower or curr = upper) or super-basic, and
  • 1: The variable is initialized basic The slack status has the following behaviour:
  • 0: The slack is initialized non-basic (if the constraint is binding in the initial point) or super-basic,
  • 1: The slack is initialized basic

If inistat == 2: The variable status has the following behaviour:

  • 0: The variable is initialized at lower bound
  • 1: The variable is initialized at upper bound
  • 2: The variable is initialized basic, and
  • 3: The variable is initialized superbasic. The slack status has the following behaviour:
  • 0: The slack is initialized at lower bound.
  • 1: The slack is initialized at upper bound.
  • 2: The slack is initialized basic, and
  • 3: The slack is initialized superbasic.

Reimplemented in pyconopt.ModelData.

Definition at line 2127 of file pyconopt.py.

◆ numVar()

pyconopt.ConoptModelData.numVar ( self)

returns the number of variables in the model

Reimplemented in pyconopt.ModelData.

Definition at line 2159 of file pyconopt.py.

◆ numCons()

pyconopt.ConoptModelData.numCons ( self)

returns the number of constraints in the model

Reimplemented in pyconopt.ModelData.

Definition at line 2167 of file pyconopt.py.

◆ numHessianNonzeros()

pyconopt.ConoptModelData.numHessianNonzeros ( self)

returns the number of non-zeros in the Hessian

Reimplemented in pyconopt.ModelData.

Definition at line 2175 of file pyconopt.py.

◆ getVariable()

pyconopt.ConoptModelData.getVariable ( self,
index )

returns a reference to the variable object

Reimplemented in pyconopt.ModelData.

Definition at line 2183 of file pyconopt.py.

◆ getConstraint()

pyconopt.ConoptModelData.getConstraint ( self,
index )

returns a reference to the constraint object

Reimplemented in pyconopt.ModelData.

Definition at line 2191 of file pyconopt.py.

◆ setSDEvaluationType()

pyconopt.ConoptModelData.setSDEvaluationType ( self,
sdevaltype )

informs CONOPT of the method for evaluating the second derivative

Reimplemented in pyconopt.ModelData.

Definition at line 2199 of file pyconopt.py.

◆ setSDLagrangianStructure()

pyconopt.ConoptModelData.setSDLagrangianStructure ( self,
rownum,
colnum )

sets the structure of the second derivatives of the Lagrangian

Parameters
rownumVector of row numbers of the lower triangular part of the Hessian.
colnumVector of column numbers of the lower triangular part of the Hessian.

Reimplemented in pyconopt.ModelData.

Definition at line 2207 of file pyconopt.py.

◆ getSDLagrangianRowNumbers()

pyconopt.ConoptModelData.getSDLagrangianRowNumbers ( self)

returns the row numbers in the second derivative of the lagrangian structure

Definition at line 2218 of file pyconopt.py.

◆ getSDLagrangianColumnNumbers()

pyconopt.ConoptModelData.getSDLagrangianColumnNumbers ( self)

returns the column numbers in the second derivative of the lagrangian structure

Definition at line 2222 of file pyconopt.py.

◆ __disown__()

pyconopt.ConoptModelData.__disown__ ( self)

Definition at line 2225 of file pyconopt.py.

Property Documentation

◆ thisown

pyconopt.ConoptModelData.thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
static

Definition at line 1954 of file pyconopt.py.


The documentation for this class was generated from the following file: