22 #include "OSInstance.h"
28 #include "OSParameters.h"
31 #include "CoinTime.hpp"
42 # error "don't have header file for time"
48 using std::ostringstream;
55 "inside CsdpSolver constructor\n");
87 std::ostringstream outStr;
95 int* blockOffset = NULL;
96 int* blockSize = NULL;
102 if(
osil.length() == 0 &&
osinstance == NULL)
throw ErrorClass(
"there is no instance");
103 clock_t start, finish;
112 duration = (double) (finish - start) / CLOCKS_PER_SEC;
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");
130 if (cType[i] !=
'E')
throw ErrorClass(
"Only equality constraints are supported");
133 if (oType[0] !=
"max")
throw ErrorClass(
"The problem must be of \"max\" type");
137 if (tempTree == NULL)
throw ErrorClass(
"Expecting matrixTrace in objective row");
140 throw ErrorClass(
"Expecting matrixTrace in objective row");
143 throw ErrorClass(
"Unsupported expression in objective row");
147 throw ErrorClass(
"Unsupported expression in objective row");
154 throw ErrorClass(
"<matrices> section was never defined");
156 throw ErrorClass(
"Illegal matrix reference");
158 if (tempMtx == NULL)
throw ErrorClass(
"A0 matrix was never defined");
160 throw ErrorClass(
"A0 matrix must be square and symmetric");
162 throw ErrorClass(
"A0 matrix must be of type \"constant\"");
171 int* tempColumnOffsets;
172 int tempNColumnBlocks;
174 int i0, itemp, imerge;
180 if (tempTree == NULL)
throw ErrorClass(
"Expecting matrixTrace in constraint row");
183 throw ErrorClass(
"Expecting matrixTrace in constraint row");
186 throw ErrorClass(
"Unsupported expression in constraint row");
190 throw ErrorClass(
"Unsupported expression in constraint row");
195 throw ErrorClass(
"Illegal matrix reference");
197 if (tempMtx == NULL)
throw ErrorClass(
"Matrix in constraint was never defined");
199 throw ErrorClass(
"Constraint matrix must be square and symmetric");
201 throw ErrorClass(
"Constraint matrix must be of type \"constant\"");
214 if (rowOffsets[i0] == tempRowOffsets[itemp])
216 if (imerge != i0) rowOffsets[imerge] = rowOffsets[i0];
223 if (rowOffsets[i0] < tempRowOffsets[itemp])
228 if (i0 >= nRowBlocks || itemp >= tempNRowBlocks)
239 if (columnOffsets[i0] == tempColumnOffsets[itemp])
241 if (imerge != i0) columnOffsets[imerge] = columnOffsets[i0];
248 if (columnOffsets[i0] < tempColumnOffsets[itemp])
253 if (i0 >= nColumnBlocks || itemp >= tempNColumnBlocks)
256 nColumnBlocks = imerge;
259 blockOffset =
new int[nRowBlocks];
268 if (rowOffsets[jrow] == columnOffsets[jcol])
270 blockOffset[nBlocks] = rowOffsets[jrow];
277 if (rowOffsets[jrow] < columnOffsets[jcol])
282 if (jrow >= nRowBlocks || jcol >= nColumnBlocks)
289 blockSize =
new int[nBlocks];
290 for (
int i=1; i < nBlocks; i++)
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");
297 blockSize[i] = blockOffset[i] - blockOffset[i-1];
300 nC_rows = blockOffset[nBlocks-1];
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");
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");
322 throw ErrorClass(
"This problem is too large to be solved in 32 bit mode!\n");
334 isdiag =
new bool[nBlocks];
335 for (
int i=1; i<nBlocks; i++)
341 ->
getBlocks(blockOffset,nBlocks,blockOffset,nBlocks,
false,
true);
343 if (!mtxBlocks[
j]->isBlockDiagonal())
344 throw ErrorClass(
"Constraint matrix must be block-diagonal");
346 for (
int i=0; i<nBlocks-1; i++)
349 if (tmpBlock != NULL && !(tmpBlock->
isDiagonal()))
356 C_matrix.blocks =
new blockrec[nBlocks];
359 for (
int blk=1; blk < nBlocks; blk++)
361 tmpBlock = mtxBlocks[0]->
getBlock(blk-1,blk-1);
362 int blksz = blockSize[blk];
363 if (isdiag[blk] == 1)
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];
370 for (
int i=1; i<=blksz; i++)
371 C_matrix.blocks[blk].data.vec[i] = 0.0;
373 if (tmpBlock != NULL)
375 for (
int i=0; i < tmpBlock->
valueSize; i++)
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];
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;
391 if (tmpBlock != NULL)
393 for (
int i=1; i < tmpBlock->
startSize; i++)
394 for (
int j=tmpBlock->
start[i-1]; j<tmpBlock->start[i];
j++)
396 C_matrix.blocks[blk].data.mat[ijtok(i,tmpBlock->
index[
j]+1,blksz)]
398 C_matrix.blocks[blk].data.mat[ijtok(tmpBlock->
index[
j]+1,i,blksz)]
409 for (
int i=1; i<=
ncon; i++)
414 struct sparseblock *p;
415 struct sparseblock *q;
416 struct sparseblock *prev;
422 for (
int i=1; i<=
ncon; i++)
425 for (
int blk=1; blk < nBlocks; blk++)
427 tmpBlock = mtxBlocks[i]->
getBlock(blk-1,blk-1);
428 if (tmpBlock != NULL && tmpBlock->
valueSize > 0)
434 p =
new sparseblock();
436 p->entries =
new double[p->numentries+1];
438 p->iindices =
new int[p->numentries+1];
439 p->jindices =
new int[p->numentries+1];
441 p->iindices =
new unsigned short[p->numentries+1];
442 p->jindices =
new unsigned short[p->numentries+1];
445 p->blocksize = blockSize[blk];
446 p->constraintnum = i;
448 p->nextbyblock = NULL;
449 if (((p->numentries) > 0.25*(p->blocksize)) && ((p->numentries) > 15))
455 for (
int icol=1; icol < tmpBlock->
startSize; icol++)
456 for (
int jent=tmpBlock->
start[icol-1]; jent<tmpBlock->start[icol]; jent++)
458 p->iindices[jent+1] = icol;
459 p->jindices[jent+1] = tmpBlock->
index[jent] + 1;
470 prev->nextbyblock = p;
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)
484 for (
int i=0; i < ncon+1; i++)
486 if (mtxBlocks[i] != NULL)
delete mtxBlocks[i];
496 catch(
const ErrorClass& eclass)
498 if (blockOffset != NULL)
delete [] blockOffset;
499 if (blockSize != NULL)
delete [] blockSize;
500 if (mtxRef != NULL)
delete [] mtxRef;
501 if (isdiag != NULL)
delete [] isdiag;
503 for (
int i=0; i <=
ncon; i++)
505 if (mtxBlocks[i] != NULL)
delete mtxBlocks[i];
515 throw ErrorClass(
osrl);
533 struct paramstruc params;
535 std::ostringstream outStr;
536 std::ostringstream optStr;
553 outStr <<
"number of solver options ";
559 std::vector<SolverOption*> optionsVector;
563 int num_ipopt_options = optionsVector.size();
564 for(i = 0; i < num_ipopt_options; i++)
569 outStr <<
"csdp solver option ";
570 outStr << optionsVector[ i]->name;
574 optStr << optionsVector[ i]->name <<
"=" << optionsVector[ i]->value << std::endl;
578 paramfile=fopen(
"param.csdp",
"w");
580 throw ErrorClass(
"File open error during option initialization");
582 fprintf(paramfile,
"%s",(optStr.str()).c_str());
588 catch(
const ErrorClass& eclass)
591 "Error in setSolverOption\n");
595 throw ErrorClass(
osrl);
601 void CsdpSolver::setInitialValues() throw (
ErrorClass)
603 std::ostringstream outStr;
607 throw ErrorClass(
"Ipopt NEEDS AN OBJECTIVE FUNCTION\n(For pure feasibility problems, use zero function.)");
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);
616 app->Options()->SetStringValue(
"check_derivatives_for_naninf",
"yes");
621 app->Options()->SetStringValue(
"hessian_constant",
"yes",
true,
true);
627 app->Options()->SetStringValue(
"nlp_scaling_method",
"user-scaling");
644 outStr <<
"number of solver options ";
649 std::vector<SolverOption*> optionsVector;
653 int num_ipopt_options = optionsVector.size();
654 for(i = 0; i < num_ipopt_options; i++)
659 outStr <<
"ipopt solver option ";
660 outStr << optionsVector[ i]->name;
664 if(optionsVector[ i]->type ==
"numeric" )
669 outStr <<
"FOUND A NUMERIC OPTION ";
670 outStr <<
os_strtod( optionsVector[ i]->value.c_str(), &pEnd );
674 app->Options()->SetNumericValue(optionsVector[ i]->name,
os_strtod( optionsVector[ i]->value.c_str(), &pEnd ) );
676 else if(optionsVector[ i]->type ==
"integer" )
681 outStr <<
"FOUND AN INTEGER OPTION ";
682 outStr << atoi( optionsVector[ i]->value.c_str() );
686 app->Options()->SetIntegerValue(optionsVector[ i]->name, atoi( optionsVector[ i]->value.c_str() ) );
688 else if(optionsVector[ i]->type ==
"string" )
693 outStr <<
"FOUND A STRING OPTION ";
694 outStr << optionsVector[ i]->value.c_str();
698 app->Options()->SetStringValue(optionsVector[ i]->name, optionsVector[ i]->value);
704 catch(
const ErrorClass& eclass)
710 throw ErrorClass(
osrl) ;
719 std::ostringstream outStr;
741 int returnCode = easy_sdp(
nC_rows,
ncon,
C_matrix,
rhsValues,
mconstraints,0.0,&X,&
y,&
Z,&
pobj,&
dobj);
743 double* mdObjValues = NULL;
745 int numberOfOtherVariableResults;
751 mdObjValues =
new double[1];
753 outStr << std::endl <<
"Objective value f(x*) = " <<
os_dtoa_format(mdObjValues[0]);
757 std::string message =
"Csdp solver finishes to the end.";
758 std::string solutionDescription =
"";
762 throw ErrorClass(
"OSResult error: setSolverInvoked");
764 throw ErrorClass(
"OSResult error: setServiceName");
766 throw ErrorClass(
"OSResult error: setInstanceName");
773 throw ErrorClass(
"OSResult error: setVariableNumer");
776 throw ErrorClass(
"OSResult error: setObjectiveNumber");
778 throw ErrorClass(
"OSResult error: setConstraintNumber");
780 throw ErrorClass(
"OSResult error: setSolutionNumer");
782 throw ErrorClass(
"OSResult error: setGeneralMessage");
792 solutionDescription =
"SUCCESS[Csdp]: Algorithm terminated normally at an optimal point, satisfying the convergence tolerances.";
797 solutionDescription =
"PARTIAL SUCCESS[Csdp]: A solution has been found, but full accuracy was not achieved.";
807 int* colOffset =
new int[X.nblocks+1];
809 for (
int i=1; i<=X.nblocks; i++)
810 colOffset[i] = colOffset[i-1] + X.blocks[i].blocksize;
812 int* colOffsetD =
new int[
Z.nblocks+1];
814 for (
int i=1; i<=
Z.nblocks; i++)
815 colOffsetD[i] = colOffsetD[i-1] +
Z.blocks[i].blocksize;
819 throw ErrorClass(
"OSResult error: setMatrixVariableSolution");
824 throw ErrorClass(
"OSResult error: setMatrixVarValuesAttributes");
827 "",
"",
"",
"csdp",
"", 1))
828 throw ErrorClass(
"OSResult error: setMatrixVariablesOtherResultGeneralAttributes");
831 throw ErrorClass(
"OSResult error: setMatrixVariablesOtherResultMatrixAttributes");
834 colOffset, X.nblocks + 1, X.nblocks))
835 throw ErrorClass(
"OSResult error: setMatrixVarValuesBlockStructure");
838 colOffsetD,
Z.nblocks + 1,
Z.nblocks))
839 throw ErrorClass(
"OSResult error: setMatrixVariablesOtherResultBlockStructure");
849 for (
int blk=1; blk<=X.nblocks; blk++)
851 start =
new int[colOffset[blk]-colOffset[blk-1]+1];
855 switch (X.blocks[blk].blockcategory)
858 for (
int i=1; i<=X.blocks[blk].blocksize; i++)
860 ent=X.blocks[blk].data.vec[i];
867 for (
int i=1; i<=X.blocks[blk].blocksize; i++)
869 for (
int j=i;
j<=X.blocks[blk].blocksize;
j++)
871 ent=X.blocks[blk].data.mat[ijtok(i,
j,X.blocks[blk].blocksize)];
880 throw ErrorClass(
"Invalid Block Type in CSDP solution");
884 index =
new int[nonz];
887 value->
el =
new double[nonz];
890 switch (X.blocks[blk].blockcategory)
893 for (
int i=1; i<=X.blocks[blk].blocksize; i++)
895 ent=X.blocks[blk].data.vec[i];
899 value->
el[nonz] = ent;
905 for (
int i=1; i<=X.blocks[blk].blocksize; i++)
907 for (
int j=i;
j<=X.blocks[blk].blocksize;
j++)
909 ent=X.blocks[blk].data.mat[ijtok(i,
j,X.blocks[blk].blocksize)];
913 value->
el[nonz] = ent;
922 throw ErrorClass(
"Invalid Block Type in CSDP solution");
930 throw ErrorClass(
"OSResult error: setMatrixVarValuesBlockElements");
934 for (
int blk=1; blk<=
Z.nblocks; blk++)
936 start =
new int[colOffsetD[blk]-colOffsetD[blk-1]+1];
940 switch (
Z.blocks[blk].blockcategory)
943 for (
int i=1; i<=
Z.blocks[blk].blocksize; i++)
945 ent=
Z.blocks[blk].data.vec[i];
953 for (
int i=1; i<=
Z.blocks[blk].blocksize; i++)
955 for (
int j=i;
j<=
Z.blocks[blk].blocksize;
j++)
957 ent=
Z.blocks[blk].data.mat[ijtok(i,
j,
Z.blocks[blk].blocksize)];
966 throw ErrorClass(
"Invalid Block Type in CSDP solution");
970 index =
new int[nonz];
973 value->
el =
new double[nonz];
976 switch (
Z.blocks[blk].blockcategory)
979 for (
int i=1; i<=
Z.blocks[blk].blocksize; i++)
981 ent=
Z.blocks[blk].data.vec[i];
985 value->
el[nonz] = ent;
991 for (
int i=1; i<=
Z.blocks[blk].blocksize; i++)
993 for (
int j=i;
j<=
Z.blocks[blk].blocksize;
j++)
995 ent=
Z.blocks[blk].data.mat[ijtok(i,
j,
Z.blocks[blk].blocksize)];
999 value->
el[nonz] = ent;
1008 throw ErrorClass(
"Invalid Block Type in CSDP solution");
1012 nonz, start, index, value,
1015 throw ErrorClass(
"OSResult error: setMatrixVariablesOtherResultBlockElements");
1020 solutionDescription =
"PRIMAL_INFEASIBILITY[Csdp]: Problem is primal infeasible.";
1025 solutionDescription =
"DUAL_INFEASIBILITY[Csdp]: Problem is dual infeasible.";
1030 solutionDescription =
"MAXITER_EXCEEDED[Csdp]: Maximum number of iterations exceeded.";
1035 solutionDescription =
"STUCK AT EDGE[Csdp]: Stuck at edge of primal infeasibility.";
1040 solutionDescription =
"STUCK AT EDGE[Csdp]: Stuck at edge of dual infeasibility.";
1045 solutionDescription =
"LACK OF PROGRESS[Csdp]: Stopped due to lack of progress.";
1050 solutionDescription =
"SINGULARITY DETECTED[Csdp]: X, Z or O was singular.";
1055 solutionDescription =
"NaN or INF[Csdp]: Detected NaN or Infinity during computations.";
1060 if (returnCode != 0)
1061 throw ErrorClass(
"Csdp FAILED TO SOLVE THE PROBLEM");
1066 catch (
const ErrorClass& eclass)
1070 outStr <<
"error in OSCsdpSolver routine solve():\n" << eclass.
errormsg << endl;
1076 throw ErrorClass(
osrl) ;
1083 struct sparseblock *pp;
1084 std::ostringstream outStr;
1086 outStr << std::endl <<
"Check problem data:" << std::endl << std::endl;
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++)
1092 outStr << std::endl <<
"Right-hand side of constraint " << i0 <<
": "
1094 outStr << std::endl <<
"Data for matrix A_" << i0 <<
":" << std::endl;
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;
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++)
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)
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;
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)]
double * getConstraintLowerBounds()
Get constraint lower bounds.
std::string OSgetVersionInfo()
double os_strtod(const char *s00, char **se)
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 "el".
a sparse matrix data structure for matrices that can hold nonconstant values
int * start
start holds an integer array of start elements in the matrix, which points to the start of a column (...
const OSSmartPtr< OSOutput > osoutput
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.
bool setVariableNumber(int variableNumber)
Set the variable number.
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
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...
int getLinearConstraintCoefficientNumber()
Get number of specified (usually nonzero) linear constraint coefficient values.
to represent the nonzeros in a constantMatrix element
std::string maxOrMin
declare the objective function to be a max or a min
std::vector< SolverOption * > getSolverOptions(std::string solver_name)
Get the options associated with a given solver.
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...
OSnLMNode ** m_mMatrixChildren
m_mMatrixChildren holds all the matrix-valued operands, if any.
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).
bool setSolverInvoked(std::string solverInvoked)
Set solver invoked.
bool bCallbuildSolverInstance
bCallbuildSolverInstance is set to true if buildSolverService has been called
Take an OSResult object and write a string that validates against OSrL.
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.
bool setDualVariableValuesDense(int solIdx, double *y)
Set the [i]th optimization solution's dual variable values, where i equals the given solution index...
int getObjectiveNumber()
Get number of objectives.
bool setObjectiveNumber(int objectiveNumber)
Set the objective number.
bool setInstanceName(std::string instanceName)
Set instance name.
OSInstance * readOSiL(const std::string &osil)
parse the OSiL model instance.
int inodeInt
inodeInt is the unique integer assigned to the OSnLNode or OSnLMNode in OSParameters.h.
int getNumberOfNonlinearExpressions()
Get number of nonlinear expressions.
virtual ~CsdpSolver()
the CsdpSolver class destructor
std::string writeOSrL(OSResult *theosresult)
create an osrl string from an OSResult object
#define OS_MATRIX_REFERENCE
struct constraintmatrix * mconstraints
std::string osol
osol holds the options for the solver
bool setSolutionNumber(int number)
set the number of solutions.
Used to hold part of the instance in memory.
CsdpSolver()
the CsdpSolver class constructor
Used to read an OSiL string.
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.
char * getConstraintTypes()
Get constraint types.
int * index
index holds an integer array of rowIdx (or colIdx) elements in coefMatrix (AMatrix).
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
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 "other" r...
std::string * getObjectiveMaxOrMins()
Get objective maxOrMins.
OSOption * readOSoL(const std::string &osol)
parse the OSoL solver options.
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.
OSoLReader * m_osolreader
m_osolreader is an OSoLReader object used to create an osoption from an osol string if needed ...
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
bool setConstraintNumber(int constraintNumber)
Set the constraint number.
Matrices * matrices
matrices is a pointer to a Matrices object
int getColumnPartitionSize()
get the size of the column partition of a matrix
int getNumberOfSolverOptions()
Get the number of solver options.
int getNumberOfQuadraticTerms()
Get the number of specified (usually nonzero) qTerms in the quadratic coefficients.
Used to read an OSoL string.
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...
Objectives * objectives
objectives is a pointer to a Objectives object
bool setMatrixVariableSolution(int solIdx, int numberOfMatrixVar_, int numberOfOtherMatrixVariableResults_)
Set the [i]th optimization solution's MatrixVariableSolution, where i equals the given solution index...
struct blockmatrix C_matrix
std::string os_dtoa_format(double x)
int * getRowPartition()
get the row partition of the matrix
virtual ENUM_MATRIX_TYPE getMatrixType()
std::string * csdpErrorMsg
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 "other" result i...
int valueSize
valueSize is the dimension of the index and value arrays
bool setObjectiveValuesDense(int solIdx, double *objectiveValues)
Set the [i]th optimization solution's objective values, where i equals the given solution index...
a sparse matrix data structure for matrices that can hold nonconstant values and have block structure...
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.
bool isDiagonal()
a method to determine whether the matrix is diagonal
OSMatrix ** matrix
matrix is a pointer to an array of OSMatrix object pointers
OSiLReader * m_osilreader
m_osilreader is an OSiLReader object used to create an osinstance from an osil string if needed ...
virtual void setSolverOptions()
The implementation of the virtual functions.
int startSize
startSize is the dimension of the starts array
used for throwing exceptions.
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.
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 ...
a data structure to represent a matrix object (derived from MatrixType)
GeneralSparseMatrix * getBlock(int rowIdx, int colIdx)
a method to retrieve a particular block from a collection
int * getColumnPartition()
get the column partition of the matrix