OSCsdpSolver.cpp
Go to the documentation of this file.
1 /* $Id: OSCsdpSolver.cpp 4787 2014-01-22 22:26:56Z Gassmann $ */
20 #include "OSCsdpSolver.h"
21 #include "OSFileUtil.h"
22 #include "OSInstance.h"
23 #include "OSOption.h"
24 #include "OSGeneral.h"
25 #include "OSMatrix.h"
26 #include "OSrLReader.h"
27 #include "OSOutput.h"
28 #include "OSParameters.h"
29 #include "OSMathUtil.h"
30 
31 #include "CoinTime.hpp"
32 
33 #include <map>
34 
35 #include <iostream>
36 #ifdef HAVE_CTIME
37 # include <ctime>
38 #else
39 # ifdef HAVE_TIME_H
40 # include <time.h>
41 # else
42 # error "don't have header file for time"
43 # endif
44 #endif
45 
46 using std::cout;
47 using std::endl;
48 using std::ostringstream;
49 
50 
52 {
53 #ifndef NDEBUG
55  "inside CsdpSolver constructor\n");
56 #endif
57  osrlwriter = new OSrLWriter();
58  osresult = new OSResult();
59  m_osilreader = NULL;
60  m_osolreader = NULL;
61  csdpErrorMsg = new std::string("");
62 }
63 
65 {
66 #ifndef NDEBUG
67  osoutput->OSPrint(ENUM_OUTPUT_AREA_OSSolverInterfaces, ENUM_OUTPUT_LEVEL_debug, "inside CsdpSolver destructor\n");
68 #endif
69  if(m_osilreader != NULL) delete m_osilreader;
70  m_osilreader = NULL;
71  if(m_osolreader != NULL) delete m_osolreader;
72  m_osolreader = NULL;
73  delete osresult;
74  osresult = NULL;
75  delete osrlwriter;
76  osrlwriter = NULL;
77  //delete osinstance;
78  //osinstance = NULL;
79  delete csdpErrorMsg;
80 #ifndef NDEBUG
81  osoutput->OSPrint(ENUM_OUTPUT_AREA_OSSolverInterfaces, ENUM_OUTPUT_LEVEL_trace, "Leaving CsdpSolver destructor\n");
82 #endif
83 }
84 
86 {
87  std::ostringstream outStr;
88  ScalarExpressionTree* tempTree;
89  OSnLNode *tr;
90  OSnLMNode *mt;
91  OSnLMNode *mr;
92  OSnLMNode *mv;
93  OSMatrix* tempMtx;
94 
95  int* blockOffset = NULL;
96  int* blockSize = NULL;
97  int* mtxRef = NULL;
98  bool* isdiag = NULL;
99  ExpandedMatrixBlocks** mtxBlocks;
100  try
101  {
102  if(osil.length() == 0 && osinstance == NULL) throw ErrorClass("there is no instance");
103  clock_t start, finish;
104  double duration;
105  start = clock();
106  if(osinstance == NULL)
107  {
108  m_osilreader = new OSiLReader();
110  }
111  finish = clock();
112  duration = (double) (finish - start) / CLOCKS_PER_SEC;
113 
114  /* Process the osinstance into the --- rather tricky --- CSDP data structures
115  * and verify that the solver is appropriate - CSDP requires a very special type of problem
116  */
117 
118  // Check general problem characteristics
120  throw ErrorClass("There must be one matrixVar object");
122  throw ErrorClass("There must be one nonlinear expression for each constraint and objective");
124  throw ErrorClass("Additional linear constraint coefficients are not supported");
126  throw ErrorClass("Additional quadratic terms are not supported");
127 
128  char* cType = osinstance->getConstraintTypes();
129  for (int i=0; i < osinstance->getConstraintNumber(); i++)
130  if (cType[i] != 'E') throw ErrorClass("Only equality constraints are supported");
131 
132  std::string* oType = osinstance->getObjectiveMaxOrMins();
133  if (oType[0] != "max") throw ErrorClass("The problem must be of \"max\" type");
134 
135  //Check the form of the objective
136  tempTree = osinstance->getNonlinearExpressionTree(-1);
137  if (tempTree == NULL) throw ErrorClass("Expecting matrixTrace in objective row");
138  tr = tempTree->m_treeRoot;
139  if (tr->inodeInt != OS_MATRIX_TRACE)
140  throw ErrorClass("Expecting matrixTrace in objective row");
141  mt = tr->m_mMatrixChildren[0];
142  if (mt->inodeInt != OS_MATRIX_TIMES)
143  throw ErrorClass("Unsupported expression in objective row");
144  mr = mt->m_mMatrixChildren[0];
145  mv = mt->m_mMatrixChildren[1];
146  if (mr->inodeInt != OS_MATRIX_REFERENCE || mv->inodeInt != OS_MATRIX_VAR)
147  throw ErrorClass("Unsupported expression in objective row");
148 
149  mtxRef = new int[osinstance->getConstraintNumber()+1];
150 
151  // Analyze A0 matrix: Verify existence, block-diagonal structure, get block dimensions, etc.
152  mtxRef[0] = ((OSnLMNodeMatrixReference*)mr)->idx;
153  if (osinstance->instanceData->matrices == NULL)
154  throw ErrorClass("<matrices> section was never defined");
155  if (mtxRef[0] < 0 || mtxRef[0] >= osinstance->getMatrixNumber())
156  throw ErrorClass("Illegal matrix reference");
157  tempMtx = osinstance->instanceData->matrices->matrix[mtxRef[0]];
158  if (tempMtx == NULL) throw ErrorClass("A0 matrix was never defined");
159  if (tempMtx->numberOfRows != tempMtx->numberOfColumns)
160  throw ErrorClass("A0 matrix must be square and symmetric");
161  if (tempMtx->getMatrixType() != ENUM_MATRIX_TYPE_constant)
162  throw ErrorClass("A0 matrix must be of type \"constant\"");
163 
164  int* rowOffsets = tempMtx->getRowPartition();
165  int nRowBlocks = tempMtx->getRowPartitionSize();
166  int* columnOffsets = tempMtx->getColumnPartition();
167  int nColumnBlocks = tempMtx->getColumnPartitionSize();
168 
169  int* tempRowOffsets;
170  int tempNRowBlocks;
171  int* tempColumnOffsets;
172  int tempNColumnBlocks;
173 
174  int i0, itemp, imerge;
175 
176  //do the same for all constraints
177  for (int i=0; i < osinstance->getConstraintNumber(); i++)
178  {
179  tempTree = osinstance->getNonlinearExpressionTree(i);
180  if (tempTree == NULL) throw ErrorClass("Expecting matrixTrace in constraint row");
181  tr = tempTree->m_treeRoot;
182  if (tr->inodeInt != OS_MATRIX_TRACE)
183  throw ErrorClass("Expecting matrixTrace in constraint row");
184  mt = tr->m_mMatrixChildren[0];
185  if (mt->inodeInt != OS_MATRIX_TIMES)
186  throw ErrorClass("Unsupported expression in constraint row");
187  mr = mt->m_mMatrixChildren[0];
188  mv = mt->m_mMatrixChildren[1];
189  if (mr->inodeInt != OS_MATRIX_REFERENCE || mv->inodeInt != OS_MATRIX_VAR)
190  throw ErrorClass("Unsupported expression in constraint row");
191 
192  // Analyze Ai matrix: Verify existence, block-diagonal structure, get block dimensions, etc.
193  mtxRef[i+1] = ((OSnLMNodeMatrixReference*)mr)->idx;
194  if (mtxRef[i+1] < 0 || mtxRef[i+1] >= osinstance->getMatrixNumber())
195  throw ErrorClass("Illegal matrix reference");
196  tempMtx = osinstance->instanceData->matrices->matrix[mtxRef[i+1]];
197  if (tempMtx == NULL) throw ErrorClass("Matrix in constraint was never defined");
198  if (tempMtx->numberOfRows != tempMtx->numberOfColumns)
199  throw ErrorClass("Constraint matrix must be square and symmetric");
200  if (tempMtx->getMatrixType() != ENUM_MATRIX_TYPE_constant)
201  throw ErrorClass("Constraint matrix must be of type \"constant\"");
202 
203  tempRowOffsets = tempMtx->getRowPartition();
204  tempNRowBlocks = tempMtx->getRowPartitionSize();
205  tempColumnOffsets = tempMtx->getColumnPartition();
206  tempNColumnBlocks = tempMtx->getColumnPartitionSize();
207 
208  // merge row partitions
209  i0 = 0;
210  itemp = 0;
211  imerge = 0;
212  for (;;)
213  {
214  if (rowOffsets[i0] == tempRowOffsets[itemp])
215  {
216  if (imerge != i0) rowOffsets[imerge] = rowOffsets[i0];
217  i0++;
218  itemp++;
219  imerge++;
220  }
221  else
222  {
223  if (rowOffsets[i0] < tempRowOffsets[itemp])
224  i0++;
225  else
226  itemp++;
227  }
228  if (i0 >= nRowBlocks || itemp >= tempNRowBlocks)
229  break;
230  }
231  nRowBlocks = imerge;
232 
233  // merge column partititons
234  i0 = 0;
235  itemp = 0;
236  imerge = 0;
237  for (;;)
238  {
239  if (columnOffsets[i0] == tempColumnOffsets[itemp])
240  {
241  if (imerge != i0) columnOffsets[imerge] = columnOffsets[i0];
242  i0++;
243  itemp++;
244  imerge++;
245  }
246  else
247  {
248  if (columnOffsets[i0] < tempColumnOffsets[itemp])
249  i0++;
250  else
251  itemp++;
252  }
253  if (i0 >= nColumnBlocks || itemp >= tempNColumnBlocks)
254  break;
255  }
256  nColumnBlocks = imerge;
257  }
258 
259  blockOffset = new int[nRowBlocks]; // step this through: nRowBlocks=?
260 
261  // make sure the row and column blocks are synchronized and compute block sizes
262  int nBlocks;
263  int jrow = 0;
264  int jcol = 0;
265  nBlocks = 0;
266  for (;;)
267  {
268  if (rowOffsets[jrow] == columnOffsets[jcol])
269  {
270  blockOffset[nBlocks] = rowOffsets[jrow];
271  jrow++;
272  jcol++;
273  nBlocks++;
274  }
275  else
276  {
277  if (rowOffsets[jrow] < columnOffsets[jcol])
278  jrow++;
279  else
280  jcol++;
281  }
282  if (jrow >= nRowBlocks || jcol >= nColumnBlocks)
283  break;
284  }
285 
286  // Note: nBlocks is one larger than the number of blocks.
287  // blockSize is 1-based, due to issues of Fortran compatibility,
288  // so we will burn off blockSize[0] anyway...
289  blockSize = new int[nBlocks];
290  for (int i=1; i < nBlocks; i++)
291  {
292 #ifndef NOSHORTS
293  if (blockOffset[i] - blockOffset[i-1] >= USHRT_MAX)
294  throw ErrorClass("This problem is too large to be solved by this version of the code!\n"
295  + "Recompile without -DUSERSHORTINDS to fix the problem.\n");
296 #endif
297  blockSize[i] = blockOffset[i] - blockOffset[i-1];
298  }
299 
300  nC_rows = blockOffset[nBlocks-1];
301  nC_blks = nBlocks-1;
303 
304 #ifndef NOSHORTS
305 
306  if (ncon >= USHRT_MAX)
307  throw ErrorClass("This problem is too large to be solved by this version of the code!\n"
308  + "Recompile without -DUSERSHORTINDS to fix the problem.\n");
309 
310  if (nBlocks >= USHRT_MAX)
311  throw ErrorClass("This problem is too large to be solved by this version of the code!\n"
312  + "Recompile without -DUSERSHORTINDS to fix the problem.\n");
313 #endif
314 
315 #ifndef BIT64
316  /*
317  * If operating in 32 bit mode, make sure that the dimension mDIM isn't
318  * too big for 32 bits. If we don't do this check, then integer overflow
319  * won't be detected, and we'll allocate a bogus amount of storage.
320  */
321  if (ncon > 23169)
322  throw ErrorClass("This problem is too large to be solved in 32 bit mode!\n");
323 #endif
324 
325  // set up the right hand side values. Note: 1-based for Fortran interface.
327 
328  // Set up storage and retrieve pointers.
329  mtxBlocks = new ExpandedMatrixBlocks*[ncon+1];
330  GeneralSparseMatrix* tmpBlock;
331 
332  // At this point we know the dimensions of all blocks.
333  // Keep track of diagonal blocks. Note: isdiag is 1-indexed
334  isdiag = new bool[nBlocks];
335  for (int i=1; i<nBlocks; i++)
336  isdiag[i] = true;
337 
338  for (int j=0; j < ncon+1; j++)
339  {
340  mtxBlocks[j] = osinstance->instanceData->matrices->matrix[mtxRef[j]]
341  ->getBlocks(blockOffset,nBlocks,blockOffset,nBlocks,false,true);
342 
343  if (!mtxBlocks[j]->isBlockDiagonal())
344  throw ErrorClass("Constraint matrix must be block-diagonal");
345 
346  for (int i=0; i<nBlocks-1; i++)
347  {
348  tmpBlock = mtxBlocks[j]->getBlock(i,i);
349  if (tmpBlock != NULL && !(tmpBlock->isDiagonal()))
350  isdiag[i+1] = false;
351  }
352  }
353 
355  C_matrix.nblocks=nBlocks-1;
356  C_matrix.blocks = new blockrec[nBlocks];
357 
359  for (int blk=1; blk < nBlocks; blk++)
360  {
361  tmpBlock = mtxBlocks[0]->getBlock(blk-1,blk-1);
362  int blksz = blockSize[blk];
363  if (isdiag[blk] == 1)
364  {
365  // diagonal block
366  C_matrix.blocks[blk].blocksize = blksz;
367  C_matrix.blocks[blk].blockcategory = DIAG;
368  C_matrix.blocks[blk].data.vec = new double[blksz+1];
369 
370  for (int i=1; i<=blksz; i++)
371  C_matrix.blocks[blk].data.vec[i] = 0.0;
372 
373  if (tmpBlock != NULL)
374  {
375  for (int i=0; i < tmpBlock->valueSize; i++)
376  C_matrix.blocks[blk].data.vec[tmpBlock->index[i]+1]
377  = ((ConstantMatrixValues*)tmpBlock->value)->el[i];
378  }
379  }
380  else
381  {
382  // There are off-diagonals (i.e., "matrix block")
383  C_matrix.blocks[blk].blocksize = blksz;
384  C_matrix.blocks[blk].blockcategory = MATRIX;
385  C_matrix.blocks[blk].data.mat = new double[blksz*blksz];
386 
387  for (int i=1; i<=blksz; i++)
388  for (int j=1; j<=blksz; j++)
389  C_matrix.blocks[blk].data.mat[ijtok(i,j,blksz)] = 0.0;
390 
391  if (tmpBlock != NULL)
392  {
393  for (int i=1; i < tmpBlock->startSize; i++)
394  for (int j=tmpBlock->start[i-1]; j<tmpBlock->start[i]; j++)
395  {
396  C_matrix.blocks[blk].data.mat[ijtok(i,tmpBlock->index[j]+1,blksz)]
397  = ((ConstantMatrixValues*)tmpBlock->value)->el[j];
398  C_matrix.blocks[blk].data.mat[ijtok(tmpBlock->index[j]+1,i,blksz)]
399  = ((ConstantMatrixValues*)tmpBlock->value)->el[j];
400  }
401  }
402  }
403  }
404 
406  mconstraints = new constraintmatrix[ncon+1];
407 
409  for (int i=1; i<=ncon; i++)
410  {
411  mconstraints[i].blocks = NULL;
412  }
413 
414  struct sparseblock *p;
415  struct sparseblock *q;
416  struct sparseblock *prev;
417 
422  for (int i=1; i<=ncon; i++)
423  {
424  prev = NULL;
425  for (int blk=1; blk < nBlocks; blk++)
426  {
427  tmpBlock = mtxBlocks[i]->getBlock(blk-1,blk-1);
428  if (tmpBlock != NULL && tmpBlock->valueSize > 0)
429  {
434  p = new sparseblock();
435  p->numentries = tmpBlock->valueSize;
436  p->entries = new double[p->numentries+1];
437 #ifdef NOSHORTS
438  p->iindices = new int[p->numentries+1];
439  p->jindices = new int[p->numentries+1];
440 #else
441  p->iindices = new unsigned short[p->numentries+1];
442  p->jindices = new unsigned short[p->numentries+1];
443 #endif
444  p->blocknum = blk;
445  p->blocksize = blockSize[blk];
446  p->constraintnum = i;
447  p->next = NULL;
448  p->nextbyblock = NULL;
449  if (((p->numentries) > 0.25*(p->blocksize)) && ((p->numentries) > 15))
450  p->issparse=0;
451  else
452  p->issparse=1;
453 
454  // Note: everything is 1-indexed, so both locations and indices are shifted
455  for (int icol=1; icol < tmpBlock->startSize; icol++)
456  for (int jent=tmpBlock->start[icol-1]; jent<tmpBlock->start[icol]; jent++)
457  {
458  p->iindices[jent+1] = icol;
459  p->jindices[jent+1] = tmpBlock->index[jent] + 1;
460  p->entries [jent+1] = ((ConstantMatrixValues*)tmpBlock->value)->el[jent];
461  }
462 
463  if (prev == NULL)
464  {
465  mconstraints[i].blocks = p;
466  }
467  else
468  {
469  prev->next = p;
470  prev->nextbyblock = p;
471  }
472  prev = p;
473  }
474  }
475  }
476 
477  //garbage collection
478  if (blockOffset != NULL) delete [] blockOffset;
479  if (blockSize != NULL) delete [] blockSize;
480  if (mtxRef != NULL) delete [] mtxRef;
481  if (isdiag != NULL) delete [] isdiag;
482  if (mtxBlocks != NULL)
483  {
484  for (int i=0; i < ncon+1; i++)
485  {
486  if (mtxBlocks[i] != NULL) delete mtxBlocks[i];
487  mtxBlocks[i] = NULL;
488  }
489  delete []mtxBlocks;
490  }
491 
492  this->bCallbuildSolverInstance = true;
493  return;
494  }
495 
496  catch(const ErrorClass& eclass)
497  {
498  if (blockOffset != NULL) delete [] blockOffset;
499  if (blockSize != NULL) delete [] blockSize;
500  if (mtxRef != NULL) delete [] mtxRef;
501  if (isdiag != NULL) delete [] isdiag;
502  {
503  for (int i=0; i <= ncon; i++)
504  {
505  if (mtxBlocks[i] != NULL) delete mtxBlocks[i];
506  mtxBlocks[i] = NULL;
507  }
508  delete []mtxBlocks;
509  }
510 
511  osresult = new OSResult();
513  osresult->setGeneralStatusType( "error");
515  throw ErrorClass( osrl);
516  }
517 
518 }// end buildSolverInstance()
519 
520 
522 {
533  struct paramstruc params;
534 
535  std::ostringstream outStr;
536  std::ostringstream optStr;
537  int printlevel = 0;
538 
539  try
540  {
541  /* get options from OSoL */
542  if(osoption == NULL && osol.length() > 0)
543  {
544  m_osolreader = new OSoLReader();
546  }
547 
548  if( osoption != NULL && osoption->getNumberOfSolverOptions() > 0 )
549  {
550 #ifndef NDEBUG
551  outStr.str("");
552  outStr.clear();
553  outStr << "number of solver options ";
554  outStr << osoption->getNumberOfSolverOptions();
555  outStr << std::endl;
557 #endif
558 
559  std::vector<SolverOption*> optionsVector;
560  optionsVector = osoption->getSolverOptions( "csdp",true);
561  char *pEnd;
562  int i;
563  int num_ipopt_options = optionsVector.size();
564  for(i = 0; i < num_ipopt_options; i++)
565  {
566 #ifndef NDEBUG
567  outStr.str("");
568  outStr.clear();
569  outStr << "csdp solver option ";
570  outStr << optionsVector[ i]->name;
571  outStr << std::endl;
573 #endif
574  optStr << optionsVector[ i]->name << "=" << optionsVector[ i]->value << std::endl;
575  }
576 
577  FILE *paramfile;
578  paramfile=fopen("param.csdp","w");
579  if (!paramfile)
580  throw ErrorClass("File open error during option initialization");
581 
582  fprintf(paramfile,"%s",(optStr.str()).c_str());
583  fclose(paramfile);
584  }
585  bSetSolverOptions = true;
586  return;
587  }
588  catch(const ErrorClass& eclass)
589  {
591  "Error in setSolverOption\n");
593  osresult->setGeneralStatusType( "error");
595  throw ErrorClass( osrl);
596  }
597 }//setSolverOptions
598 
599 
600 #if 0
601 void CsdpSolver::setInitialValues() throw (ErrorClass)
602 {
603  std::ostringstream outStr;
604  try
605  {
606  if(osinstance->getObjectiveNumber() <= 0)
607  throw ErrorClass("Ipopt NEEDS AN OBJECTIVE FUNCTION\n(For pure feasibility problems, use zero function.)");
608  this->bSetSolverOptions = true;
609  /* set the default options */
610  //app->Options()->SetNumericValue("tol", 1e-9);
611  app->Options()->SetIntegerValue("print_level", 0);
612  app->Options()->SetIntegerValue("max_iter", 20000);
613  app->Options()->SetNumericValue("bound_relax_factor", 0, true, true);
614  app->Options()->SetStringValue("mu_strategy", "adaptive", true, true);
615  //app->Options()->SetStringValue("output_file", "ipopt.out");
616  app->Options()->SetStringValue("check_derivatives_for_naninf", "yes");
617  // hessian constant for an LP
620  {
621  app->Options()->SetStringValue("hessian_constant", "yes", true, true);
622  }
623  if(osinstance->getObjectiveNumber() > 0)
624  {
625  if( osinstance->instanceData->objectives->obj[ 0]->maxOrMin.compare("min") != 0)
626  {
627  app->Options()->SetStringValue("nlp_scaling_method", "user-scaling");
628  }
629  }
630  /* end of the default options, now get options from OSoL */
631 
632 
633  if(osoption == NULL && osol.length() > 0)
634  {
635  m_osolreader = new OSoLReader();
637  }
638 
639  if( osoption != NULL && osoption->getNumberOfSolverOptions() > 0 )
640  {
641 #ifndef NDEBUG
642  outStr.str("");
643  outStr.clear();
644  outStr << "number of solver options ";
645  outStr << osoption->getNumberOfSolverOptions();
646  outStr << std::endl;
648 #endif
649  std::vector<SolverOption*> optionsVector;
650  optionsVector = osoption->getSolverOptions( "ipopt",true);
651  char *pEnd;
652  int i;
653  int num_ipopt_options = optionsVector.size();
654  for(i = 0; i < num_ipopt_options; i++)
655  {
656 #ifndef NDEBUG
657  outStr.str("");
658  outStr.clear();
659  outStr << "ipopt solver option ";
660  outStr << optionsVector[ i]->name;
661  outStr << std::endl;
663 #endif
664  if(optionsVector[ i]->type == "numeric" )
665  {
666 #ifndef NDEBUG
667  outStr.str("");
668  outStr.clear();
669  outStr << "FOUND A NUMERIC OPTION ";
670  outStr << os_strtod( optionsVector[ i]->value.c_str(), &pEnd );
671  outStr << std::endl;
673 #endif
674  app->Options()->SetNumericValue(optionsVector[ i]->name, os_strtod( optionsVector[ i]->value.c_str(), &pEnd ) );
675  }
676  else if(optionsVector[ i]->type == "integer" )
677  {
678 #ifndef NDEBUG
679  outStr.str("");
680  outStr.clear();
681  outStr << "FOUND AN INTEGER OPTION ";
682  outStr << atoi( optionsVector[ i]->value.c_str() );
683  outStr << std::endl;
685 #endif
686  app->Options()->SetIntegerValue(optionsVector[ i]->name, atoi( optionsVector[ i]->value.c_str() ) );
687  }
688  else if(optionsVector[ i]->type == "string" )
689  {
690 #ifndef NDEBUG
691  outStr.str("");
692  outStr.clear();
693  outStr << "FOUND A STRING OPTION ";
694  outStr << optionsVector[ i]->value.c_str();
695  outStr << std::endl;
697 #endif
698  app->Options()->SetStringValue(optionsVector[ i]->name, optionsVector[ i]->value);
699  }
700  }
701  }
702  return;
703  }
704  catch(const ErrorClass& eclass)
705  {
706  osoutput->OSPrint(ENUM_OUTPUT_AREA_OSSolverInterfaces, ENUM_OUTPUT_LEVEL_error, "Error while setting options in IpoptSolver\n");
708  osresult->setGeneralStatusType( "error");
710  throw ErrorClass( osrl) ;
711  }
712 }//end setInitialValues()
713 
714 #endif
715 
716 
717 void CsdpSolver::solve() throw (ErrorClass)
718 {
719  std::ostringstream outStr;
720 
721  if( this->bCallbuildSolverInstance == false) buildSolverInstance();
722  if( this->bSetSolverOptions == false) setSolverOptions();
723  try
724  {
725 
726 // what about initial values for X and Y? perhaps even y?
727 //if osoption->...->initialmatrix != NUll, set initial values. Make sure that defaults are there
728 //in case X or Z is empty
729 
730  /*
731  * Create an initial solution. This allocates space for X, y, and Z,
732  * and sets initial values.
733  */
734 //else
735  initsoln(nC_rows,ncon,C_matrix,rhsValues,mconstraints,&X,&y,&Z);
736 
737 
738 
739 
740  //call solver
741  int returnCode = easy_sdp(nC_rows,ncon,C_matrix,rhsValues,mconstraints,0.0,&X,&y,&Z,&pobj,&dobj);
742 
743  double* mdObjValues = NULL;
744  int solIdx = 0;
745  int numberOfOtherVariableResults;
746  int otherIdx;
747  int numCon = osinstance->getConstraintNumber();
748 
749  if(osinstance->getObjectiveNumber() > 0)
750  {
751  mdObjValues = new double[1];
752  mdObjValues[0] = (dobj+pobj)/2;
753  outStr << std::endl << "Objective value f(x*) = " << os_dtoa_format(mdObjValues[0]);
755  }
756 
757  std::string message = "Csdp solver finishes to the end.";
758  std::string solutionDescription = "";
759 
760  // write resultHeader information
761  if(osresult->setSolverInvoked( "COIN-OR Csdp") != true)
762  throw ErrorClass("OSResult error: setSolverInvoked");
763  if(osresult->setServiceName( OSgetVersionInfo()) != true)
764  throw ErrorClass("OSResult error: setServiceName");
766  throw ErrorClass("OSResult error: setInstanceName");
767 
768  //if(osresult->setJobID( osoption->jobID) != true)
769  // throw ErrorClass("OSResult error: setJobID");
770 
771  // set basic problem parameters
773  throw ErrorClass("OSResult error: setVariableNumer");
774 
775  if(osresult->setObjectiveNumber( 1) != true)
776  throw ErrorClass("OSResult error: setObjectiveNumber");
778  throw ErrorClass("OSResult error: setConstraintNumber");
779  if(osresult->setSolutionNumber( 1) != true)
780  throw ErrorClass("OSResult error: setSolutionNumer");
781  if(osresult->setGeneralMessage( message) != true)
782  throw ErrorClass("OSResult error: setGeneralMessage");
783 
784 
785  switch( returnCode)
786  {
787  case 0:
788  case 3:
789  {
790  if (returnCode == 0)
791  {
792  solutionDescription = "SUCCESS[Csdp]: Algorithm terminated normally at an optimal point, satisfying the convergence tolerances.";
793  osresult->setSolutionStatus(solIdx, "optimal", solutionDescription);
794  }
795  else
796  {
797  solutionDescription = "PARTIAL SUCCESS[Csdp]: A solution has been found, but full accuracy was not achieved.";
798  osresult->setSolutionStatus(solIdx, "unsure", solutionDescription);
799  }
800 
801  if (osinstance->getObjectiveNumber() > 0)
802  osresult->setObjectiveValuesDense(solIdx, mdObjValues);
803  //set X, y, Z
804  if(numCon > 0)
805  osresult->setDualVariableValuesDense(solIdx, y+1); // !! Csdp uses Fortran indexing
806 
807  int* colOffset = new int[X.nblocks+1];
808  colOffset[0] = 0;
809  for (int i=1; i<=X.nblocks; i++)
810  colOffset[i] = colOffset[i-1] + X.blocks[i].blocksize;
811 
812  int* colOffsetD = new int[Z.nblocks+1];
813  colOffsetD[0] = 0;
814  for (int i=1; i<=Z.nblocks; i++)
815  colOffsetD[i] = colOffsetD[i-1] + Z.blocks[i].blocksize;
816 
817  // initial the <variables> element: one primal matrixVar, one dual matrixVar (in <other>)
819  throw ErrorClass("OSResult error: setMatrixVariableSolution");
820 
821 
822  if (!osresult->setMatrixVarValuesAttributes(0,0,0,colOffset[X.nblocks],
823  colOffset[X.nblocks], ENUM_MATRIX_SYMMETRY_lower))
824  throw ErrorClass("OSResult error: setMatrixVarValuesAttributes");
825 
826  if (!osresult->setMatrixVariablesOtherResultGeneralAttributes(0, 0, "dual matrix",
827  "", "", "", "csdp", "", 1))
828  throw ErrorClass("OSResult error: setMatrixVariablesOtherResultGeneralAttributes");
830  colOffset[Z.nblocks],colOffset[Z.nblocks], ENUM_MATRIX_SYMMETRY_lower))
831  throw ErrorClass("OSResult error: setMatrixVariablesOtherResultMatrixAttributes");
832 
833  if (!osresult->setMatrixVarValuesBlockStructure(0, 0, colOffset, X.nblocks + 1,
834  colOffset, X.nblocks + 1, X.nblocks))
835  throw ErrorClass("OSResult error: setMatrixVarValuesBlockStructure");
836 
837  if (!osresult->setMatrixVariablesOtherResultBlockStructure(0, 0, 0, colOffsetD, Z.nblocks + 1,
838  colOffsetD, Z.nblocks + 1, Z.nblocks))
839  throw ErrorClass("OSResult error: setMatrixVariablesOtherResultBlockStructure");
840 
841  int* start;
842  int* index;
843  ConstantMatrixValues* value;
844 
845  int nonz;
846  double ent;
847 
848  //count nonzeroes and set column starts
849  for (int blk=1; blk<=X.nblocks; blk++)
850  {
851  start = new int[colOffset[blk]-colOffset[blk-1]+1];
852  start[0] = 0;
853  nonz = 0;
854 
855  switch (X.blocks[blk].blockcategory)
856  {
857  case DIAG:
858  for (int i=1; i<=X.blocks[blk].blocksize; i++)
859  {
860  ent=X.blocks[blk].data.vec[i];
861  if (ent != 0.0)
862  nonz++;
863  start[i] = nonz;
864  };
865  break;
866  case MATRIX:
867  for (int i=1; i<=X.blocks[blk].blocksize; i++)
868  {
869  for (int j=i; j<=X.blocks[blk].blocksize; j++)
870  {
871  ent=X.blocks[blk].data.mat[ijtok(i,j,X.blocks[blk].blocksize)];
872  if (ent != 0.0)
873  nonz++;
874  };
875  start[i] = nonz;
876  };
877  break;
878  case PACKEDMATRIX:
879  default:
880  throw ErrorClass("Invalid Block Type in CSDP solution");
881  }; // end switch
882 
883  // go through nonzeros a second time and store values
884  index = new int[nonz];
885  value = new ConstantMatrixValues();
886  value->numberOfEl = nonz;
887  value->el = new double[nonz];
888 
889  nonz = 0;
890  switch (X.blocks[blk].blockcategory)
891  {
892  case DIAG:
893  for (int i=1; i<=X.blocks[blk].blocksize; i++)
894  {
895  ent=X.blocks[blk].data.vec[i];
896  if (ent != 0.0)
897  {
898  index[nonz] = i-1;
899  value->el[nonz] = ent;
900  nonz++;
901  }
902  };
903  break;
904  case MATRIX:
905  for (int i=1; i<=X.blocks[blk].blocksize; i++)
906  {
907  for (int j=i; j<=X.blocks[blk].blocksize; j++)
908  {
909  ent=X.blocks[blk].data.mat[ijtok(i,j,X.blocks[blk].blocksize)];
910  if (ent != 0.0)
911  {
912  index[nonz] = j-1;
913  value->el[nonz] = ent;
914  nonz++;
915  }
916  };
917  start[i] = nonz;
918  };
919  break;
920  case PACKEDMATRIX:
921  default:
922  throw ErrorClass("Invalid Block Type in CSDP solution");
923  }; // end switch
924 
925 
926  if (!osresult->setMatrixVarValuesBlockElements(0, 0, blk-1, blk-1, blk-1, nonz,
927  start, index, value,
930  throw ErrorClass("OSResult error: setMatrixVarValuesBlockElements");
931  }; // end block
932 
933  // now the dual variables
934  for (int blk=1; blk<=Z.nblocks; blk++)
935  {
936  start = new int[colOffsetD[blk]-colOffsetD[blk-1]+1];
937  start[0] = 0;
938  nonz = 0;
939 
940  switch (Z.blocks[blk].blockcategory)
941  {
942  case DIAG:
943  for (int i=1; i<=Z.blocks[blk].blocksize; i++)
944  {
945  ent=Z.blocks[blk].data.vec[i];
946  if (ent != 0.0)
947  nonz++;
948  start[i] = nonz;
949  };
950 
951  break;
952  case MATRIX:
953  for (int i=1; i<=Z.blocks[blk].blocksize; i++)
954  {
955  for (int j=i; j<=Z.blocks[blk].blocksize; j++)
956  {
957  ent=Z.blocks[blk].data.mat[ijtok(i,j,Z.blocks[blk].blocksize)];
958  if (ent != 0.0)
959  nonz++;
960  };
961  start[i] = nonz;
962  };
963  break;
964  case PACKEDMATRIX:
965  default:
966  throw ErrorClass("Invalid Block Type in CSDP solution");
967  }; // end switch
968 
969  // go through nonzeros a second time and store values
970  index = new int[nonz];
971  value = new ConstantMatrixValues();
972  value->numberOfEl = nonz;
973  value->el = new double[nonz];
974 
975  nonz = 0;
976  switch (Z.blocks[blk].blockcategory)
977  {
978  case DIAG:
979  for (int i=1; i<=Z.blocks[blk].blocksize; i++)
980  {
981  ent=Z.blocks[blk].data.vec[i];
982  if (ent != 0.0)
983  {
984  index[nonz] = i-1;
985  value->el[nonz] = ent;
986  nonz++;
987  }
988  };
989  break;
990  case MATRIX:
991  for (int i=1; i<=Z.blocks[blk].blocksize; i++)
992  {
993  for (int j=i; j<=Z.blocks[blk].blocksize; j++)
994  {
995  ent=Z.blocks[blk].data.mat[ijtok(i,j,Z.blocks[blk].blocksize)];
996  if (ent != 0.0)
997  {
998  index[nonz] = j-1;
999  value->el[nonz] = ent;
1000  nonz++;
1001  }
1002  };
1003  start[i] = nonz;
1004  };
1005  break;
1006  case PACKEDMATRIX:
1007  default:
1008  throw ErrorClass("Invalid Block Type in CSDP solution");
1009  }; // end switch
1010 
1011  if (!osresult->setMatrixVariablesOtherResultBlockElements(0, 0, 0, blk-1, blk-1, blk-1,
1012  nonz, start, index, value,
1015  throw ErrorClass("OSResult error: setMatrixVariablesOtherResultBlockElements");
1016  }; // end block
1017  break;
1018  }
1019  case 1:
1020  solutionDescription = "PRIMAL_INFEASIBILITY[Csdp]: Problem is primal infeasible.";
1021  osresult->setSolutionStatus(solIdx, "infeasible", solutionDescription);
1022  break;
1023 
1024  case 2:
1025  solutionDescription = "DUAL_INFEASIBILITY[Csdp]: Problem is dual infeasible.";
1026  osresult->setSolutionStatus(solIdx, "infeasible", solutionDescription);
1027  break;
1028 
1029  case 4:
1030  solutionDescription = "MAXITER_EXCEEDED[Csdp]: Maximum number of iterations exceeded.";
1031  osresult->setSolutionStatus(solIdx, "stoppedByLimit", solutionDescription);
1032  break;
1033 
1034  case 5:
1035  solutionDescription = "STUCK AT EDGE[Csdp]: Stuck at edge of primal infeasibility.";
1036  osresult->setSolutionStatus(solIdx, "error", solutionDescription);
1037  break;
1038 
1039  case 6:
1040  solutionDescription = "STUCK AT EDGE[Csdp]: Stuck at edge of dual infeasibility.";
1041  osresult->setSolutionStatus(solIdx, "error", solutionDescription);
1042  break;
1043 
1044  case 7:
1045  solutionDescription = "LACK OF PROGRESS[Csdp]: Stopped due to lack of progress.";
1046  osresult->setSolutionStatus(solIdx, "error", solutionDescription);
1047  break;
1048 
1049  case 8:
1050  solutionDescription = "SINGULARITY DETECTED[Csdp]: X, Z or O was singular.";
1051  osresult->setSolutionStatus(solIdx, "error", solutionDescription);
1052  break;
1053 
1054  case 9:
1055  solutionDescription = "NaN or INF[Csdp]: Detected NaN or Infinity during computations.";
1056  osresult->setSolutionStatus(solIdx, "error", solutionDescription);
1057  break;
1058  }
1059 
1060  if (returnCode != 0)
1061  throw ErrorClass("Csdp FAILED TO SOLVE THE PROBLEM");
1062 
1064  }
1065 
1066  catch (const ErrorClass& eclass)
1067  {
1068  outStr.str("");
1069  outStr.clear();
1070  outStr << "error in OSCsdpSolver routine solve():\n" << eclass.errormsg << endl;
1072 
1074  osresult->setGeneralStatusType( "error");
1076  throw ErrorClass( osrl) ;
1077  }
1078 }
1079 
1081 {
1082  int i0, j0, blk0;
1083  struct sparseblock *pp;
1084  std::ostringstream outStr;
1085 
1086  outStr << std::endl << "Check problem data:" << std::endl << std::endl;
1087 
1088  outStr << "Dimension of matrices (number of rows): n=" << nC_rows << std::endl;
1089  outStr << "Number of constraints (and matrices A_i): k=" << ncon << std::endl;
1090  for (i0=1; i0 <= ncon; i0++)
1091  {
1092  outStr << std::endl << "Right-hand side of constraint " << i0 << ": "
1093  << rhsValues[i0] << std::endl;
1094  outStr << std::endl << "Data for matrix A_" << i0 << ":" << std::endl;
1095  pp = mconstraints[i0].blocks;
1096  while (pp != NULL)
1097  {
1098  outStr << std::endl << "Block " << pp->blocknum << ":" << std::endl;;
1099  outStr << "Block size: " << pp->blocksize << std::endl;
1100  outStr << "Number of entries: " << pp->numentries << std::endl;
1101  for (j0=1; j0 <= pp->numentries; j0++)
1102  outStr << "Entry in row " << pp->iindices[j0] << ", col " << pp->jindices[j0]
1103  << " has value " << pp->entries[j0] << std::endl;
1104  pp = pp->next;
1105  }
1106  }
1107 
1108  outStr << std::endl << "Data for matrix C:" << std::endl;
1109  outStr << "Number of blocks: " << C_matrix.nblocks << std::endl;
1110  for (blk0=1; blk0 <= C_matrix.nblocks; blk0++)
1111  {
1112  outStr << std::endl << "Data for block " << blk0 << ":" << std::endl;
1113  outStr << "Size: " << C_matrix.blocks[blk0].blocksize << std::endl;
1114  if (C_matrix.blocks[blk0].blockcategory == DIAG)
1115  {
1116  outStr << "Type: diagonal" << std::endl;
1117  for (i0=1; i0 <= C_matrix.blocks[blk0].blocksize; i0++)
1118  outStr << "Entry in row " << i0 << ", col " << i0 << " has value "
1119  << C_matrix.blocks[blk0].data.vec[i0] << std::endl;
1120  }
1121  else
1122  {
1123  outStr << "Type: dense" << std::endl;
1124  for (i0=1; i0 <= C_matrix.blocks[blk0].blocksize; i0++)
1125  for (j0=1; j0 <= C_matrix.blocks[blk0].blocksize; j0++)
1126  outStr << "Entry in row " << i0 << ", col " << j0 << " has value "
1127  << C_matrix.blocks[blk0].data.mat[ijtok(i0,j0,C_matrix.blocks[blk0].blocksize)]
1128  << std::endl;
1129  }
1130  }
1132 }
1133 
1134 
double * getConstraintLowerBounds()
Get constraint lower bounds.
std::string OSgetVersionInfo()
double os_strtod(const char *s00, char **se)
Definition: OSdtoa.cpp:2541
int getNumberOfMatrixVariables()
Get the number of matrix variables.
ScalarExpressionTree * getNonlinearExpressionTree(int rowIdx)
Get the expression tree for a given row 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.
int numberOfEl
each type of value is stored as an array named &quot;el&quot;.
Definition: OSMatrix.h:327
a sparse matrix data structure for matrices that can hold nonconstant values
Definition: OSMatrix.h:1654
int * start
start holds an integer array of start elements in the matrix, which points to the start of a column (...
Definition: OSMatrix.h:1702
const OSSmartPtr< OSOutput > osoutput
Definition: OSOutput.cpp:39
int getVariableNumber()
Get number of variables.
virtual void buildSolverInstance()
The implementation of the virtual functions.
std::string osrl
osrl holds the solution or result of the model
bool setServiceName(std::string serviceName)
Set service name.
int numberOfColumns
Definition: OSMatrix.h:1905
bool setVariableNumber(int variableNumber)
Set the variable number.
Definition: OSResult.cpp:4712
std::string osil
osil holds the problem instance as a std::string
std::string errormsg
errormsg is the error that is causing the exception to be thrown
Definition: OSErrorClass.h:42
bool setMatrixVariablesOtherResultMatrixAttributes(int solIdx, int otherIdx, int matrixVarIdx, int numberOfRows, int numberOfColumns, ENUM_MATRIX_SYMMETRY symmetry=ENUM_MATRIX_SYMMETRY_none, ENUM_MATRIX_TYPE type=ENUM_MATRIX_TYPE_unknown, std::string name="")
A method to set attributes for a matrixVar in the [j]th other result associated with matrix variables...
Definition: OSResult.cpp:6979
int getLinearConstraintCoefficientNumber()
Get number of specified (usually nonzero) linear constraint coefficient values.
to represent the nonzeros in a constantMatrix element
Definition: OSMatrix.h:501
std::string maxOrMin
declare the objective function to be a max or a min
Definition: OSInstance.h:157
std::vector< SolverOption * > getSolverOptions(std::string solver_name)
Get the options associated with a given solver.
Definition: OSOption.cpp:4508
bool setMatrixVarValuesBlockElements(int solIdx, int idx, int blkno, int blkRowIdx, int blkColIdx, int nz, int *start, int *index, MatrixElementValues *value, ENUM_MATRIX_TYPE valueType, ENUM_MATRIX_SYMMETRY symmetry=ENUM_MATRIX_SYMMETRY_none, bool rowMajor=false)
A method to set the elements within a block of a matrixVar in the [i]th optimization solution...
Definition: OSResult.cpp:6789
OSnLMNode ** m_mMatrixChildren
m_mMatrixChildren holds all the matrix-valued operands, if any.
Definition: OSnLNode.h:89
The Result Class.
Definition: OSResult.h:2548
ExpandedMatrixBlocks * getBlocks(int *rowPartition, int rowPartitionSize, int *colPartition, int colPartitionSize, bool rowMajor, bool appendToBlockArray)
A method to extract a block from a larger matrix The result is a sparse matrix object, depending on the matrixType, of constant matrix elements, variable references, linear or nonlinear expressions, or objective and constraint references (possibly mixed).
Definition: OSMatrix.cpp:2269
bool setSolverInvoked(std::string solverInvoked)
Set solver invoked.
Definition: OSResult.cpp:4155
if(!yyg->yy_init)
double * y
Definition: OSCsdpSolver.h:82
bool bCallbuildSolverInstance
bCallbuildSolverInstance is set to true if buildSolverService has been called
#define OS_MATRIX_VAR
Definition: OSParameters.h:74
Take an OSResult object and write a string that validates against OSrL.
Definition: OSrLWriter.h:30
OSResult * osresult
osresult holds the solution or result of the model in-memory as an OSResult object ...
bool bSetSolverOptions
bSetSolverOptions is set to true if setSolverOptions has been called, false otherwise ...
The OSnLMNode Class for nonlinear expressions involving matrices.
Definition: OSnLNode.h:1760
bool setDualVariableValuesDense(int solIdx, double *y)
Set the [i]th optimization solution&#39;s dual variable values, where i equals the given solution index...
Definition: OSResult.cpp:6291
int getObjectiveNumber()
Get number of objectives.
bool setObjectiveNumber(int objectiveNumber)
Set the objective number.
Definition: OSResult.cpp:4721
bool setInstanceName(std::string instanceName)
Set instance name.
OSInstance * readOSiL(const std::string &osil)
parse the OSiL model instance.
Definition: OSiLReader.cpp:53
int inodeInt
inodeInt is the unique integer assigned to the OSnLNode or OSnLMNode in OSParameters.h.
Definition: OSnLNode.h:62
int getNumberOfNonlinearExpressions()
Get number of nonlinear expressions.
virtual ~CsdpSolver()
the CsdpSolver class destructor
double * rhsValues
Definition: OSCsdpSolver.h:79
std::string writeOSrL(OSResult *theosresult)
create an osrl string from an OSResult object
Definition: OSrLWriter.cpp:45
static char * j
Definition: OSdtoa.cpp:3622
#define OS_MATRIX_REFERENCE
Definition: OSParameters.h:72
struct constraintmatrix * mconstraints
Definition: OSCsdpSolver.h:80
std::string osol
osol holds the options for the solver
bool setSolutionNumber(int number)
set the number of solutions.
Definition: OSResult.cpp:4740
struct blockmatrix X Z
Definition: OSCsdpSolver.h:81
Used to hold part of the instance in memory.
CsdpSolver()
the CsdpSolver class constructor
#define OS_MATRIX_TRACE
Definition: OSParameters.h:53
Used to read an OSiL string.
Definition: OSiLReader.h:37
bool setMatrixVarValuesAttributes(int solIdx, int idx, int matrixVarIdx, int numberOfRows, int numberOfColumns, ENUM_MATRIX_SYMMETRY symmetry=ENUM_MATRIX_SYMMETRY_none, ENUM_MATRIX_TYPE type=ENUM_MATRIX_TYPE_unknown, std::string name="")
A method to set general attributes for a matrixVar in the [i]th optimization solution, where i equals the given solution index.
Definition: OSResult.cpp:6703
char * getConstraintTypes()
Get constraint types.
int * index
index holds an integer array of rowIdx (or colIdx) elements in coefMatrix (AMatrix).
Definition: OSMatrix.h:1708
OSOption * osoption
osoption holds the solver options in-memory as an OSOption object
int getRowPartitionSize()
get the size of the row partition of a matrix
Definition: OSMatrix.cpp:2101
bool setMatrixVariablesOtherResultBlockStructure(int solIdx, int otherIdx, int matrixVarIdx, int *colOffset, int colOffsetSize, int *rowOffset, int rowOffsetSize, int numberOfBlocks, int blocksConstructorIdx=0)
A method to set the block structure for the values of a matrixVar associated with the [j]th &quot;other&quot; r...
Definition: OSResult.cpp:7021
std::string * getObjectiveMaxOrMins()
Get objective maxOrMins.
OSOption * readOSoL(const std::string &osol)
parse the OSoL solver options.
Definition: OSoLReader.cpp:76
bool setGeneralMessage(std::string message)
Set the general message.
int getMatrixNumber()
Get the number of matrices.
OSInstance * osinstance
osinstance holds the problem instance in-memory as an OSInstance object
bool setGeneralStatusType(std::string type)
Set the general status type, which can be: success, error, warning.
OSnLNode * m_treeRoot
m_treeRoot holds the root node (of OSnLNode type) of the expression tree.
std::string getInstanceName()
Get instance name.
InstanceData * instanceData
A pointer to an InstanceData object.
Definition: OSInstance.h:2278
OSoLReader * m_osolreader
m_osolreader is an OSoLReader object used to create an osoption from an osol string if needed ...
Definition: OSCsdpSolver.h:133
virtual void solve()
solve results in an instance being read into the Csdp data structures and optimized ...
int getConstraintNumber()
Get number of constraints.
Objective ** obj
coef is pointer to an array of ObjCoef object pointers
Definition: OSInstance.h:205
bool setConstraintNumber(int constraintNumber)
Set the constraint number.
Definition: OSResult.cpp:4731
Matrices * matrices
matrices is a pointer to a Matrices object
Definition: OSInstance.h:2211
int getColumnPartitionSize()
get the size of the column partition of a matrix
Definition: OSMatrix.cpp:2121
int getNumberOfSolverOptions()
Get the number of solver options.
Definition: OSOption.cpp:2207
int getNumberOfQuadraticTerms()
Get the number of specified (usually nonzero) qTerms in the quadratic coefficients.
Used to read an OSoL string.
Definition: OSoLReader.h:37
bool setMatrixVarValuesBlockStructure(int solIdx, int idx, int *colOffset, int colOffsetSize, int *rowOffset, int rowOffsetSize, int numberOfBlocks, int blocksConstructorIdx=0)
A method to set the block structure for the values of a matrixVar in the [i]th optimization solution...
Definition: OSResult.cpp:6737
Objectives * objectives
objectives is a pointer to a Objectives object
Definition: OSInstance.h:2188
bool setMatrixVariableSolution(int solIdx, int numberOfMatrixVar_, int numberOfOtherMatrixVariableResults_)
Set the [i]th optimization solution&#39;s MatrixVariableSolution, where i equals the given solution index...
Definition: OSResult.cpp:6666
struct blockmatrix C_matrix
Definition: OSCsdpSolver.h:78
std::string os_dtoa_format(double x)
Definition: OSMathUtil.cpp:154
int numberOfRows
Definition: OSMatrix.h:1904
int * getRowPartition()
get the row partition of the matrix
Definition: OSMatrix.cpp:2111
double pobj
Definition: OSCsdpSolver.h:83
virtual ENUM_MATRIX_TYPE getMatrixType()
Definition: OSMatrix.cpp:3020
std::string * csdpErrorMsg
Definition: OSCsdpSolver.h:155
OSrLWriter * osrlwriter
Definition: OSCsdpSolver.h:137
bool setMatrixVariablesOtherResultBlockElements(int solIdx, int otherIdx, int matrixVarIdx, int blkno, int blkRowIdx, int blkColIdx, int nz, int *start, int *index, MatrixElementValues *value, ENUM_MATRIX_TYPE valueType, ENUM_MATRIX_SYMMETRY symmetry=ENUM_MATRIX_SYMMETRY_none, bool rowMajor=false)
A method to set the elements within a block of a matrixVar associated with the [j]th &quot;other&quot; result i...
Definition: OSResult.cpp:7077
int valueSize
valueSize is the dimension of the index and value arrays
Definition: OSMatrix.h:1696
bool setObjectiveValuesDense(int solIdx, double *objectiveValues)
Set the [i]th optimization solution&#39;s objective values, where i equals the given solution index...
Definition: OSResult.cpp:5824
double dobj
Definition: OSCsdpSolver.h:83
a sparse matrix data structure for matrices that can hold nonconstant values and have block structure...
Definition: OSMatrix.h:1768
for(int i=0;i< nnz;i++)
#define OS_MATRIX_TIMES
Definition: OSParameters.h:61
void dataEchoCheck()
use this for debugging, print out the instance that the solver thinks it has and compare this with th...
The OSnLNode Class for nonlinear expressions.
Definition: OSnLNode.h:179
bool isDiagonal()
a method to determine whether the matrix is diagonal
Definition: OSMatrix.cpp:6483
OSMatrix ** matrix
matrix is a pointer to an array of OSMatrix object pointers
Definition: OSInstance.h:499
OSiLReader * m_osilreader
m_osilreader is an OSiLReader object used to create an osinstance from an osil string if needed ...
Definition: OSCsdpSolver.h:127
virtual void setSolverOptions()
The implementation of the virtual functions.
int startSize
startSize is the dimension of the starts array
Definition: OSMatrix.h:1691
used for throwing exceptions.
Definition: OSErrorClass.h:31
MatrixElementValues * value
value holds a general array of value elements in the matrix, which could be constants, linear expressions, general nonlinear expressions, variable, constraint or objective references, etc.
Definition: OSMatrix.h:1723
bool setMatrixVariablesOtherResultGeneralAttributes(int solIdx, int idx, std::string name, std::string description, std::string value, std::string type, std::string solver, std::string category, int numberOfMatrixVar=0, std::string matrixType="", int numberOfEnumerations=0, std::string enumType="")
A method to set general attributes for another (non-standard/solver specific) result associated with ...
Definition: OSResult.cpp:6922
a data structure to represent a matrix object (derived from MatrixType)
Definition: OSMatrix.h:2185
GeneralSparseMatrix * getBlock(int rowIdx, int colIdx)
a method to retrieve a particular block from a collection
Definition: OSMatrix.cpp:6595
int * getColumnPartition()
get the column partition of the matrix
Definition: OSMatrix.cpp:2131