23 #include "OSParameters.h"
25 #include "CoinFinite.hpp"
26 #include "CoinTime.hpp"
27 #include "BonOsiTMINLPInterface.hpp"
28 #include "BonTMINLP.hpp"
30 using namespace Bonmin;
31 using namespace Ipopt;
34 using std::ostringstream;
50 if(m_osilreader != NULL)
delete m_osilreader;
52 if(m_osolreader != NULL)
delete m_osolreader;
55 if(osrlwriter != NULL )
delete osrlwriter;
72 varType = osinstance->getVariableTypes();
73 n = osinstance->getVariableNumber();
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;
109 osinstance->initForAlgDiff( );
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;
183 n = osinstance->getVariableNumber();
185 m = osinstance->getConstraintNumber();
189 outStr <<
"Bonmin number variables !!!!!!!!!!!!!!!!!!!!!!!!!!!" << n << endl;
190 outStr <<
"Bonmin number constraints !!!!!!!!!!!!!!!!!!!!!!!!!!!" << m << endl;
195 osinstance->initForAlgDiff( );
203 osinstance->bUseExpTreeForFunEval =
true;
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");
327 outStr <<
"number of variables initialed: " << m1 << endl;
331 n1 = osinstance->getVariableNumber();
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;
366 if (osinstance->instanceData->variables->var[i]->ub ==
OSDBL_MAX)
368 if (osinstance->instanceData->variables->var[i]->lb > initval)
369 throw ErrorClass (
"Initial value outside of bounds");
371 else if (osinstance->instanceData->variables->var[i]->lb == -
OSDBL_MAX)
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++)
402 if (osinstance->instanceData->variables->var[k]->ub ==
OSDBL_MAX)
403 if (osinstance->instanceData->variables->var[k]->lb <= default_initval)
404 x[k] = default_initval;
406 x[k] = osinstance->instanceData->variables->var[k]->lb;
407 else if (osinstance->instanceData->variables->var[k]->lb == -
OSDBL_MAX)
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);
444 if(osinstance->getObjectiveNumber() > 0)
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;
469 if(osinstance->getObjectiveNumber() > 0)
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;
664 if(osil.length() == 0 && osinstance == NULL)
throw ErrorClass(
"there is no instance");
665 if(osinstance == NULL)
668 osinstance = m_osilreader->readOSiL( osil);
672 if (osinstance->getObjectiveNumber() > 1)
673 throw ErrorClass(
"Solver cannot handle multiple objectives --- please delete all but one");
677 this->bCallbuildSolverInstance =
true;
686 osrl = osrlwriter->writeOSrL(
osresult);
695 std::ostringstream outStr;
698 this->bSetSolverOptions =
true;
699 bonminSetup.initializeOptionsAndJournalist();
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();
740 if(
osoption == NULL && osol.length() > 0)
743 osoption = m_osolreader->readOSoL( osol);
750 std::vector<SolverOption*> optionsVector;
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);
834 osrl = osrlwriter->writeOSrL(
osresult);
842 if( this->bCallbuildSolverInstance ==
false) buildSolverInstance();
843 if( this->bSetSolverOptions ==
false) setSolverOptions();
848 bonminSetup.initialize(
GetRawPtr(tminlp) );
852 catch(TNLPSolver::UnsolvedError *E)
857 osrl = osrlwriter->writeOSrL(
osresult);
860 catch(OsiTMINLPInterface::SimpleError &E)
862 ostringstream outStr;
863 outStr << E.className() <<
"::"<< E.methodName() << std::endl << E.message() << std::endl;
867 osrl = osrlwriter->writeOSrL(
osresult);
872 ostringstream outStr;
873 outStr << E.className() <<
"::"<< E.methodName() << std::endl << E.message() << std::endl;
877 osrl = osrlwriter->writeOSrL(
osresult);
881 if(( bb.model().isContinuousUnbounded() ==
true) && (osinstance->getNumberOfIntegerVariables() + osinstance->getNumberOfBinaryVariables() <= 0) )
883 std::string solutionDescription =
"";
884 std::string message =
"Success";
888 throw ErrorClass(
"OSResult error: setServiceName");
890 throw ErrorClass(
"OSResult error: setInstanceName");
892 throw ErrorClass(
"OSResult error: setVariableNumber");
894 throw ErrorClass(
"OSResult error: setObjectiveNumber");
896 throw ErrorClass(
"OSResult error: setConstraintNumber");
898 throw ErrorClass(
"OSResult error: setSolutionNumer");
900 throw ErrorClass(
"OSResult error: setGeneralMessage");
901 solutionDescription =
"The problem is unbounded";
904 if( osinstance->getVariableNumber() == 0)
osresult->
setSolutionMessage(solIdx,
"Warning: this problem has zero decision variables!");
905 osrl = osrlwriter->writeOSrL(
osresult);
910 if(( bb.model().isProvenInfeasible() ==
true) )
912 std::string solutionDescription =
"";
913 std::string message =
"Success";
918 throw ErrorClass(
"OSResult error: setServiceName");
920 throw ErrorClass(
"OSResult error: setInstanceName");
922 throw ErrorClass(
"OSResult error: setVariableNumer");
924 throw ErrorClass(
"OSResult error: setObjectiveNumber");
926 throw ErrorClass(
"OSResult error: setConstraintNumber");
928 throw ErrorClass(
"OSResult error: setSolutionNumber");
930 throw ErrorClass(
"OSResult error: setGeneralMessage");
931 solutionDescription =
"The problem is infeasible";
935 if( osinstance->getVariableNumber() == 0)
osresult->
setSolutionMessage(solIdx,
"Warning: this problem has zero decision variables!");
936 osrl = osrlwriter->writeOSrL(
osresult);
939 status = tminlp->status;
947 osrl = osrlwriter->writeOSrL(
osresult);
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!");
966 if(osinstance->getVariableNumber() > 0) x =
new double[osinstance->getVariableNumber() ];
970 throw ErrorClass(
"OSResult error: setServiceName");
972 throw ErrorClass(
"OSResult error: setSolverInvoked");
974 throw ErrorClass(
"OSResult error: setInstanceName");
980 throw ErrorClass(
"OSResult error: setVariableNumer");
982 throw ErrorClass(
"OSResult error: setObjectiveNumber");
984 throw ErrorClass(
"OSResult error: setConstraintNumber");
986 throw ErrorClass(
"OSResult error: setSolutionNumer");
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.";
996 if(osinstance->getObjectiveNumber() > 0)
998 *(z + 0) = osinstance->calculateAllObjectiveFunctionValues(
const_cast<double*
>(bb.bestSolution()),
true)[ 0];
1001 if( osinstance->getVariableNumber() > 0)
1003 for(i=0; i < osinstance->getVariableNumber(); i++)
1005 *(x + i) = bb.bestSolution()[i];
1011 case TMINLP::LIMIT_EXCEEDED:
1012 solutionDescription =
"LIMIT_EXCEEDED[BONMIN]: A resource limit was exceeded, we provide the current solution.";
1017 if(osinstance->getObjectiveNumber() > 0)
1019 *(z + 0) = osinstance->calculateAllObjectiveFunctionValues(
const_cast<double*
>(bb.bestSolution()),
true)[ 0];
1022 if( osinstance->getVariableNumber() > 0)
1024 for(i=0; i < osinstance->getVariableNumber(); i++)
1026 *(x + i) = bb.bestSolution()[i];
1032 case TMINLP::MINLP_ERROR:
1033 solutionDescription =
"MINLP_ERROR [BONMIN]: Algorithm stopped with unspecified error.";
1038 case TMINLP::CONTINUOUS_UNBOUNDED:
1039 solutionDescription =
"CONTINUOUS_UNBOUNDED [BONMIN]: The continuous relaxation is unbounded, the MINLP may or may not be unbounded.";
1045 case TMINLP::INFEASIBLE:
1046 solutionDescription =
"INFEASIBLE [BONMIN]: Problem may be infeasible.";
1052 solutionDescription =
"OTHER[BONMIN]: other unknown solution status from Bonmin solver";
1056 osrl = osrlwriter->writeOSrL(
osresult);
1057 if(osinstance->getVariableNumber() > 0 )
delete[] x;
1066 if(osinstance->getVariableNumber() > 0)
delete[] x;
1072 osrl = osrlwriter->writeOSrL(
osresult);
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;
1092 if(osinstance->getVariableNumber() > 0)
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;
1114 if(osinstance->getConstraintNumber() > 0)
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;
1153 osinstance = osinstance_;
const OSSmartPtr< OSOutput > osoutput
std::string OSgetVersionInfo()
U * GetRawPtr(const OSSmartPtr< U > &smart_ptr)
double os_strtod(const char *s00, char **se)
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.
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...
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...
void writeResult()
use this to write the solution information to an OSResult object
~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
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..
InitVarValue ** getInitVarValuesSparse()
Get the initial values associated with the variables in sparse form.
int getNumberOfInitVarValues()
Get the number of initial variable values.
std::vector< SolverOption * > getSolverOptions(std::string solver_name)
Get the options associated with a given solver.
int getNumberOfSolverOptions()
Get the number of solver options.
bool setGeneralMessage(std::string message)
Set the general message.
bool setSolutionNumber(int number)
set the number of solutions.
bool setInstanceName(std::string instanceName)
Set instance name.
bool setObjectiveValuesDense(int solIdx, double *objectiveValues)
Set the [i]th optimization solution's objective values, where i equals the given solution index.
bool setGeneralStatusType(std::string type)
Set the general status type, which can be: success, error, warning.
bool setObjectiveNumber(int objectiveNumber)
Set the objective number.
bool setPrimalVariableValuesDense(int solIdx, double *x)
Set the [i]th optimization solution's primal variable values, where i equals the given solution index...
bool setServiceName(std::string serviceName)
Set service name.
bool setSolverInvoked(std::string solverInvoked)
Set solver invoked.
bool setVariableNumber(int variableNumber)
Set the variable number.
bool setSolutionMessage(int solIdx, std::string msg)
Set the [i]th optimization solution's message, where i equals the given solution index.
bool setSolutionStatus(int solIdx, std::string type, std::string description)
Set the [i]th optimization solution status, where i equals the given solution index.
bool setConstraintNumber(int constraintNumber)
Set the constraint number.
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