OSDipInterface.cpp
Go to the documentation of this file.
1 /* $Id: OSDipInterface.cpp 3038 2009-11-07 11:43:44Z Gassmann $ */
16 //===========================================================================//
17 
18 
19 #include "OSDipInterface.h"
20 #include "UtilMacrosDecomp.h"
21 
22 //===========================================================================//
23 void OS_DipInterface::readOSiL(std::string & fileName) {
24 
25  FileUtil *fileUtil = NULL;
26  fileUtil = new FileUtil();
27 
28  try {
29 
30  std::string osil;
31  osil = fileUtil->getFileAsString(fileName.c_str());
32  m_osilreader = new OSiLReader();
34 
35  bool columnMajor = false;
36  double maxGap = 0;
37 
38  m_coinpm
39  = new CoinPackedMatrix(
40  columnMajor, //Column or Row Major
41  columnMajor ? m_osinstance->getConstraintNumber()
42  : m_osinstance->getVariableNumber(), //Minor Dimension
43  columnMajor ? m_osinstance->getVariableNumber()
44  : m_osinstance->getConstraintNumber(), //Major Dimension
45  m_osinstance->getLinearConstraintCoefficientNumber(), //Number of nonzeroes
47  : m_osinstance->getLinearConstraintCoefficientsInRowMajor()->values, //Pointer to matrix nonzeroes
49  : m_osinstance->getLinearConstraintCoefficientsInRowMajor()->indexes, //Pointer to start of minor dimension indexes -- change to allow for row storage
51  : m_osinstance->getLinearConstraintCoefficientsInRowMajor()->starts, //Pointers to start of columns.
52  0, 0, maxGap);
53 
54  delete fileUtil;
55  fileUtil = NULL;
56  //kipp -- worry about garbage collection here -- do I delete m_osinstance
57  //delete osilreader;
58  //osilreader = NULL;
59 
60 
61  } catch (const ErrorClass& eclass) {
62  std::cout << "PROBLEM READING OSiL File" << std::endl;
63  delete fileUtil;
64  std::cout << eclass.errormsg << std::endl;
65  fileUtil = NULL;
66  throw ErrorClass(eclass.errormsg);
67 
68  }
69 
70 }//end readOSiL
71 
72 
73 //===========================================================================//
74 void OS_DipInterface::readOSoL(std::string & fileName) {
75 
76  FileUtil *fileUtil = NULL;
77  fileUtil = new FileUtil();
78  try {
79 
80  std::string osol;
81  osol = fileUtil->getFileAsString(fileName.c_str());
82  m_osolreader = new OSoLReader();
84 
85  delete fileUtil;
86  fileUtil = NULL;
87  //kipp -- worry about garbage collection here -- do I delete m_osinstance
88  //delete osilreader;
89  //osilreader = NULL;
90 
91 
92  } catch (const ErrorClass& eclass) {
93  std::cout << "Problem reading OSoL File" << std::endl;
94  delete fileUtil;
95  std::cout << eclass.errormsg << std::endl;
96  fileUtil = NULL;
97  throw ErrorClass(eclass.errormsg);
98 
99  }
100 
101 }// end readOSoL
102 
104 
105  return m_coinpm;
106 }//end getCoinPackedMatrix
107 
108 CoinPackedVector * OS_DipInterface::getRow(int i) {
109 
110  m_row = new CoinPackedVector();
111 
112  int k;
113 
114  SparseMatrix* sm;
115 
117 
118  for (k = sm->starts[i]; k < sm->starts[i + 1]; k++) {
119 
120  m_row->insert(sm->indexes[k], sm->values[k]);
121 
122  }
123 
124  return m_row;
125 }//end getRow
126 
128 
129  int numVars = getVariableNumber();
130  m_integerVars = new char[numVars];
131  int i;
132 
133  for (i = 0; i < numVars; i++) {
134 
135  if (m_osinstance->getVariableTypes()[i] == 'B'
136  || m_osinstance->getVariableTypes()[i] == 'I')
137  m_integerVars[i] = '1';
138  else
139  m_integerVars[i] = '0';
140 
141  }
142  return m_integerVars;
143 
144 }// end getIntegerColumns
145 
146 
148 
149  double offset = 0;
150  //assume only one objective function for now
151 
152  if (getObjectiveConstants() != NULL) {
153  offset = getObjectiveConstants()[0];
154  }
155 
156  return offset;
157 }// end getObjectiveOffset
158 
159 
160 std::vector<std::string> OS_DipInterface::getBlockFactories() {
161 
162  //get the factory solver for each block in the model
163 
164  if (m_blockFactoriesProcessed == true)
165  return m_blockFactories;
166 
167  try {
168  if (m_osoption == NULL)
169  throw ErrorClass("we have a null osoption");
170 
171  std::vector<OtherVariableOption*> otherVariableOptions;
172  std::vector<OtherVariableOption*>::iterator vit;
173 
175  > 0) {
176 
177  otherVariableOptions = m_osoption->getOtherVariableOptions("Dip");
178  //iterate over the vector of variable options
179  for (vit = otherVariableOptions.begin(); vit
180  != otherVariableOptions.end(); vit++) {
181 
182  // right now we assume blocks are ordered -- we ignor value
183  if ((*vit)->name.compare("variableBlockSet") == 0) {
184 
185  if ((*vit)->value.size() > 0) {
186 
187  m_blockFactories.push_back((*vit)->value);
188 
189  } else {
190 
191  m_blockFactories.push_back("");
192  }
193 
194  }
195 
196  }
197  }
198 
199  }//end try
200 
201  catch (const ErrorClass& eclass) {
202 
203  std::cout << eclass.errormsg << std::endl;
204  throw ErrorClass(eclass.errormsg);
205 
206  }
208  return m_blockFactories;
209 }//end getBlockVarIndexes
210 
211 std::vector<std::set<int> > OS_DipInterface::getBlockVarIndexes() {
212 
213  //get the variable indexes for each block in the model
214  std::set<int> varSet; //variables indexes in a specific block
216  return m_blockVariableIndexes;
217 
218  try {
219  if (m_osoption == NULL)
220  throw ErrorClass("we have a null osoption");
221 
222  int numVar;
223  int i;
224  std::vector<OtherVariableOption*> otherVariableOptions;
225  std::vector<OtherVariableOption*>::iterator vit;
226 
228  > 0) {
229 
230  otherVariableOptions = m_osoption->getOtherVariableOptions("Dip");
231  //iterate over the vector of variable options
232  for (vit = otherVariableOptions.begin(); vit
233  != otherVariableOptions.end(); vit++) {
234 
235  // right now we assume blocks are ordered -- we ignor value
236  if ((*vit)->name.compare("variableBlockSet") == 0) {
237 
238  // see if we have a set of block variables
239  // if so we insert into our vector of sets
240  varSet.clear();
241 
242  numVar = (*vit)->numberOfVar;
243 
244  for (i = 0; i < numVar; i++) {
245 
246  if ((*vit)->var[i]->idx
248  throw ErrorClass(
249  "found an invalid varaible index in OSoL file");
250 
251  varSet.insert((*vit)->var[i]->idx);
252 
253  }//end for on variables in this block
254 
255  m_blockVariableIndexes.push_back(varSet);
256  }// end of if
257 
258 
259  }//end for over constraint options
260  }// if on ospton null
261 
262 
263  if (m_blockVariableIndexes.size() <= 0)
264  throw ErrorClass("someting wrong -- no variables in the blocks");
265 
266  } //end try
267 
268  catch (const ErrorClass& eclass) {
269 
270  std::cout << eclass.errormsg << std::endl;
271  throw ErrorClass(eclass.errormsg);
272 
273  }
275  return m_blockVariableIndexes;
276 }//end getBlockVarIndexes
277 
278 
279 std::vector<std::map<int, int> > OS_DipInterface::getBlockConstraintIndexes() {
280 
283  //get the variable indexes for each block in the model
284  std::map<int, int> conMap; //constraint indexes in a specific block
285  std::set<int> varSet; //constraint indexes in a specific block
286  std::set<int> coreConstraintIndexes;
287  std::vector<std::set<int> > blockVariableIndexes;
288 
289  int *starts = NULL;
290  int *indexes = NULL;
291  int kount;
292 
293  try {
294 
295  // first get the block variable indexes, these are necessary
296  blockVariableIndexes = getBlockVarIndexes();
297  // get the core constraint indexes
298  coreConstraintIndexes = getCoreConstraintIndexes();
299 
300  if (blockVariableIndexes.size() <= 0)
301  throw ErrorClass("someting wrong -- no variables in the blocks");
302 
303  std::vector<std::set<int> >::iterator vit;
304  std::set<int>::iterator sit;
305  int i;
306 
307  for (vit = blockVariableIndexes.begin(); vit
308  != blockVariableIndexes.end(); vit++) {
309 
310  varSet.clear();
311  conMap.clear();
312 
313  varSet = *vit;
314  //now get the nonzeros for the variables in
315  //varSet and see which nonzeros are in non-core
316  //constraints
317  kount = 0;
318  for (sit = varSet.begin(); sit != varSet.end(); sit++) {
319 
320  starts
322  indexes
324 
325  for (i = starts[*sit]; i < starts[*sit + 1]; i++) {
326 
327  //add the row index if not in a core constraint
328  //don't count same index twice
329  if (coreConstraintIndexes.find(indexes[i])
330  == coreConstraintIndexes.end() &&
331  (conMap.find(indexes[i] ) == conMap.end() )
332  ) {
333  //we have a new constraint index
334 
335  conMap.insert(std::make_pair(indexes[i], kount));
336  kount++;
337  }
338  }
339  }
340 
341  m_blockConstraintIndexes.push_back(conMap);
342 
343  }//end for iterator
344 
345 
346  } //end try
347 
348  catch (const ErrorClass& eclass) {
349 
350  std::cout << eclass.errormsg << std::endl;
351  throw ErrorClass(eclass.errormsg);
352 
353  }
356 }//end getBlockConstraintIndexes
357 
358 
359 std::vector<OSInstance*> OS_DipInterface::getBlockOSInstances() {
360  //get the OSInstance for each block
361  if (m_blockOSInstancesProcessed == true)
362  return m_blockOSInstances;
363 
364  std::map<int, int> conMap; //constraint indexes in a specific block
365  std::set<int> varSet; //constraint indexes in a specific block
366  std::vector<std::map<int, int> > blockConstraintIndexes;
367  std::set<int> coreConstraintIndexes;
368  std::vector<std::set<int> > blockVariableIndexes;
369 
370  int *starts = NULL;
371  int *indexes = NULL;
372  double *values = NULL;
373 
375  std::vector<std::set<int> >::iterator vit;
376  std::set<int>::iterator sit;
377  std::map<int, int>::iterator mit;
378  int i;
379  int kount;
380 
381  int whichBlock;
382  int numNonz;
383  int k1, k2;
384 
385  //variable stuff
386  int numberVar;
387  std::string* varNames = NULL;
388  char* varTypes = NULL;
389  double* varLowerBounds = NULL;
390  double* varUpperBounds = NULL;
391 
392  //constraint stuff
393  int numberCon;
394  std::string* conNames = NULL;
395  double* conLowerBounds = NULL;
396  double* conUpperBounds = NULL;
397  double* conConstants = NULL;
398 
399  int idx;
400 
401  try {
402 
403  // first get the block variable indexes, these are necessary
404  blockVariableIndexes = getBlockVarIndexes();
405  // get the core constraint indexes
406 
407  coreConstraintIndexes = getCoreConstraintIndexes();
408  // get the block constraint indexes
409 
410  blockConstraintIndexes = getBlockConstraintIndexes();
411 
412  if (blockVariableIndexes.size() <= 0)
413  throw ErrorClass(
414  "someting wrong in getBlockOSInstances() -- no variables in the blocks");
415 
416  //
417  //loop over each block
418  //
419  whichBlock = 0;
420  for (vit = blockVariableIndexes.begin(); vit
421  != blockVariableIndexes.end(); vit++) {
422 
423  varSet.clear();
424  conMap.clear();
425  varSet = *vit;
426 
427  osinstance = new OSInstance();
428  //define variable arrays
429  numberVar = varSet.size();
430  varTypes = new char[numberVar];
431  varNames = new std::string[numberVar];
432  varLowerBounds = new double[numberVar];
433  varUpperBounds = new double[numberVar];
434 
435  //now get the nonzeros for the variables in
436  //varSet and see which nonzeros are in non-core
437  //constraints
438  kount = 0;
439 
440  osinstance->setVariableNumber(numberVar);
441 
442  SparseVector *objcoeff;
443  objcoeff = new SparseVector(numberVar);
444 
445  //need to count the number of nonzero elements
446  //in the block constraints
447  numNonz = 0;
448 
449  for (sit = varSet.begin(); sit != varSet.end(); sit++) {
450 
451  varTypes[kount] = m_osinstance->getVariableTypes()[*sit];
452  varLowerBounds[kount]
454  varUpperBounds[kount]
456 
457  varNames[kount] = m_osinstance->getVariableNames()[*sit];
458 
459  objcoeff->indexes[kount] = kount;
460  //objcoeff->values[kount] = 0.0;
461  objcoeff->values[kount] = m_osinstance->getDenseObjectiveCoefficients()[0][ *sit];
462  numNonz
465 
466  kount++;
467 
468  }//end of loop over the variables in this block
469 
470  osinstance->setVariables(numberVar, varNames, varLowerBounds,
471  varUpperBounds, varTypes);
472 
473  // now the objective function
474  osinstance->setObjectiveNumber(1);
475  // now the coefficient
476  osinstance->addObjective(-1, "objfunction",
477  m_osinstance->getObjectiveMaxOrMins()[0], 0.0, 1.0,
478  objcoeff);
479 
480  conMap = blockConstraintIndexes[whichBlock];
481  numberCon = conMap.size();
482 
483  if (numberCon > 0) {
484 
485  starts = new int[numberVar + 1];
486  indexes = new int[numNonz];
487  values = new double[numNonz];
488  kount = 0;
489  starts[kount] = 0;
490 
491  numNonz = 0;
492  for (sit = varSet.begin(); sit != varSet.end(); sit++) {
493 
494  k2
496  + 1];
497  k1
499 
500  for (i = k1; i < k2; i++) {
501 
502  idx
504 
505  //check to make sure we are not in a core constraint
506  if (coreConstraintIndexes.find(idx)
507  == coreConstraintIndexes.end()) {
508 
509  indexes[numNonz] = conMap[idx];
510  values[numNonz]
512  numNonz++;
513  }
514 
515  }
516  starts[kount + 1] = numNonz;
517 
518  kount++;
519 
520  }
521 
522  //now the constraints
523 
524 
525  osinstance->setConstraintNumber(numberCon);
526  conLowerBounds = new double[numberCon];
527  conUpperBounds = new double[numberCon];
528  conConstants = new double[numberCon];
529 
530  for (mit = conMap.begin(); mit != conMap.end(); mit++) {
531 
532  conLowerBounds[mit->second]
533  = m_osinstance->getConstraintLowerBounds()[mit->first];
534  conUpperBounds[mit->second]
535  = m_osinstance->getConstraintUpperBounds()[mit->first];
536  conConstants[mit->second] = 1.0;
537 
538 
539 
540  }
541 
542  std::cout << "Call setConstraints " << numberCon << std::endl;
543 
544  osinstance->setConstraints(numberCon, conNames, conLowerBounds,
545  conUpperBounds, conConstants);
546 
547  osinstance->setLinearConstraintCoefficients(numNonz, true,
548  values, 0, numNonz - 1, indexes, 0, numNonz - 1,
549  starts, 0, numberVar);
550 
551  }
552 
553  //numNonz--;
554 
555 
556  //add the osinstance
557  m_blockOSInstances.push_back(osinstance);
558 
559  //see what this puppy looks like
560 
561  //std::cout << osinstance->printModel( ) << std::endl;
562 
563  objcoeff->bDeleteArrays = true;
564  delete objcoeff;
565  if (varLowerBounds != NULL)
566  delete[] varLowerBounds;
567  if (varUpperBounds != NULL)
568  delete[] varUpperBounds;
569  if (varTypes != NULL)
570  delete[] varTypes;
571  if (varNames != NULL)
572  delete[] varNames;
573 
574  //delete []starts;
575  //delete []indexes;
576  //delete []values;
577 
578  if (conLowerBounds != NULL)
579  delete[] conLowerBounds;
580  if (conUpperBounds != NULL)
581  delete[] conUpperBounds;
582  if (conConstants != NULL)
583  delete[] conConstants;
584 
585  whichBlock++;
586 
587  }//end for iterator for the blocks
588 
589 
590  } //end try
591 
592  catch (const ErrorClass& eclass) {
593 
594  std::cout << eclass.errormsg << std::endl;
595  throw ErrorClass(eclass.errormsg);
596 
597  }
599  return m_blockOSInstances;
600 
601 }//end getBlockOSInstances()
602 
604 
605  //get the indexes of the core constraints
606 
609  try {
610  if (m_osoption == NULL)
611  throw ErrorClass("we have a null osoption");
612 
613  int numCoreCon;
614  int i;
615  std::vector<OtherConstraintOption*> otherConstraintOptions;
616  std::vector<OtherConstraintOption*>::iterator vit;
617 
618  if (m_osoption != NULL
620 
621  otherConstraintOptions = m_osoption->getOtherConstraintOptions(
622  "Dip");
623  //iterate over the vector of contraint options
624  for (vit = otherConstraintOptions.begin(); vit
625  != otherConstraintOptions.end(); vit++) {
626 
627  // get the core constraints
628  // get the indexes of these constraints
629  if (((*vit)->name.compare("constraintSet") == 0)
630  && ((*vit)->type.compare("Core") == 0)) {
631 
632  numCoreCon = (*vit)->numberOfCon;
633 
634  for (i = 0; i < numCoreCon; i++) {
635 
636  if ((*vit)->con[i]->idx
638  throw ErrorClass(
639  "found an invalid constraint index in OSoL file");
640 
641  m_coreConstraintIndexes.insert((*vit)->con[i]->idx);
642 
643  }//end for on variables in this block
644 
645  }//end iff on core constraints
646 
647 
648  }// end of for on constraint options
649 
650 
651  }//end of if on osptio null
652 
653  if (m_coreConstraintIndexes.size() <= 0)
654  throw ErrorClass(
655  "there were no core constraints listed in the option file");
656  }// end of try
657 
658 
659  catch (const ErrorClass& eclass) {
660 
661  std::cout << eclass.errormsg << std::endl;
662  throw ErrorClass(eclass.errormsg);
663 
664  }
667 
668 }//end getCoreConstraintIndexes
669 
670 
672 
673  //Dip has only one objective function
674 
676 }// end getObjectiveFunctionCoeff()
677 
678 
681 
682  m_isProvenOptimal(false), m_bestKnownLB(-1.e20), m_bestKnownUB(1.e20),
683  m_osinstance(NULL),
684  m_osoption(NULL),
685  m_osilreader(NULL),
686  m_osolreader(NULL),
687  m_integerVars(NULL),
688  m_coinpm(NULL),
689  m_row(NULL),
690  m_blockVariableIndexesProcessed(false),
691  m_coreConstraintIndexesProcessed(false),
692  m_blockConstraintIndexesProcessed(false),
693  m_blockOSInstancesProcessed(false),
694  m_blockFactoriesProcessed(false)
695 {
696 
697 }
698 
700  std::cout << "INSIDE OS DIP INTERFACE DESTRUCTOR" << std::endl;
701  if (m_osilreader != NULL)
702  delete m_osilreader;
703  if (m_osolreader != NULL)
704  delete m_osolreader;
705  delete m_coinpm;
706 
707  std::vector<OSInstance*>::iterator vit;
708 
709  if (m_blockOSInstances.size() > 0) {
710  for (vit = m_blockOSInstances.begin(); vit != m_blockOSInstances.end(); vit++) {
711 
712  delete *vit;
713  }
714  }
715 }
716 
717 
718 
719 std::map<int, std::vector< int> > OS_DipInterface::generateInitialMaster(){
720 
721 
722  // define the classes
723  FileUtil *fileUtil = NULL;
724  OSiLReader *osilreader = NULL;
725  DefaultSolver *solver = NULL;
726  OSInstance *osinstance = NULL;
727  OSOption *osoption = NULL;
728 
729  // end classes
730 
731  std::string testFileName;
732  std::string osil;
733 
734 
735  std::map<int, std::vector< int> > indexMap;
736  std::vector< int> indexes;
737  fileUtil = new FileUtil();
738 
739 
740  try {
741  testFileName = "../data/restrictedMaster5.osil";
742 
743  osil = fileUtil->getFileAsString(testFileName.c_str());
744 
745 #ifdef MY_DEBUG
746  std::cout << "Done reading the file" << std::endl;
747 #endif
748 
749  osilreader = new OSiLReader();
750 
751  //create the osption
752  osoption = new OSOption();
753 
754 #ifdef MY_DEBUG
755  parsingTestResult << "Reading files successfully" << std::endl;
756 #endif
757 
758  osinstance = osilreader->readOSiL(osil);
759 
760  solver = new CoinSolver();
761  solver->sSolverName ="cbc";
762  solver->osinstance = osinstance;
763  solver->osoption = osoption;
764  std::cout << "CALLING SOLVE FOR RESTRICTED MASTER" << std::endl;
765  solver->solve();
766  int i;
767  int j;
768  int k;
769  int vecSize;
770  // now get the primal solution
771  std::vector<IndexValuePair*> primalValPair;
772  primalValPair = solver->osresult->getOptimalPrimalVariableValues( 0);
773  vecSize = primalValPair.size();
774 
775 
776  int numNodes = 5;
777  int numHubs = 1;
778  int totalDemand = 4;
779 
780 
781 
782  int* routeDemand = NULL;
783  int startPnt;
784 
785  routeDemand = new int[ numHubs];
786  int kount;
787 
788  std::string* varNames;
789  varNames = osinstance->getVariableNames();
790 
791  //get route demands
792  kount = 0;
793  for(k = 0; k < numHubs; k++){
794 
795  routeDemand[k ] = (int)primalValPair[ kount]->value;
796 
797  std::cout << "Route Demand = " << routeDemand[k] << std::endl;
798  kount++;
799 
800  }
801 
802  //now get x variable values
803 
804  for(k = 0; k < numHubs; k++){
805 
806  startPnt = k*totalDemand*(numNodes*numNodes - numNodes) + (routeDemand[ k] - 1)*(numNodes*numNodes - numNodes);
807 
808  for(i = 0; i < numNodes; i++){
809 
810 
811  for(j = 0; j < i; j++){
812 
813  if( primalValPair[ kount]->value > .1){
814 
815  std::cout << varNames[ kount] << std::endl;
816  indexes.push_back(startPnt + i*(numNodes-1) + j );
817 
818 
819  }
820 
821  kount++;
822 
823  }
824 
825  for(j = i + 1; j < numNodes; j++){
826 
827 
828  if( primalValPair[ kount]->value > .1){
829  std::cout << varNames[ kount] << std::endl;
830  indexes.push_back(startPnt + i*(numNodes-1) + j -1 );
831 
832 
833  }
834 
835 
836  kount++;
837 
838  }
839 
840  }
841 
842  //create the map
843 
844  indexMap.insert(make_pair(k, indexes));
845 
846  }//end loop on k -- hubs
847 
848 
849  std::cout << "DONE CALLING SOLVE FOR RESTRICTED MASTER" << std::endl;
850 
851 
852 
853  delete[] routeDemand;
854 
855 
856  delete osilreader;
857  osilreader = NULL;
858  delete solver;
859  solver = NULL;
860  delete osoption;
861  osoption = NULL;
862 
863 
864  } catch (const ErrorClass& eclass) {
865  std::cout << std::endl << std::endl << std::endl;
866  if (osilreader != NULL)
867  delete osilreader;
868  if (solver != NULL)
869  delete solver;
870  if (osoption != NULL)
871  delete osoption;
872  // Problem with the parser
873  throw ErrorClass(eclass.errormsg);
874  }
875 
876  delete fileUtil;
877  fileUtil = NULL;
878  return indexMap;
879 
880 }//end generateInitialMaster
double * getConstraintLowerBounds()
Get constraint lower bounds.
double * getVariableLowerBounds()
Get variable lower bounds.
double * getConstraintUpperBounds()
Get constraint upper bounds.
double * values
char * getVariableTypes()
Get variable initial values.
CoinPackedMatrix * getCoinPackedMatrix()
Returns array[getNumCols()] specifying if a variable is integer.
std::vector< OtherConstraintOption * > getOtherConstraintOptions(std::string solver_name)
Get the array of other constraint options.
Definition: OSOption.cpp:4435
bool m_blockOSInstancesProcessed
Returns array[getNumCols()] specifying if a variable is integer.
const int getVariableNumber() const
Get variable number.
int getNumberOfOtherConstraintOptions()
Get the number of other constraint options.
Definition: OSOption.cpp:2195
bool m_coreConstraintIndexesProcessed
Returns array[getNumCols()] specifying if a variable is integer.
bool setLinearConstraintCoefficients(int numberOfValues, bool isColumnMajor, double *values, int valuesBegin, int valuesEnd, int *indexes, int indexesBegin, int indexesEnd, int *starts, int startsBegin, int startsEnd)
set linear constraint coefficients
int getVariableNumber()
Get number of variables.
std::string errormsg
errormsg is the error that is causing the exception to be thrown
Definition: OSErrorClass.h:42
int getLinearConstraintCoefficientNumber()
Get number of specified (usually nonzero) linear constraint coefficient values.
std::vector< IndexValuePair * > getOptimalPrimalVariableValues(int solIdx)
Get one solution of optimal primal variable values.
Definition: OSResult.cpp:2215
OSOption * osoption
std::vector< std::set< int > > m_blockVariableIndexes
Returns array[getNumCols()] specifying if a variable is integer.
OSResult * osresult
osresult holds the solution or result of the model in-memory as an OSResult object ...
bool m_blockVariableIndexesProcessed
Returns array[getNumCols()] specifying if a variable is integer.
CoinPackedMatrix * m_coinpm
double * getObjectiveFunctionCoeff()
Returns array[getNumCols()] specifying if a variable is integer.
OSiLReader * m_osilreader
OSInstance * readOSiL(const std::string &osil)
parse the OSiL model instance.
Definition: OSiLReader.cpp:53
std::string * getVariableNames()
Get variable names.
static char * j
Definition: OSdtoa.cpp:3622
The Option Class.
Definition: OSOption.h:3564
CoinPackedVector * getRow(int i)
Returns array[getNumCols()] specifying if a variable is integer.
int * indexes
indexes holds an integer array of rowIdx (or colIdx) elements in coefMatrix (AMatrix).
Definition: OSGeneral.h:258
virtual void solve()=0
solve is a virtual function – the actual solvers will implement their own solve method ...
double ** getDenseObjectiveCoefficients()
getDenseObjectiveCoefficients.
std::vector< std::set< int > > getBlockVarIndexes()
Returns array[getNumCols()] specifying if a variable is integer.
std::vector< std::map< int, int > > getBlockConstraintIndexes()
Returns array[getNumCols()] specifying if a variable is integer.
~OS_DipInterface()
class destructor
void readOSiL(std::string &filename)
Returns array[getNumCols()] specifying if a variable is integer.
bool setConstraintNumber(int number)
set the number of constraints.
Used to read an OSiL string.
Definition: OSiLReader.h:37
bool bDeleteArrays
bDeleteArrays is true if we delete the arrays in garbage collection set to true by default ...
Definition: OSGeneral.h:149
double getObjectiveOffset()
Returns array[getNumCols()] specifying if a variable is integer.
OSOption * m_osoption
a sparse matrix data structure
Definition: OSGeneral.h:223
SparseMatrix * getLinearConstraintCoefficientsInRowMajor()
Get linear constraint coefficients in row major.
OS_DipInterface()
class constructor
bool setObjectiveNumber(int number)
set the number of objectives.
OSOption * osoption
osoption holds the solver options in-memory as an OSOption object
OSoLReader * m_osolreader
The Default Solver Class.
void fint fint * k
bool addObjective(int index, std::string name, std::string maxOrMin, double constant, double weight, SparseVector *objectiveCoefficients)
add an objective.
std::string * getObjectiveMaxOrMins()
Get objective maxOrMins.
a sparse vector data structure
Definition: OSGeneral.h:122
CoinPackedVector * m_row
SparseMatrix * getLinearConstraintCoefficientsInColumnMajor()
Get linear constraint coefficients in column major.
OSOption * readOSoL(const std::string &osol)
parse the OSoL solver options.
Definition: OSoLReader.cpp:76
bool setVariables(int number, std::string *names, double *lowerBounds, double *upperBounds, char *types)
set all the variable related elements.
static int
Definition: OSdtoa.cpp:2173
double * values
values holds a double array of value elements in coefMatrix (AMatrix), which contains nonzero element...
Definition: OSGeneral.h:264
OSInstance * osinstance
osinstance holds the problem instance in-memory as an OSInstance object
const double * getObjectiveConstants() const
Get objective constants.
std::set< int > getCoreConstraintIndexes()
Returns array[getNumCols()] specifying if a variable is integer.
int getConstraintNumber()
Get number of constraints.
std::string sSolverName
sSolverName is the name of the Coin solver used, e.g.
void readOSoL(std::string &filename)
Returns array[getNumCols()] specifying if a variable is integer.
std::vector< OSInstance * > getBlockOSInstances()
Returns array[getNumCols()] specifying if a variable is integer.
Used to read an OSoL string.
Definition: OSoLReader.h:37
std::vector< std::map< int, int > > m_blockConstraintIndexes
Returns array[getNumCols()] specifying if a variable is integer.
std::vector< OSInstance * > m_blockOSInstances
Returns array[getNumCols()] specifying if a variable is integer.
std::vector< std::string > getBlockFactories()
Returns array[getNumCols()] specifying if a variable is integer.
Implements a solve method for the Coin solvers.
Definition: OSCoinSolver.h:37
std::string getFileAsString(const char *fname)
read a file and return contents as a string.
Definition: OSFileUtil.cpp:35
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 nonzero values.
Definition: OSGeneral.h:164
double * getVariableUpperBounds()
Get variable upper bounds.
const char * getIntegerColumns()
Returns array[getNumCols()] specifying if a variable is integer.
bool m_blockConstraintIndexesProcessed
Returns array[getNumCols()] specifying if a variable is integer.
int * indexes
indexes holds an integer array of indexes whose corresponding values are nonzero. ...
Definition: OSGeneral.h:159
OSInstance * m_osinstance
int getNumberOfOtherVariableOptions()
Get the number of other variable options.
Definition: OSOption.cpp:2122
std::vector< std::string > m_blockFactories
Returns array[getNumCols()] specifying if a variable is integer.
bool setVariableNumber(int number)
set the number of variables.
The in-memory representation of an OSiL instance..
Definition: OSInstance.h:2262
OSInstance * osinstance
class used to make it easy to read and write files.
Definition: OSFileUtil.h:37
bool setConstraints(int number, std::string *names, double *lowerBounds, double *upperBounds, double *constants)
set all the constraint related elements.
std::set< int > m_coreConstraintIndexes
Returns array[getNumCols()] specifying if a variable is integer.
used for throwing exceptions.
Definition: OSErrorClass.h:31
bool m_blockFactoriesProcessed
Returns array[getNumCols()] specifying if a variable is integer.
std::map< int, std::vector< int > > generateInitialMaster()
Returns array[getNumCols()] specifying if a variable is integer.
std::vector< OtherVariableOption * > getOtherVariableOptions(std::string solver_name)
Get the &lt;other&gt; variable options associated with a particular solver.
Definition: OSOption.cpp:3315