#include <OSBonminSolver.h>
Inheritance diagram for BonminProblem:
Public Member Functions | |
BonminProblem (OSInstance *osinstance_, OSResult *osresult_) | |
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 | |
OSResult * | osresult |
OSInstance * | osinstance |
Private Attributes | |
bool | printSol_ |
std::string | bonminErrorMsg |
Definition at line 80 of file OSBonminSolver.h.
BonminProblem::BonminProblem | ( | OSInstance * | osinstance_, | |
OSResult * | osresult_ | |||
) |
the BonminProblemclass constructor
Definition at line 778 of file OSBonminSolver.cpp.
References osinstance, osresult, 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 63 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 84 of file OSBonminSolver.cpp.
References bonminErrorMsg, ErrorClass::errormsg, OSInstance::getAllNonlinearVariablesIndexMap(), OSInstance::initForAlgDiff(), 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 124 of file OSBonminSolver.cpp.
References OSInstance::getNonlinearExpressionTreeModIndexes(), OSInstance::getNumberOfNonlinearExpressionTreeModIndexes(), 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 150 of file OSBonminSolver.cpp.
References bonminErrorMsg, OSInstance::bUseExpTreeForFunEval, ErrorClass::errormsg, OSInstance::getConstraintNumber(), OSInstance::getJacobianSparsityPattern(), OSInstance::getLagrangianHessianSparsityPattern(), OSInstance::getNumberOfNonlinearExpressions(), OSInstance::getNumberOfQuadraticTerms(), OSInstance::getObjectiveNumber(), 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 203 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 238 of file OSBonminSolver.cpp.
References OSInstance::getVariableInitialValues(), CommonUtil::ISOSNAN(), and osinstance.
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 270 of file OSBonminSolver.cpp.
References bonminErrorMsg, OSInstance::calculateAllObjectiveFunctionValues(), ErrorClass::errormsg, CommonUtil::ISOSNAN(), 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 282 of file OSBonminSolver.cpp.
References bonminErrorMsg, OSInstance::calculateObjectiveFunctionGradient(), ErrorClass::errormsg, 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 304 of file OSBonminSolver.cpp.
References bonminErrorMsg, OSInstance::calculateAllConstraintFunctionValues(), ErrorClass::errormsg, CommonUtil::ISOSNAN(), 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 322 of file OSBonminSolver.cpp.
References bonminErrorMsg, ErrorClass::errormsg, OSInstance::getJacobianSparsityPattern(), SparseJacobianMatrix::indexes, k, 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 372 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 421 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 442 of file OSBonminSolver.cpp.
References ErrorClass::errormsg, OSInstance::getConstraintNumber(), OSInstance::getInstanceName(), OSInstance::getVariableNumber(), osinstance, osresult, printSol_, OSResult::setConstraintNumber(), OSResult::setGeneralMessage(), OSResult::setGeneralStatusType(), OSResult::setInstanceName(), OSResult::setObjectiveNumber(), OSResult::setObjectiveValues(), OSResult::setPrimalVariableValues(), OSResult::setServiceName(), OSResult::setSolutionNumber(), OSResult::setSolutionStatus(), OSResult::setVariableNumber(), Bonmin::TMINLP::SUCCESS, and OSrLWriter::writeOSrL().
virtual const SosInfo* BonminProblem::sosConstraints | ( | ) | const [inline, virtual] |
virtual const BranchingInfo* BonminProblem::branchingInfo | ( | ) | const [inline, virtual] |
void BonminProblem::printSolutionAtEndOfAlgorithm | ( | ) | [inline] |
Definition at line 91 of file OSBonminSolver.h.
Referenced by BonminProblem(), and finalize_solution().
Definition at line 93 of file OSBonminSolver.h.
Referenced by BonminProblem(), eval_f(), eval_g(), eval_grad_f(), eval_h(), eval_jac_g(), finalize_solution(), get_bounds_info(), get_constraints_linearity(), get_nlp_info(), get_starting_point(), get_variables_linearity(), and get_variables_types().
bool BonminProblem::printSol_ [private] |
Definition at line 200 of file OSBonminSolver.h.
Referenced by BonminProblem(), finalize_solution(), and printSolutionAtEndOfAlgorithm().
std::string BonminProblem::bonminErrorMsg [private] |
Definition at line 220 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().