23 #include "OSInstance.h"
36 #include "CoinError.hpp"
37 #include "CoinHelperFunctions.hpp"
47 WindowsErrorPopupBlocker();
50 cout <<
"Start Building the Model" << endl;
54 const char dirsep = CoinFindDirSeparator();
57 std::string osilFileName;
58 dataDir = dirsep ==
'/' ?
"../data/" :
"..\\data\\";
60 osilFileName = dataDir +
"osilFiles" + dirsep +
"parincLinear.osil";
61 std::cout <<
"Try to read a sample file" << std::endl;
62 std::cout <<
"The file is: " ;
63 std::cout << osilFileName << std::endl;
69 osinstance = osilreader->
readOSiL( osil);
86 std::string solStatus;
91 if( solStatus.find(
"ptimal") != string::npos ){
94 std::cout <<
"OPTIMAL SOLUTION VALUE " << optSolValue << std::endl;
96 std::cout <<
"NO OPTIMAL SOLUTION FOUND " << std::endl;
104 std::vector<IndexValuePair*> primalValPair;
106 vecSize = primalValPair.size();
107 for(i = 0; i < vecSize; i++){
108 std::cout <<
"index = " << primalValPair[ i]->idx << std::endl;
109 std::cout <<
"value = " << primalValPair[ i]->value << std::endl;
112 std::vector<IndexValuePair*> dualValPair;
114 vecSize = dualValPair.size();
115 for(i = 0; i < vecSize; i++){
116 std::cout <<
"index = " << dualValPair[ i]->idx << std::endl;
117 std::cout <<
"value = " << dualValPair[ i]->value << std::endl;
122 int numberOfOtherVariableResults;
123 int numberOfOtherVar;
124 numSolutions =osresult-> getSolutionNumber();
125 for(i = 0; i < numSolutions; i++){
126 numberOfOtherVariableResults = osresult->
127 getNumberOfOtherVariableResults( i);
128 for(j = 0; j < numberOfOtherVariableResults; j++){
133 for(k = 0; k < numberOfOtherVar; k++){
148 cout <<
"Done with garbage collection" << endl;
149 cout <<
"Program terminates normally" << endl;
155 std::cout << eclass.
errormsg << std::endl;
std::string getSolutionStatusType(int solIdx)
Get the [i]th optimization solution status type, where i equals the given solution index...
std::string osrl
osrl holds the solution or result of the model
std::string errormsg
errormsg is the error that is causing the exception to be thrown
int main(int argc, char *argv[])
std::vector< IndexValuePair * > getOptimalPrimalVariableValues(int solIdx)
Get one solution of optimal primal variable values.
OSResult * readOSrL(const std::string &posrl)
Get an OSResult object from an OSrL string.
OptimizationResult * optimization
optimization holds the fifth child of the OSResult specified by the OSrL Schema.
double getOptimalObjValue(int objIdx, int solIdx)
Get one solution's optimal objective value.
std::vector< IndexValuePair * > getOptimalDualVariableValues(int solIdx)
Get one solution of optimal dual variable values.
std::string description
a brief description of the type of result
OSInstance * readOSiL(const std::string &osil)
parse the OSiL model instance.
virtual void buildSolverInstance()
The implementation of the corresponding virtual function.
int numberOfVar
the number of variables which have values for this particular type of result
VariableSolution * variables
variables holds the solution information for the variables
Used to read an OSiL string.
std::string name
the name of the result the user is defining
int idx
the index of a variable in the solution
OSInstance * osinstance
osinstance holds the problem instance in-memory as an OSInstance object
OptimizationSolution ** solution
solution is an array of pointers to OptimizationSolution objects
std::string sSolverName
sSolverName is the name of the Coin solver used, e.g.
OtherVariableResult ** other
a pointer to an array of other pointer objects for variables
Implements a solve method for the Coin solvers.
std::string getFileAsString(const char *fname)
read a file and return contents as a string.
The in-memory representation of an OSiL instance..
class used to make it easy to read and write files.
virtual void solve()
The implementation of the corresponding virtual function.
std::string value
value holds a general value associated with a variable, for example, rather than the value of a varia...
used for throwing exceptions.