|
Minotaur 0.4.1
Docs for developers
|


Public Member Functions | |
| Problem (EnvPtr env) | |
| Default constructor. | |
| virtual | ~Problem () |
| Destroy. | |
| virtual void | addToCons (ConstraintPtr cons, double c) |
| Add 'c' to both lb and ub of a constraint. | |
| virtual void | addToObj (LinearFunctionPtr lf) |
| Add a linear function to the objective. | |
| virtual void | addToObj (double cb) |
| Add a constant term to the objective. | |
| virtual void | calculateSize (bool shouldRedo=false) |
| Fill up the statistics about the size of the problem into size_. | |
| virtual void | changeBoundByInd (UInt ind, BoundType lu, double new_val) |
| Change a bound (lower or upper) on a variable with ID=id. | |
| virtual void | changeBoundByInd (UInt ind, double new_lb, double new_ub) |
| Change both bounds (lower and upper) on a variable with ID=id. | |
| virtual void | changeBound (VariablePtr var, BoundType lu, double new_val) |
| Change a bound (lower or upper) on a variable 'var'. | |
| virtual void | changeBound (VariablePtr var, double new_lb, double new_ub) |
| Change lower and upper bounds on the variable 'var'. | |
| virtual void | changeBound (ConstraintPtr con, BoundType lu, double new_val) |
| Change a bound (lower or upper) on a constraint 'con'. | |
| virtual void | changeBound (ConstraintPtr con, double new_lb, double new_ub) |
| Change lower and upper bounds on the constraint 'con'. | |
| virtual void | changeConstraint (ConstraintPtr con, LinearFunctionPtr lf, double lb, double ub) |
| Change the linear function, and the bounds of a constraint. | |
| virtual void | changeConstraint (ConstraintPtr con, NonlinearFunctionPtr nlf) |
| Change the nonlinear function and bounds of a constraint. | |
| virtual void | changeObj (FunctionPtr f, double cb) |
| Replace the objective function with a new function. | |
| virtual int | checkConVars () const |
| Check whether variables used in the constraints belong to the problem or not. | |
| virtual void | classifyCon () |
| ProblemPtr | clone (EnvPtr env) const |
| Clone the given Problem class. Jacobian and Hessian in the cloned problem are NULL. | |
| ProblemPtr | shuffle (bool varshuff, bool conshuff, EnvPtr env) |
| shuffle variables and constraints while making a clone of the problem | |
| void | cg2qf () |
| Convert all quadratic forms that are stored as CGraph into QuadraticFunction. The order of constraints changes after this conversion. | |
| virtual ConstraintConstIterator | consBegin () const |
| Iterate over constraints. Returns the 'begin' iterator. | |
| virtual ConstraintConstIterator | consEnd () const |
| Iterate over constraints. Returns the 'end' iterator. | |
| virtual void | delMarkedCons () |
| Delete marked constraints. | |
| virtual void | delMarkedVars (bool keep=false) |
| virtual ProblemType | findType () |
| Return what type of problem it is. May result in re-calculation of the problem size. | |
| virtual ConstraintPtr | getConstraint (UInt index) const |
| Return a pointer to the constraint with a given index. | |
| virtual DoubleVector * | getDebugSol () const |
| Give a pointer to the debug solution. | |
| virtual HessianOfLagPtr | getHessian () const |
| Return the hessian of the lagrangean. Could be NULL. | |
| virtual JacobianPtr | getJacobian () const |
| Return the jacobian. Could be NULL. | |
| virtual UInt | getNumCons () const |
| Return the number of constraints. | |
| virtual UInt | getNumDCons () const |
| Return the number of constraints marked for deletion. | |
| virtual UInt | getNumDVars () const |
| Return the number of variables marked for deletion. | |
| virtual UInt | getNumHessNnzs () const |
| Return the number of non-zeros in the hessian of the lagrangean of the problem. | |
| virtual UInt | getNumJacNnzs () const |
| Return the number of non zerors in the jacobian of the constraints. | |
| UInt | getNumLinCons () |
| Return the number of linear constraints in the problem. | |
| UInt | getNumSOS1 () |
| Return the number of SOS Type 1 constraints. | |
| UInt | getNumSOS2 () |
| Return the number of SOS Type 2 constraints. | |
| virtual UInt | getNumVars () const |
| Return the number of variables. | |
| virtual ObjectivePtr | getObjective () const |
| Return a pointer to the objective Function. | |
| double | getObjValue (const double *x, int *err) const |
| Return the value of objective function at given point x. | |
| ConstProblemSizePtr | getSize () const |
| Fill up the statistics about the size of the problem into size_. | |
| double | getSizeEstimate () |
| Calculate and return a measure of the size of the problem. | |
| virtual VariablePtr | getVariable (UInt index) const |
| Return a pointer to the variable with a given index. | |
| virtual bool | hasNativeDer () const |
| Return true if the derivative is available through Minotaur's own routines for storing nonlinear functions. | |
| virtual bool | isDebugSolFeas (double atol, double rtol) |
| Returns true if the debug solution is cut off by the constraints of the problem. | |
| virtual bool | isFeasible (const double *x, double objval, double &inf_meas) const |
| Check feasibility of original constraints and objective. Evaluates all constraints and the objective function at point x, constraint violations into inf_meas. | |
| virtual bool | isLinear () |
| Returns true if the problem has only linear constraints and linear objectives. | |
| virtual bool | isMarkedDel (ConstConstraintPtr con) |
| Return true if a constraint is marked deleted. | |
| virtual bool | isMarkedDel (ConstVariablePtr var) |
| Return true if a constraint is marked deleted. | |
| virtual bool | isQP () |
| Returns true if the problem has (1) linear or quadratic objective, and (2) linear constraints only. | |
| virtual bool | isQuadratic () |
| Returns true if the problem has only linear or quadratic constraints and linear or quadratic objectives. Returns false if a problem is linear. Returns false if problem is nonlinear. | |
| virtual void | markDelete (ConstraintPtr con) |
| Mark a constraint for deleting. | |
| bool | checkQuadCond (const ConstraintStats &stats) |
| bool | checkCoeffCond (const ConstraintStats &stats, bool positive) |
| virtual void | markDelete (VariablePtr var) |
| Mark a variable as deleted. | |
| virtual void | negateObj () |
| The objective is multiplied by -1. | |
| virtual VariablePtr | newBinaryVariable () |
| Add a new binary variable and return a pointer to it. A name is automatically generated by default. | |
| virtual VariablePtr | newBinaryVariable (std::string name) |
| Add a new binary variable. | |
| virtual ConstraintPtr | newConstraint (FunctionPtr f, double lb, double ub) |
| Add a new constraint and return a pointer to it. A name is automatically generated by default. | |
| virtual ConstraintPtr | newConstraint (FunctionPtr f, double lb, double ub, std::string name) |
| Add a new constraint and return a pointer to it. | |
| virtual ObjectivePtr | newObjective (FunctionPtr f, double cb, ObjectiveType otyp) |
| Add a new objective. A name is automatically generated by default. | |
| virtual ObjectivePtr | newObjective (double cb, ObjectiveType otyp) |
| virtual ObjectivePtr | newObjective (FunctionPtr f, double cb, ObjectiveType otyp, std::string name) |
| Add a new objective. | |
| virtual SOSPtr | newSOS (int n, SOSType type, const double *weights, const VarVector &vars, int priority, std::string name) |
| Add a new SOS constraint with a name. | |
| virtual SOSPtr | newSOS (int n, SOSType type, const double *weights, const VarVector &vars, int priority) |
| Add a new SOS constraint (name generated automatically). | |
| virtual VariablePtr | newVariable (VarSrcType stype=VarOrig) |
| Add a new continuous, unbounded variable to the Problem. | |
| virtual VariablePtr | newVariable (double lb, double ub, VariableType vtype, VarSrcType=VarOrig) |
| Add a new variable with bounds, type. A name is automatically generated by default. | |
| virtual VariablePtr | newVariable (double lb, double ub, VariableType vtype, std::string name, VarSrcType=VarOrig) |
| Add a new variable. | |
| virtual void | newVariables (VariableConstIterator v_begin, VariableConstIterator v_end, VarSrcType stype=VarOrig) |
| Clone the variables pointed by the iterators and add them. | |
| virtual void | prepareForSolve () |
| Setup problem data-structures for solving it. | |
| virtual void | objToCons () |
| virtual void | removeObjective () |
| Remove objective from the Problem. | |
| virtual QuadraticFunctionPtr | removeQuadFromObj () |
| Remove the quadratic part of objective and return it. | |
| virtual NonlinearFunctionPtr | removeNonlinFromObj () |
| virtual void | resetDer () |
| virtual void | resConTypCnt () |
| virtual void | reverseSense (ConstraintPtr cons) |
| Reverse the sense of a constraint. | |
| virtual void | setDebugSol (const DoubleVector &x) |
| Set a solution that can be checked for accidental cutting off by cuts, branching, reformulations etc. | |
| virtual void | setEngine (Engine *engine) |
| Set the engine that is used to solve this problem. | |
| virtual void | setHessian (HessianOfLagPtr hessian) |
| Add a pointer to the hessian of the Lagrangean. | |
| virtual void | setInitialPoint (const double *x) |
| Set an initial point. | |
| virtual void | setInitialPoint (const double *x, size_t k) |
| Set an initial point. | |
| virtual void | setInitVal (VariablePtr v, double val) |
| virtual void | setInitValByInd (UInt ind, double val) |
| virtual void | setJacobian (JacobianPtr jacobian) |
| Set the jacobian of the constraints. | |
| void | setNativeDer () |
| Ask Problem to construct its own jacobian and hessian using Minotaur's native code for nonlinear functions. | |
| virtual void | setVarType (VariablePtr var, VariableType type) |
| Change the variable type. | |
| virtual SOSConstIterator | sos1Begin () const |
| virtual SOSConstIterator | sos1End () const |
| virtual SOSConstIterator | sos2Begin () const |
| virtual SOSConstIterator | sos2End () const |
| virtual void | subst (VariablePtr out, VariablePtr in, double rat=1.0) |
| Substitute a variable 'out' with the variable 'in' through out the problem. | |
| virtual void | unsetEngine () |
| Should be called in the Engine's destructor. | |
| virtual VariableConstIterator | varsBegin () const |
| Iterate over variables. | |
| virtual VariableConstIterator | varsEnd () const |
| Iterate over variables. | |
| virtual void | write (std::ostream &out, std::streamsize out_p=6) const |
| only for debugging, developing etc. | |
| virtual void | writeSize (std::ostream &out) const |
| Write the problem size to logger_. | |
| void | statistics (std::ostream &out) const |
Public Attributes | |
| const double | INFTY = std::numeric_limits<double>::infinity() |
Protected Member Functions | |
| bool | isAggregation_ (ConstraintPtr c) |
| bool | isPrecedence_ (ConstraintPtr c, const ConstraintStats &stats) |
| bool | isVariableBound_ (ConstraintPtr c, const ConstraintStats &stats) |
| bool | isSetPartitioning_ (ConstraintPtr c, const ConstraintStats &stats) |
| bool | isSetPacking_ (ConstraintPtr c, const ConstraintStats &stats) |
| bool | isSetCovering_ (ConstraintPtr c, const ConstraintStats &stats) |
| bool | isCardinality_ (ConstraintPtr c, const ConstraintStats &stats) |
| bool | isInvariantKnapsack_ (ConstraintPtr c, const ConstraintStats &stats) |
| bool | isEquationKnapsack_ (ConstraintPtr c, const ConstraintStats &stats) |
| bool | isBinPacking_ (ConstraintPtr c, const ConstraintStats &stats) |
| bool | isKnapsack_ (ConstraintPtr c, const ConstraintStats &stats) |
| bool | isIntegerKnapsack_ (ConstraintPtr c, const ConstraintStats &stats) |
| bool | isMixedBinary_ (ConstraintPtr c, const ConstraintStats &stats) |
| bool | isNoSpecificStructure_ (ConstraintPtr c) |
| bool | isDiagonalQuadratic_ (ConstraintPtr c, const ConstraintStats &stats) |
| bool | isSimpleBall_ (ConstraintPtr c, const ConstraintStats &stats) |
| bool | isEllipsoid_ (ConstraintPtr c, const ConstraintStats &stats) |
| bool | isComplementEllipsoid_ (ConstraintPtr c, const ConstraintStats &stats) |
| bool | isComplementSimpleBall_ (ConstraintPtr c, const ConstraintStats &stats) |
| bool | isSocSimple_ (ConstraintPtr c, const ConstraintStats &stats) |
| bool | isPureBilinear_ (ConstraintPtr c, const ConstraintStats &stats) |
| bool | isOtherQuadType_ (ConstraintPtr c, const ConstraintStats &stats) |
| void | printConstraintStatistics_ () |
| void | printConstraintStatisticsQuad_ () |
| void | lockNum_ () |
| virtual void | countConsTypes_ () |
| Count the types of constraints and fill the values in size_. | |
| virtual void | countObjTypes_ () |
| Count the types of objectives and fill the values in size_. | |
| virtual void | countVarTypes_ () |
| Fill up the size_ with number of variables of each type. | |
| virtual void | findVarFunTypes_ () |
| Update the function types of all variables based on whether they appear as linear, quadratic or nonlinear in each objective and constraint. | |
| bool | isPolyp_ () |
| void | setIndex_ (VariablePtr v, UInt i) |
Protected Attributes | |
| ConstraintVector | cons_ |
| Vector of constraints. | |
| bool | consModed_ |
| Flag that is turned on if the constraints are added or modified. | |
| DoubleVector * | debugSol_ |
| A solution to be used for debugging against accidentally cutting of feasible points. | |
| Engine * | engine_ |
| Engine that must be updated if problem is loaded to it, could be null. | |
| HessianOfLagPtr | hessian_ |
| Pointer to the hessian of the lagrangean. Could be NULL. | |
| JacobianPtr | jacobian_ |
| Pointer to the jacobian of constraints. Can be NULL. | |
| LoggerPtr | logger_ |
| Pointer to the log manager. All output messages are sent to it. | |
| bool | nativeDer_ |
| If true, set up our own Hessian and Jacobian. | |
| UInt | nextCId_ |
| ID of the next constraint. | |
| int | nextSId_ |
| ID of the next SOS constraint. | |
| UInt | nextVId_ |
| ID of the next variable. | |
| UInt | numDCons_ |
| Number of constraints marked for deletion. | |
| UInt | numDVars_ |
| Number of variables marked for deletion. | |
| ObjectivePtr | obj_ |
| Objective, could be NULL. | |
| ProblemSizePtr | size_ |
| Size statistics for this Problem. | |
| SOSVector | sos1_ |
| SOS1 constraints. | |
| SOSVector | sos2_ |
| SOS2 constraints. | |
| VarVector | vars_ |
| Vector of variables. | |
| VarVector | varsRem_ |
| Vector of variables removed from the problem but not yet freed from memory. | |
| bool | varsModed_ |
| True if variables delete, added or their bounds changed. | |
Static Protected Attributes | |
| static const std::string | me_ = "Problem: " |
| For logging. | |
|
virtual |
Change the linear function, and the bounds of a constraint.
| [in] | con | Original constraint that is to be changed. |
| [in] | lf | The new linear function. |
| [in] | lb | The new lower bound. |
| [in] | ub | The new upper bound. |
|
virtual |
Change the nonlinear function and bounds of a constraint.
| [in] | con | Original constraint that is to be changed. |
| [in] | nlf | The new nonlinear function. |
|
virtual |
Replace the objective function with a new function.
| [in] | f | The new obejctive function. f is cloned. If f is modified after this call, it won't affect the objective. |
| [in] | cb | The new objective constant. |
|
virtual |
Check whether variables used in the constraints belong to the problem or not.
This is a sanity check, used only for debugging.
| ProblemPtr Problem::clone | ( | EnvPtr | env | ) | const |
Clone the given Problem class. Jacobian and Hessian in the cloned problem are NULL.
The variables are created. If the functions are stored in native format, they are also cloned. Problem size and the initial point are cloned as well.
| [in] | env | Pointer to environment for the clone. |
|
virtual |
Remove marked variables from the problem.
| [in] | keep | If false, the variable pointer is freed from memory. If true, then it is not deleted, and can possibly be revisited (e.g. for restoring variables in postsolve). Default is false. |
|
virtual |
Give a pointer to the debug solution.
\Returns null if there is none, otherwise a pointer to a vector of doubles.
|
virtual |
Return the number of non-zeros in the hessian of the lagrangean of the problem.
The lagrangean is defined as: \sigma . f(x) + \sum_{i=0}^{m-1}\lambda_i . g_i(x), where \sigma \in R^1 and \lambda \in R^m are the dual multipliers. The hessian, w.r.t. x, is thus a square symmetric matrix. usually the multipliers are provided by NLP solvers. Such solvers may require during initialization, the number of non-zeros in the lower triangular of the hessian.
|
virtual |
Mark a constraint for deleting.
The constraint is not deleted, just marked. Call Problem::delMarkedCons() to actually delete all the marked constraints.
| [in] | con | The constraint to be marked. |
|
virtual |
Mark a variable as deleted.
The variable is not deleted, just marked. Call Problem::delMarkedVars() to actually delete all the marked variables.
| [in] | var | The variable to be marked. |
|
virtual |
Add a new binary variable.
| [in] | name | The predefined name for this variable. |
|
virtual |
Add a new constraint and return a pointer to it. A name is automatically generated by default.
| [in] | f | Pointer to the Function in the constraint. It is not cloned. The pointer is saved as it is. |
| [in] | lb | The lower bound of the constraint. May be -INFINITY. |
| [in] | ub | The upper bound of the constraint. May be +INFINITY. |
|
virtual |
Add a new constraint and return a pointer to it.
| [in] | f | Pointer to the Function in the constraint. It is not cloned. The pointer is saved as it is. |
| [in] | lb | The lower bound of the constraint. May be -INFINITY. |
| [in] | ub | The upper bound of the constraint. May be +INFINITY. |
| [in] | name | The name for the constraint. |
|
virtual |
Add a new objective. A name is automatically generated by default.
| [in] | f | Pointer to the Function in the objective. It is not cloned. The pointer is saved as it is. |
| [in] | cb | The constant term in the objective function. |
| [in] | otyp | Whether the objective is to Minimize or Maximize. |
|
virtual |
Add a new objective.
| [in] | f | Pointer to the Function in the objective. It is not cloned. The pointer is saved as it is. |
| [in] | cb | The constant term in the objective function. |
| [in] | otyp | Whether the objective is to Minimize or Maximize. |
| [in] | name | The name for the objective function. |
|
virtual |
Add a new SOS constraint (name generated automatically).
| [in] | n | Number of variables in this SOS constraint. |
| [in] | type | SOS1 (SOS type 1) or SOS2 (SOS type 2). |
| [in] | weights | Values of coefficients of variables in the SOS constraint or just relative weights. |
| [in] | vars | Variables in the constraint. |
| [in] | priority | The priority provided by the user for this constraint. |
|
virtual |
Add a new SOS constraint with a name.
| [in] | n | Number of variables in this SOS constraint. |
| [in] | type | SOS1 (SOS type 1) or SOS2 (SOS type 2). |
| [in] | weights | Values of coefficients of variables in the SOS constraint or just relative weights. |
| [in] | vars | Variables in the constraint. |
| [in] | priority | The priority provided by the user for this constraint. |
| [in] | name | The name provided by the user for this SOS. |
|
virtual |
Add a new variable.
| [in] | lb | The lower bound on the variable. May be -INFINITY. |
| [in] | ub | The upper bound on the variable. May be +INFINITY. |
| [in] | vtype | Type of the variable: Integer, Continuous, Binary. |
| [in] | name | Name of the variable. |
| [in] | stype | The source of the variable |
|
virtual |
Add a new variable with bounds, type. A name is automatically generated by default.
| [in] | lb | The lower bound on the variable. May be -INFINITY. |
| [in] | ub | The upper bound on the variable. May be +INFINITY. |
| [in] | vtype | Type of the variable: Integer, Continuous, Binary. |
| [in] | stype | The source of the variable |
|
virtual |
Add a new continuous, unbounded variable to the Problem.
| [in] | stype | The source of the variable |
|
virtual |
Clone the variables pointed by the iterators and add them.
Given starting and stopping iterators of variables, clone these variables and add the copies to this problem. Do not add them to any constraints or objectives. The IDs are not copied.
| [in] | v_begin | The 'begin' iterator of the variable vector. |
| [in] | v_end | The 'end' iterator of the variable vector. |
| [in] | stype | The source of the variables |
|
virtual |
Move the nonlinear part of the objective function to constraints set using an auxiliary variable
|
virtual |
Setup problem data-structures for solving it.
Prepare necessary data structures for the next solve. e.g. if constraints have been modified, then re-evalate the sparsity pattern of Jacobian and Hessian.
|
virtual |
Remove the jacobian and hessian data structures. Useful when you want to re-compute the derivatives after a problem has been modified.
|
virtual |
Reverse the sense of a constraint.
| [in] | cons | The constraint whose sense has to be reversed. |
|
virtual |
Set a solution that can be checked for accidental cutting off by cuts, branching, reformulations etc.
| [in] | x | A vector of double values in the same order as variables in the problem. |
|
virtual |
Set the engine that is used to solve this problem.
The problem contains a pointer to the engine so that whenever the problem is modified, the engine also gets the modifications. This function sets the engine that must be modified whenever the problem is modified.
| [in] | engine | The engine pointer. |
|
virtual |
Add a pointer to the hessian of the Lagrangean.
| [in] | hessian | Pointer to the HessianOfLag object. |
|
virtual |
Set an initial point.
Initial point is used by some engines like IpoptEngine. If the initial point has already been set before, it is overwritten by the new point.
| [in] | x | An array of double values containing the coordinates of the initial point. |
|
virtual |
Set an initial point.
Same as function Problem::setInitialPoint, but only set values for the first 'k' variables. Put in because of AMPL's defined variables.
| [in] | x | An array of double values containing the coordinates of the initial point. |
| [in] | k | The first 'k' variables will be initialized. |
|
virtual |
Set the jacobian of the constraints.
| [in] | jacobian | Pointer to the Jacobian object. |
|
virtual |
Change the variable type.
| [in] | var | The variable pointer whose type needs to be changed. |
| [in] | type | The new VariableType. |
| ProblemPtr Problem::shuffle | ( | bool | varshuff, |
| bool | conshuff, | ||
| EnvPtr | env | ||
| ) |
shuffle variables and constraints while making a clone of the problem
| [in] | varshuff | If true, the variables are to be shuffled |
| [in] | conshuff | If true, the constraints are to be shuffled |
| [in] | env | Environment pointer for the cloned problem |
|
virtual |
Substitute a variable 'out' with the variable 'in' through out the problem.
| [in] | out | The variable that is to be substituted out. |
| [in] | in | The variable that replaces the variable 'out'. |
| [in] | rat | The ratio of substitution. ![]() |
|
protected |
Flag that is turned on if the constraints are added or modified.
When the problem is changed, say constraints are added or deleted, all associated changes do not happen at that time. For example, when new constraint is added, the hessian and jacobian do not change. This variable is true if constraints have changed since the last time all changes were applied.