23#include "OSParameters.h"
25#include "CoinFinite.hpp"
26#include "CoinTime.hpp"
27#include "BonOsiTMINLPInterface.hpp"
28#include "BonTMINLP.hpp"
30using namespace Bonmin;
34using std::ostringstream;
74 for(i = 0; i < n; i++)
76 if( varType[i] ==
'B')
78 var_types[i] = BINARY;
82 if( varType[i] ==
'I')
88 if( varType[i] ==
'C')
90 var_types[i] = CONTINUOUS;
94 throw ErrorClass(
"variable type not yet implemented");
105 std::ostringstream outStr;
121 std::map<int, int> varIndexMap;
122 std::map<int, int>::iterator posVarIndexMap;
123 varIndexMap =
osinstance->getAllNonlinearVariablesIndexMap( );
128 for(i = 0; i < n; i++)
130 var_types[ i] = Ipopt::TNLP::LINEAR;
138 for(posVarIndexMap = varIndexMap.begin(); posVarIndexMap != varIndexMap.end(); ++posVarIndexMap)
140 outStr <<
"Variable Index = " << posVarIndexMap->first << std::endl ;
141 var_types[ posVarIndexMap->first] = Ipopt::TNLP::NON_LINEAR;
143 outStr <<
"Number of nonlinear variables = " << varIndexMap.size() << std::endl;
151 std::ostringstream outStr;
154 for(i = 0; i < m; i++)
156 const_types[ i] = Ipopt::TNLP::LINEAR;
159 int mm =
osinstance->getNumberOfNonlinearExpressionTreeModIndexes();
163 for(i = 0; i < mm; i++)
165 if(
osinstance->getNonlinearExpressionTreeModIndexes()[ i] >= 0)
167 outStr <<
osinstance->getNonlinearExpressionTreeModIndexes()[ i] << std::endl;
168 const_types[
osinstance->getNonlinearExpressionTreeModIndexes()[ i] ] = Ipopt::TNLP::NON_LINEAR;
178 Index& nnz_h_lag, TNLP::IndexStyleEnum& index_style)
180 std::ostringstream outStr;
189 outStr <<
"Bonmin number variables !!!!!!!!!!!!!!!!!!!!!!!!!!!" << n << endl;
190 outStr <<
"Bonmin number constraints !!!!!!!!!!!!!!!!!!!!!!!!!!!" << m << endl;
207 sparseJacobian =
osinstance->getJacobianSparsityPattern();
218 outStr <<
"nnz_jac_g !!!!!!!!!!!!!!!!!!!!!!!!!!!" << nnz_jac_g << endl;
223 if( (
osinstance->getNumberOfNonlinearExpressions() == 0) && (
osinstance->getNumberOfQuadraticTerms() == 0) )
236 outStr <<
"nnz_h_lag !!!!!!!!!!!!!!!!!!!!!!!!!!!" << nnz_h_lag << endl;
240 index_style = TNLP::C_STYLE;
247 Index m, Number* g_l, Number* g_u)
249 std::ostringstream outStr;
252 double * mdVarLB =
osinstance->getVariableLowerBounds();
254 double * mdVarUB =
osinstance->getVariableUpperBounds();
256 for(i = 0; i < n; i++)
258 x_l[ i] = mdVarLB[ i];
259 x_u[ i] = mdVarUB[ i];
263 outStr <<
"x_l !!!!!!!!!!!!!!!!!!!!!!!!!!!" << x_l[i] << endl;
264 outStr <<
"x_u !!!!!!!!!!!!!!!!!!!!!!!!!!!" << x_u[i] << endl;
274 double * mdConLB =
osinstance->getConstraintLowerBounds();
276 double * mdConUB =
osinstance->getConstraintUpperBounds();
278 for(
int i = 0; i < m; i++)
280 g_l[ i] = mdConLB[ i];
281 g_u[ i] = mdConUB[ i];
285 outStr <<
"lower !!!!!!!!!!!!!!!!!!!!!!!!!!!" << g_l[i] << endl;
286 outStr <<
"upper !!!!!!!!!!!!!!!!!!!!!!!!!!!" << g_u[i] << endl;
296 bool init_z, Number* z_L, Number* z_U, Index m,
bool init_lambda,
299 std::ostringstream outStr;
303 assert(init_x ==
true);
304 assert(init_z ==
false);
305 assert(init_lambda ==
false);
311 "get initial values !!!!!!!!!!!!!!!!!!!!!!!!!!\n");
317 "get number of initial values !!!!!!!!!!!!!!!!!!!!!!!!!!\n");
321 m1 =
osoption->getNumberOfInitVarValues();
327 outStr <<
"number of variables initialed: " << m1 << endl;
333 initialed =
new bool[n1];
337 outStr <<
"number of variables in total: " << n1 << endl;
342 for(k = 0; k < n1; k++)
343 initialed[k] =
false;
359 for(k = 0; k < m1; k++)
361 i = initVarVector[k]->
idx;
362 if (initVarVector[k]->idx > n1)
363 throw ErrorClass (
"Illegal index value in variable initialization");
365 initval = initVarVector[k]->
value;
368 if (
osinstance->instanceData->variables->var[i]->lb > initval)
369 throw ErrorClass (
"Initial value outside of bounds");
373 if (
osinstance->instanceData->variables->var[i]->ub < initval)
374 throw ErrorClass (
"Initial value outside of bounds");
378 if ((
osinstance->instanceData->variables->var[i]->lb > initval) ||
379 (
osinstance->instanceData->variables->var[i]->ub < initval))
380 throw ErrorClass (
"Initial value outside of bounds");
383 x[initVarVector[k]->
idx] = initval;
384 initialed[initVarVector[k]->idx] =
true;
390 "Error in BonminProblem::get_starting_point (OSBonminSolver.cpp)\n\n\n");
394 double default_initval;
395 default_initval = 1.7171;
398 for(k = 0; k < n1; k++)
403 if (
osinstance->instanceData->variables->var[k]->lb <= default_initval)
404 x[k] = default_initval;
406 x[k] =
osinstance->instanceData->variables->var[k]->lb;
408 if (
osinstance->instanceData->variables->var[k]->ub >= default_initval)
409 x[k] = default_initval;
411 x[k] =
osinstance->instanceData->variables->var[k]->ub;
412 else if ((
osinstance->instanceData->variables->var[k]->lb <= default_initval) &&
413 (
osinstance->instanceData->variables->var[k]->ub >= default_initval))
414 x[k] = default_initval;
415 else if (
osinstance->instanceData->variables->var[k]->lb > default_initval)
416 x[k] =
osinstance->instanceData->variables->var[k]->lb;
418 x[k] =
osinstance->instanceData->variables->var[k]->ub;
425 for(i = 0; i < n1; i++)
427 outStr <<
"INITIAL VALUE !!!!!!!!!!!!!!!!!!!! " << x[ i] << std::endl;
432 osinstance->calculateAllObjectiveFunctionValues( x,
true);
446 if(
osinstance->instanceData->objectives->obj[ 0]->maxOrMin.compare(
"min") == 0)
448 obj_value =
osinstance->calculateAllObjectiveFunctionValues(
const_cast<double*
>(x), NULL, NULL, new_x, 0 )[ 0];
452 obj_value = -
osinstance->calculateAllObjectiveFunctionValues(
const_cast<double*
>(x), NULL, NULL, new_x, 0 )[ 0];
461 if( CoinIsnan( (
double)obj_value) )
return false;
468 double *objGrad = NULL;
474 objGrad =
osinstance->calculateObjectiveFunctionGradient(
const_cast<double*
>(x), NULL, NULL, -1, new_x, 1);
482 for(i = 0; i < n; i++)
484 if(
osinstance->instanceData->objectives->obj[ 0]->maxOrMin.compare(
"min") == 0)
486 grad_f[ i] = objGrad[ i];
490 grad_f[ i] = -objGrad[ i];
502 double *conVals =
osinstance->calculateAllConstraintFunctionValues(
const_cast<double*
>(x), NULL, NULL, new_x, 0 );
504 for(i = 0; i < m; i++)
506 if( CoinIsnan( (
double)conVals[ i] ) )
return false;
521 Index m, Index nele_jac, Index* iRow, Index *jCol,
530 sparseJacobian =
osinstance->getJacobianSparsityPattern();
539 for(idx = 0; idx < m; idx++)
541 for(k = *(sparseJacobian->
starts + idx); k < *(sparseJacobian->
starts + idx + 1); k++)
544 jCol[i] = *(sparseJacobian->
indexes + k);
553 sparseJacobian =
osinstance->calculateAllConstraintFunctionGradients(
const_cast<double*
>(x), NULL, NULL, new_x, 1);
561 for(
int i = 0; i < nele_jac; i++)
563 values[ i] = sparseJacobian->
values[i];
572 Number obj_factor, Index m,
const Number* lambda,
573 bool new_lambda, Index nele_hess, Index* iRow,
574 Index* jCol, Number* values)
585 sparseHessian =
osinstance->getLagrangianHessianSparsityPattern( );
592 for(i = 0; i < nele_hess; i++)
601 double* objMultipliers =
new double[1];
602 objMultipliers[0] = obj_factor;
605 sparseHessian =
osinstance->calculateLagrangianHessian(
const_cast<double*
>(x), objMultipliers,
const_cast<double*
>(lambda) , new_x, 2);
606 delete[] objMultipliers;
611 delete[] objMultipliers;
614 for(i = 0; i < nele_hess; i++)
616 values[ i] = *(sparseHessian->
hessValues + i);
624 bool& use_x_scaling, Index n,
626 bool& use_g_scaling, Index m,
645 Index n,
const Number* x, Number obj_value)
647 std::ostringstream outStr;
653 outStr <<
"FINALIZE OBJ SOLUTION VALUE = " << obj_value << std::endl;
673 throw ErrorClass(
"Solver cannot handle multiple objectives --- please delete all but one");
685 osresult->setGeneralStatusType(
"error");
695 std::ostringstream outStr;
701 bonminSetup.roptions()->AddStringOption2(
"print_solution",
"Do we print the solution or not?",
703 "no",
"No, we don't.",
704 "yes",
"Yes, we do.",
705 "A longer comment can be put here");
708 bonminSetup.options()->SetNumericValue(
"bonmin.time_limit", 5000);
726 bonminSetup.readOptionsString(
"bonmin.algorithm B-BB\n");
729 bonminSetup.options()->SetIntegerValue(
"bonmin.bb_log_level", 0 );
730 bonminSetup.options()->SetIntegerValue(
"bonmin.nlp_log_level", 0 );
734 bonminSetup.options()->GetEnumValue(
"print_solution", printSolution,
"");
735 if(printSolution == 1)
737 tminlp->printSolutionAtEndOfAlgorithm();
750 std::vector<SolverOption*> optionsVector;
751 optionsVector =
osoption->getSolverOptions(
"bonmin",
true);
752 int num_bonmin_options = optionsVector.size();
753 for(i = 0; i < num_bonmin_options; i++)
755 if(optionsVector[ i]->type ==
"numeric" )
759 outStr <<
"FOUND A NUMERIC OPTION "
760 <<
os_strtod( optionsVector[ i]->value.c_str(), &pEnd )
763 if(optionsVector[ i]->category ==
"ipopt")
765 bonminSetup.options()->SetNumericValue(optionsVector[ i]->name,
os_strtod( optionsVector[ i]->value.c_str(), &pEnd ) );
769 if(optionsVector[ i]->category ==
"cbc" )
771 bonminSetup.options()->SetNumericValue(
"milp_solver."+optionsVector[ i]->name,
os_strtod( optionsVector[ i]->value.c_str(), &pEnd ) );
775 bonminSetup.options()->SetNumericValue(
"bonmin."+optionsVector[ i]->name,
os_strtod( optionsVector[ i]->value.c_str(), &pEnd ) );
779 else if(optionsVector[ i]->type ==
"integer" )
783 outStr <<
"FOUND AN INTEGER OPTION " << optionsVector[ i]->name << std::endl;
785 if(optionsVector[ i]->category ==
"ipopt")
787 bonminSetup.options()->SetIntegerValue(optionsVector[ i]->name, atoi( optionsVector[ i]->value.c_str() ) );
791 if(optionsVector[ i]->category ==
"cbc" )
794 "SETTING INTEGER CBC OPTION\n");
795 bonminSetup.options()->SetIntegerValue(
"milp_solver."+optionsVector[ i]->name, atoi( optionsVector[ i]->value.c_str() ));
799 bonminSetup.options()->SetIntegerValue(
"bonmin."+optionsVector[ i]->name, atoi( optionsVector[ i]->value.c_str() ) );
803 else if(optionsVector[ i]->type ==
"string" )
807 outStr <<
"FOUND A STRING OPTION " << optionsVector[ i]->name << std::endl;
809 if(optionsVector[ i]->category ==
"ipopt")
811 bonminSetup.options()->SetStringValue(optionsVector[ i]->name, optionsVector[ i]->value );
815 if(optionsVector[ i]->category ==
"cbc" )
817 bonminSetup.options()->SetStringValue(
"milp_solver."+optionsVector[ i]->name, optionsVector[ i]->value);
821 bonminSetup.options()->SetStringValue(
"bonmin."+optionsVector[ i]->name, optionsVector[ i]->value);
833 osresult->setGeneralStatusType(
"error");
852 catch(TNLPSolver::UnsolvedError *E)
855 osresult->setGeneralMessage(
"Ipopt has failed to solve a problem");
856 osresult->setGeneralStatusType(
"error");
860 catch(OsiTMINLPInterface::SimpleError &E)
862 ostringstream outStr;
863 outStr << E.className() <<
"::"<< E.methodName() << std::endl << E.message() << std::endl;
865 osresult->setGeneralMessage(outStr.str());
866 osresult->setGeneralStatusType(
"error");
872 ostringstream outStr;
873 outStr << E.className() <<
"::"<< E.methodName() << std::endl << E.message() << std::endl;
875 osresult->setGeneralMessage(outStr.str());
876 osresult->setGeneralStatusType(
"error");
881 if((
bb.model().isContinuousUnbounded() ==
true) && (
osinstance->getNumberOfIntegerVariables() +
osinstance->getNumberOfBinaryVariables() <= 0) )
883 std::string solutionDescription =
"";
884 std::string message =
"Success";
887 if(
osresult->setServiceName(
"Bonmin solver service") !=
true)
888 throw ErrorClass(
"OSResult error: setServiceName");
890 throw ErrorClass(
"OSResult error: setInstanceName");
892 throw ErrorClass(
"OSResult error: setVariableNumber");
893 if(
osresult->setObjectiveNumber( 1) !=
true)
894 throw ErrorClass(
"OSResult error: setObjectiveNumber");
896 throw ErrorClass(
"OSResult error: setConstraintNumber");
897 if(
osresult->setSolutionNumber( 1) !=
true)
898 throw ErrorClass(
"OSResult error: setSolutionNumer");
899 if(
osresult->setGeneralMessage( message) !=
true)
900 throw ErrorClass(
"OSResult error: setGeneralMessage");
901 solutionDescription =
"The problem is unbounded";
902 osresult->setSolutionStatus(solIdx,
"error", solutionDescription);
903 osresult->setGeneralStatusType(
"normal");
904 if(
osinstance->getVariableNumber() == 0)
osresult->setSolutionMessage(solIdx,
"Warning: this problem has zero decision variables!");
910 if((
bb.model().isProvenInfeasible() ==
true) )
912 std::string solutionDescription =
"";
913 std::string message =
"Success";
917 if(
osresult->setServiceName(
"Bonmin solver service") !=
true)
918 throw ErrorClass(
"OSResult error: setServiceName");
920 throw ErrorClass(
"OSResult error: setInstanceName");
922 throw ErrorClass(
"OSResult error: setVariableNumer");
923 if(
osresult->setObjectiveNumber( 1) !=
true)
924 throw ErrorClass(
"OSResult error: setObjectiveNumber");
926 throw ErrorClass(
"OSResult error: setConstraintNumber");
927 if(
osresult->setSolutionNumber( 1) !=
true)
928 throw ErrorClass(
"OSResult error: setSolutionNumber");
929 if(
osresult->setGeneralMessage( message) !=
true)
930 throw ErrorClass(
"OSResult error: setGeneralMessage");
931 solutionDescription =
"The problem is infeasible";
932 osresult->setSolutionStatus(solIdx,
"error", solutionDescription);
934 osresult->setGeneralStatusType(
"normal");
935 if(
osinstance->getVariableNumber() == 0)
osresult->setSolutionMessage(solIdx,
"Warning: this problem has zero decision variables!");
946 osresult->setGeneralStatusType(
"error");
959 std::string solutionDescription =
"";
960 std::string message =
"Bonmin solver finishes to the end.";
961 if(
osinstance->getVariableNumber() == 0)
osresult->setSolutionMessage(0,
"Warning: this problem has zero decision variables!");
970 throw ErrorClass(
"OSResult error: setServiceName");
971 if(
osresult->setSolverInvoked(
"COIN-OR Bonmin") !=
true)
972 throw ErrorClass(
"OSResult error: setSolverInvoked");
974 throw ErrorClass(
"OSResult error: setInstanceName");
980 throw ErrorClass(
"OSResult error: setVariableNumer");
981 if(
osresult->setObjectiveNumber( 1) !=
true)
982 throw ErrorClass(
"OSResult error: setObjectiveNumber");
984 throw ErrorClass(
"OSResult error: setConstraintNumber");
985 if(
osresult->setSolutionNumber( 1) !=
true)
986 throw ErrorClass(
"OSResult error: setSolutionNumer");
987 if(
osresult->setGeneralMessage( message) !=
true)
988 throw ErrorClass(
"OSResult error: setGeneralMessage");
992 case TMINLP::SUCCESS:
993 solutionDescription =
"SUCCESS[BONMIN]: Algorithm terminated normally at a locally optimal point, satisfying the convergence tolerances.";
994 osresult->setSolutionStatus(solIdx,
"locallyOptimal", solutionDescription);
998 *(z + 0) =
osinstance->calculateAllObjectiveFunctionValues(
const_cast<double*
>(
bb.bestSolution()),
true)[ 0];
999 osresult->setObjectiveValuesDense(solIdx, z);
1003 for(i=0; i <
osinstance->getVariableNumber(); i++)
1005 *(x + i) =
bb.bestSolution()[i];
1007 osresult->setPrimalVariableValuesDense(solIdx, x);
1011 case TMINLP::LIMIT_EXCEEDED:
1012 solutionDescription =
"LIMIT_EXCEEDED[BONMIN]: A resource limit was exceeded, we provide the current solution.";
1013 osresult->setSolutionStatus(solIdx,
"other", solutionDescription);
1019 *(z + 0) =
osinstance->calculateAllObjectiveFunctionValues(
const_cast<double*
>(
bb.bestSolution()),
true)[ 0];
1020 osresult->setObjectiveValuesDense(solIdx, z);
1024 for(i=0; i <
osinstance->getVariableNumber(); i++)
1026 *(x + i) =
bb.bestSolution()[i];
1028 osresult->setPrimalVariableValuesDense(solIdx, x);
1032 case TMINLP::MINLP_ERROR:
1033 solutionDescription =
"MINLP_ERROR [BONMIN]: Algorithm stopped with unspecified error.";
1034 osresult->setSolutionStatus(solIdx,
"error", solutionDescription);
1038 case TMINLP::CONTINUOUS_UNBOUNDED:
1039 solutionDescription =
"CONTINUOUS_UNBOUNDED [BONMIN]: The continuous relaxation is unbounded, the MINLP may or may not be unbounded.";
1040 osresult->setSolutionStatus(solIdx,
"error", solutionDescription);
1045 case TMINLP::INFEASIBLE:
1046 solutionDescription =
"INFEASIBLE [BONMIN]: Problem may be infeasible.";
1047 osresult->setSolutionStatus(solIdx,
"infeasible", solutionDescription);
1052 solutionDescription =
"OTHER[BONMIN]: other unknown solution status from Bonmin solver";
1053 osresult->setSolutionStatus(solIdx,
"other", solutionDescription);
1055 osresult->setGeneralStatusType(
"normal");
1057 if(
osinstance->getVariableNumber() > 0 )
delete[] x;
1066 if(
osinstance->getVariableNumber() > 0)
delete[] x;
1071 osresult->setGeneralStatusType(
"error");
1080 std::ostringstream outStr;
1085 outStr <<
"This is problem: " <<
osinstance->getInstanceName() << endl;
1086 outStr <<
"The problem source is: " <<
osinstance->getInstanceSource() << endl;
1087 outStr <<
"The problem description is: " <<
osinstance->getInstanceDescription() << endl;
1088 outStr <<
"number of variables = " <<
osinstance->getVariableNumber() << endl;
1089 outStr <<
"number of Rows = " <<
osinstance->getConstraintNumber() << endl;
1094 for(i = 0; i <
osinstance->getVariableNumber(); i++)
1096 if(
osinstance->getVariableNames() != NULL) outStr <<
"variable Names " <<
osinstance->getVariableNames()[ i] << endl;
1097 if(
osinstance->getVariableTypes() != NULL) outStr <<
"variable Types " <<
osinstance->getVariableTypes()[ i] << endl;
1098 if(
osinstance->getVariableLowerBounds() != NULL) outStr <<
"variable Lower Bounds " <<
osinstance->getVariableLowerBounds()[ i] << endl;
1099 if(
osinstance->getVariableUpperBounds() != NULL) outStr <<
"variable Upper Bounds " <<
osinstance->getVariableUpperBounds()[i] << endl;
1104 if(
osinstance->getVariableNumber() > 0 ||
osinstance->instanceData->objectives->obj != NULL ||
osinstance->instanceData->objectives->numberOfObjectives > 0)
1106 if(
osinstance->getObjectiveMaxOrMins()[0] ==
"min") outStr <<
"problem is a minimization" << endl;
1107 else outStr <<
"problem is a maximization" << endl;
1108 for(i = 0; i <
osinstance->getVariableNumber(); i++)
1110 outStr <<
"OBJ COEFFICIENT = " <<
osinstance->getDenseObjectiveCoefficients()[0][i] << endl;
1116 for(i = 0; i <
osinstance->getConstraintNumber(); i++)
1118 if(
osinstance->getConstraintNames() != NULL) outStr <<
"row name = " <<
osinstance->getConstraintNames()[i] << endl;
1119 if(
osinstance->getConstraintLowerBounds() != NULL) outStr <<
"row lower bound = " <<
osinstance->getConstraintLowerBounds()[i] << endl;
1120 if(
osinstance->getConstraintUpperBounds() != NULL) outStr <<
"row upper bound = " <<
osinstance->getConstraintUpperBounds()[i] << endl;
1126 outStr <<
"number of nonzeros = " <<
osinstance->getLinearConstraintCoefficientNumber() << endl;
1127 for(i = 0; i <=
osinstance->getVariableNumber(); i++)
1129 outStr <<
"Start Value = " <<
osinstance->getLinearConstraintCoefficientsInColumnMajor()->starts[ i] << endl;
1132 for(i = 0; i <
osinstance->getLinearConstraintCoefficientNumber(); i++)
1134 outStr <<
"Index Value = " <<
osinstance->getLinearConstraintCoefficientsInColumnMajor()->indexes[i] << endl;
1135 outStr <<
"Nonzero Value = " <<
osinstance->getLinearConstraintCoefficientsInColumnMajor()->values[i] << endl;
1139 outStr <<
"number of qterms = " <<
osinstance->getNumberOfQuadraticTerms() << endl;
1140 for(
int i = 0; i <
osinstance->getNumberOfQuadraticTerms(); i++)
1142 outStr <<
"Row Index = " <<
osinstance->getQuadraticTerms()->rowIndexes[i] << endl;
1143 outStr <<
"Var Index 1 = " <<
osinstance->getQuadraticTerms()->varOneIndexes[ i] << endl;
1144 outStr <<
"Var Index 2 = " <<
osinstance->getQuadraticTerms()->varTwoIndexes[ i] << endl;
1145 outStr <<
"Coefficient = " <<
osinstance->getQuadraticTerms()->coefficients[ i] << endl;
const OSSmartPtr< OSOutput > osoutput
std::string OSgetVersionInfo()
U * GetRawPtr(const OSSmartPtr< U > &smart_ptr)
double os_strtod(const char *s00, char **se)
bool printSol_
Method called by Ipopt at the end of optimization.
virtual ~BonminProblem()
the BonminProblem class destructor
virtual bool get_constraints_linearity(Ipopt::Index m, Ipopt::TNLP::LinearityType *const_types)
Pass the type of the constraints (LINEAR, NON_LINEAR) to the optimizer.
virtual bool eval_g(Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Index m, Ipopt::Number *g)
Method to return the constraint residuals.
virtual void finalize_solution(Bonmin::TMINLP::SolverReturn status_, Ipopt::Index n, const Ipopt::Number *x, Ipopt::Number obj_value)
Method called by Ipopt at the end of optimization.
virtual bool get_nlp_info(Ipopt::Index &n, Ipopt::Index &m, Ipopt::Index &nnz_jac_g, Ipopt::Index &nnz_h_lag, Ipopt::TNLP::IndexStyleEnum &index_style)
Method to pass the main dimensions of the problem to Ipopt.
virtual bool eval_grad_f(Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Number *grad_f)
Method to return the gradient of the objective.
virtual bool get_starting_point(Ipopt::Index n, bool init_x, Ipopt::Number *x, bool init_z, Ipopt::Number *z_L, Ipopt::Number *z_U, Ipopt::Index m, bool init_lambda, Ipopt::Number *lambda)
Method to return the starting point for the algorithm.
virtual bool get_variables_types(Ipopt::Index n, VariableType *var_types)
Pass the type of the variables (INTEGER, BINARY, CONTINUOUS) to the optimizer.
virtual bool eval_f(Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Number &obj_value)
Method to return the objective value.
virtual bool get_variables_linearity(Ipopt::Index n, Ipopt::TNLP::LinearityType *var_types)
Pass info about linear and nonlinear variables.
virtual bool get_bounds_info(Ipopt::Index n, Ipopt::Number *x_l, Ipopt::Number *x_u, Ipopt::Index m, Ipopt::Number *g_l, Ipopt::Number *g_u)
Bonmin specific methods for defining the nlp problem.
std::string bonminErrorMsg
Bonmin::TMINLP::SolverReturn status
BonminProblem(OSInstance *osinstance_, OSOption *osoption_)
the BonminProblemclass constructor
virtual bool eval_h(Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Number obj_factor, Ipopt::Index m, const Ipopt::Number *lambda, bool new_lambda, Ipopt::Index nele_hess, Ipopt::Index *iRow, Ipopt::Index *jCol, Ipopt::Number *values)
Method to return: 1) The structure of the hessian of the lagrangian (if "values" is NULL) 2) The valu...
virtual bool get_scaling_parameters(Ipopt::Number &obj_scaling, bool &use_x_scaling, Ipopt::Index n, Ipopt::Number *x_scaling, bool &use_g_scaling, Ipopt::Index m, Ipopt::Number *g_scaling)
Method to pass the main dimensions of the problem to Ipopt.
virtual bool eval_jac_g(Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Index m, Ipopt::Index nele_jac, Ipopt::Index *iRow, Ipopt::Index *jCol, Ipopt::Number *values)
Method to return: 1) The structure of the jacobian (if "values" is NULL) 2) The values of the jacobia...
Bonmin::TMINLP::SolverReturn status
std::string bonminErrorMsg
Ipopt::SmartPtr< BonminProblem > tminlp
virtual void setSolverOptions()
The implementation of the virtual functions.
virtual void buildSolverInstance()
buildSolverInstance is a virtual function – the actual solvers will implement their own buildSolverIn...
void dataEchoCheck()
use this for debugging, print out the instance that the solver thinks it has and compare this with th...
Bonmin::BonminSetup bonminSetup
OSiLReader * m_osilreader
m_osilreader is an OSiLReader object used to create an osinstance from an osil string if needed
void writeResult()
use this to write the solution information to an OSResult object
OSoLReader * m_osolreader
m_osolreader is an OSoLReader object used to create an osoption from an osol string if needed
~BonminSolver()
the IpoptSolver class destructor
virtual void solve()
solve results in an instance being read into the Bonmin data structrues and optimized
BonminSolver()
the BonminSolver class constructor
std::string osol
osol holds the options for the solver
bool bSetSolverOptions
bSetSolverOptions is set to true if setSolverOptions has been called, false otherwise
std::string osrl
osrl holds the solution or result of the model
OSInstance * osinstance
osinstance holds the problem instance in-memory as an OSInstance object
bool bCallbuildSolverInstance
bCallbuildSolverInstance is set to true if buildSolverService has been called
std::string osil
osil holds the problem instance as a std::string
OSOption * osoption
osoption holds the solver options in-memory as an OSOption object
OSResult * osresult
osresult holds the solution or result of the model in-memory as an OSResult object
used for throwing exceptions.
std::string errormsg
errormsg is the error that is causing the exception to be thrown
double value
initial value
The in-memory representation of an OSiL instance..
Used to read an OSiL string.
Used to read an OSoL string.
Take an OSResult object and write a string that validates against OSrL.
The in-memory representation of a SparseHessianMatrix..
int * hessRowIdx
hessRowIdx is an integer array of row indices in the range 0, ..., n - 1.
int hessDimension
hessDimension is the number of nonzeros in each array.
double * hessValues
hessValues is a double array of the Hessian values.
int * hessColIdx
hessColIdx is an integer array of column indices in the range 0, ..., n - 1.
a sparse Jacobian matrix data structure
int * indexes
indexes holds an integer array of variable indices.
int valueSize
valueSize is the dimension of the values array
int * starts
starts holds an integer array of start elements, each start element points to the start of partials f...
double * values
values holds a double array of nonzero partial derivatives
@ ENUM_OUTPUT_LEVEL_debug
@ ENUM_OUTPUT_LEVEL_error
@ ENUM_OUTPUT_LEVEL_warning
@ ENUM_OUTPUT_AREA_OSSolverInterfaces