#include <OSBonminSolver.h>
Inheritance diagram for BonminProblem:
Public Member Functions | |
BonminProblem (OSInstance *osinstance_, OSOption *osoption_) | |
the BonminProblemclass constructor | |
virtual | ~BonminProblem () |
the BonminProblem class destructor | |
virtual bool | get_scaling_parameters (Number &obj_scaling, bool &use_x_scaling, Index n, Number *x_scaling, bool &use_g_scaling, Index m, Number *g_scaling) |
overload this method to return scaling parameters. | |
virtual const SosInfo * | sosConstraints () const |
virtual const BranchingInfo * | branchingInfo () const |
void | printSolutionAtEndOfAlgorithm () |
Overloaded functions specific to a TMINLP. | |
virtual bool | get_variables_types (Index n, VariableType *var_types) |
Pass the type of the variables (INTEGER, BINARY, CONTINUOUS) to the optimizer. | |
virtual bool | get_variables_linearity (Index n, Ipopt::TNLP::LinearityType *var_types) |
Pass info about linear and nonlinear variables. | |
virtual bool | get_constraints_linearity (Index m, Ipopt::TNLP::LinearityType *const_types) |
Pass the type of the constraints (LINEAR, NON_LINEAR) to the optimizer. | |
Overloaded functions defining a TNLP. | |
This group of function implement the various elements needed to define and solve a TNLP. They are the same as those in a standard Ipopt NLP problem | |
virtual bool | get_nlp_info (Index &n, Index &m, Index &nnz_jac_g, Index &nnz_h_lag, TNLP::IndexStyleEnum &index_style) |
Method to pass the main dimensions of the problem to Ipopt. | |
virtual bool | get_bounds_info (Index n, Number *x_l, Number *x_u, Index m, Number *g_l, Number *g_u) |
Method to return the bounds for my problem. | |
virtual bool | get_starting_point (Index n, bool init_x, Number *x, bool init_z, Number *z_L, Number *z_U, Index m, bool init_lambda, Number *lambda) |
Method to return the starting point for the algorithm. | |
virtual bool | eval_f (Index n, const Number *x, bool new_x, Number &obj_value) |
Method to return the objective value. | |
virtual bool | eval_grad_f (Index n, const Number *x, bool new_x, Number *grad_f) |
Method to return the gradient of the objective. | |
virtual bool | eval_g (Index n, const Number *x, bool new_x, Index m, Number *g) |
Method to return the constraint residuals. | |
virtual bool | eval_jac_g (Index n, const Number *x, bool new_x, Index m, Index nele_jac, Index *iRow, Index *jCol, Number *values) |
Method to return: 1) The structure of the jacobian (if "values" is NULL) 2) The values of the jacobian (if "values" is not NULL). | |
virtual bool | eval_h (Index n, const Number *x, bool new_x, Number obj_factor, Index m, const Number *lambda, bool new_lambda, Index nele_hess, Index *iRow, Index *jCol, Number *values) |
Method to return: 1) The structure of the hessian of the lagrangian (if "values" is NULL) 2) The values of the hessian of the lagrangian (if "values" is not NULL). | |
Solution Methods | |
virtual void | finalize_solution (TMINLP::SolverReturn status_, Index n, const Number *x, Number obj_value) |
Method called by Ipopt at the end of optimization. | |
Public Attributes | |
OSInstance * | osinstance |
OSOption * | osoption |
TMINLP::SolverReturn | status |
Private Attributes | |
bool | printSol_ |
std::string | bonminErrorMsg |
Definition at line 86 of file OSBonminSolver.h.
BonminProblem::BonminProblem | ( | OSInstance * | osinstance_, | |
OSOption * | osoption_ | |||
) |
the BonminProblemclass constructor
Definition at line 1013 of file OSBonminSolver.cpp.
References osinstance, osoption, and printSol_.
BonminProblem::~BonminProblem | ( | ) | [virtual] |
bool BonminProblem::get_variables_types | ( | Index | n, | |
VariableType * | var_types | |||
) | [virtual] |
Pass the type of the variables (INTEGER, BINARY, CONTINUOUS) to the optimizer.
n | size of var_types (has to be equal to the number of variables in the problem) | |
var_types | types of the variables (has to be filled by function). |
Definition at line 75 of file OSBonminSolver.cpp.
References Bonmin::TMINLP::BINARY, Bonmin::TMINLP::CONTINUOUS, OSInstance::getVariableNumber(), OSInstance::getVariableTypes(), Bonmin::TMINLP::INTEGER, and osinstance.
bool BonminProblem::get_variables_linearity | ( | Index | n, | |
Ipopt::TNLP::LinearityType * | var_types | |||
) | [virtual] |
Pass info about linear and nonlinear variables.
get an index map of the nonlinear variables and see which variable are in <nonlinearExpressions> element
iterate through and get an index of all variables that are in <nonlinearExpressions> element
Implements Bonmin::TMINLP.
Definition at line 96 of file OSBonminSolver.cpp.
References bonminErrorMsg, ErrorClass::errormsg, OSInstance::getAllNonlinearVariablesIndexMap(), OSInstance::initForAlgDiff(), LINEAR, and osinstance.
bool BonminProblem::get_constraints_linearity | ( | Index | m, | |
Ipopt::TNLP::LinearityType * | const_types | |||
) | [virtual] |
Pass the type of the constraints (LINEAR, NON_LINEAR) to the optimizer.
m | size of const_types (has to be equal to the number of constraints in the problem) | |
const_types | types of the constraints (has to be filled by function). |
Implements Bonmin::TMINLP.
Definition at line 136 of file OSBonminSolver.cpp.
References OSInstance::getNonlinearExpressionTreeModIndexes(), OSInstance::getNumberOfNonlinearExpressionTreeModIndexes(), LINEAR, and osinstance.
bool BonminProblem::get_nlp_info | ( | Index & | n, | |
Index & | m, | |||
Index & | nnz_jac_g, | |||
Index & | nnz_h_lag, | |||
TNLP::IndexStyleEnum & | index_style | |||
) | [virtual] |
Method to pass the main dimensions of the problem to Ipopt.
n | number of variables in problem. | |
m | number of constraints. | |
nnz_jac_g | number of nonzeroes in Jacobian of constraints system. | |
nnz_h_lag | number of nonzeroes in Hessian of the Lagrangean. | |
index_style | indicate wether arrays are numbered from 0 (C-style) or from 1 (Fortran). |
Implements Bonmin::TMINLP.
Definition at line 162 of file OSBonminSolver.cpp.
References bonminErrorMsg, OSInstance::bUseExpTreeForFunEval, ErrorClass::errormsg, OSInstance::getConstraintNumber(), OSInstance::getJacobianSparsityPattern(), OSInstance::getLagrangianHessianSparsityPattern(), OSInstance::getNumberOfNonlinearExpressions(), OSInstance::getNumberOfQuadraticTerms(), OSInstance::getVariableNumber(), SparseHessianMatrix::hessDimension, OSInstance::initForAlgDiff(), osinstance, and SparseJacobianMatrix::valueSize.
bool BonminProblem::get_bounds_info | ( | Index | n, | |
Number * | x_l, | |||
Number * | x_u, | |||
Index | m, | |||
Number * | g_l, | |||
Number * | g_u | |||
) | [virtual] |
Method to return the bounds for my problem.
Implements Bonmin::TMINLP.
Definition at line 220 of file OSBonminSolver.cpp.
References OSInstance::getConstraintLowerBounds(), OSInstance::getConstraintUpperBounds(), OSInstance::getVariableLowerBounds(), OSInstance::getVariableUpperBounds(), and osinstance.
bool BonminProblem::get_starting_point | ( | Index | n, | |
bool | init_x, | |||
Number * | x, | |||
bool | init_z, | |||
Number * | z_L, | |||
Number * | z_U, | |||
Index | m, | |||
bool | init_lambda, | |||
Number * | lambda | |||
) | [virtual] |
Method to return the starting point for the algorithm.
Implements Bonmin::TMINLP.
Definition at line 260 of file OSBonminSolver.cpp.
References DEBUG, OSOption::getInitVarValuesSparse(), OSOption::getNumberOfInitVarValues(), OSInstance::getVariableNumber(), InitVarValue::idx, OSInstance::instanceData, k, Variable::lb, m1, OSDBL_MAX, osinstance, osoption, Variable::ub, InitVarValue::value, Variables::var, and InstanceData::variables.
bool BonminProblem::eval_f | ( | Index | n, | |
const Number * | x, | |||
bool | new_x, | |||
Number & | obj_value | |||
) | [virtual] |
Method to return the objective value.
Implements Bonmin::TMINLP.
Definition at line 387 of file OSBonminSolver.cpp.
References bonminErrorMsg, OSInstance::calculateAllObjectiveFunctionValues(), ErrorClass::errormsg, OSInstance::getObjectiveNumber(), OSInstance::instanceData, Objective::maxOrMin, Objectives::obj, InstanceData::objectives, and osinstance.
bool BonminProblem::eval_grad_f | ( | Index | n, | |
const Number * | x, | |||
bool | new_x, | |||
Number * | grad_f | |||
) | [virtual] |
Method to return the gradient of the objective.
Implements Bonmin::TMINLP.
Definition at line 406 of file OSBonminSolver.cpp.
References bonminErrorMsg, OSInstance::calculateObjectiveFunctionGradient(), ErrorClass::errormsg, OSInstance::getObjectiveNumber(), OSInstance::instanceData, Objective::maxOrMin, Objectives::obj, InstanceData::objectives, and osinstance.
bool BonminProblem::eval_g | ( | Index | n, | |
const Number * | x, | |||
bool | new_x, | |||
Index | m, | |||
Number * | g | |||
) | [virtual] |
Method to return the constraint residuals.
Implements Bonmin::TMINLP.
Definition at line 435 of file OSBonminSolver.cpp.
References bonminErrorMsg, OSInstance::calculateAllConstraintFunctionValues(), ErrorClass::errormsg, and osinstance.
bool BonminProblem::eval_jac_g | ( | Index | n, | |
const Number * | x, | |||
bool | new_x, | |||
Index | m, | |||
Index | nele_jac, | |||
Index * | iRow, | |||
Index * | jCol, | |||
Number * | values | |||
) | [virtual] |
Method to return: 1) The structure of the jacobian (if "values" is NULL) 2) The values of the jacobian (if "values" is not NULL).
Implements Bonmin::TMINLP.
Definition at line 453 of file OSBonminSolver.cpp.
References bonminErrorMsg, ErrorClass::errormsg, OSInstance::getJacobianSparsityPattern(), SparseJacobianMatrix::indexes, osinstance, and SparseJacobianMatrix::starts.
bool BonminProblem::eval_h | ( | Index | n, | |
const Number * | x, | |||
bool | new_x, | |||
Number | obj_factor, | |||
Index | m, | |||
const Number * | lambda, | |||
bool | new_lambda, | |||
Index | nele_hess, | |||
Index * | iRow, | |||
Index * | jCol, | |||
Number * | values | |||
) | [virtual] |
Method to return: 1) The structure of the hessian of the lagrangian (if "values" is NULL) 2) The values of the hessian of the lagrangian (if "values" is not NULL).
Implements Bonmin::TMINLP.
Definition at line 503 of file OSBonminSolver.cpp.
References bonminErrorMsg, OSInstance::calculateLagrangianHessian(), ErrorClass::errormsg, OSInstance::getLagrangianHessianSparsityPattern(), SparseHessianMatrix::hessColIdx, SparseHessianMatrix::hessRowIdx, SparseHessianMatrix::hessValues, and osinstance.
bool BonminProblem::get_scaling_parameters | ( | Number & | obj_scaling, | |
bool & | use_x_scaling, | |||
Index | n, | |||
Number * | x_scaling, | |||
bool & | use_g_scaling, | |||
Index | m, | |||
Number * | g_scaling | |||
) | [virtual] |
overload this method to return scaling parameters.
This is only called if the options are set to retrieve user scaling. There, use_x_scaling (or use_g_scaling) should get set to true only if the variables (or constraints) are to be scaled. This method should return true only if the scaling parameters could be provided.
Reimplemented from Bonmin::TMINLP.
Definition at line 552 of file OSBonminSolver.cpp.
void BonminProblem::finalize_solution | ( | TMINLP::SolverReturn | status_, | |
Index | n, | |||
const Number * | x, | |||
Number | obj_value | |||
) | [virtual] |
Method called by Ipopt at the end of optimization.
Implements Bonmin::TMINLP.
Definition at line 572 of file OSBonminSolver.cpp.
References status.
virtual const SosInfo* BonminProblem::sosConstraints | ( | ) | const [inline, virtual] |
virtual const BranchingInfo* BonminProblem::branchingInfo | ( | ) | const [inline, virtual] |
void BonminProblem::printSolutionAtEndOfAlgorithm | ( | ) | [inline] |
Definition at line 98 of file OSBonminSolver.h.
Referenced by BonminProblem(), eval_f(), eval_g(), eval_grad_f(), eval_h(), eval_jac_g(), get_bounds_info(), get_constraints_linearity(), get_nlp_info(), get_starting_point(), get_variables_linearity(), and get_variables_types().
Definition at line 100 of file OSBonminSolver.h.
Referenced by BonminProblem(), and get_starting_point().
bool BonminProblem::printSol_ [private] |
Definition at line 209 of file OSBonminSolver.h.
Referenced by BonminProblem(), and printSolutionAtEndOfAlgorithm().
std::string BonminProblem::bonminErrorMsg [private] |
Definition at line 229 of file OSBonminSolver.h.
Referenced by eval_f(), eval_g(), eval_grad_f(), eval_h(), eval_jac_g(), get_nlp_info(), and get_variables_linearity().