20 #include "OSParameters.h"
22 #include "CoinFinite.hpp"
28 using std::ostringstream;
29 using namespace Ipopt;
36 "inside IpoptSolver constructor\n");
42 ipoptErrorMsg =
new std::string(
"");
49 "inside IpoptSolver destructor\n");
51 if(m_osilreader != NULL)
delete m_osilreader;
53 if(m_osolreader != NULL)
delete m_osolreader;
64 "Leaving IpoptSolver destructor\n");
70 Index& nnz_h_lag, IndexStyleEnum& index_style)
72 std::ostringstream outStr;
76 if( (osinstance->getNumberOfIntegerVariables() + osinstance->getNumberOfBinaryVariables()) > 0 )
77 throw ErrorClass(
"Ipopt does not solve integer programs -- please try Bonmin or Couenne");
79 n = osinstance->getVariableNumber();
81 m = osinstance->getConstraintNumber();
85 outStr <<
"number variables !!!!!!!!!!!!!!!!!!!!!!!!!!!" << n << endl;
86 outStr <<
"number constraints !!!!!!!!!!!!!!!!!!!!!!!!!!!" << m << endl;
91 osinstance->initForAlgDiff( );
97 outStr <<
"error in OSIpoptSolver, AD initialization failed:\n" << eclass.
errormsg << endl;
103 osinstance->bUseExpTreeForFunEval =
true;
107 sparseJacobian = osinstance->getJacobianSparsityPattern();
113 outStr <<
"error in OSIpoptSolver, Jacobian sparsity:\n" << eclass.
errormsg << endl;
118 if (sparseJacobian != NULL)
130 outStr <<
"nnz_jac_g !!!!!!!!!!!!!!!!!!!!!!!!!!!" << nnz_jac_g << endl;
135 if( (osinstance->getNumberOfNonlinearExpressions() == 0) &&
136 (osinstance->getNumberOfQuadraticTerms() == 0) )
146 if(sparseHessian != NULL)
158 outStr <<
"print nnz_h_lag (OSIpoptSolver.cpp)" << endl;
159 outStr <<
"nnz_h_lag !!!!!!!!!!!!!!!!!!!!!!!!!!!" << nnz_h_lag << endl;
160 outStr <<
"set index_style (OSIpoptSolver.cpp)" << endl;
164 index_style = TNLP::C_STYLE;
168 outStr <<
"return from get_nlp_info (OSIpoptSolver.cpp)" << nnz_h_lag << endl;
186 Index m, Number* g_l, Number* g_u)
189 double * mdVarLB = osinstance->getVariableLowerBounds();
191 double * mdVarUB = osinstance->getVariableUpperBounds();
193 for(i = 0; i < n; i++)
195 x_l[ i] = mdVarLB[ i];
196 x_u[ i] = mdVarUB[ i];
204 double * mdConLB = osinstance->getConstraintLowerBounds();
206 double * mdConUB = osinstance->getConstraintUpperBounds();
208 for(
int i = 0; i < m; i++)
210 g_l[ i] = mdConLB[ i];
211 g_u[ i] = mdConUB[ i];
219 bool init_z, Number* z_L, Number* z_U, Index m,
bool init_lambda,
222 std::ostringstream outStr;
227 assert(init_x ==
true);
228 assert(init_z ==
false);
229 assert(init_lambda ==
false);
248 outStr <<
"number of variables initialed: " << m1 << endl;
252 n1 = osinstance->getVariableNumber();
254 initialed =
new bool[n1];
258 outStr <<
"number of variables in total: " << n1 << endl;
262 for(k = 0; k < n1; k++)
263 initialed[k] =
false;
269 "get initial values\n");
279 for(k = 0; k < m1; k++)
281 i = initVarVector[k]->
idx;
282 if (initVarVector[k]->idx > n1)
283 throw ErrorClass (
"Illegal index value in variable initialization");
285 initval = initVarVector[k]->
value;
286 if (osinstance->instanceData->variables->var[k]->ub ==
OSDBL_MAX)
288 if (osinstance->instanceData->variables->var[k]->lb > initval)
289 throw ErrorClass (
"Initial value outside of bounds");
291 else if (osinstance->instanceData->variables->var[k]->lb == -
OSDBL_MAX)
293 if (osinstance->instanceData->variables->var[k]->ub < initval)
294 throw ErrorClass (
"Initial value outside of bounds");
298 if ((osinstance->instanceData->variables->var[k]->lb > initval) ||
299 (osinstance->instanceData->variables->var[k]->ub < initval))
300 throw ErrorClass (
"Initial value outside of bounds");
303 x[initVarVector[k]->
idx] = initval;
304 initialed[initVarVector[k]->idx] =
true;
310 "Error in IpoptProblem::get_starting_point (see OSIpoptSolver.cpp)\n"+eclass.
errormsg+
"\n\n");
314 double default_initval;
315 default_initval = 1.7171;
318 for(k = 0; k < n1; k++)
322 if (osinstance->instanceData->variables->var[k]->ub ==
OSDBL_MAX)
323 if (osinstance->instanceData->variables->var[k]->lb <= default_initval)
324 x[k] = default_initval;
326 x[k] = osinstance->instanceData->variables->var[k]->lb;
327 else if (osinstance->instanceData->variables->var[k]->lb == -
OSDBL_MAX)
328 if (osinstance->instanceData->variables->var[k]->ub >= default_initval)
329 x[k] = default_initval;
331 x[k] = osinstance->instanceData->variables->var[k]->ub;
332 else if ((osinstance->instanceData->variables->var[k]->lb <= default_initval) &&
333 (osinstance->instanceData->variables->var[k]->ub >= default_initval))
334 x[k] = default_initval;
335 else if (osinstance->instanceData->variables->var[k]->lb > default_initval)
336 x[k] = osinstance->instanceData->variables->var[k]->lb;
338 x[k] = osinstance->instanceData->variables->var[k]->ub;
345 for(i = 0; i < n1; i++)
347 outStr <<
"INITIAL VALUE !!!!!!!!!!!!!!!!!!!! " << x[ i] << std::endl;
352 osinstance->calculateAllObjectiveFunctionValues( x,
true);
363 if(osinstance->getObjectiveNumber() > 0)
368 obj_value = osinstance->calculateAllObjectiveFunctionValues(
const_cast<double*
>(x),
false)[ 0];
370 obj_value = osinstance->calculateAllObjectiveFunctionValues(
const_cast<double*
>(x), NULL, NULL,
true, 0 )[ 0];
386 std::ostringstream outStr;
388 double *objGrad = NULL;
389 if(osinstance->getObjectiveNumber() > 0)
394 objGrad = osinstance->calculateObjectiveFunctionGradient(
const_cast<double*
>(x), NULL, NULL, -1, new_x, 1);
401 outStr <<
"error in IpoptProblem::eval_grad_f (see OSIpoptSolver.cpp)\n" << eclass.
errormsg << endl;
407 for(i = 0; i < n; i++)
409 grad_f[ i] = objGrad[ i];
418 std::ostringstream outStr;
421 double *conVals = osinstance->calculateAllConstraintFunctionValues(
const_cast<double*
>(x), NULL, NULL, new_x, 0 );
423 for(i = 0; i < m; i++)
425 if( CoinIsnan( (
double)conVals[ i] ) )
return false;
435 outStr <<
"error in IpoptProblem::eval_grad_g (see OSIpoptSolver.cpp)\n" << eclass.
errormsg << endl;
446 Index m, Index nele_jac, Index* iRow, Index *jCol,
449 std::ostringstream outStr;
456 sparseJacobian = osinstance->getJacobianSparsityPattern();
463 outStr <<
"error in IpoptProblem::eval_jac_g (see OSIpoptSolver.cpp)\n" << eclass.
errormsg << endl;
471 for(idx = 0; idx < m; idx++)
473 for(k = *(sparseJacobian->
starts + idx); k < *(sparseJacobian->
starts + idx + 1); k++)
476 jCol[i] = *(sparseJacobian->
indexes + k);
485 sparseJacobian = osinstance->calculateAllConstraintFunctionGradients(
const_cast<double*
>(x), NULL, NULL, new_x, 1);
492 outStr <<
"error in IpoptProblem::eval_jac_g (see OSIpoptSolver.cpp)\n" << eclass.
errormsg << endl;
499 for(
int i = 0; i < nele_jac; i++)
501 values[ i] = sparseJacobian->
values[i];
509 Number obj_factor, Index m,
const Number* lambda,
510 bool new_lambda, Index nele_hess, Index* iRow,
511 Index* jCol, Number* values)
513 std::ostringstream outStr;
524 sparseHessian = osinstance->getLagrangianHessianSparsityPattern( );
532 for(i = 0; i < nele_hess; i++)
541 double* objMultipliers =
new double[1];
542 objMultipliers[0] = obj_factor;
545 sparseHessian = osinstance->calculateLagrangianHessian(
const_cast<double*
>(x), objMultipliers,
const_cast<double*
>(lambda) , new_x, 2);
546 delete[] objMultipliers;
553 outStr <<
"error in OSIpoptSolver, line 444:\n" << eclass.
errormsg << endl;
557 delete[] objMultipliers;
560 for(i = 0; i < nele_hess; i++)
562 values[ i] = *(sparseHessian->
hessValues + i);
570 bool& use_x_scaling, Index n,
572 bool& use_g_scaling, Index m,
575 if( osinstance->instanceData->objectives->obj[ 0]->maxOrMin.compare(
"min") != 0)
579 else obj_scaling = 1;
580 use_x_scaling =
false;
581 use_g_scaling =
false;
586 Index n,
const Number* x,
const Number* z_L,
const Number* z_U,
587 Index m,
const Number* g,
const Number* lambda, Number obj_value,
588 const IpoptData* ip_data, IpoptCalculatedQuantities* ip_cq)
592 if(osinstance->getObjectiveNumber() > 0)
593 obj_value = osinstance->calculateAllObjectiveFunctionValues(
const_cast<double*
>(x),
true)[ 0];
597 ostringstream outStr;
600 outStr << std::endl << std::endl <<
"Solution of the primal variables, x" << std::endl;
601 for (Index i=0; i<n; i++)
603 outStr <<
"x[" << i <<
"] = " << x[i] << std::endl;
606 outStr << std::endl << std::endl <<
"Solution of the bound multipliers, z_L and z_U" << std::endl;
607 for (Index i=0; i<n; i++)
609 outStr <<
"z_L[" << i <<
"] = " << z_L[i] << std::endl;
611 for (Index i=0; i<n; i++)
613 outStr <<
"z_U[" << i <<
"] = " << z_U[i] << std::endl;
619 if(osinstance->getObjectiveNumber() > 0)
621 outStr << std::endl <<
"Objective value f(x*) = " <<
os_dtoa_format(obj_value) << std::endl;
625 int numberOfOtherVariableResults;
627 int numCon = osinstance->getConstraintNumber();
630 double *dualValue = NULL;
631 std::string *rcost = NULL;
633 double* mdObjValues = NULL;
634 if(osinstance->getObjectiveNumber() > 0)
636 mdObjValues =
new double[1];
639 std::string message =
"Ipopt solver finishes to the end.";
640 std::string solutionDescription =
"";
646 throw ErrorClass(
"OSResult error: setSolverInvoked");
648 throw ErrorClass(
"OSResult error: setServiceName");
650 throw ErrorClass(
"OSResult error: setInstanceName");
657 throw ErrorClass(
"OSResult error: setVariableNumer");
659 throw ErrorClass(
"OSResult error: setObjectiveNumber");
661 throw ErrorClass(
"OSResult error: setConstraintNumber");
663 throw ErrorClass(
"OSResult error: setSolutionNumer");
665 throw ErrorClass(
"OSResult error: setGeneralMessage");
670 solutionDescription =
"SUCCESS[IPOPT]: Algorithm terminated normally at a locally optimal point, satisfying the convergence tolerances.";
677 dualValue =
new double[ numCon];
678 for (Index i=0; i < numCon; i++)
680 dualValue[ i] = -lambda[ i];
686 if(osinstance->getObjectiveNumber() > 0)
688 mdObjValues[0] = obj_value ;
693 if(osinstance->getVariableNumber() > 0)
695 numberOfOtherVariableResults = 1;
697 rcost =
new std::string[ osinstance->getVariableNumber()];
698 idx =
new int[ osinstance->getVariableNumber()];
699 for (Index i = 0; i < n; i++)
706 "the variable reduced costs", idx, rcost, osinstance->getVariableNumber(),
"",
725 if(osinstance->getVariableNumber() > 0)
delete[] rcost;
726 if(osinstance->getVariableNumber() > 0)
delete[] idx;
727 if(osinstance->getConstraintNumber() > 0)
delete[] dualValue;
730 case MAXITER_EXCEEDED:
731 solutionDescription =
"MAXITER_EXCEEDED[IPOPT]: Maximum number of iterations exceeded.";
735 if(osinstance->getObjectiveNumber() > 0)
737 mdObjValues[0] = obj_value ;
742 case STOP_AT_TINY_STEP:
743 solutionDescription =
"STOP_AT_TINY_STEP[IPOPT]: Algorithm proceeds with very little progress.";
747 if(osinstance->getObjectiveNumber() > 0)
749 mdObjValues[0] = obj_value ;
754 case STOP_AT_ACCEPTABLE_POINT:
755 solutionDescription =
"STOP_AT_ACCEPTABLE_POINT[IPOPT]: Algorithm stopped at a point that was converged, not to _desired_ tolerances, but to _acceptable_ tolerances";
759 if(osinstance->getObjectiveNumber() > 0)
761 mdObjValues[0] = obj_value ;
766 case LOCAL_INFEASIBILITY:
767 solutionDescription =
"LOCAL_INFEASIBILITY[IPOPT]: Algorithm converged to a point of local infeasibility. Problem may be infeasible.";
769 if( osinstance->getVariableNumber() == 0)
773 case USER_REQUESTED_STOP:
774 solutionDescription =
"USER_REQUESTED_STOP[IPOPT]: The user call-back function intermediate_callback returned false, i.e., the user code requested a premature termination of the optimization.";
776 if( osinstance->getVariableNumber() == 0)
780 case DIVERGING_ITERATES:
781 solutionDescription =
"DIVERGING_ITERATES[IPOPT]: It seems that the iterates diverge.";
783 if( osinstance->getVariableNumber() == 0)
787 case RESTORATION_FAILURE:
788 solutionDescription =
"RESTORATION_FAILURE[IPOPT]: Restoration phase failed, algorithm doesn't know how to proceed.";
790 if( osinstance->getVariableNumber() == 0)
794 case ERROR_IN_STEP_COMPUTATION:
795 solutionDescription =
"ERROR_IN_STEP_COMPUTATION[IPOPT]: An unrecoverable error occurred while IPOPT tried to compute the search direction.";
797 if( osinstance->getVariableNumber() == 0)
801 case INVALID_NUMBER_DETECTED:
802 solutionDescription =
"INVALID_NUMBER_DETECTED[IPOPT]: Algorithm received an invalid number (such as NaN or Inf) from the NLP; see also option check_derivatives_for_naninf.";
804 if( osinstance->getVariableNumber() == 0)
809 solutionDescription =
"INTERNAL_ERROR[IPOPT]: An unknown internal error occurred. Please contact the IPOPT authors through the mailing list.";
811 if( osinstance->getVariableNumber() == 0)
816 solutionDescription =
"OTHER[IPOPT]: other unknown solution status from Ipopt solver";
818 if( osinstance->getVariableNumber() == 0)
825 if(osinstance->getObjectiveNumber() > 0)
827 delete[] mdObjValues;
837 outStr <<
"error trap in OSIpoptSolver:\n" << eclass.
errormsg << endl;
845 if(osinstance->getObjectiveNumber() > 0)
847 delete[] mdObjValues;
858 std::ostringstream outStr;
861 if(osil.length() == 0 && osinstance == NULL)
throw ErrorClass(
"there is no instance");
862 if(osinstance == NULL)
865 osinstance = m_osilreader->readOSiL( osil);
869 if (osinstance->getObjectiveNumber() > 1)
870 throw ErrorClass(
"Solver cannot handle multiple objectives --- please delete all but one");
874 app =
new IpoptApplication();
876 this->bCallbuildSolverInstance =
true;
884 outStr <<
"error in OSIpoptSolver, line 722:\n" << eclass.
errormsg << endl;
889 osrl = osrlwriter->writeOSrL(
osresult);
897 std::ostringstream outStr;
900 if(osinstance->getObjectiveNumber() <= 0)
901 throw ErrorClass(
"Ipopt NEEDS AN OBJECTIVE FUNCTION\n(For pure feasibility problems, use zero function.)");
902 this->bSetSolverOptions =
true;
905 app->Options()->SetIntegerValue(
"print_level", 0);
906 app->Options()->SetIntegerValue(
"max_iter", 20000);
907 app->Options()->SetNumericValue(
"bound_relax_factor", 0,
true,
true);
908 app->Options()->SetStringValue(
"mu_strategy",
"adaptive",
true,
true);
910 app->Options()->SetStringValue(
"check_derivatives_for_naninf",
"yes");
912 if( (osinstance->getNumberOfNonlinearExpressions() <= 0) &&
913 (osinstance->getNumberOfQuadraticTerms() <= 0) )
915 app->Options()->SetStringValue(
"hessian_constant",
"yes",
true,
true);
917 if(osinstance->getObjectiveNumber() > 0)
919 if( osinstance->instanceData->objectives->obj[ 0]->maxOrMin.compare(
"min") != 0)
921 app->Options()->SetStringValue(
"nlp_scaling_method",
"user-scaling");
927 if(
osoption == NULL && osol.length() > 0)
930 osoption = m_osolreader->readOSoL( osol);
938 outStr <<
"number of solver options ";
943 std::vector<SolverOption*> optionsVector;
947 int num_ipopt_options = optionsVector.size();
948 for(i = 0; i < num_ipopt_options; i++)
953 outStr <<
"ipopt solver option ";
954 outStr << optionsVector[ i]->name;
958 if(optionsVector[ i]->type ==
"numeric" )
963 outStr <<
"FOUND A NUMERIC OPTION ";
964 outStr <<
os_strtod( optionsVector[ i]->value.c_str(), &pEnd );
968 app->Options()->SetNumericValue(optionsVector[ i]->name,
os_strtod( optionsVector[ i]->value.c_str(), &pEnd ) );
970 else if(optionsVector[ i]->type ==
"integer" )
975 outStr <<
"FOUND AN INTEGER OPTION ";
976 outStr << atoi( optionsVector[ i]->value.c_str() );
980 app->Options()->SetIntegerValue(optionsVector[ i]->name, atoi( optionsVector[ i]->value.c_str() ) );
982 else if(optionsVector[ i]->type ==
"string" )
987 outStr <<
"FOUND A STRING OPTION ";
988 outStr << optionsVector[ i]->value.c_str();
992 app->Options()->SetStringValue(optionsVector[ i]->name, optionsVector[ i]->value);
1003 osrl = osrlwriter->writeOSrL(
osresult);
1012 std::ostringstream outStr;
1014 if( this->bCallbuildSolverInstance ==
false) buildSolverInstance();
1015 if( this->bSetSolverOptions ==
false) setSolverOptions();
1019 ApplicationReturnStatus status = app->OptimizeTNLP( nlp);
1020 osrl = osrlwriter->writeOSrL(
osresult);
1023 throw ErrorClass(
"Ipopt FAILED TO SOLVE THE PROBLEM: " + *ipoptErrorMsg);
1031 outStr <<
"error in OSIpoptSolver routine solve():\n" << eclass.
errormsg << endl;
1036 osrl = osrlwriter->writeOSrL(
osresult);
1045 ostringstream outStr;
1048 outStr <<
"This is problem: " << osinstance->getInstanceName() << endl;
1049 outStr <<
"The problem source is: " << osinstance->getInstanceSource() << endl;
1050 outStr <<
"The problem description is: " << osinstance->getInstanceDescription() << endl;
1051 outStr <<
"number of variables = " << osinstance->getVariableNumber() << endl;
1052 outStr <<
"number of Rows = " << osinstance->getConstraintNumber() << endl;
1055 if(osinstance->getVariableNumber() > 0)
1057 for(i = 0; i < osinstance->getVariableNumber(); i++)
1059 if(osinstance->getVariableNames() != NULL)
1060 outStr <<
"variable Names " << osinstance->getVariableNames()[i] << endl;
1061 if(osinstance->getVariableTypes() != NULL)
1062 outStr <<
"variable Types " << osinstance->getVariableTypes()[i] << endl;
1063 if(osinstance->getVariableLowerBounds() != NULL)
1064 outStr <<
"variable Lower Bounds " << osinstance->getVariableLowerBounds()[i] << endl;
1065 if(osinstance->getVariableUpperBounds() != NULL)
1066 outStr <<
"variable Upper Bounds " << osinstance->getVariableUpperBounds()[i] << endl;
1071 if(osinstance->getVariableNumber() > 0 || osinstance->instanceData->objectives->obj != NULL || osinstance->instanceData->objectives->numberOfObjectives > 0)
1073 if( osinstance->getObjectiveMaxOrMins()[0] ==
"min")
1074 outStr <<
"problem is a minimization" << endl;
1076 outStr <<
"problem is a maximization" << endl;
1077 for(i = 0; i < osinstance->getVariableNumber(); i++)
1079 outStr <<
"OBJ COEFFICIENT = " << osinstance->getDenseObjectiveCoefficients()[0][i] << endl;
1083 if(osinstance->getConstraintNumber() > 0)
1085 for(i = 0; i < osinstance->getConstraintNumber(); i++)
1087 if(osinstance->getConstraintNames() != NULL)
1088 outStr <<
"row name = " << osinstance->getConstraintNames()[i] << endl;
1089 if(osinstance->getConstraintLowerBounds() != NULL)
1090 outStr <<
"row lower bound = " << osinstance->getConstraintLowerBounds()[i] << endl;
1091 if(osinstance->getConstraintUpperBounds() != NULL)
1092 outStr <<
"row upper bound = " << osinstance->getConstraintUpperBounds()[i] << endl;
1098 outStr <<
"number of nonzeros = " << osinstance->getLinearConstraintCoefficientNumber() << endl;
1099 for(i = 0; i <= osinstance->getVariableNumber(); i++)
1101 outStr <<
"Start Value = "
1102 << osinstance->getLinearConstraintCoefficientsInColumnMajor()->starts[ i] << endl;
1105 for(i = 0; i < osinstance->getLinearConstraintCoefficientNumber(); i++)
1107 outStr <<
"Index Value = "
1108 << osinstance->getLinearConstraintCoefficientsInColumnMajor()->indexes[i] << endl;
1109 outStr <<
"Nonzero Value = "
1110 << osinstance->getLinearConstraintCoefficientsInColumnMajor()->values[i] << endl;
1114 outStr <<
"number of qterms = " << osinstance->getNumberOfQuadraticTerms() << endl;
1115 for(
int i = 0; i < osinstance->getNumberOfQuadraticTerms(); i++)
1117 outStr <<
"Row Index = " << osinstance->getQuadraticTerms()->rowIndexes[i] << endl;
1118 outStr <<
"Var Index 1 = " << osinstance->getQuadraticTerms()->varOneIndexes[i] << endl;
1119 outStr <<
"Var Index 2 = " << osinstance->getQuadraticTerms()->varTwoIndexes[i] << endl;
1120 outStr <<
"Coefficient = " << osinstance->getQuadraticTerms()->coefficients[i] << endl;
1130 osinstance = osinstance_;
1133 ipoptErrorMsg = ipoptErrorMsg_;
const OSSmartPtr< OSOutput > osoutput
std::string os_dtoa_format(double x)
std::string OSgetVersionInfo()
double os_strtod(const char *s00, char **se)
used for throwing exceptions.
std::string errormsg
errormsg is the error that is causing the exception to be thrown
double value
initial value
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_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)
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.
IpoptProblem(OSInstance *osinstance_, OSOption *osoption_, OSResult *osresult_, std::string *ipoptErrorMsg_)
the IpoptProblemclass constructor
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 ~IpoptProblem()
the IpoptProblem class destructor
virtual bool get_nlp_info(Ipopt::Index &n, Ipopt::Index &m, Ipopt::Index &nnz_jac_g, Ipopt::Index &nnz_h_lag, IndexStyleEnum &index_style)
IPOpt specific methods for defining the nlp problem.
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 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_bounds_info(Ipopt::Index n, Ipopt::Number *x_l, Ipopt::Number *x_u, Ipopt::Index m, Ipopt::Number *g_l, Ipopt::Number *g_u)
Method to return the bounds for my problem.
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 void finalize_solution(Ipopt::SolverReturn status, Ipopt::Index n, const Ipopt::Number *x, const Ipopt::Number *z_L, const Ipopt::Number *z_U, Ipopt::Index m, const Ipopt::Number *g, const Ipopt::Number *lambda, Ipopt::Number obj_value, const Ipopt::IpoptData *ip_data, Ipopt::IpoptCalculatedQuantities *ip_cq)
This method is called when the algorithm is complete so the TNLP can store/write the solution.
virtual void setSolverOptions()
The implementation of the virtual functions.
virtual void solve()
solve results in an instance being read into the Ipopt data structures and optimize
IpoptSolver()
the IpoptSolver class constructor
~IpoptSolver()
the IpoptSolver class destructor
void dataEchoCheck()
use this for debugging, print out the instance that the solver thinks it has and compare this with th...
virtual void buildSolverInstance()
The implementation of the virtual functions.
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 setNumberOfOtherVariableResults(int solIdx, int numberOfOtherVariableResults)
Set the [i]th optimization solution's other (non-standard/solver specific) variable-related results,...
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 setDualVariableValuesDense(int solIdx, double *y)
Set the [i]th optimization solution's dual variable values, where i equals the given solution index.
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 setAnOtherVariableResultSparse(int solIdx, int otherIdx, std::string name, std::string value, std::string description, int *idx, std::string *s, int n)
Set the [i]th optimization solution's other (non-standard/solver specific)variable-related results,...
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.
std::string writeOSrL(OSResult *theosresult)
create an osrl string from an OSResult object
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_trace
@ ENUM_OUTPUT_LEVEL_error
@ ENUM_OUTPUT_LEVEL_summary
@ ENUM_OUTPUT_AREA_OSSolverInterfaces