My Project
OSCoinSolver.cpp
Go to the documentation of this file.
1/* $Id$ */
19#include "OSCoinSolver.h"
20#include "OSInstance.h"
21#include "OSFileUtil.h"
22#include "OSOutput.h"
23#include "CoinTime.hpp"
24#include "CglPreProcess.hpp"
25#include "CglGomory.hpp"
26#include "CglSimpleRounding.hpp"
27#include "CglMixedIntegerRounding2.hpp"
28#include "CglKnapsackCover.hpp"
29#include "CglFlowCover.hpp"
30#include "CbcBranchActual.hpp" //for CbcSOS
31#include "CoinMessageHandler.hpp"
32#include "CoinMessage.hpp"
33
34#include "OsiClpSolverInterface.hpp"
35#include "CoinWarmStartBasis.hpp"
36#include "CbcSolver.hpp"
37
38#ifdef COIN_HAS_SYMPHONY
39#include "OsiSymSolverInterface.hpp"
40#endif
41
42#ifdef COIN_HAS_VOL
43#include "OsiVolSolverInterface.hpp"
44#endif
45
46#ifdef COIN_HAS_DYLP
47#include "OsiDylpSolverInterface.hpp"
48#endif
49
50#ifdef COIN_HAS_GLPK
51#include "OsiGlpkSolverInterface.hpp"
52#endif
53
54#ifdef COIN_HAS_CPX
55#include "OsiCpxSolverInterface.hpp"
56#endif
57
58#ifdef COIN_HAS_GRB
59#include "OsiGrbSolverInterface.hpp"
60#endif
61
62#ifdef COIN_HAS_MSK
63#include "OsiMskSolverInterface.hpp"
64#endif
65
66#ifdef COIN_HAS_SOPLEX
67#include "OsiSpxSolverInterface.hpp"
68#endif
69
70#ifdef COIN_HAS_XPR
71#include "OsiXprSolverInterface.hpp"
72#endif
73
74#include "OSGeneral.h"
75#include "OSParameters.h"
76#include "OSMathUtil.h"
77
78#include <map>
79
80#include <iostream>
81#ifdef HAVE_CTIME
82# include <ctime>
83#else
84# ifdef HAVE_TIME_H
85# include <time.h>
86# else
87# error "don't have header file for time"
88# endif
89#endif
90
91using std::cout;
92using std::endl;
93using std::ostringstream;
94
95
96
98 osiSolver(NULL),
99 m_osilreader(NULL),
100 m_osolreader(NULL),
101 m_CoinPackedMatrix(NULL),
102 cbc_argv( NULL),
103 num_cbc_argv( 0),
104 cpuTime( 0)
105{
106 osrlwriter = new OSrLWriter();
107}
108
110{
111#ifndef NDEBUG
113 ENUM_OUTPUT_LEVEL_debug, "inside CoinSolver destructor\n");
114#endif
115 if(m_osilreader != NULL) delete m_osilreader;
116 m_osilreader = NULL;
117 if(m_osolreader != NULL) delete m_osolreader;
118 m_osolreader = NULL;
119 delete m_CoinPackedMatrix;
120 m_CoinPackedMatrix = NULL;
121 delete osiSolver;
122 if(osiSolver != NULL) osiSolver = NULL;
123 delete osrlwriter;
124 osrlwriter = NULL;
125 delete osresult;
126 osresult = NULL;
127 if(num_cbc_argv > 0)
128 {
129/* -----
130 int i;
131 for(i = 0; i < num_cbc_argv; i++)
132 {
133 delete cbc_argv[ i];
134 }
135 delete[] cbc_argv;
136 ----- */
137 cbc_argv = NULL;
138 }
139#ifndef NDEBUG
141 ENUM_OUTPUT_LEVEL_trace, "Leaving CoinSolver destructor\n");
142#endif
143}
144
145
147{
148 std::ostringstream outStr;
149 try
150 {
151 if(osil.length() == 0 && osinstance == NULL) throw ErrorClass("there is no instance");
152 clock_t start, finish;
153 double duration;
154 start = clock();
155 if(osinstance == NULL)
156 {
157 m_osilreader = new OSiLReader();
159 }
160 finish = clock();
161 duration = (double) (finish - start) / CLOCKS_PER_SEC;
162
163 // Can't handle multiobjective problems properly --- especially nonlinear ones
165 throw ErrorClass("Solver cannot handle multiple objectives --- please delete all but one");
166
167 // get the type of solver requested from OSoL string
168 if (sSolverName == "clp")
169 osiSolver = new OsiClpSolverInterface();
170
171 else if (sSolverName == "cbc")
172 osiSolver = new OsiClpSolverInterface();
173
174 else if (sSolverName == "vol")
175 #ifdef COIN_HAS_VOL
176 osiSolver = new OsiVolSolverInterface();
177 #else
178 throw ErrorClass("This OSSolverService was built without solver vol");
179 #endif
180
181 else if (sSolverName == "cplex")
182 #ifdef COIN_HAS_CPX
183 osiSolver = new OsiCpxSolverInterface();
184 #else
185 throw ErrorClass("This OSSolverService was built without solver cplex");
186 #endif
187
188 else if (sSolverName == "gurobi")
189 #ifdef COIN_HAS_GRB
190 osiSolver = new OsiGrbSolverInterface();
191 #else
192 throw ErrorClass("This OSSolverService was built without solver gurobi");
193 #endif
194
195 else if (sSolverName == "mosek")
196 #ifdef COIN_HAS_MSK
197 osiSolver = new OsiMskSolverInterface();
198 #else
199 throw ErrorClass("This OSSolverService was built without solver mosek");
200 #endif
201
202 else if (sSolverName == "soplex")
203 #ifdef COIN_HAS_SOPLEX
204 osiSolver = new OsiSpxSolverInterface();
205 #else
206 throw ErrorClass("This OSSolverService was built without solver soplex");
207 #endif
208
209 else if (sSolverName == "xpress")
210 #ifdef COIN_HAS_XPR
211 osiSolver = new OsiXprSolverInterface();
212 #else
213 throw ErrorClass("This OSSolverService was built without solver xpress");
214 #endif
215
216 else if (sSolverName == "glpk")
217 #ifdef COIN_HAS_GLPK
218 osiSolver = new OsiGlpkSolverInterface();
219 #else
220 throw ErrorClass("This OSSolverService was built without solver glpk");
221 #endif
222
223 else if (sSolverName == "dylp")
224 #ifdef COIN_HAS_DYLP
225 osiSolver = new OsiDylpSolverInterface();
226 #else
227 throw ErrorClass("This OSSolverService was built without solver dylp");
228 #endif
229
230 else if (sSolverName == "symphony")
231 #ifdef COIN_HAS_SYMPHONY
232 osiSolver = new OsiSymSolverInterface();
233 #else
234 throw ErrorClass("This OSSolverService was built without solver symphony");
235 #endif
236
237 else if (sSolverName == "")
238 { // default solver is Clp in continuous case,
239 // Cbc for an integer program
241 sSolverName.find( "cbc") != std::string::npos ) sSolverName = "cbc";
242 else sSolverName = "clp";
243 osiSolver = new OsiClpSolverInterface();
244 }
245 else
246 throw ErrorClass("Solver selected is not supported by this version of OSSolverService");
247
248 // first check the various solvers and see if they support the given problem type
250 {
251 throw ErrorClass( "This COIN-OR Solver is not configured for nonlinear programming");
252 }
254 (sSolverName.find( "cbc") == std::string::npos) &&
255 (sSolverName.find( "clp") == std::string::npos))
256 {
257 throw ErrorClass( "This COIN-OR Solver is not configured for quadratic programming");
258 }
259 // throw an exception if we have a solver that cannot do integer programming
261 {
262 if( sSolverName.find("clp") != std::string::npos)
263 throw ErrorClass( "Clp cannot do integer programming");
264 if( sSolverName.find("vol") != std::string::npos)
265 throw ErrorClass( "Vol cannot do integer programming");
266 if( sSolverName.find("dylp") != std::string::npos)
267 throw ErrorClass( "DyLP cannot do integer programming");
268 if( sSolverName.find("soplex") != std::string::npos)
269 throw ErrorClass( "SoPlex cannot do integer programming");
270 }
271 // throw an exception if we have a solver that cannot handle semi-continuous or semi-integer variables
273 {
274 throw ErrorClass( "Semi-integer and semi-continuous variables not supported");
275 //if( sSolverName.find("clp") != std::string::npos) throw ErrorClass( "Clp cannot do semi-integer variables");
276 //if( sSolverName.find("vol") != std::string::npos) throw ErrorClass( "Vol cannot do semi-integer variables");
277 //if( sSolverName.find("dylp") != std::string::npos) throw ErrorClass( "DyLP cannot do semi-integer variables");
278 //if( sSolverName.find("soplex") != std::string::npos) throw ErrorClass( "SoPlex cannot do semi-integer variables");
279 }
280 // check other trivial solver limitations
281 //if(osinstance->getConstraintNumber() <= 0)throw ErrorClass("Coin solver:" + sSolverName +" cannot handle unconstrained problems");
282 //if(osinstance->getVariableNumber() <= 0)throw ErrorClass("Coin solver requires decision variables");
284 throw ErrorClass("Coin solver: " + sSolverName + " needs an objective function");
286 throw ErrorClass("Coin solver: " + sSolverName + " can only handle numeric variables");
288 throw ErrorClass("Coin solver: " + sSolverName + " needs a positive number of constraints");
289
290 if(!setCoinPackedMatrix() ) throw ErrorClass("Problem generating coin packed matrix");
296 );
297#ifndef NDEBUG
298 //dataEchoCheck();
299#endif
300 if( osinstance->getObjectiveMaxOrMins()[0] == "min") osiSolver->setObjSense(1.0);
301 else osiSolver->setObjSense(-1.0);
302 // set the integer variables
303 int numOfIntVars
305 if (numOfIntVars > 0)
306 {
307 int *intIndex = NULL;
308 int i = 0;
309 int k = 0;
310 char *varType;
311 intIndex = new int[ numOfIntVars];
312 varType = osinstance->getVariableTypes();
313 for(i = 0; i < osinstance->getVariableNumber(); i++)
314 {
315 if( (varType[i] == 'B') || (varType[i]) == 'I' )
316 {
317 intIndex[k++] = i;
318 }
319 }
320 osiSolver->setInteger( intIndex, numOfIntVars);
321
322 delete[] intIndex;
323 intIndex = NULL;
324 }
325
326 // the clpSolver supports quadratic objectives if present in the input
328 if (nq > 0)
329 {
330 if ( (sSolverName.find("clp") != std::string::npos) )
331 {
332 // get quadratic data, verify objective terms only, convert to sparse matrix format
334
335#ifndef NDEBUG
336 outStr.str("");
337 outStr.clear();
338 outStr << "original arrays:" << std::endl;
339 outStr << " var One indexes:";
340 for (int i=0; i<nq; i++)
341 outStr << " " << qterms->varOneIndexes[i];
342 outStr << std::endl;
343 outStr << " var Two indexes:";
344 for (int i=0; i<nq; i++)
345 outStr << " " << qterms->varTwoIndexes[i];
346 outStr << std::endl;
347 outStr << " coefficients: ";
348 for (int i=0; i<nq; i++)
349 outStr << " " << qterms->coefficients[i];
350 outStr << std::endl;
352 ENUM_OUTPUT_LEVEL_trace, outStr.str());
353#endif
354
355 int ncols = osinstance->getVariableNumber();
356 int* colStarts = new int[ncols+1];
357 for (int i=0; i<=ncols; i++)
358 colStarts[i] = 0;
359
360 //get column lengths
361 for (int i=0; i<nq; i++)
362 {
363 if (qterms->rowIndexes[i] != -1)
364 throw ErrorClass("Clp solver cannot handle quadratic terms in the constraints");
365 else
366 colStarts[qterms->varOneIndexes[i]+1] += 1;
367 }
368
369 // convert column lengths to column starts
370 for (int i=0; i<ncols; i++)
371 colStarts[i+1] += colStarts[i];
372
373 // sort the varOneIndexes array in ascending order
374 // assumptions: 1. Most likely the quadratic terms are sorted already
375 // 2. The order of varTwoIndexes within varOneIndexes does not matter
376 int swapLoc;
377 int iswap;
378 double dswap;
379 for (int i=0; i< ncols-1; i++)
380 {
381 swapLoc = colStarts[i+1];
382 for (int j=colStarts[i]; j<colStarts[i+1]; j++)
383 {
384 if (qterms->varOneIndexes[j] != i)
385 {
386 while ( (qterms->varOneIndexes[swapLoc] != i) && (swapLoc < nq))
387 swapLoc++;
388 if (swapLoc < nq)
389 {
390 iswap = qterms->varOneIndexes[j];
391 qterms->varOneIndexes[j] = qterms->varOneIndexes[swapLoc];
392 qterms->varOneIndexes[swapLoc] = iswap;
393 iswap = qterms->varTwoIndexes[j];
394 qterms->varTwoIndexes[j] = qterms->varTwoIndexes[swapLoc];
395 qterms->varTwoIndexes[swapLoc] = iswap;
396 dswap = qterms->coefficients[j];
397 qterms->coefficients[j] = qterms->coefficients[swapLoc];
398 qterms->coefficients[swapLoc] = dswap;
399#ifndef NDEBUG
400 outStr.str("");
401 outStr.clear();
402 outStr << "swapping locations " << j << " and " << swapLoc << std::endl;
403
404 outStr << "after swap:" << std::endl;
405 outStr << " var One indexes:";
406 for (int i=0; i<nq; i++)
407 outStr << " " << qterms->varOneIndexes[i];
408 outStr << std::endl;
409 outStr << " var Two indexes:";
410 for (int i=0; i<nq; i++)
411 outStr << " " << qterms->varTwoIndexes[i];
412 outStr << std::endl;
413 outStr << " coefficients: ";
414 for (int i=0; i<nq; i++)
415 outStr << " " << qterms->coefficients[i];
416 outStr << std::endl;
418 ENUM_OUTPUT_LEVEL_detailed_trace, outStr.str());
419#endif
420 }
421 else
422 throw ErrorClass("Sorting of quadratic terms failed in OSCoinSolver");
423 }
424 }
425 }
426#ifndef NDEBUG
427 outStr.str("");
428 outStr.clear();
429 outStr << "terminal arrays:" << std::endl;
430 outStr << " var One indexes:";
431 for (int i=0; i<nq; i++)
432 outStr << " " << qterms->varOneIndexes[i];
433 outStr << std::endl;
434 outStr << " var Two indexes:";
435 for (int i=0; i<nq; i++)
436 outStr << " " << qterms->varTwoIndexes[i];
437 outStr << std::endl;
438 outStr << " coefficients: ";
439 for (int i=0; i<nq; i++)
440 outStr << " " << qterms->coefficients[i];
441 outStr << std::endl;
443 ENUM_OUTPUT_LEVEL_trace, outStr.str());
444#endif
445
446 //osiSolver->loadQuadraticObjective(ncols, colStarts, qterms->varTwoIndexes, qterms->coefficients);
447 throw ErrorClass("Quadratic terms not implemented yet");
448 }
449 }
450
452 }
453 catch(const ErrorClass& eclass)
454 {
455 osresult = new OSResult();
459 throw ErrorClass( osrl) ;
460 }
461}//end buildSolverInstance()
462
463
464
466{
467 std::ostringstream outStr;
468
469#ifndef NDEBUG
470 osoutput->OSPrint(ENUM_OUTPUT_AREA_OSSolverInterfaces, ENUM_OUTPUT_LEVEL_debug, "build solver options\n");
471#endif
472 this->bSetSolverOptions = true;
473 // the osi maps (NOTE: These are the only options supported by generic OsiSolverInterface)
474 // the OsiHintParameter Map
475 std::map<std::string, OsiHintParam> hintParamMap;
476 hintParamMap["OsiDoPresolveInInitial"] = OsiDoPresolveInInitial;
477 hintParamMap["OsiDoDualInInitial"] = OsiDoDualInInitial;
478 hintParamMap["OsiDoPresolveInResolve"] = OsiDoPresolveInResolve;
479 hintParamMap["OsiDoDualInResolve"] = OsiDoDualInResolve;
480 hintParamMap["OsiDoScale"] = OsiDoScale;
481 hintParamMap["OsiDoCrash"] = OsiDoCrash;
482 hintParamMap["OsiDoReducePrint"] = OsiDoReducePrint;
483 hintParamMap["OsiDoInBranchAndCut"] = OsiDoInBranchAndCut;
484 hintParamMap["OsiLastHintParam"] = OsiLastHintParam;
485 //
486 // the OsiHintStrength Map
487 std::map<std::string, OsiHintStrength> hintStrengthMap;
488 hintStrengthMap["OsiHintIgnore"] = OsiHintIgnore;
489 hintStrengthMap["OsiHintTry"] = OsiHintTry;
490 hintStrengthMap["OsiHintDo"] = OsiHintDo;
491 hintStrengthMap["OsiForceDo"] = OsiForceDo;
492 //
493 // the OsiStrParam Map
494 std::map<std::string, OsiStrParam> strParamMap;
495 strParamMap["OsiProbName"] = OsiProbName;
496 strParamMap["OsiSolverName"] = OsiSolverName;
497 strParamMap["OsiLastStrParam"] = OsiLastStrParam;
498 //
499 // the OsiDblParam Map
500 std::map<std::string, OsiDblParam> dblParamMap;
501 dblParamMap["OsiDualObjectiveLimit"] = OsiDualObjectiveLimit;
502 dblParamMap["OsiPrimalObjectiveLimit"] = OsiPrimalObjectiveLimit;
503 dblParamMap["OsiDualTolerance"] = OsiDualTolerance;
504 dblParamMap["OsiPrimalTolerance"] = OsiPrimalTolerance;
505 dblParamMap["OsiObjOffset"] = OsiObjOffset;
506 dblParamMap["OsiLastDblParam"] = OsiLastDblParam;
507 //
508 // the OsiIntParam Map
509 std::map<std::string, OsiIntParam> intParamMap;
510 intParamMap["OsiMaxNumIteration"] = OsiMaxNumIteration;
511 intParamMap["OsiMaxNumIterationHotStart"] = OsiMaxNumIterationHotStart;
512 intParamMap["OsiNameDiscipline"] = OsiNameDiscipline;
513 intParamMap["OsiLastIntParam"] = OsiLastIntParam;
514
515 /*
516 * start default settings -- these get set
517 * even when the OSOption object is NULL
518 *
519 * */
520 OsiHintStrength hintStrength = OsiHintTry; //don't want too much output
521 osiSolver->setHintParam(OsiDoReducePrint, true, hintStrength);
522 // it looks like the COIN-OR default is to subtract off the constant rather than add it.
523 // this seems true regardless of max or min
524 osiSolver->setDblParam(OsiObjOffset, -osinstance->getObjectiveConstants()[0]);
525
526 // Set SYMPHONY default print level
527#ifdef COIN_HAS_SYMPHONY
528 if( sSolverName.find( "symphony") != std::string::npos)
529 {
530 OsiSymSolverInterface * si =
531 dynamic_cast<OsiSymSolverInterface *>(osiSolver) ;
532 si->setSymParam("verbosity", -2);
533 }
534#endif //symphony end
535 /*
536 * end default settings
537 *
538 */
539
540 // read option string if necessary
541 try
542 {
543 if(osoption == NULL && osol.length() > 0)
544 {
545 m_osolreader = new OSoLReader();
547 }
548
549// Process any options found
550 if(osoption != NULL)
551 {
552 int i;
553
554#ifndef NDEBUG
555 outStr.str("");
556 outStr.clear();
557 outStr << "number of solver options " << osoption->getNumberOfSolverOptions() << std::endl;
559#endif
561 {
562 //this->bSetSolverOptions = true;
563 std::vector<SolverOption*> optionsVector;
564
565 //get the osi options, which apply to all solvers
566 optionsVector = osoption->getSolverOptions( "osi",true);
567 int num_osi_options = optionsVector.size();
568 char *pEnd;
569 bool yesNo;
570
575 for(i = 0; i < num_osi_options; i++)
576 {
577#ifndef NDEBUG
578 outStr.str("");
579 outStr.clear();
580 outStr << "osi solver option " << optionsVector[ i]->name << std::endl;
581 outStr << "osi solver value " << optionsVector[ i]->value << std::endl;
583 ENUM_OUTPUT_LEVEL_trace, outStr.str());
584#endif
585 if (optionsVector[ i]->type == "OsiHintStrength" )
586 {
587 if( hintStrengthMap.find( optionsVector[ i]->name ) != hintStrengthMap.end() )
588 {
589 hintStrength = hintStrengthMap[ optionsVector[ i]->name] ;
590 }
591 }
592 }
593
597 for(i = 0; i < num_osi_options; i++)
598 {
599#ifndef NDEBUG
600 outStr.str("");
601 outStr.clear();
602 outStr << "osi solver option " << optionsVector[ i]->name << std::endl;
603 outStr << "osi solver value " << optionsVector[ i]->value << std::endl;
605 ENUM_OUTPUT_LEVEL_trace, outStr.str());
606#endif
607 if (optionsVector[ i]->type == "OsiHintParam" )
608 {
609 if( optionsVector[ i]->value == "true" )
610 {
611 yesNo = true;
612 }
613 else
614 {
615 yesNo = false;
616 }
617 if( hintParamMap.find( optionsVector[ i]->name ) != hintParamMap.end() )
618 {
619 osiSolver->setHintParam( hintParamMap[ optionsVector[ i]->name] , yesNo, hintStrength);
620 }
621 }
622 else if(optionsVector[ i]->type == "OsiStrParam" )
623 {
624 if( strParamMap.find( optionsVector[ i]->name ) != strParamMap.end() )
625 {
626 osiSolver->setStrParam( strParamMap[ optionsVector[ i]->name] , optionsVector[ i]->value);
627 }
628 }
629 else if(optionsVector[ i]->type == "OsiDblParam" )
630 {
631 if( dblParamMap.find( optionsVector[ i]->name ) != dblParamMap.end() )
632 {
633 osiSolver->setDblParam( dblParamMap[ optionsVector[ i]->name] , os_strtod( optionsVector[ i]->value.c_str(), &pEnd ));
634 }
635
636 }
637 else if(optionsVector[ i]->type == "OsiIntParam" )
638 {
639 if( intParamMap.find( optionsVector[ i]->name ) != intParamMap.end() )
640 {
641 osiSolver->setIntParam( intParamMap[ optionsVector[ i]->name] , atoi( optionsVector[ i]->value.c_str() ) );
642 }
643 }
644 else if (optionsVector[ i]->type == "bool" )
645 {
646 if( optionsVector[ i]->name == "primalSimplex" )
647 {
648 if (optionsVector[ i]->value != "false")
649 osiSolver->enableSimplexInterface((optionsVector[ i]->value != "false"));
650 }
651 }
652 }
653
654 // Next get all options that are specific to one solver
655
656 if( sSolverName.find( "cbc") != std::string::npos)
657 {
658 // get Cbc options and create a command line for CbcMain1()
659 if(optionsVector.size() > 0) optionsVector.clear();
660 optionsVector = osoption->getSolverOptions( "cbc",true);
661
662 int num_cbc_options = optionsVector.size();
663 char *cstr;
664 std::string cbc_option;
665 num_cbc_argv = optionsVector.size() + 3;
666 cbc_argv = new const char*[ num_cbc_argv];
667
668 // the first option
669 cbc_option = "OS";
670 cstr = new char [cbc_option.size() + 1];
671 strcpy (cstr, cbc_option.c_str());
672 cbc_argv[ 0] = cstr;
673
674 for(i = 0; i < num_cbc_options; i++)
675 {
676#ifndef NDEBUG
677 outStr.str("");
678 outStr.clear();
679 outStr << "cbc solver option " << optionsVector[ i]->name << std::endl;
680 outStr << "cbc solver value " << optionsVector[ i]->name << std::endl;
682 ENUM_OUTPUT_LEVEL_debug, outStr.str());
683#endif
684
685 if(optionsVector[ i]->value.length() > 0 )
686 {
687 cbc_option = "-" + optionsVector[ i]->name +"="+optionsVector[ i]->value;
688 }
689 else
690 {
691 cbc_option = "-" + optionsVector[ i]->name ;
692 }
693 cstr = new char [cbc_option.size() + 1];
694 strcpy (cstr, cbc_option.c_str());
695 cbc_argv[i + 1] = cstr;
696 }
697
698 // the solve option
699 cbc_option = "-solve";
700 cstr = new char [cbc_option.size() + 1];
701 strcpy (cstr, cbc_option.c_str());
702 cbc_argv[ num_cbc_argv - 2] = cstr;
703
704 // the quit option
705 cbc_option = "-quit";
706 cstr = new char [cbc_option.size() + 1];
707 strcpy (cstr, cbc_option.c_str());
708 cbc_argv[ num_cbc_argv - 1] = cstr;
709
710 }//end of cbc if
711
712 // Here we look for options specific to Clp. Use the Cbc interface if there are any
713
714 else if( sSolverName.find( "clp") != std::string::npos)
715 {
716 // get Clp options and create a command line for CbcMain1()
717 if(optionsVector.size() > 0) optionsVector.clear();
718 optionsVector = osoption->getSolverOptions( "clp",true);
719
720 int num_cbc_options = optionsVector.size();
721 if (num_cbc_options > 0)
722 {
723 char *cstr;
724 std::string cbc_option;
725 num_cbc_argv = optionsVector.size() + 3;
726 cbc_argv = new const char*[ num_cbc_argv];
727
728 // the first option
729 cbc_option = "OS";
730 cstr = new char [cbc_option.size() + 1];
731 strcpy (cstr, cbc_option.c_str());
732 cbc_argv[ 0] = cstr;
733
734 for(i = 0; i < num_cbc_options; i++)
735 {
736#ifndef NDEBUG
737 outStr.str("");
738 outStr.clear();
739 outStr << "clp solver option " << optionsVector[ i]->name << std::endl;
740 outStr << "clp solver value " << optionsVector[ i]->name << std::endl;
742 ENUM_OUTPUT_LEVEL_debug, outStr.str());
743#endif
744
745 if(optionsVector[ i]->value.length() > 0 )
746 {
747 cbc_option = "-" + optionsVector[ i]->name +"="+optionsVector[ i]->value;
748 }
749 else
750 {
751 cbc_option = "-" + optionsVector[ i]->name ;
752 }
753 cstr = new char [cbc_option.size() + 1];
754 strcpy (cstr, cbc_option.c_str());
755 cbc_argv[i + 1] = cstr;
756 }
757
758 // the solve option
759 cbc_option = "-solve";
760 cstr = new char [cbc_option.size() + 1];
761 strcpy (cstr, cbc_option.c_str());
762 cbc_argv[ num_cbc_argv - 2] = cstr;
763
764 // the quit option
765 cbc_option = "-quit";
766 cstr = new char [cbc_option.size() + 1];
767 strcpy (cstr, cbc_option.c_str());
768 cbc_argv[ num_cbc_argv - 1] = cstr;
769 }
770 }
771
772 // Options for SYMPHONY
773
774 else if( sSolverName.find( "symphony") != std::string::npos)
775 {
776#ifdef COIN_HAS_SYMPHONY
777 if(optionsVector.size() > 0) optionsVector.clear();
778 //first the number of processors -- applies only to SYMPHONY
779 OsiSymSolverInterface * si =
780 dynamic_cast<OsiSymSolverInterface *>(osiSolver) ;
781
782 optionsVector = osoption->getSolverOptions( "symphony",true);
783 int num_sym_options = optionsVector.size();
784 for(i = 0; i < num_sym_options; i++)
785 {
786#ifndef NDEBUG
787 outStr.str("");
788 outStr.clear();
789 outStr << "symphony solver option " << optionsVector[ i]->name << std::endl;
790 outStr << "symphony solver value " << optionsVector[ i]->name << std::endl;
792#endif
793 if (optionsVector[ i]->type == "OsiStrParam" || optionsVector[ i]->type == "string")
794 {
795 if (!si->setSymParam(optionsVector[ i]->name, optionsVector[ i]->value))
796 throw ErrorClass ("Failed to set Symphony solver option "+optionsVector[ i]->name);
797 }
798 else if (optionsVector[ i]->type == "OsiDblParam" || optionsVector[ i]->type == "double")
799 {
800 if (!si->setSymParam(optionsVector[ i]->name, os_strtod( optionsVector[ i]->value.c_str(), &pEnd )))
801 throw ErrorClass ("Failed to set Symphony solver option "+optionsVector[ i]->name);
802 }
803 else if (optionsVector[ i]->type == "OsiIntParam" || optionsVector[ i]->type == "integer")
804 {
805 if (!si->setSymParam(optionsVector[ i]->name, atoi( optionsVector[ i]->value.c_str() ) ))
806 throw ErrorClass ("Failed to set Symphony solver option "+optionsVector[ i]->name);
807 }
808 }
809#endif //symphony end
810 }
811 }
812
813 //now set initial values
814 int n,m,k;
815 if (osoption != NULL)
817 else
818 m = 0;
819#ifndef NDEBUG
820 outStr.str("");
821 outStr.clear();
822 outStr << "number of variables initialed: " << m << std::endl;
824#endif
825
826 if (m > 0)
827 {
828#ifndef NDEBUG
830#endif
832 double* denseInitVarVector;
833 denseInitVarVector = new double[n];
834 bool* initialed;
835 initialed = new bool[n];
836
837 for(k = 0; k < n; k++)
838 initialed[k] = false;
839
840 InitVarValue** initVarVector = osoption->getInitVarValuesSparse();
841#ifndef NDEBUG
843#endif
844
845 double initval;
846 for(k = 0; k < m; k++)
847 {
848 i = initVarVector[k]->idx;
849 if (initVarVector[k]->idx >= n)
850 throw ErrorClass ("Illegal index value in variable initialization");
851
852 initval = initVarVector[k]->value;
854 {
855 if (osinstance->instanceData->variables->var[k]->lb > initval)
856 throw ErrorClass ("Initial value outside of bounds");
857 }
858 else if (osinstance->instanceData->variables->var[k]->lb == -OSDBL_MAX)
859 {
860 if (osinstance->instanceData->variables->var[k]->ub < initval)
861 throw ErrorClass ("Initial value outside of bounds");
862 }
863 else
864 {
865 if ((osinstance->instanceData->variables->var[k]->lb > initval) ||
866 (osinstance->instanceData->variables->var[k]->ub < initval))
867 throw ErrorClass ("Initial value outside of bounds");
868 }
869
870 denseInitVarVector[initVarVector[k]->idx] = initval;
871 initialed[initVarVector[k]->idx] = true;
872 }
873
874 double default_initval;
875 default_initval = 0.0;
876
877 for(k = 0; k < n; k++)
878 {
879 if (!initialed[k])
880 {
882 if (osinstance->instanceData->variables->var[k]->lb <= default_initval)
883 denseInitVarVector[k] = default_initval;
884 else
885 denseInitVarVector[k] = osinstance->instanceData->variables->var[k]->lb;
886 else if (osinstance->instanceData->variables->var[k]->lb == -OSDBL_MAX)
887 if (osinstance->instanceData->variables->var[k]->ub >= default_initval)
888 denseInitVarVector[k] = default_initval;
889 else
890 denseInitVarVector[k] = osinstance->instanceData->variables->var[k]->ub;
891 else if ((osinstance->instanceData->variables->var[k]->lb <= default_initval) &&
892 (osinstance->instanceData->variables->var[k]->ub >= default_initval))
893 denseInitVarVector[k] = default_initval;
894 else if (osinstance->instanceData->variables->var[k]->lb > default_initval)
895 denseInitVarVector[k] = osinstance->instanceData->variables->var[k]->lb;
896 else
897 denseInitVarVector[k] = osinstance->instanceData->variables->var[k]->ub;
898 }
899// denseInitVarVector[k] = default_initval;
900// denseInitVarVector[k] = osinstance->instanceData->variables->var[k]->lb;
901 }
902#ifndef NDEBUG
903 outStr.str("");
904 outStr.clear();
905 outStr << "set initial values: " << std::endl;
906 for (k=0; k < n; k++)
907 outStr << " " << k << ": " << denseInitVarVector[k] << std::endl;
909#endif
910 osiSolver->setColSolution( denseInitVarVector);
911 delete[] denseInitVarVector;
912 delete[] initialed;
913#ifndef NDEBUG
915#endif
916
917 } // end set initial variable values
918
919
920 // add starting basis --- only supported by Clp
921
922// if (sSolverName == "clp" || sSolverName == "cbc")
923 {
924 if ( osoption != NULL &&
925 osoption->optimization != NULL &&
926 ((osoption->optimization->variables != NULL &&
928 (osoption->optimization->constraints != NULL &&
930
931 /* Only the following statuses are recognized:
932 *
933 * enum Status {
934 * isFree = 0x00, ///< Nonbasic free variable
935 * basic = 0x01, ///< Basic variable
936 * atUpperBound = 0x02, ///< Nonbasic at upper bound
937 * atLowerBound = 0x03 ///< Nonbasic at lower bound
938 * }
939 *
940 * Any others, or any missing statuses, are set to isFree; let Clp deal with it.
941 */
942 {
943 int nsBas,naBas,nsUpp,naUpp,nsLow,naLow,nvar,ncon;
944 int* tmpBas = NULL;
945 CoinWarmStartBasis* warmstart = new CoinWarmStartBasis();
948 warmstart->setSize(nvar, ncon); // this initials everything to isFree
949
950 // pull the number of basis elements of each type
951 if ( osoption->optimization->variables != NULL &&
953 {
957 }
958 else
959 {
960 nsBas = 0;
961 nsUpp = 0;
962 nsLow = 0;
963 }
964 if ( osoption->optimization->constraints != NULL &&
966 {
970 }
971 else
972 {
973 naBas = 0;
974 naUpp = 0;
975 naLow = 0;
976 }
977
978 // get the elements and store them into the Clp warm start object
979 if (nsBas > 0)
980 {
981 tmpBas = new int[nsBas];
983 for (int i=0; i<nsBas; i++)
984 warmstart->setStructStatus(tmpBas[i], (CoinWarmStartBasis::Status)0x01);
985 delete [] tmpBas;
986 }
987 if (naBas > 0)
988 {
989 tmpBas = new int[naBas];
991 for (int i=0; i<naBas; i++)
992 warmstart->setArtifStatus(tmpBas[i], (CoinWarmStartBasis::Status)0x01);
993 delete [] tmpBas;
994 }
995
996 if (nsUpp > 0)
997 {
998 tmpBas = new int[nsUpp];
1000 for (int i=0; i<nsUpp; i++)
1001 warmstart->setStructStatus(tmpBas[i], (CoinWarmStartBasis::Status)0x02);
1002 delete [] tmpBas;
1003 }
1004 if (naUpp > 0)
1005 {
1006 tmpBas = new int[naUpp];
1008 for (int i=0; i<naUpp; i++)
1009 warmstart->setArtifStatus(tmpBas[i], (CoinWarmStartBasis::Status)0x02);
1010 delete [] tmpBas;
1011 }
1012
1013 if (nsLow > 0)
1014 {
1015 tmpBas = new int[nsLow];
1017 for (int i=0; i<nsLow; i++)
1018 warmstart->setStructStatus(tmpBas[i], (CoinWarmStartBasis::Status)0x03);
1019 delete [] tmpBas;
1020 }
1021 if (naLow > 0)
1022 {
1023 tmpBas = new int[naLow];
1025 for (int i=0; i<naLow; i++)
1026 warmstart->setArtifStatus(tmpBas[i], (CoinWarmStartBasis::Status)0x03);
1027 delete [] tmpBas;
1028 }
1029
1030 osiSolver->setWarmStart(warmstart);
1031
1032 } // end if (some basis info available)
1033 } // end if solver = clp
1034
1035 }// end of osoption if
1036
1037#ifndef NDEBUG
1038 osoutput->OSPrint(ENUM_OUTPUT_AREA_OSSolverInterfaces, ENUM_OUTPUT_LEVEL_debug, "solver options set\n");
1039#endif
1040 }//end of try
1041
1042 catch(const ErrorClass& eclass)
1043 {
1045 osresult = new OSResult();
1047 osresult->setGeneralStatusType( "error");
1049 throw ErrorClass( osrl) ;
1050 }
1051}//end setSolverOptions()
1052
1053
1055{
1056 bool columnMajor = osinstance->getLinearConstraintCoefficientMajor();
1057 try
1058 {
1059 double maxGap = 0;
1061 {
1062 m_CoinPackedMatrix = new CoinPackedMatrix(
1063 columnMajor, //Column or Row Major
1064 columnMajor? osinstance->getConstraintNumber() : osinstance->getVariableNumber(), //Minor Dimension
1065 columnMajor? osinstance->getVariableNumber() : osinstance->getConstraintNumber(), //Major Dimension
1066 osinstance->getLinearConstraintCoefficientNumber(), //Number of nonzeroes
1068 columnMajor? osinstance->getLinearConstraintCoefficientsInColumnMajor()->indexes : osinstance->getLinearConstraintCoefficientsInRowMajor()->indexes, //Pointer to start of minor dimension indexes -- change to allow for row storage
1070 0, 0, maxGap );
1071 }
1072 else
1073 {
1074 int* start = new int[osinstance->getVariableNumber()+1];
1075 for (int i=0; i <= osinstance->getVariableNumber(); i++)
1076 start[i] = 0;
1077 m_CoinPackedMatrix = new CoinPackedMatrix(
1078 columnMajor, //Column or Row Major
1079 columnMajor? osinstance->getConstraintNumber() : osinstance->getVariableNumber(), //Minor Dimension
1080 columnMajor? osinstance->getVariableNumber() : osinstance->getConstraintNumber(), //Major Dimension
1081 osinstance->getLinearConstraintCoefficientNumber(), //Number of nonzeroes
1082 NULL, //Pointer to matrix nonzeroes
1083 NULL, //Pointer to start of minor dimension indexes -- change to allow for row storage
1084 start, //Pointers to start of columns.
1085 NULL, 0.0, maxGap );
1086 }
1087
1088
1089 return true;
1090 }
1091 catch(const ErrorClass& eclass)
1092 {
1093 osresult = new OSResult();
1095 osresult->setGeneralStatusType( "error");
1097 throw ErrorClass( osrl) ;
1098 }
1099} // end setCoinPackedMatrix
1100
1102{
1103 std::ostringstream outStr;
1104 if(osresult != NULL) delete osresult;
1105 osresult = new OSResult();
1106 try
1107 {
1108 // make sure the solver instance exists
1109 if( this->bCallbuildSolverInstance == false) buildSolverInstance();
1110 //set the options
1111 if( this->bSetSolverOptions == false) setSolverOptions();
1112 }
1113 catch(const ErrorClass& eclass)
1114 {
1115 throw ErrorClass( osrl) ;
1116 }
1117
1118 // resultHeader information
1119 if(osresult->setSolverInvoked("COIN-OR " + sSolverName) != true)
1120 throw ErrorClass("OSResult error: SetSolverInvoked");
1122 throw ErrorClass("OSResult error: setInstanceName");
1123 //if(osresult->setJobID( osresultdata->jobID) != true)
1124 // throw ErrorClass("OSResult error: setJobID");
1125 //if(osresult->setGeneralMessage( osresultdata->message) != true)
1126 // throw ErrorClass("OSResult error: setGeneralMessage");
1127 // set basic problem parameters
1128
1130 throw ErrorClass("OSResult error: setVariableNumer");
1131 if(osresult->setObjectiveNumber( 1) != true)
1132 throw ErrorClass("OSResult error: setObjectiveNumber");
1134 throw ErrorClass("OSResult error: setConstraintNumber");
1135 if(osresult->setSolutionNumber( 1) != true)
1136 throw ErrorClass("OSResult error: setSolutionNumer");
1137
1138 //
1139 try
1140 {
1141 double start = CoinCpuTime();
1142 try
1143 {
1144 if( (sSolverName.find( "cbc") != std::string::npos) ||
1145 ((sSolverName.find( "clp") != std::string::npos) && num_cbc_argv > 0) )
1146 {
1147 // just use simple branch and bound for anything but cbc
1148 CbcModel model( *osiSolver);
1149
1150 CbcMain0( model);
1151
1152 // make sure we define cbc_argv if not done already when reading options
1153 if(num_cbc_argv <= 0)
1154 {
1155 char *cstr;
1156 std::string cbc_option;
1157 num_cbc_argv = 4;
1158 cbc_argv = new const char*[ num_cbc_argv];
1159
1160 // the first option
1161 cbc_option = "OS";
1162 cstr = new char [cbc_option.size() + 1];
1163 strcpy (cstr, cbc_option.c_str());
1164 cbc_argv[ 0] = cstr;
1165
1166 // the log option -- by default minimal printing
1167 cbc_option = "-log=0";
1168 cstr = new char [cbc_option.size() + 1];
1169 strcpy (cstr, cbc_option.c_str());
1170 cbc_argv[ 1] = cstr;
1171
1172 // the solve option
1173 cbc_option = "-solve";
1174 cstr = new char [cbc_option.size() + 1];
1175 strcpy (cstr, cbc_option.c_str());
1176 cbc_argv[ 2] = cstr;
1177
1178 // the quit option
1179 cbc_option = "-quit";
1180 cstr = new char [cbc_option.size() + 1];
1181 strcpy (cstr, cbc_option.c_str());
1182 cbc_argv[ 3] = cstr;
1183 }
1184 int i;
1185
1187 ENUM_OUTPUT_LEVEL_info, "CALLING THE CBC SOLVER CBCMAIN1()\n");
1188#ifndef NDEBUG
1189 outStr.str("");
1190 outStr.clear();
1191 for(i = 0; i < num_cbc_argv; i++)
1192 {
1193 outStr << sSolverName << " option: " << cbc_argv[ i] << std::endl;
1194 }
1196#endif
1197 CbcMain1( num_cbc_argv, cbc_argv, model);
1198
1199 //do the garbage collection on cbc_argv
1200 for(i = 0; i < num_cbc_argv; i++)
1201 {
1202 delete[] cbc_argv[ i];
1203 cbc_argv[i] = NULL;
1204 }
1205 if( num_cbc_argv > 0)
1206 {
1207 delete[] cbc_argv;
1208 cbc_argv = NULL;
1209 num_cbc_argv = 0;
1210 }
1211
1212 cpuTime = CoinCpuTime() - start;
1213
1214 // create a solver
1215 OsiSolverInterface *solver = model.solver();
1217 {
1218 writeResult( &model);
1219 }
1220 else
1221 {
1222 writeResult( solver);
1223 }
1224 }
1225 else // use other solvers
1226 {
1227 //if an LP just do initial solve
1229 {
1230 osiSolver->branchAndBound();
1231 }
1232 else
1233 {
1234 osiSolver->initialSolve();
1235 }
1236 cpuTime = CoinCpuTime() - start;
1237
1239 }
1240 }
1241
1242 catch(CoinError& e)
1243 {
1244 std::string errmsg;
1245 errmsg = "Coin Solver Error: " + e.message() + "\n" + " see method "
1246 + e.methodName() + " in class " + e.className();
1247 throw ErrorClass( errmsg );
1248 }
1249 }
1250
1251 catch(const ErrorClass& eclass)
1252 {
1253 std::string::size_type pos1 = eclass.errormsg.find( "<osrl");
1254 if(pos1 == std::string::npos)
1255 {
1259 }
1260 else
1261 {
1262 osrl = eclass.errormsg;
1263 }
1264 throw ErrorClass( osrl);
1265 }
1266} // end solve
1267
1268std::string CoinSolver::getCoinSolverType(std::string lcl_osol)
1269{
1270// this is deprecated, but keep it around
1271 try
1272 {
1273 if( lcl_osol.find( "clp") != std::string::npos)
1274 {
1275 return "coin_solver_glpk";
1276 }
1277 else
1278 {
1279 if( lcl_osol.find( "cbc") != std::string::npos)
1280 {
1281 return "coin_solver_cpx";
1282 }
1283 else
1284 {
1285 if( lcl_osol.find( "cpx") != std::string::npos)
1286 {
1287 return "coin_solver_clp";
1288 }
1289 else
1290 {
1291 if(lcl_osol.find( "glpk") != std::string::npos)
1292 {
1293 return "";
1294 }
1295 else throw ErrorClass("a supported solver was not defined");
1296 }
1297 }
1298 }
1299 }
1300 catch(const ErrorClass& eclass)
1301 {
1303 osresult->setGeneralStatusType( "error");
1305 throw ErrorClass( osrl) ;
1306 }
1307} // end getCoinSolverType
1308
1309#ifndef NDEBUG
1311{
1312 int i;
1313 // print out problem parameters
1314 cout << "This is problem: " << osinstance->getInstanceName() << endl;
1315 cout << "The problem source is: " << osinstance->getInstanceSource() << endl;
1316 cout << "The problem description is: " << osinstance->getInstanceDescription() << endl;
1317 cout << "number of variables = " << osinstance->getVariableNumber() << endl;
1318 cout << "number of Rows = " << osinstance->getConstraintNumber() << endl;
1319
1320 // print out the variable information
1321 if(osinstance->getVariableNumber() > 0)
1322 {
1323 for(i = 0; i < osinstance->getVariableNumber(); i++)
1324 {
1325 if(osinstance->getVariableNames() != NULL) cout << "variable Names " << osinstance->getVariableNames()[ i] << endl;
1326 if(osinstance->getVariableTypes() != NULL) cout << "variable Types " << osinstance->getVariableTypes()[ i] << endl;
1327 if(osinstance->getVariableLowerBounds() != NULL) cout << "variable Lower Bounds " << osinstance->getVariableLowerBounds()[ i] << endl;
1328 if(osinstance->getVariableUpperBounds() != NULL) cout << "variable Upper Bounds " << osinstance->getVariableUpperBounds()[i] << endl;
1329 }
1330 }
1331
1332 // print out objective function information
1334 {
1335 if( osinstance->getObjectiveMaxOrMins()[0] == "min") cout << "problem is a minimization" << endl;
1336 else cout << "problem is a maximization" << endl;
1337 for(i = 0; i < osinstance->getVariableNumber(); i++)
1338 {
1339 cout << "OBJ COEFFICIENT = " << osinstance->getDenseObjectiveCoefficients()[0][i] << endl;
1340 }
1341 }
1342 // print out constraint information
1344 {
1345 for(i = 0; i < osinstance->getConstraintNumber(); i++)
1346 {
1347 if(osinstance->getConstraintNames() != NULL) cout << "row name = " << osinstance->getConstraintNames()[i] << endl;
1348 if(osinstance->getConstraintLowerBounds() != NULL) cout << "row lower bound = " << osinstance->getConstraintLowerBounds()[i] << endl;
1349 if(osinstance->getConstraintUpperBounds() != NULL) cout << "row upper bound = " << osinstance->getConstraintUpperBounds()[i] << endl;
1350 }
1351 }
1352
1353 // print out linear constraint data
1354 if(m_CoinPackedMatrix != NULL) m_CoinPackedMatrix->dumpMatrix();
1355} // end dataEchoCheck
1356#endif
1357
1358
1359void CoinSolver::writeResult(OsiSolverInterface *solver)
1360{
1361 double *x = NULL;
1362 double *y = NULL;
1363 double *z = NULL;
1364 int *cbasis = NULL; //column basis information
1365 int *rbasis = NULL; //row basis information
1366 int *idx = NULL;
1367 int kount;
1368
1369 //vectors to hold the basis information
1370 std::vector<int> freeVars;
1371 std::vector<int> basicVars;
1372 std::vector<int> nonBasicLower;
1373 std::vector<int> nonBasicUpper;
1374 std::vector<int>::iterator vit;
1375 int **basisIdx;
1376 basisIdx = new int*[ 4];
1377 //end of vectors
1378
1379 int numberOfVar = solver->getNumCols();
1380 int numberOfCon = solver->getNumRows();
1382 std::string *rcost = NULL;
1383 if ( numberOfVar > 0 ) x = new double[numberOfVar];
1384 if ( numberOfCon > 0 ) y = new double[numberOfCon ];
1385 if ( numberOfVar > 0 ) idx = new int[ numberOfVar];
1386 if ( numberOfVar > 0 ) rcost = new std::string[numberOfVar];
1387 z = new double[1];
1388
1389 //allocate basis if solver supports it (Clp, Cbc, Cplex, Gurobi
1390 bool supportsBasis = false;
1391 if ( (sSolverName.find( "clp") != std::string::npos)
1392 || (sSolverName.find( "cbc") != std::string::npos)
1393 || (sSolverName.find( "cplex") != std::string::npos)
1394 || (sSolverName.find( "gurobi") != std::string::npos) )
1395 {
1396 if (numOfIntVars == 0) // basis information is meaningless for (M)IP
1397 {
1398 if (numberOfVar > 0) cbasis = new int[numberOfVar];
1399 if (numberOfCon > 0) rbasis = new int[numberOfCon];
1400 supportsBasis = true;
1401 }
1402 }
1403
1404 int solIdx = 0;
1405 int i = 0;
1406 int numberOfOtherVariableResults = 1;
1407 int otherIdx = 0;
1408 std::string description = "";
1409
1410 try
1411 {
1412 osresult->setGeneralStatusType("normal");
1415 osresult->setSolverInvoked( "COIN-OR " + sSolverName );
1416 if (solver->isProvenOptimal() == true)
1417 {
1418 osresult->setSolutionStatus(solIdx, "optimal", description);
1419 if ( supportsBasis )
1420 {
1421 solver->getBasisStatus( cbasis, rbasis);
1422 }
1423
1424 }//end if proven optimal
1425 else // some other terminating condition
1426 {
1427 if(solver->isProvenPrimalInfeasible() == true)
1428 osresult->setSolutionStatus(solIdx, "infeasible", "the problem is primal infeasible");
1429 else
1430 {
1431 if(solver->isProvenDualInfeasible() == true)
1432 osresult->setSolutionStatus(solIdx, "unbounded", "the problem is unbounded");
1433 else
1434 {
1435 if(solver->isPrimalObjectiveLimitReached() == true)
1436 {
1437 osresult->setSolutionStatus(solIdx, "other", "primal objective limit reached");
1438 if ( supportsBasis )
1439 {
1440 solver->getBasisStatus( cbasis, rbasis);
1441 }
1442 }
1443 else
1444 {
1445 if(solver->isDualObjectiveLimitReached() == true)
1446 {
1447 osresult->setSolutionStatus(solIdx, "other", "dual objective limit reached");
1448 if ( supportsBasis )
1449 {
1450 solver->getBasisStatus( cbasis, rbasis);
1451 }
1452 }
1453 else
1454 {
1455 if(solver->isIterationLimitReached() == true)
1456 {
1457 osresult->setSolutionStatus(solIdx, "other", "iteration limit reached");
1458 if ( supportsBasis )
1459 {
1460 solver->getBasisStatus( cbasis, rbasis);
1461 }
1462 }
1463 else
1464 {
1465 if(solver->isAbandoned() == true)
1466 osresult->setSolutionStatus(solIdx, "other", "there are numerical difficulties");
1467 else
1468 if( solver->getNumCols() == 0) osresult->setSolutionMessage(solIdx, "Warning: this problem has zero decision variables!");
1469 else
1470 osresult->setSolutionStatus(solIdx, "other", description);
1471 }
1472 }
1473 }
1474 }
1475 }
1476 }
1477
1478 /* Retrieve the solution */
1479 //
1480 *(z + 0) = solver->getObjValue();
1481
1483
1484 for(i=0; i < numberOfVar; i++)
1485 {
1486 *(x + i) = solver->getColSolution()[i];
1487 *(idx + i) = i;
1488
1489 // sort basis information for variables into four categories
1490 if( (cbasis != NULL) && (solver->isProvenOptimal() == true) )
1491 {
1492 switch (cbasis[ i] )
1493 {
1494 case 0:
1495 {
1496 //a free variable
1497 freeVars.push_back( i);
1498 break;
1499 }
1500
1501 case 1:
1502 {
1503 //a basic variable
1504 basicVars.push_back( i);
1505 break;
1506 }
1507
1508 case 2:
1509 {
1510 //nonbasic at upper bound
1511 nonBasicUpper.push_back( i );
1512 break;
1513 }
1514
1515 case 3:
1516 {
1517 //nonbasic at lower bound
1518 nonBasicLower.push_back( i) ;
1519 break;
1520 }
1521 default:
1522 throw ErrorClass("unknown result from Osi getBasisStatus when getting variable basis status");
1523
1524 }//end switch
1525
1526 } //end if on cbasis == NULL
1527
1528 }// end for on number of variables
1529
1530 //now store basis information for variables
1531 if(freeVars.size() > 0)
1532 {
1533 kount = 0;
1534
1535
1536 basisIdx[ 0] = new int[ freeVars.size()];
1537
1538 for(vit = freeVars.begin(); vit < freeVars.end(); vit++)
1539 {
1540 basisIdx[0][ kount++] = *vit;
1541 }
1542
1544 delete[] basisIdx[ 0];
1545 freeVars.clear();
1546 }
1547
1548 if(basicVars.size() > 0)
1549 {
1550 kount = 0;
1551
1552 basisIdx[ 1] = new int[ basicVars.size()];
1553
1554 for(vit = basicVars.begin(); vit < basicVars.end(); vit++)
1555 {
1556 basisIdx[1][ kount++] = *vit;
1557 }
1558
1560 delete[] basisIdx[ 1];
1561 basicVars.clear();
1562 }
1563
1564 if(nonBasicUpper.size() > 0)
1565 {
1566 kount = 0;
1567
1568 basisIdx[ 2] = new int[ nonBasicUpper.size()];
1569
1570 for(vit = nonBasicUpper.begin(); vit < nonBasicUpper.end(); vit++)
1571 {
1572 basisIdx[2][ kount++] = *vit;
1573 }
1574
1576 delete[] basisIdx[ 2];
1577 nonBasicUpper.clear();
1578 }
1579
1580
1581 if(nonBasicLower.size() > 0)
1582 {
1583 kount = 0;
1584
1585 basisIdx[ 3] = new int[ nonBasicLower.size()];
1586
1587 for(vit = nonBasicLower.begin(); vit < nonBasicLower.end(); vit++)
1588 {
1589 basisIdx[3][ kount++] = *vit;
1590 }
1591
1593 delete[] basisIdx[ 3];
1594 nonBasicLower.clear();
1595 }
1596 //end get basis information for variables
1597
1599 // Symphony does not get dual prices
1600 if( sSolverName.find( "symphony") == std::string::npos && osinstance->getNumberOfIntegerVariables() == 0 && osinstance->getNumberOfBinaryVariables() == 0)
1601 {
1602 for(i = 0; i < numberOfCon; i++)
1603 {
1604 *(y + i) = solver->getRowPrice()[ i];
1605
1606 // get basis information
1607 if((rbasis != NULL) && (solver->isProvenOptimal() == true) )
1608 {
1609 switch (rbasis[ i] )
1610 {
1611 case 0:
1612 {
1613 //a free variable
1614 freeVars.push_back( i);
1615 break;
1616 }
1617
1618 case 1:
1619 {
1620 //a basic variable
1621 basicVars.push_back( i);
1622 break;
1623 }
1624
1625 case 2:
1626 {
1627 //nonbasic at upper bound
1628 nonBasicUpper.push_back( i );
1629 break;
1630 }
1631
1632 case 3:
1633 {
1634 //nonbasic at lower bound
1635 nonBasicLower.push_back( i) ;
1636 break;
1637 }
1638 default:
1639 throw ErrorClass("unknown result from Osi getBasisStatus when getting row basis status");
1640
1641 }//end switch
1642
1643 } //end if on rbasis == NULL
1644
1645
1646 }// end for of loop on constraints
1647
1649
1650
1651 //now set basis information for variables
1652 if(freeVars.size() > 0)
1653 {
1654 kount = 0;
1655
1656 basisIdx[ 0] = new int[ freeVars.size()];
1657
1658 for(vit = freeVars.begin(); vit < freeVars.end(); vit++)
1659 {
1660 basisIdx[0][ kount++] = *vit;
1661 }
1662
1664 delete[] basisIdx[ 0];
1665 freeVars.clear();
1666 }
1667
1668 if(basicVars.size() > 0)
1669 {
1670 kount = 0;
1671
1672 basisIdx[ 1] = new int[ basicVars.size()];
1673
1674 for(vit = basicVars.begin(); vit < basicVars.end(); vit++)
1675 {
1676 basisIdx[1][ kount++] = *vit;
1677 }
1678
1680 delete[] basisIdx[ 1];
1681 basicVars.clear();
1682 }
1683
1684 if(nonBasicUpper.size() > 0)
1685 {
1686
1687 kount = 0;
1688
1689 basisIdx[ 2] = new int[ nonBasicUpper.size()];
1690
1691 for(vit = nonBasicUpper.begin(); vit < nonBasicUpper.end(); vit++)
1692 {
1693 basisIdx[2][ kount++] = *vit;
1694 }
1695
1697 delete[] basisIdx[ 2];
1698 nonBasicUpper.clear();
1699 }
1700
1701 if(nonBasicLower.size() > 0)
1702 {
1703 kount = 0;
1704
1705 basisIdx[ 3] = new int[ nonBasicLower.size()];
1706
1707 for(vit = nonBasicLower.begin(); vit < nonBasicLower.end(); vit++)
1708 {
1709 basisIdx[3][ kount++] = *vit;
1710 }
1711
1713 delete[] basisIdx[ 3];
1714 nonBasicLower.clear();
1715
1716 }
1717 //end get basis information for variables
1718
1719
1720 }// end of if on integer variables
1721
1722
1723 // now put the reduced costs into the osrl
1724 // Symphony does not get reduced costs
1725 if( sSolverName.find( "symphony") == std::string::npos && osinstance->getNumberOfIntegerVariables() == 0 && osinstance->getNumberOfBinaryVariables() == 0)
1726 {
1727 // first set the number of Other Variable Results
1728 if(numOfIntVars <= 0)
1729 {
1730 osresult->setNumberOfOtherVariableResults(solIdx, numberOfOtherVariableResults);
1731 for(i=0; i < numberOfVar; i++)
1732 {
1733 rcost[ i] = os_dtoa_format( solver->getReducedCost()[ i]);
1734 }
1735 osresult->setAnOtherVariableResultSparse(solIdx, otherIdx, "reduced_costs", "", "the variable reduced costs", idx, rcost, solver->getNumCols(), "", "double", "");
1736 // end of setting reduced costs
1737 }
1738 }
1739
1740 ostringstream temp;
1741 temp << solver->getIterationCount();
1742 if (!osresult->setAnOtherSolutionResult(0,"iterations",temp.str(),"","",0,NULL))
1743 throw ErrorClass("error setting iteration count");
1744
1746
1747 if (y != NULL)
1748 {
1749 delete[] y;
1750 y = NULL;
1751 }
1752
1753 if (rbasis != NULL)
1754 {
1755 delete[] rbasis;
1756 rbasis = NULL;
1757 }
1758
1759 delete[] z;
1760 z = NULL;
1761
1762 delete[] basisIdx;
1763 basisIdx = NULL;
1764
1765 if (x != NULL)
1766 {
1767 delete[] x;
1768 x = NULL;
1769 }
1770
1771 if (cbasis != NULL)
1772 {
1773 delete[] cbasis;
1774 cbasis = NULL;
1775 }
1776
1777 if (rcost != NULL)
1778 {
1779 delete[] rcost;
1780 rcost = NULL;
1781 }
1782
1783 if (idx != NULL)
1784 {
1785 delete[] idx;
1786 idx = NULL;
1787 }
1788 }
1789
1790 catch(const ErrorClass& eclass)
1791 {
1792 if (y != NULL)
1793 {
1794 delete[] y;
1795 y = NULL;
1796 }
1797
1798 if (rbasis != NULL)
1799 {
1800 delete[] rbasis;
1801 rbasis = NULL;
1802 }
1803
1804 delete[] z;
1805 z = NULL;
1806
1807 delete[] basisIdx;
1808 basisIdx = NULL;
1809
1810 if (x != NULL)
1811 {
1812 delete[] x;
1813 x = NULL;
1814 }
1815
1816 if (cbasis != NULL)
1817 {
1818 delete[] cbasis;
1819 cbasis = NULL;
1820 }
1821
1822 if (rcost != NULL)
1823 {
1824 delete[] rcost;
1825 rcost = NULL;
1826 }
1827
1828 if (idx != NULL)
1829 {
1830 delete[] idx;
1831 idx = NULL;
1832 }
1833
1835 osresult->setGeneralStatusType( "error");
1837 throw ErrorClass( osrl) ;
1838 }
1839}//writeResult(OsiSolverInterface)
1840
1841
1842void CoinSolver::writeResult(CbcModel *model)
1843{
1844 double *x = NULL;
1845 double *y = NULL;
1846
1847 double *z = NULL;
1848 int *idx = NULL;
1849 std::string *rcost = NULL;
1850 //if( osinstance->getVariableNumber() > 0 ) x = new double[osinstance->getVariableNumber() ];
1851 if( model->getNumCols() > 0 ) x = new double[model->getNumCols() ];
1852 if( model->getNumRows() > 0 ) y = new double[model->getNumRows() ];
1853 if( model->getNumCols() > 0 ) idx = new int[ model->getNumCols() ];
1854 z = new double[1];
1855 if( model->getNumCols() > 0 ) rcost = new std::string[ model->getNumCols()];
1856
1857 int numberOfOtherVariableResults = 1;
1858 int otherIdx = 0;
1859 int numberOfVar = model->getNumCols();
1861 int i = 0;
1862 int solIdx = 0;
1863 std::string description = "";
1864 osresult->setGeneralStatusType("normal");
1866
1868
1869 //first determine if we are feasible
1870 int numberIntegerInfeasibilities = 0;
1871 int numberObjectInfeasibilities = 0;
1872 bool isFeasible = false;
1873 isFeasible = model->feasibleSolution( numberIntegerInfeasibilities,
1874 numberObjectInfeasibilities);
1875 std::string statusMsg;
1876 if(isFeasible == true)
1877 {
1878 statusMsg = "feasible";
1879 }
1880 else
1881 {
1882 statusMsg = "infeasible";
1883 }
1884
1885
1886 if (model->isProvenOptimal() == true )
1887 {
1888 osresult->setSolutionStatus(solIdx, "optimal", description);
1889 }
1890 else
1891 {
1892 if(model->isProvenInfeasible() == true)
1893 osresult->setSolutionStatus(solIdx, "infeasible", "the integer program is infeasible");
1894 else
1895 {
1896 if(model->isProvenDualInfeasible() == true)
1897 osresult->setSolutionStatus(solIdx, "infeasible", "the continuous relaxation is dual infeasible");
1898 else
1899 {
1900 if(model->isContinuousUnbounded() == true)
1901 osresult->setSolutionStatus(solIdx, statusMsg, "the continuous relaxation is unbounded");
1902 else
1903 {
1904 if(model->isNodeLimitReached() == true)
1905 osresult->setSolutionStatus(solIdx, statusMsg, "node limit reached");
1906 else
1907 {
1908 if(model->isSecondsLimitReached() == true)
1909 osresult->setSolutionStatus(solIdx, statusMsg, "time limit reached");
1910 else
1911 {
1912 if(model->isSolutionLimitReached() == true)
1913 osresult->setSolutionStatus(solIdx, statusMsg, "solution limit reached");
1914 else
1915 {
1916 if(model->isAbandoned() == true)
1917 osresult->setSolutionStatus(solIdx, statusMsg, "there are numerical difficulties");
1918 else
1919 osresult->setSolutionStatus(solIdx, statusMsg,"unknown");
1920 }
1921 }
1922 }
1923 }
1924 }
1925 }
1926 }
1927
1928 /* Retrieve the solution -- of course it may not be optimal */
1929 if(numOfIntVars > 0) *(z + 0) = model->getObjValue();
1931 for(i=0; i < model->getNumCols(); i++)
1932 {
1933 *(x + i) = model->getColSolution()[i];
1934 *(idx + i) = i;
1935 }
1937 for(i=0; i < model->getNumRows(); i++)
1938 {
1939 *(y + i) = model->getRowPrice()[ i];
1940 }
1941 if(numOfIntVars <= 0) osresult->setDualVariableValuesDense(solIdx, y);
1942 // now put the reduced costs into the osrl
1943 // first set the number of Other Variable Results
1944 if(numOfIntVars <= 0)
1945 {
1946 osresult->setNumberOfOtherVariableResults(solIdx, numberOfOtherVariableResults);
1947 for(i=0; i < numberOfVar; i++)
1948 {
1949 rcost[ i] = os_dtoa_format( model->getReducedCost()[ i]);
1950 }
1951 osresult->setAnOtherVariableResultSparse(solIdx, otherIdx, "reduced_costs", "", "the variable reduced costs", idx, rcost, model->getNumCols());
1952 }
1953 // end of setting reduced costs
1955 //garbage collection
1956 if(model->getNumCols() > 0) delete[] x;
1957 x = NULL;
1958 if(model->getNumRows() > 0) delete[] y;
1959 y = NULL;
1960 delete[] z;
1961 z = NULL;
1962 if(model->getNumCols() > 0)
1963 {
1964 delete[] rcost;
1965 rcost = NULL;
1966 delete[] idx;
1967 idx = NULL;
1968 }
1969}//writeResult( CbcModel)
1970
1971
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
const char ** cbc_argv
when Cbc is the solver, these are the arguments sent to Cbc Solve
virtual void setSolverOptions()
The implementation of the corresponding virtual function.
virtual void buildSolverInstance()
The implementation of the corresponding virtual function.
int num_cbc_argv
the number of arguments in the argument list to the Cbc Solver
CoinPackedMatrix * m_CoinPackedMatrix
m_CoinPackedMatrix is a Coin Packed Matrix ojbect
std::string getCoinSolverType(std::string osol_)
Get the solver type, e.g. clp or glpk.
OSiLReader * m_osilreader
m_osilreader is an OSiLReader object used to create an osinstance from an osil string if needed
OsiSolverInterface * osiSolver
osiSolver is the osi solver object – in this case clp, glpk, cbc, cplex, symphony or dylp
CoinSolver()
The class constructor.
~CoinSolver()
The class destructor.
OSoLReader * m_osolreader
m_osolreader is an OSoLReader object used to create an osoption from an osol string if needed
void writeResult(OsiSolverInterface *solver)
OSrLWriter * osrlwriter
osrlwriter object used to write osrl from an OSResult object
virtual void solve()
The implementation of the corresponding virtual function.
void dataEchoCheck()
Print out problem parameters.
bool setCoinPackedMatrix()
Create a CoinPackedMatrix.
double cpuTime
BasisStatus * initialBasisStatus
initial basis status for the slack variables
Definition OSOption.h:3277
std::string sSolverName
sSolverName is the name of the Coin solver used, e.g.
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
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.
int getNumberOfIntegerVariables()
getNumberOfIntegerVariables
int getNumberOfBinaryVariables()
getNumberOfBinaryVariables
bool getLinearConstraintCoefficientMajor()
Get whether the constraint coefficients is in column major (true) or row major (false).
std::string getInstanceDescription()
Get instance description.
std::string getInstanceSource()
Get instance source.
int getConstraintNumber()
Get number of constraints.
int getNumberOfStringVariables()
getNumberOfStringVariables
int getLinearConstraintCoefficientNumber()
Get number of specified (usually nonzero) linear constraint coefficient values.
int getNumberOfSemiIntegerVariables()
getNumberOfSemiIntegerVariables
SparseMatrix * getLinearConstraintCoefficientsInRowMajor()
Get linear constraint coefficients in row major.
char * getVariableTypes()
Get variable initial values.
SparseMatrix * getLinearConstraintCoefficientsInColumnMajor()
Get linear constraint coefficients in column major.
int getNumberOfSemiContinuousVariables()
getNumberOfSemiContinuousVariables
double ** getDenseObjectiveCoefficients()
getDenseObjectiveCoefficients.
InstanceData * instanceData
A pointer to an InstanceData object.
int getNumberOfNonlinearExpressions()
Get number of nonlinear expressions.
QuadraticTerms * getQuadraticTerms()
Get all the quadratic terms in the instance.
double * getObjectiveConstants()
Get objective constants.
double * getVariableLowerBounds()
Get variable lower bounds.
int getVariableNumber()
Get number of variables.
std::string * getVariableNames()
Get variable names.
std::string getInstanceName()
Get instance name.
std::string * getConstraintNames()
Get constraint names.
std::string * getObjectiveMaxOrMins()
Get objective maxOrMins.
double * getConstraintUpperBounds()
Get constraint upper bounds.
int getObjectiveNumber()
Get number of objectives.
OptimizationOption * optimization
optimizationOption holds the fifth child of the OSOption specified by the OSoL Schema.
Definition OSOption.h:3596
InitVarValue ** getInitVarValuesSparse()
Get the initial values associated with the variables in sparse form.
int getNumberOfInitVarValues()
Get the number of initial variable values.
int getNumberOfInitialBasisElements(int type, int status)
Get the number of initial basis elements for a particular variable type and basis status.
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 getInitialBasisElements(int type, int status, int *elem)
Get the initial basis elements for a particular variable type and basis status.
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 setTime(double time)
Set time.
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.
bool setBasisStatus(int solIdx, int object, int status, int *i, int ni)
Set the basis status of a number of variables/constraints/objectives.
bool setAnOtherSolutionResult(int solIdx, std::string name, std::string value, std::string category, std::string description, int numberOfItems, std::string *item)
Set another solution result of solution [i].
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
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
VariableOption * variables
the options for the variables
Definition OSOption.h:3509
ConstraintOption * constraints
the options for the constraints
Definition OSOption.h:3515
a data structure for holding quadratic terms
Definition OSGeneral.h:432
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
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
BasisStatus * initialBasisStatus
initial basis information
Definition OSOption.h:2110
Variable ** var
Here we define a pointer to an array of var pointers.
Definition OSInstance.h:97
@ ENUM_OUTPUT_LEVEL_detailed_trace
@ ENUM_OUTPUT_LEVEL_debug
@ ENUM_OUTPUT_LEVEL_trace
@ ENUM_OUTPUT_LEVEL_error
@ ENUM_OUTPUT_LEVEL_info
@ ENUM_BASIS_STATUS_isFree
@ ENUM_BASIS_STATUS_basic
@ ENUM_BASIS_STATUS_atLower
@ ENUM_BASIS_STATUS_atUpper
@ ENUM_OUTPUT_AREA_OSSolverInterfaces
@ ENUM_PROBLEM_COMPONENT_constraints
@ ENUM_PROBLEM_COMPONENT_variables
#define OSDBL_MAX