My Project
OSIpoptSolver.cpp
Go to the documentation of this file.
1/* $Id$ */
18#include "OSIpoptSolver.h"
19#include "OSGeneral.h"
20#include "OSParameters.h"
21#include "OSMathUtil.h"
22#include "CoinFinite.hpp"
23#include "OSOutput.h"
24
25
26using std::cout;
27using std::endl;
28using std::ostringstream;
29using namespace Ipopt;
30
31
33{
34#ifndef NDEBUG
36 "inside IpoptSolver constructor\n");
37#endif
38 osrlwriter = new OSrLWriter();
39 osresult = new OSResult();
40 m_osilreader = NULL;
41 m_osolreader = NULL;
42 ipoptErrorMsg = new std::string("");
43}
44
46{
47#ifndef NDEBUG
49 "inside IpoptSolver destructor\n");
50#endif
51 if(m_osilreader != NULL) delete m_osilreader;
52 m_osilreader = NULL;
53 if(m_osolreader != NULL) delete m_osolreader;
54 m_osolreader = NULL;
55 delete osresult;
56 osresult = NULL;
57 delete osrlwriter;
58 osrlwriter = NULL;
59 //delete osinstance;
60 //osinstance = NULL;
61 delete ipoptErrorMsg;
62#ifndef NDEBUG
64 "Leaving IpoptSolver destructor\n");
65#endif
66}
67
68// returns the size of the problem
69bool IpoptProblem::get_nlp_info(Index& n, Index& m, Index& nnz_jac_g,
70 Index& nnz_h_lag, IndexStyleEnum& index_style)
71{
72 std::ostringstream outStr;
73 try
74 {
75 //if(osinstance->getObjectiveNumber() <= 0) throw ErrorClass("Ipopt NEEDS AN OBJECTIVE FUNCTION");
77 throw ErrorClass("Ipopt does not solve integer programs -- please try Bonmin or Couenne");
78 // number of variables
80 // number of constraints
82#ifndef NDEBUG
83 outStr.str("");
84 outStr.clear();
85 outStr << "number variables !!!!!!!!!!!!!!!!!!!!!!!!!!!" << n << endl;
86 outStr << "number constraints !!!!!!!!!!!!!!!!!!!!!!!!!!!" << m << endl;
88#endif
89 try
90 {
92 }
93 catch(const ErrorClass& eclass)
94 {
95 outStr.str("");
96 outStr.clear();
97 outStr << "error in OSIpoptSolver, AD initialization failed:\n" << eclass.errormsg << endl;
99 *ipoptErrorMsg = eclass.errormsg;
100 throw;
101 }
102 // use the OS Expression tree for function evaluations instead of CppAD
104 SparseJacobianMatrix *sparseJacobian = NULL;
105 try
106 {
107 sparseJacobian = osinstance->getJacobianSparsityPattern();
108 }
109 catch(const ErrorClass& eclass)
110 {
111 outStr.str("");
112 outStr.clear();
113 outStr << "error in OSIpoptSolver, Jacobian sparsity:\n" << eclass.errormsg << endl;
115 *ipoptErrorMsg = eclass.errormsg;
116 throw;
117 }
118 if (sparseJacobian != NULL)
119 {
120 nnz_jac_g = sparseJacobian->valueSize;
121 }
122 else
123 {
124 nnz_jac_g = 0;
125 }
126
127#ifndef NDEBUG
128 outStr.str("");
129 outStr.clear();
130 outStr << "nnz_jac_g !!!!!!!!!!!!!!!!!!!!!!!!!!!" << nnz_jac_g << endl;
132#endif
133 // nonzeros in upper hessian
134
137 {
138#ifndef NDEBUG
139 osoutput->OSPrint(ENUM_OUTPUT_AREA_OSSolverInterfaces, ENUM_OUTPUT_LEVEL_debug, "This is a linear program\n");
140#endif
141 nnz_h_lag = 0;
142 }
143 else
144 {
146 if(sparseHessian != NULL)
147 {
148 nnz_h_lag = sparseHessian->hessDimension;
149 }
150 else
151 {
152 nnz_h_lag = 0;
153 }
154 }
155#ifndef NDEBUG
156 outStr.str("");
157 outStr.clear();
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;
162#endif
163 // use the C style indexing (0-based)
164 index_style = TNLP::C_STYLE;
165#ifndef NDEBUG
166 outStr.str("");
167 outStr.clear();
168 outStr << "return from get_nlp_info (OSIpoptSolver.cpp)" << nnz_h_lag << endl;
170#endif
171
173
174 return true;
175 }
176 catch(const ErrorClass& eclass)
177 {
178 *ipoptErrorMsg = eclass.errormsg;
179 throw;
180 }
181
182}//get_nlp_info
183
184
185bool IpoptProblem::get_bounds_info(Index n, Number* x_l, Number* x_u,
186 Index m, Number* g_l, Number* g_u)
187{
188 int i;
189 double * mdVarLB = osinstance->getVariableLowerBounds();
190 // variables upper bounds
191 double * mdVarUB = osinstance->getVariableUpperBounds();
192
193 for(i = 0; i < n; i++)
194 {
195 x_l[ i] = mdVarLB[ i];
196 x_u[ i] = mdVarUB[ i];
197 }
198 // Ipopt interprets any number greater than nlp_upper_bound_inf as
199 // infinity. The default value of nlp_upper_bound_inf and nlp_lower_bound_inf
200 // is 1e19 and can be changed through ipopt options.
201 // e.g. g_u[0] = 2e19;
202
203 //constraint lower bounds
204 double * mdConLB = osinstance->getConstraintLowerBounds();
205 //constraint upper bounds
206 double * mdConUB = osinstance->getConstraintUpperBounds();
207
208 for(int i = 0; i < m; i++)
209 {
210 g_l[ i] = mdConLB[ i];
211 g_u[ i] = mdConUB[ i];
212 }
213 return true;
214}//get_bounds_info
215
216
217// returns the initial point for the problem
218bool IpoptProblem::get_starting_point(Index n, bool init_x, Number* x,
219 bool init_z, Number* z_L, Number* z_U, Index m, bool init_lambda,
220 Number* lambda)
221{
222 std::ostringstream outStr;
223
224 // Here, we assume we only have starting values for x, if you code
225 // your own NLP, you can provide starting values for the dual variables
226 // if you wish
227 assert(init_x == true);
228 assert(init_z == false);
229 assert(init_lambda == false);
230 int i, m1, n1;
231
232#ifndef NDEBUG
233 osoutput->OSPrint(ENUM_OUTPUT_AREA_OSSolverInterfaces, ENUM_OUTPUT_LEVEL_debug, "get initial values !!!!!!!!!!!!!!!!!!!!!!!!!!\n");
234#endif
235
236 //now set initial values
237#ifndef NDEBUG
238 osoutput->OSPrint(ENUM_OUTPUT_AREA_OSSolverInterfaces, ENUM_OUTPUT_LEVEL_debug, "get number of initial values !!!!!!!!!!!!!!!!!!!!!!!!!!\n");
239#endif
240 int k;
241 if (osoption != NULL)
243 else
244 m1 = 0;
245#ifndef NDEBUG
246 outStr.str("");
247 outStr.clear();
248 outStr << "number of variables initialed: " << m1 << endl;
250#endif
251
253 bool* initialed;
254 initialed = new bool[n1];
255#ifndef NDEBUG
256 outStr.str("");
257 outStr.clear();
258 outStr << "number of variables in total: " << n1 << endl;
260#endif
261
262 for(k = 0; k < n1; k++)
263 initialed[k] = false;
264
265 if (m1 > 0)
266 {
267#ifndef NDEBUG
269 "get initial values\n");
270#endif
271
272 InitVarValue** initVarVector = osoption->getInitVarValuesSparse();
273#ifndef NDEBUG
275#endif
276 try
277 {
278 double initval;
279 for(k = 0; k < m1; k++)
280 {
281 i = initVarVector[k]->idx;
282 if (initVarVector[k]->idx > n1)
283 throw ErrorClass ("Illegal index value in variable initialization");
284
285 initval = initVarVector[k]->value;
287 {
288 if (osinstance->instanceData->variables->var[k]->lb > initval)
289 throw ErrorClass ("Initial value outside of bounds");
290 }
291 else if (osinstance->instanceData->variables->var[k]->lb == -OSDBL_MAX)
292 {
293 if (osinstance->instanceData->variables->var[k]->ub < initval)
294 throw ErrorClass ("Initial value outside of bounds");
295 }
296 else
297 {
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");
301 }
302
303 x[initVarVector[k]->idx] = initval;
304 initialed[initVarVector[k]->idx] = true;
305 }
306 }
307 catch(const ErrorClass& eclass)
308 {
310 "Error in IpoptProblem::get_starting_point (see OSIpoptSolver.cpp)\n"+eclass.errormsg+"\n\n");
311 }
312 } // end if (m1 > 0)
313
314 double default_initval;
315 default_initval = 1.7171;
316 //default_initval = 0;
317
318 for(k = 0; k < n1; k++)
319 {
320 if (!initialed[k])
321 {
323 if (osinstance->instanceData->variables->var[k]->lb <= default_initval)
324 x[k] = default_initval;
325 else
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;
330 else
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;
337 else
338 x[k] = osinstance->instanceData->variables->var[k]->ub;
339 }
340 }
341
342#ifndef NDEBUG
343 outStr.str("");
344 outStr.clear();
345 for(i = 0; i < n1; i++)
346 {
347 outStr << "INITIAL VALUE !!!!!!!!!!!!!!!!!!!! " << x[ i] << std::endl;
348 }
350#endif
351 //make sure objvalue is initialized
353 delete[] initialed;
354
355 return true;
356}//get_starting_point
357
358// returns the value of the objective function
359bool IpoptProblem::eval_f(Index n, const Number* x, bool new_x, Number& obj_value)
360{
361 try
362 {
364 {
365 //the following is a kludge for ipopt, new_x does not seem to get initialized if there are no constraints.
366 //if(osinstance->getConstraintNumber() <= 0) new_x = true;
367 if (new_x == false)
368 obj_value = osinstance->calculateAllObjectiveFunctionValues( const_cast<double*>(x), false)[ 0];
369 else
370 obj_value = osinstance->calculateAllObjectiveFunctionValues( const_cast<double*>(x), NULL, NULL, true, 0 )[ 0];
371 //if( CoinIsnan( (double)obj_value) ) return false;
372 //if( CoinIsnan( obj_value ) )return false;
373 }
374 }
375 catch(const ErrorClass& eclass)
376 {
377 *ipoptErrorMsg = eclass.errormsg;
378 throw;
379 }
380
381 return true;
382}
383
384bool IpoptProblem::eval_grad_f(Index n, const Number* x, bool new_x, Number* grad_f)
385{
386 std::ostringstream outStr;
387 int i;
388 double *objGrad = NULL;
390 {
391 try
392 {
393 //objGrad = osinstance->calculateAllObjectiveFunctionGradients( const_cast<double*>(x), NULL, NULL, new_x, 1)[ 0];
394 objGrad = osinstance->calculateObjectiveFunctionGradient( const_cast<double*>(x), NULL, NULL, -1, new_x, 1);
395 }
396 catch(const ErrorClass& eclass)
397 {
398#ifndef NDEBUG
399 outStr.str("");
400 outStr.clear();
401 outStr << "error in IpoptProblem::eval_grad_f (see OSIpoptSolver.cpp)\n" << eclass.errormsg << endl;
403#endif
404 *ipoptErrorMsg = eclass.errormsg;
405 throw;
406 }
407 for(i = 0; i < n; i++)
408 {
409 grad_f[ i] = objGrad[ i];
410 }
411 }
412 return true;
413}//eval_grad_f
414
415// return the value of the constraints: g(x)
416bool IpoptProblem::eval_g(Index n, const Number* x, bool new_x, Index m, Number* g)
417{
418 std::ostringstream outStr;
419 try
420 {
421 double *conVals = osinstance->calculateAllConstraintFunctionValues( const_cast<double*>(x), NULL, NULL, new_x, 0 );
422 int i;
423 for(i = 0; i < m; i++)
424 {
425 if( CoinIsnan( (double)conVals[ i] ) ) return false;
426 g[i] = conVals[ i] ;
427 }
428 return true;
429 }
430 catch(const ErrorClass& eclass)
431 {
432#ifndef NDEBUG
433 outStr.str("");
434 outStr.clear();
435 outStr << "error in IpoptProblem::eval_grad_g (see OSIpoptSolver.cpp)\n" << eclass.errormsg << endl;
437#endif
438 *ipoptErrorMsg = eclass.errormsg;
439 throw;
440 }
441}//eval_g
442
443
444// return the structure or values of the jacobian
445bool IpoptProblem::eval_jac_g(Index n, const Number* x, bool new_x,
446 Index m, Index nele_jac, Index* iRow, Index *jCol,
447 Number* values)
448{
449 std::ostringstream outStr;
450 SparseJacobianMatrix *sparseJacobian;
451 if (values == NULL)
452 {
453 // return the structure of the jacobian
454 try
455 {
456 sparseJacobian = osinstance->getJacobianSparsityPattern();
457 }
458 catch(const ErrorClass& eclass)
459 {
460#ifndef NDEBUG
461 outStr.str("");
462 outStr.clear();
463 outStr << "error in IpoptProblem::eval_jac_g (see OSIpoptSolver.cpp)\n" << eclass.errormsg << endl;
465#endif
466 *ipoptErrorMsg = eclass.errormsg;
467 throw;
468 }
469 int i = 0;
470 int k, idx;
471 for(idx = 0; idx < m; idx++)
472 {
473 for(k = *(sparseJacobian->starts + idx); k < *(sparseJacobian->starts + idx + 1); k++)
474 {
475 iRow[i] = idx;
476 jCol[i] = *(sparseJacobian->indexes + k);
477 i++;
478 }
479 }
480 }
481 else
482 {
483 try
484 {
485 sparseJacobian = osinstance->calculateAllConstraintFunctionGradients( const_cast<double*>(x), NULL, NULL, new_x, 1);
486 }
487 catch(const ErrorClass& eclass)
488 {
489#ifndef NDEBUG
490 outStr.str("");
491 outStr.clear();
492 outStr << "error in IpoptProblem::eval_jac_g (see OSIpoptSolver.cpp)\n" << eclass.errormsg << endl;
494#endif
495 *ipoptErrorMsg = eclass.errormsg;
496 throw;
497 }
498 //osinstance->getIterateResults( (double*)x, 0.0, NULL, -1, new_x, 1);
499 for(int i = 0; i < nele_jac; i++)
500 {
501 values[ i] = sparseJacobian->values[i];
502 }
503 }
504 return true;
505}//eval_jac_g
506
507//return the structure or values of the hessian
508bool IpoptProblem::eval_h(Index n, const Number* x, bool new_x,
509 Number obj_factor, Index m, const Number* lambda,
510 bool new_lambda, Index nele_hess, Index* iRow,
511 Index* jCol, Number* values)
512{
513 std::ostringstream outStr;
514
516 SparseHessianMatrix *sparseHessian;
517
518 int i;
519 if (values == NULL)
520 {
521 // return the structure. This is a symmetric matrix, fill the lower left triangle only.
522 try
523 {
525 }
526 catch(const ErrorClass& eclass)
527 {
528
529 *ipoptErrorMsg = eclass.errormsg;
530 throw;
531 }
532 for(i = 0; i < nele_hess; i++)
533 {
534 iRow[i] = *(sparseHessian->hessColIdx + i);
535 jCol[i] = *(sparseHessian->hessRowIdx + i);
536 }
537 }
538 else
539 {
540 // return the values. This is a symmetric matrix, fill the lower left triangle only
541 double* objMultipliers = new double[1];
542 objMultipliers[0] = obj_factor;
543 try
544 {
545 sparseHessian = osinstance->calculateLagrangianHessian( const_cast<double*>(x), objMultipliers, const_cast<double*>(lambda) , new_x, 2);
546 delete[] objMultipliers;
547 }
548 catch(const ErrorClass& eclass)
549 {
550#ifndef NDEBUG
551 outStr.str("");
552 outStr.clear();
553 outStr << "error in OSIpoptSolver, line 444:\n" << eclass.errormsg << endl;
555#endif
556 *ipoptErrorMsg = eclass.errormsg;
557 delete[] objMultipliers;
558 throw;
559 }
560 for(i = 0; i < nele_hess; i++)
561 {
562 values[ i] = *(sparseHessian->hessValues + i);
563 }
564 }
566 return true;
567}//eval_h
568
570 bool& use_x_scaling, Index n,
571 Number* x_scaling,
572 bool& use_g_scaling, Index m,
573 Number* g_scaling)
574{
575 if( osinstance->instanceData->objectives->obj[ 0]->maxOrMin.compare("min") != 0)
576 {
577 obj_scaling = -1;
578 }
579 else obj_scaling = 1;
580 use_x_scaling = false;
581 use_g_scaling = false;
582 return true;
583}//get_scaling_parameters
584
585void IpoptProblem::finalize_solution(SolverReturn status,
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)
589{
590 // here is where we would store the solution to variables, or write to a file, etc
591 // so we could use the solution.
593 obj_value = osinstance->calculateAllObjectiveFunctionValues( const_cast<double*>(x), true)[ 0];
594 OSrLWriter *osrlwriter ;
595 osrlwriter = new OSrLWriter();
596
597 ostringstream outStr;
598#ifdef DEBUG
599
600 outStr << std::endl << std::endl << "Solution of the primal variables, x" << std::endl;
601 for (Index i=0; i<n; i++)
602 {
603 outStr << "x[" << i << "] = " << x[i] << std::endl;
604 }
605
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++)
608 {
609 outStr << "z_L[" << i << "] = " << z_L[i] << std::endl;
610 }
611 for (Index i=0; i<n; i++)
612 {
613 outStr << "z_U[" << i << "] = " << z_U[i] << std::endl;
614 }
616 outStr.str("");
617 outStr.clear();
618#endif
620 {
621 outStr << std::endl << "Objective value f(x*) = " << os_dtoa_format(obj_value) << std::endl;
623 }
624 int solIdx = 0;
625 int numberOfOtherVariableResults;
626 int otherIdx;
627 int numCon = osinstance->getConstraintNumber();
628
629 //make sure the sign on the dual values is correct
630 double *dualValue = NULL;
631 std::string *rcost = NULL;
632 int* idx = NULL;
633 double* mdObjValues = NULL;
635 {
636 mdObjValues = new double[1];
637 }
638
639 std::string message = "Ipopt solver finishes to the end.";
640 std::string solutionDescription = "";
641
642 try
643 {
644 // resultHeader information
645 if(osresult->setSolverInvoked( "COIN-OR Ipopt") != true)
646 throw ErrorClass("OSResult error: setSolverInvoked");
648 throw ErrorClass("OSResult error: setServiceName");
650 throw ErrorClass("OSResult error: setInstanceName");
651
652 //if(osresult->setJobID( osoption->jobID) != true)
653 // throw ErrorClass("OSResult error: setJobID");
654
655 // set basic problem parameters
657 throw ErrorClass("OSResult error: setVariableNumer");
658 if(osresult->setObjectiveNumber( 1) != true)
659 throw ErrorClass("OSResult error: setObjectiveNumber");
661 throw ErrorClass("OSResult error: setConstraintNumber");
662 if(osresult->setSolutionNumber( 1) != true)
663 throw ErrorClass("OSResult error: setSolutionNumer");
664 if(osresult->setGeneralMessage( message) != true)
665 throw ErrorClass("OSResult error: setGeneralMessage");
666
667 switch( status)
668 {
669 case SUCCESS:
670 solutionDescription = "SUCCESS[IPOPT]: Algorithm terminated normally at a locally optimal point, satisfying the convergence tolerances.";
671 osresult->setSolutionStatus(solIdx, "locallyOptimal", solutionDescription);
672
673 if(osinstance->getVariableNumber() > 0) osresult->setPrimalVariableValuesDense(solIdx, const_cast<double*>(x));
674
675 if(numCon > 0)
676 {
677 dualValue = new double[ numCon];
678 for (Index i=0; i < numCon; i++)
679 {
680 dualValue[ i] = -lambda[ i];
681 }
682 //osresult->setDualVariableValuesDense(solIdx, const_cast<double*>(lambda));
683 osresult->setDualVariableValuesDense(solIdx, dualValue);
684 }
685
687 {
688 mdObjValues[0] = obj_value ;
689 osresult->setObjectiveValuesDense(solIdx, mdObjValues);
690 }
691 // set other
692
694 {
695 numberOfOtherVariableResults = 1;
696 osresult->setNumberOfOtherVariableResults(solIdx, numberOfOtherVariableResults);
697 rcost = new std::string[ osinstance->getVariableNumber()];
698 idx = new int[ osinstance->getVariableNumber()];
699 for (Index i = 0; i < n; i++)
700 {
701 rcost[ i] = os_dtoa_format( z_L[i] - z_U[i]);
702 idx[ i] = i;
703 }
704 otherIdx = 0;
705 osresult->setAnOtherVariableResultSparse(solIdx, otherIdx, "reduced_costs", "",
706 "the variable reduced costs", idx, rcost, osinstance->getVariableNumber(), "",
707 "double", "");
708 }
709 //set dual values on variable upper and lower bounds
710 /*
711 for (Index i = 0; i < n; i++) {
712 rcost[ i] = os_dtoa_format( z_L[i]);
713 idx[ i] = i;
714 }
715 otherIdx = 0;
716 osresult->setAnOtherVariableResultSparse(solIdx, otherIdx, "varL", "", "Lagrange Multiplier on the Variable Lower Bound", idx, rcost, osinstance->getVariableNumber() );
717
718
719 for (Index i = 0; i < n; i++) {
720 rcost[ i] = os_dtoa_format( z_U[i]);
721 }
722 otherIdx = 1;
723 osresult->setAnOtherVariableResultSparse(solIdx, otherIdx, "varU", "", "Lagrange Multiplier on the Variable Upper Bound", idx, rcost, osinstance->getVariableNumber() );
724 */
725 if(osinstance->getVariableNumber() > 0) delete[] rcost;
726 if(osinstance->getVariableNumber() > 0) delete[] idx;
727 if(osinstance->getConstraintNumber() > 0) delete[] dualValue;
728 break;
729
730 case MAXITER_EXCEEDED:
731 solutionDescription = "MAXITER_EXCEEDED[IPOPT]: Maximum number of iterations exceeded.";
732 osresult->setSolutionStatus(solIdx, "stoppedByLimit", solutionDescription);
733 if(x != NULL) osresult->setPrimalVariableValuesDense(solIdx, const_cast<double*>(x));
734 if(lambda != NULL) osresult->setDualVariableValuesDense(solIdx, const_cast<double*>( lambda));
736 {
737 mdObjValues[0] = obj_value ;
738 osresult->setObjectiveValuesDense(solIdx, mdObjValues);
739 }
740 break;
741
742 case STOP_AT_TINY_STEP:
743 solutionDescription = "STOP_AT_TINY_STEP[IPOPT]: Algorithm proceeds with very little progress.";
744 osresult->setSolutionStatus(solIdx, "stoppedByLimit", solutionDescription);
745 if(x != NULL) osresult->setPrimalVariableValuesDense(solIdx, const_cast<double*>( x));
746 if(lambda != NULL) osresult->setDualVariableValuesDense(solIdx, const_cast<double*>( lambda));
748 {
749 mdObjValues[0] = obj_value ;
750 osresult->setObjectiveValuesDense(solIdx, mdObjValues);
751 }
752 break;
753
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";
756 osresult->setSolutionStatus(solIdx, "IpoptAccetable", solutionDescription);
757 if(lambda != NULL) osresult->setDualVariableValuesDense(solIdx, const_cast<double*>( lambda));
758 if(x != NULL)osresult->setPrimalVariableValuesDense(solIdx, const_cast<double*>(x));
760 {
761 mdObjValues[0] = obj_value ;
762 osresult->setObjectiveValuesDense(solIdx, mdObjValues);
763 }
764 break;
765
766 case LOCAL_INFEASIBILITY:
767 solutionDescription = "LOCAL_INFEASIBILITY[IPOPT]: Algorithm converged to a point of local infeasibility. Problem may be infeasible.";
768 osresult->setSolutionStatus(solIdx, "infeasible", solutionDescription);
769 if( osinstance->getVariableNumber() == 0)
770 osresult->setSolutionMessage(solIdx, "Warning: this problem has zero decision variables!");
771 break;
772
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.";
775 osresult->setSolutionStatus(solIdx, "error", solutionDescription);
776 if( osinstance->getVariableNumber() == 0)
777 osresult->setSolutionMessage(solIdx, "Warning: this problem has zero decision variables!");
778 break;
779
780 case DIVERGING_ITERATES:
781 solutionDescription = "DIVERGING_ITERATES[IPOPT]: It seems that the iterates diverge.";
782 osresult->setSolutionStatus(solIdx, "unbounded", solutionDescription);
783 if( osinstance->getVariableNumber() == 0)
784 osresult->setSolutionMessage(solIdx, "Warning: this problem has zero decision variables!");
785 break;
786
787 case RESTORATION_FAILURE:
788 solutionDescription = "RESTORATION_FAILURE[IPOPT]: Restoration phase failed, algorithm doesn't know how to proceed.";
789 osresult->setSolutionStatus(solIdx, "error", solutionDescription);
790 if( osinstance->getVariableNumber() == 0)
791 osresult->setSolutionMessage(solIdx, "Warning: this problem has zero decision variables!");
792 break;
793
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.";
796 osresult->setSolutionStatus(solIdx, "error", solutionDescription);
797 if( osinstance->getVariableNumber() == 0)
798 osresult->setSolutionMessage(solIdx, "Warning: this problem has zero decision variables!");
799 break;
800
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.";
803 osresult->setSolutionStatus(solIdx, "error", solutionDescription);
804 if( osinstance->getVariableNumber() == 0)
805 osresult->setSolutionMessage(solIdx, "Warning: this problem has zero decision variables!");
806 break;
807
808 case INTERNAL_ERROR:
809 solutionDescription = "INTERNAL_ERROR[IPOPT]: An unknown internal error occurred. Please contact the IPOPT authors through the mailing list.";
810 osresult->setSolutionStatus(solIdx, "error", solutionDescription);
811 if( osinstance->getVariableNumber() == 0)
812 osresult->setSolutionMessage(solIdx, "Warning: this problem has zero decision variables!");
813 break;
814
815 default:
816 solutionDescription = "OTHER[IPOPT]: other unknown solution status from Ipopt solver";
817 osresult->setSolutionStatus(solIdx, "other", solutionDescription);
818 if( osinstance->getVariableNumber() == 0)
819 osresult->setSolutionMessage(solIdx, "Warning: this problem has zero decision variables!");
820 }
821
823 delete osrlwriter;
824 osrlwriter = NULL;
826 {
827 delete[] mdObjValues;
828 }
829
830 return;
831 }
832 catch(const ErrorClass& eclass)
833 {
834#ifndef NDEBUG
835 outStr.str("");
836 outStr.clear();
837 outStr << "error trap in OSIpoptSolver:\n" << eclass.errormsg << endl;
839#endif
842 std::string osrl = osrlwriter->writeOSrL( osresult);
843 delete osrlwriter;
844 osrlwriter = NULL;
846 {
847 delete[] mdObjValues;
848 }
849 mdObjValues = NULL;
850 throw ErrorClass( osrl) ;
851 }
853}
854
855
857{
858 std::ostringstream outStr;
859 try
860 {
861 if(osil.length() == 0 && osinstance == NULL) throw ErrorClass("there is no instance");
862 if(osinstance == NULL)
863 {
864 m_osilreader = new OSiLReader();
866 }
867
868 // Can't handle multiobjective problems properly --- especially nonlinear ones
870 throw ErrorClass("Solver cannot handle multiple objectives --- please delete all but one");
871
872 // Create a new instance of your nlp
874 app = new IpoptApplication();
875
876 this->bCallbuildSolverInstance = true;
877 return;
878 }
879 catch(const ErrorClass& eclass)
880 {
881#ifndef NDEBUG
882 outStr.str("");
883 outStr.clear();
884 outStr << "error in OSIpoptSolver, line 722:\n" << eclass.errormsg << endl;
886#endif
890 throw ErrorClass( osrl) ;
891 }
892}//end buildSolverInstance()
893
894
896{
897 std::ostringstream outStr;
898 try
899 {
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;
903 /* set the default options */
904 //app->Options()->SetNumericValue("tol", 1e-9);
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);
909 //app->Options()->SetStringValue("output_file", "ipopt.out");
910 app->Options()->SetStringValue("check_derivatives_for_naninf", "yes");
911 // hessian constant for an LP
914 {
915 app->Options()->SetStringValue("hessian_constant", "yes", true, true);
916 }
918 {
919 if( osinstance->instanceData->objectives->obj[ 0]->maxOrMin.compare("min") != 0)
920 {
921 app->Options()->SetStringValue("nlp_scaling_method", "user-scaling");
922 }
923 }
924 /* end of the default options, now get options from OSoL */
925
926
927 if(osoption == NULL && osol.length() > 0)
928 {
929 m_osolreader = new OSoLReader();
931 }
932
933 if( osoption != NULL && osoption->getNumberOfSolverOptions() > 0 )
934 {
935#ifndef NDEBUG
936 outStr.str("");
937 outStr.clear();
938 outStr << "number of solver options ";
940 outStr << std::endl;
942#endif
943 std::vector<SolverOption*> optionsVector;
944 optionsVector = osoption->getSolverOptions( "ipopt",true);
945 char *pEnd;
946 int i;
947 int num_ipopt_options = optionsVector.size();
948 for(i = 0; i < num_ipopt_options; i++)
949 {
950#ifndef NDEBUG
951 outStr.str("");
952 outStr.clear();
953 outStr << "ipopt solver option ";
954 outStr << optionsVector[ i]->name;
955 outStr << std::endl;
957#endif
958 if(optionsVector[ i]->type == "numeric" )
959 {
960#ifndef NDEBUG
961 outStr.str("");
962 outStr.clear();
963 outStr << "FOUND A NUMERIC OPTION ";
964 outStr << os_strtod( optionsVector[ i]->value.c_str(), &pEnd );
965 outStr << std::endl;
967#endif
968 app->Options()->SetNumericValue(optionsVector[ i]->name, os_strtod( optionsVector[ i]->value.c_str(), &pEnd ) );
969 }
970 else if(optionsVector[ i]->type == "integer" )
971 {
972#ifndef NDEBUG
973 outStr.str("");
974 outStr.clear();
975 outStr << "FOUND AN INTEGER OPTION ";
976 outStr << atoi( optionsVector[ i]->value.c_str() );
977 outStr << std::endl;
979#endif
980 app->Options()->SetIntegerValue(optionsVector[ i]->name, atoi( optionsVector[ i]->value.c_str() ) );
981 }
982 else if(optionsVector[ i]->type == "string" )
983 {
984#ifndef NDEBUG
985 outStr.str("");
986 outStr.clear();
987 outStr << "FOUND A STRING OPTION ";
988 outStr << optionsVector[ i]->value.c_str();
989 outStr << std::endl;
991#endif
992 app->Options()->SetStringValue(optionsVector[ i]->name, optionsVector[ i]->value);
993 }
994 }
995 }
996 return;
997 }
998 catch(const ErrorClass& eclass)
999 {
1000 osoutput->OSPrint(ENUM_OUTPUT_AREA_OSSolverInterfaces, ENUM_OUTPUT_LEVEL_error, "Error while setting options in IpoptSolver\n");
1002 osresult->setGeneralStatusType( "error");
1004 throw ErrorClass( osrl) ;
1005 }
1006}//end setSolverOptions()
1007
1008
1009
1011{
1012 std::ostringstream outStr;
1013
1014 if( this->bCallbuildSolverInstance == false) buildSolverInstance();
1015 if( this->bSetSolverOptions == false) setSolverOptions();
1016 try
1017 {
1018 app->Initialize();
1019 ApplicationReturnStatus status = app->OptimizeTNLP( nlp);
1021 if (status < -2)
1022 {
1023 throw ErrorClass("Ipopt FAILED TO SOLVE THE PROBLEM: " + *ipoptErrorMsg);
1024 }
1025 return;
1026 }
1027 catch(const ErrorClass& eclass)
1028 {
1029 outStr.str("");
1030 outStr.clear();
1031 outStr << "error in OSIpoptSolver routine solve():\n" << eclass.errormsg << endl;
1033
1035 osresult->setGeneralStatusType( "error");
1037 throw ErrorClass( osrl) ;
1038 }
1039}//solve
1040
1042{
1043#ifndef NDEBUG
1044 int i;
1045 ostringstream outStr;
1046
1047 // print out problem parameters
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;
1053
1054 // print out the variable information
1055 if(osinstance->getVariableNumber() > 0)
1056 {
1057 for(i = 0; i < osinstance->getVariableNumber(); i++)
1058 {
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;
1067 }
1068 }
1069
1070 // print out objective function information
1072 {
1073 if( osinstance->getObjectiveMaxOrMins()[0] == "min")
1074 outStr << "problem is a minimization" << endl;
1075 else
1076 outStr << "problem is a maximization" << endl;
1077 for(i = 0; i < osinstance->getVariableNumber(); i++)
1078 {
1079 outStr << "OBJ COEFFICIENT = " << osinstance->getDenseObjectiveCoefficients()[0][i] << endl;
1080 }
1081 }
1082 // print out constraint information
1084 {
1085 for(i = 0; i < osinstance->getConstraintNumber(); i++)
1086 {
1087 if(osinstance->getConstraintNames() != NULL)
1088 outStr << "row name = " << osinstance->getConstraintNames()[i] << endl;
1090 outStr << "row lower bound = " << osinstance->getConstraintLowerBounds()[i] << endl;
1092 outStr << "row upper bound = " << osinstance->getConstraintUpperBounds()[i] << endl;
1093 }
1094 }
1095
1096 // print out linear constraint data
1097 outStr << endl;
1098 outStr << "number of nonzeros = " << osinstance->getLinearConstraintCoefficientNumber() << endl;
1099 for(i = 0; i <= osinstance->getVariableNumber(); i++)
1100 {
1101 outStr << "Start Value = "
1103 }
1104 outStr << endl;
1105 for(i = 0; i < osinstance->getLinearConstraintCoefficientNumber(); i++)
1106 {
1107 outStr << "Index Value = "
1109 outStr << "Nonzero Value = "
1111 }
1112
1113 // print out quadratic data
1114 outStr << "number of qterms = " << osinstance->getNumberOfQuadraticTerms() << endl;
1115 for(int i = 0; i < osinstance->getNumberOfQuadraticTerms(); i++)
1116 {
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;
1121 }
1123#endif
1124 return;
1125} // end dataEchoCheck
1126
1127
1128IpoptProblem::IpoptProblem(OSInstance *osinstance_, OSOption *osoption_, OSResult *osresult_, std::string* ipoptErrorMsg_)
1129{
1130 osinstance = osinstance_;
1131 osoption = osoption_;
1132 osresult = osresult_;
1133 ipoptErrorMsg = ipoptErrorMsg_;
1134}
1135
1140
const OSSmartPtr< OSOutput > osoutput
Definition OSOutput.cpp:39
std::string os_dtoa_format(double x)
std::string OSgetVersionInfo()
double os_strtod(const char *s00, char **se)
Definition OSdtoa.cpp:2541
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
the InitVarValue class.
Definition OSOption.h:1160
double value
initial value
Definition OSOption.h:1170
int idx
variable index
Definition OSOption.h:1164
Variables * variables
variables is a pointer to a Variables object
Objectives * objectives
objectives is a pointer to a Objectives object
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.
OSOption * osoption
OSInstance * osinstance
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)
std::string * ipoptErrorMsg
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...
OSResult * osresult
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.
std::string * ipoptErrorMsg
OSoLReader * m_osolreader
m_osolreader is an OSoLReader object used to create an osoption from an osol string if needed
OSrLWriter * osrlwriter
OSiLReader * m_osilreader
m_osilreader is an OSiLReader object used to create an osinstance from an osil string if needed
virtual void setSolverOptions()
The implementation of the virtual functions.
Ipopt::SmartPtr< Ipopt::TNLP > nlp
Ipopt::SmartPtr< Ipopt::IpoptApplication > app
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..
SparseJacobianMatrix * calculateAllConstraintFunctionGradients(double *x, double *objLambda, double *conLambda, bool new_x, int highestOrder)
Calculate the gradient of all constraint functions.
double * getConstraintLowerBounds()
Get constraint lower bounds.
int getNumberOfQuadraticTerms()
Get the number of specified (usually nonzero) qTerms in the quadratic coefficients.
double * getVariableUpperBounds()
Get variable upper bounds.
SparseJacobianMatrix * getJacobianSparsityPattern()
int getNumberOfIntegerVariables()
getNumberOfIntegerVariables
bool bUseExpTreeForFunEval
bUseExpTreeForFunEval is set to true if you wish to use the OS Expression Tree for function evaluatio...
int getNumberOfBinaryVariables()
getNumberOfBinaryVariables
std::string getInstanceDescription()
Get instance description.
std::string getInstanceSource()
Get instance source.
int getConstraintNumber()
Get number of constraints.
double * calculateAllConstraintFunctionValues(double *x, double *objLambda, double *conLambda, bool new_x, int highestOrder)
Calculate all of the constraint function values.
int getLinearConstraintCoefficientNumber()
Get number of specified (usually nonzero) linear constraint coefficient values.
char * getVariableTypes()
Get variable initial values.
double * calculateAllObjectiveFunctionValues(double *x, double *objLambda, double *conLambda, bool new_x, int highestOrder)
Calculate all of the objective function values.
SparseMatrix * getLinearConstraintCoefficientsInColumnMajor()
Get linear constraint coefficients in column major.
double * calculateObjectiveFunctionGradient(double *x, double *objLambda, double *conLambda, int objIdx, bool new_x, int highestOrder)
Calculate the gradient of the objective function indexed by objIdx.
double ** getDenseObjectiveCoefficients()
getDenseObjectiveCoefficients.
bool initForAlgDiff()
This should be called by nonlinear solvers using callback functions.
InstanceData * instanceData
A pointer to an InstanceData object.
int getNumberOfNonlinearExpressions()
Get number of nonlinear expressions.
SparseHessianMatrix * getLagrangianHessianSparsityPattern()
QuadraticTerms * getQuadraticTerms()
Get all the quadratic terms in the instance.
double * getVariableLowerBounds()
Get variable lower bounds.
int getVariableNumber()
Get number of variables.
std::string * getVariableNames()
Get variable names.
std::string getInstanceName()
Get instance name.
SparseHessianMatrix * calculateLagrangianHessian(double *x, double *objLambda, double *conLambda, bool new_x, int highestOrder)
Calculate the Hessian of the Lagrangian Expression Tree This method will build the CppAD expression t...
std::string * getConstraintNames()
Get constraint names.
std::string * getObjectiveMaxOrMins()
Get objective maxOrMins.
double * getConstraintUpperBounds()
Get constraint upper bounds.
int getObjectiveNumber()
Get number of objectives.
The Option Class.
Definition OSOption.h:3565
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.
The Result Class.
Definition OSResult.h:2549
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.
Definition OSiLReader.h:38
OSInstance * readOSiL(const std::string &osil)
parse the OSiL model instance.
Used to read an OSoL string.
Definition OSoLReader.h:38
OSOption * readOSoL(const std::string &osol)
parse the OSoL solver options.
Take an OSResult object and write a string that validates against OSrL.
Definition OSrLWriter.h:31
std::string writeOSrL(OSResult *theosresult)
create an osrl string from an OSResult object
std::string maxOrMin
declare the objective function to be a max or a min
Definition OSInstance.h:157
int numberOfObjectives
numberOfObjectives is the number of objective functions in the instance
Definition OSInstance.h:201
Objective ** obj
coef is pointer to an array of ObjCoef object pointers
Definition OSInstance.h:205
int * varTwoIndexes
varTwoIndexes holds an integer array of the second variable indexes of all the quadratic terms.
Definition OSGeneral.h:450
int * rowIndexes
rowIndexes holds an integer array of row indexes of all the quadratic terms.
Definition OSGeneral.h:440
double * coefficients
coefficients holds a double array all the quadratic term coefficients.
Definition OSGeneral.h:455
int * varOneIndexes
varOneIndexes holds an integer array of the first variable indexes of all the quadratic terms.
Definition OSGeneral.h:445
The in-memory representation of a SparseHessianMatrix..
Definition OSGeneral.h:377
int * hessRowIdx
hessRowIdx is an integer array of row indices in the range 0, ..., n - 1.
Definition OSGeneral.h:394
int hessDimension
hessDimension is the number of nonzeros in each array.
Definition OSGeneral.h:389
double * hessValues
hessValues is a double array of the Hessian values.
Definition OSGeneral.h:404
int * hessColIdx
hessColIdx is an integer array of column indices in the range 0, ..., n - 1.
Definition OSGeneral.h:399
a sparse Jacobian matrix data structure
Definition OSGeneral.h:301
int * indexes
indexes holds an integer array of variable indices.
Definition OSGeneral.h:335
int valueSize
valueSize is the dimension of the values array
Definition OSGeneral.h:318
int * starts
starts holds an integer array of start elements, each start element points to the start of partials f...
Definition OSGeneral.h:324
double * values
values holds a double array of nonzero partial derivatives
Definition OSGeneral.h:340
int * indexes
indexes holds an integer array of rowIdx (or colIdx) elements in coefMatrix (AMatrix).
Definition OSGeneral.h:258
int * starts
starts holds an integer array of start elements in coefMatrix (AMatrix), which points to the start of...
Definition OSGeneral.h:252
double * values
values holds a double array of value elements in coefMatrix (AMatrix), which contains nonzero element...
Definition OSGeneral.h:264
double ub
ub corresponds to the optional attribute that holds the variable upper bound.
Definition OSInstance.h:61
double lb
lb corresponds to the optional attribute that holds the variable lower bound.
Definition OSInstance.h:56
Variable ** var
Here we define a pointer to an array of var pointers.
Definition OSInstance.h:97
@ ENUM_OUTPUT_LEVEL_debug
@ ENUM_OUTPUT_LEVEL_trace
@ ENUM_OUTPUT_LEVEL_error
@ ENUM_OUTPUT_LEVEL_summary
@ ENUM_OUTPUT_AREA_OSSolverInterfaces
#define OSDBL_MAX