24 #include "OSCommonUtil.h"
38 cout <<
"Inside GeneralStatus Constructor" << endl;
44 cout <<
"GeneralStatus Destructor Called" << endl;
49 m_iVariableNumber( -1),
50 m_iObjectiveNumber( -1),
51 m_iConstraintNumber( -1),
52 m_iNumberOfOtherVariableResults( -1),
53 m_mdPrimalValues( NULL),
58 cout <<
"Inside OSResult Constructor" << endl;
69 cout <<
"OSResult Destructor Called" << endl;
82 if(
job != NULL)
delete job;
104 cout <<
"Inside the GeneralResult Constructor" << endl;
112 cout <<
"Inside the GeneralResult Destructor" << endl;
122 cout <<
"Inside the SystemResult Constructor" << endl;
129 cout <<
"Inside the SystemResult Destructor" << endl;
138 cout <<
"Inside the ServiceResult Constructor" << endl;
145 cout <<
"Inside the ServiceResult Destructor" << endl;
158 cout <<
"Inside the Time Constructor" << endl;
165 cout <<
"Inside the Time Destructor" << endl;
174 cout <<
"Inside the TimingInformation Constructor" << endl;
182 cout <<
"Inside the TimingInformation Destructor" << endl;
199 cout <<
"Inside the JobResult Constructor" << endl;
207 cout <<
"Inside the JobResult Destructor" << endl;
218 cout <<
"Inside the VarValue Constructor" << endl;
225 cout <<
"Inside the VarValue Destructor" << endl;
235 cout <<
"Inside the OtherVarResult Constructor" << endl;
242 cout <<
"Inside the OtherVarResult Destructor" << endl;
252 cout <<
"Inside the OtherObjResult Constructor" << endl;
259 cout <<
"Inside the OtherObjResult Destructor" << endl;
269 cout <<
"Inside the OtherConResult Constructor" << endl;
276 cout <<
"Inside the OtherConResult Destructor" << endl;
286 cout <<
"Inside the ObjValue Constructor" << endl;
292 cout <<
"Inside the ObjValue Destructor" << endl;
303 cout <<
"Inside the DualVarValue Constructor" << endl;
310 cout <<
"Inside the DualVarValue Destructor" << endl;
318 cout <<
"Inside the VariableValues Constructor" << endl;
326 cout <<
"Inside the VariableValues Destructor" << endl;
330 for(
int i = 0; i <
n; i++){
347 cout <<
"Inside the OtherVariableResult Constructor" << endl;
355 cout <<
"Inside the OtherVariableResult Destructor" << endl;
359 for(
int i = 0; i <
n; i++){
366 cout <<
"Inside the OtherVariableResult Destructor - Done" << endl;
376 cout <<
"Inside the OtherObjectiveResult Constructor" << endl;
383 cout <<
"Inside the OtherObjectiveResult Destructor" << endl;
387 for(
int i = 0; i <
n; i++){
401 cout <<
"Inside the OtherConstraintResult Constructor" << endl;
408 cout <<
"Inside the OtherConstraintResult Destructor" << endl;
412 for(
int i = 0; i <
n; i++){
423 cout <<
"Inside the ObjectiveValues Constructor" << endl;
431 cout <<
"Inside the ObjectiveValues Destructor" << endl;
435 for(
int i = 0; i <
n; i++){
448 cout <<
"Inside the DualVariableValues Constructor" << endl;
456 cout <<
"Inside the DualVariableValues Destructor" << endl;
460 for(
int i = 0; i <
n; i++){
471 numberOfOtherVariableResults( 0),
477 cout <<
"Inside the VariableSolution Constructor" << endl;
484 cout <<
"Inside the VariableSolution Destructor" << endl;
499 numberOfOtherObjectiveResults( 0),
505 cout <<
"Inside the ObjectiveSolution Constructor" << endl;
512 cout <<
"Inside the ObjectieSolution Destructor" << endl;
529 numberOfOtherConstraintResults( 0),
534 cout <<
"Inside the ConstraintSolution Constructor" << endl;
541 cout <<
"Inside the ConstraintSolution Destructor" << endl;
563 cout <<
"Inside the OptimizationSolutionStatus Constructor" << endl;
570 cout <<
"Inside the OptimzationSolutionStatus Destructor" << endl;
576 targetObjectiveIdx( -1),
584 cout <<
"Inside the OptimizationSolution Constructor" << endl;
592 cout <<
"Inside the OptimzationSolution Destructor" << endl;
614 numberOfVariables( -1),
615 numberOfObjectives( -1),
616 numberOfConstraints(-1),
617 numberOfSolutions( -1),
621 cout <<
"Inside the OptimizationResult Constructor" << endl;
628 cout <<
"Inside the OptimzationResult Destructor" << endl;
636 cout <<
"Delelting Solution: " << i << endl;
688 {
if (
job == NULL)
return 0.0;
696 {
if (
job == NULL)
return -1;
782 if(iNumberOfVariables <= 0)
return NULL;
784 for(
int i = 0; i < iSolutions; i++){
791 m_mdPrimalValues =
new double[iNumberOfVariables];
792 for(
int j = 0;
j < iNumberOfVariables;
j++){
807 if(iNumberOfConstraints <= 0)
return NULL;
809 for(
int i = 0; i < iSolutions; i++){
816 m_mdDualValues =
new double[iNumberOfConstraints];
817 for(
int j = 0;
j < iNumberOfConstraints;
j++){
842 std::string unit, std::string description,
double value)
844 cout <<
"add timing information: " << endl;
845 cout <<
"type " << type << endl;
846 cout <<
"category " << category << endl;
847 cout <<
"unit " << unit << endl;
848 cout <<
"description " << description << endl;
849 cout <<
"value " << value << endl;
854 cout <<
"allocate new pointers" << endl;
856 cout <<
" copy pointers --- " << nt << endl;
857 for (i = 0; i <
nt; i++)
860 cout <<
"delete old pointers" << endl;
864 cout <<
"add new element" << endl;
865 temp[ nt] =
new Time();
873 cout <<
"hook new pointers into OSResult" << endl;
877 cout <<
"done" << endl;
918 if (timeNumber <= 0)
return false;
929 if(variableNumber <= 0){
938 if(objectiveNumber < 0){
947 if(constraintNumber < 0){
959 if(number < 0)
return false;
960 if(number == 0)
return true;
964 for(
int i = 0; i < number; i++){
965 std::cout <<
"CREATING A NEW OPTIMIZATION SOLUTION" << std::endl;
967 std::cout <<
"DONE CREATING A NEW OPTIMIZATION SOLUTION" << std::endl;
975 if(nSols <= 0)
return false;
977 solIdx < 0 || solIdx >= nSols)
return false;
993 if(nSols <= 0)
return false;
996 solIdx < 0 || solIdx >= nSols)
return false;
1000 if(objectiveIdx >= 0)
return false;
1008 if (numberOfVar <= 0 || numberOfVar > nVar)
return false;
1010 if(nSols <= 0)
return false;
1012 solIdx < 0 || solIdx >= nSols)
return false;
1031 if(nSols <= 0)
return false;
1033 solIdx < 0 || solIdx >= nSols)
return false;
1048 for(
int i = 0; i < numberOfVar; i++){
1058 if(iNumberOfVariables <= 0)
return false;
1060 if(nSols <= 0)
return false;
1063 solIdx < 0 || solIdx >= nSols)
return false;
1072 for(
int i = 0; i < numberOfOtherVariableResults; i++){
1081 int iNumberOfVariables = numberOfVar;
1082 if(iNumberOfVariables <= 0)
return false;
1085 if(nSols <= 0)
return false;
1088 solIdx < 0 || solIdx >= nSols)
return false;
1096 for(
int i = 0; i < iNumberOfVariables; i++){
1108 if (numberOfObj <= 0 || numberOfObj > nObj)
return false;
1110 if(nSols <= 0)
return false;
1112 solIdx < 0 || solIdx >= nSols)
return false;
1131 int iNumberOfObjectives = numberOfObj;
1132 if(iNumberOfObjectives < 0)
return false;
1133 if(iNumberOfObjectives == 0)
return true;
1134 if(objectiveValues == NULL)
return false;
1137 if(nSols <= 0)
return false;
1140 solIdx < 0 || solIdx >= nSols)
return false;
1151 for(
int i = 0; i < iNumberOfObjectives; i++){
1162 if (numberOfCon <= 0 || numberOfCon > nCon)
return false;
1164 if(nSols <= 0)
return false;
1166 solIdx < 0 || solIdx >= nSols)
return false;
1185 int iNumberOfConstraints = numberOfCon;
1186 if(iNumberOfConstraints < 0)
return false;
1187 if(iNumberOfConstraints == 0)
return true;
1190 if(nSols <= 0)
return false;
1193 solIdx < 0 || solIdx >= nSols)
return false;
1203 if(lbValues == NULL && ubValues == NULL){
1208 if(lbValues == NULL){
1209 for(
int i = 0; i < iNumberOfConstraints; i++){
1210 if(ubValues[i] != 0) iCons++;
1213 else if(ubValues == NULL){
1214 for(
int i = 0; i < iNumberOfConstraints; i++){
1215 if(lbValues[i] != 0) iCons++;
1219 for(
int i = 0; i < iNumberOfConstraints; i++){
1220 if(lbValues[i] != 0 || ubValues[i] != 0) iCons++;
1228 if(lbValues == NULL){
1229 for(
int i = 0; i < iNumberOfConstraints; i++){
1230 if(ubValues[i] != 0){
1238 else if(ubValues == NULL){
1239 for(
int i = 0; i < iNumberOfConstraints; i++){
1240 if(lbValues[i] != 0){
1249 for(
int i = 0; i < iNumberOfConstraints; i++){
1250 if(lbValues[i] != 0 || ubValues[i] != 0){
1262 int iNumberOfConstraints = numberOfCon;
1263 if(iNumberOfConstraints < 0)
return false;
1264 if(iNumberOfConstraints == 0)
return true;
1267 if(nSols <= 0)
return false;
1270 solIdx < 0 || solIdx >= nSols)
return false;
1285 for(
int i = 0; i < iNumberOfConstraints; i++){
1294 int iNumberOfConstraints = numberOfCon;
1295 if(iNumberOfConstraints <= 0)
return false;
1298 if(nSols <= 0)
return false;
1301 solIdx < 0 || solIdx >= nSols)
return false;
1311 if(dualVarValues == NULL){
1317 for(
int i = 0; i < iNumberOfConstraints; i++){
OptimizationSolutionStatus * status
status is a pointer to an OptimizationSolutionStatus object associated with this optimization solutio...
int getObjectiveNumber()
Get objective number.
VariableValues()
Default constructor.
~OSResult()
Class destructor.
std::string getGeneralMessage()
Get the general message.
GeneralStatus * getGeneralStatus()
Get the general status.
int m_iVariableNumber
m_iVariableNumber holds the variable number.
OtherConstraintResult ** other
a pointer to an array of other pointer objects for constraint functions
bool setGeneralStatusDescription(std::string description)
Set the general status description.
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 numberOfVar
the number of variable values that are in the solution
std::string getGeneralStatusType()
Get the general status type, which can be: success, error, warning.
double value
value is a double that holds the value of the entity
std::string getSolutionStatusType(int solIdx)
Get the [i]th optimization solution status type, where i equals the given solution index...
bool setDualVariableValues(int solIdx, double *lbValues, double *ubValues, int n)
Set the [i]th optimization solution's dual variable values, where i equals the given solution index...
ObjectiveValues()
Default constructor.
~ObjectiveSolution()
Class destructor.
int numberOfOtherObjectiveResults
the number of types of objective function results other than the basic objective function values ...
TimingInformation * timingInformation
a pointer to the TimingInformation class
Time()
Default constructor.
The OptimizationResult Class.
ObjValue ** obj
obj is a pointer to an array of ObjValue objects that give an index and objective function value for ...
bool setServiceName(std::string serviceName)
Set service name.
int idx
idx is the index on variable in the solution
The ObjectiveValues Class.
OtherObjResult()
Default constructor.
bool setVariableNumber(int variableNumber)
Set the variable number.
DualVarValue ** con
con is a vector of DualVarValue objects that give an index and dual variable value for each constrain...
DualVariableValues * dualValues
a pointer to an array of DualVariableValues objects
~GeneralResult()
Class destructor.
std::string description
Further description on the timer used.
~JobResult()
Class destructor.
bool setNumberOfPrimalVariableValues(int solIdx, int n)
Set the [i]th optimization solution's number of primal variable values, where i equals the given solu...
std::string message
a message associated with this solution
std::vector< IndexValuePair * > getOptimalPrimalVariableValues(int solIdx)
Get one solution of optimal primal variable values.
std::string unit
The unit of time (tick/millisecond/second/minute/hour/day/week/month/year)
bool setAnOtherVariableResult(int solIdx, int otherIdx, std::string name, std::string description, int *indexes, std::string *s, int n)
Set the [i]th optimization solution's other (non-standard/solver specific)variable-related results...
JobResult * job
job holds the fourth child of the OSResult specified by the OSrL Schema.
DualVarValue()
Default constructor.
~OptimizationSolution()
Class destructor.
ServiceResult()
Default constructor.
GeneralResult * general
general holds the first child of the OSResult specified by the OSrL Schema.
ServiceResult * service
service holds the third child of the OSResult specified by the OSrL Schema.
double value
the number of units
ObjectiveSolution()
Default constructor.
bool setTime(double time)
Set time.
GeneralResult()
Default constructor.
The OptimizationSolution Class.
The ConstraintSolution Class.
bool setGeneralStatus(GeneralStatus *status)
Set the general status.
OptimizationResult * optimization
optimization holds the fifth child of the OSResult specified by the OSrL Schema.
DualVariableValues()
Default constructor.
SystemResult()
Default constructor.
SystemResult * system
system holds the second child of the OSResult specified by the OSrL Schema.
std::vector< IndexValuePair * > getOptimalDualVariableValues(int solIdx)
Get one solution of optimal dual variable values.
OtherVariableResult()
Default constructor.
bool setConstraintValues(int solIdx, double *constraintValues, int n)
Set the [i]th optimization solution's constraint values, where i equals the given solution index...
bool setServiceURI(std::string serviceURI)
Set service uri.
std::string description
a brief description of the type of result
bool setObjectiveNumber(int objectiveNumber)
Set the objective number.
~OtherVariableResult()
Class destructor.
bool setInstanceName(std::string instanceName)
Set instance name.
bool setNumberOfObjectiveValues(int solIdx, int n)
Set the [i]th optimization solution's number of objective values, where i equals the given solution i...
double getTimeValue()
Get the time measurement.
bool setTimeNumber(int timeNumber)
Set the number of time measurements.
OSResult()
Default constructor.
~VariableSolution()
Class destructor.
~DualVarValue()
Class destructor.
~GeneralStatus()
Class destructor.
~OtherConstraintResult()
Class destructor.
~OtherObjResult()
Class destructor.
ObjectiveSolution * objectives
objectives holds the solution information for the objectives
OtherObjectiveResult()
Default constructor.
int numberOfVar
the number of variables which have values for this particular type of result
int m_iObjectiveNumber
m_iObjectiveNumber holds the objective number.
std::string getGeneralStatusDescription()
Get the general status description.
~OtherConResult()
Class destructor.
The OptimizationSolutionStatus Class.
bool setSolutionNumber(int number)
set the number of solutions.
double * m_mdPrimalValues
m_mdPrimalValues a vector of primal variables.
~ConstraintSolution()
Class destructor.
std::string getServiceName()
Get service name.
std::string message
any general message associated with the optimization
OtherVarResult()
Default constructor.
std::string getSolutionMessage(int solIdx)
Get the [i]th optimization solution message, where i equals the given solution index.
int numberOfCon
record the number of constraints for which values are given
double ubValue
ubValue is the value of dual variable on the constraint indexed by idx if the constraint is at its up...
VarValue ** var
a vector of VarValue objects, there will be one for each variable in the solution ...
VariableSolution * variables
variables holds the solution information for the variables
bool setObjectiveValues(int solIdx, double *objectiveValues, int n)
Set the [i]th optimization solution's objective values, where i equals the given solution index...
std::string getJobID()
Get the job id.
bool setNumberOfOtherVariableResults(int solIdx, int numberOfOtherVariableResults)
Set the [i]th optimization solution's other (non-standard/solver specific) variable-related results...
~OptimizationSolutionStatus()
Class destructor.
ObjValue()
Default constructor.
OptimizationResult()
Default constructor.
int numberOfSolutions
numberOfSolutions is the number of objective functions reported.
std::string name
the name of the result the user is defining
double lbValue
lbValue is the value of dual variable on the constraint indexed by idx if the constraint is at its lo...
bool setPrimalVariableValues(int solIdx, double *x, int n)
Set the [i]th optimization solution's primal variable values, where i equals the given solution index...
~OtherVarResult()
Class destructor.
VariableValues * values
a pointer to a VariableValues object
GeneralStatus * generalStatus
a pointer to the GeneralStatus class
int idx
the index of a variable in the solution
The VariableValues Class.
void fint fint fint fint fint fint fint fint fint fint real real real real real real real real * s
int getSolutionNumber()
get the number of solutions.
bool setGeneralMessage(std::string message)
Set the general message.
int idx
idx holds the index of an entity (such as a variable, constraint, objective) that is part of a sparse...
std::string getInstanceName()
Get instance name.
~VariableValues()
Class destructor.
std::string type
the type of solution status
bool setGeneralStatusType(std::string type)
Set the general status type, which can be: success, error, warning.
int targetObjectiveIdx
the index of the objective function for which we are reporting solution information ...
std::string type
the type of status
~ObjectiveValues()
Class destructor.
~ServiceResult()
Class destructor.
~VarValue()
Class destructor.
ConstraintSolution()
Default constructor.
The VariableSolution Class.
bool setNumberOfDualVariableValues(int solIdx, int n)
Set the [i]th optimization solution's number of dual variable values, where i equals the given soluti...
OptimizationSolution ** solution
solution is an array of pointers to OptimizationSolution objects
double * m_mdDualValues
m_mdDualValues a vector of dual variables.
ConstraintSolution * constraints
constraints holds the solution information for the constraints
~OptimizationResult()
Class destructor.
ObjectiveValues * values
a pointer to an array of ObjectiveValues objects
std::string instanceName
the name of the instance that was solved
bool setConstraintNumber(int constraintNumber)
Set the constraint number.
VarValue()
Default constructor.
bool setSolutionObjectiveIndex(int solIdx, int objectiveIdx)
Set the [i]th optimization solution's objective index, where i equals the given solution index...
std::string serviceName
the serviceName is the name of the solver service that did the optimization
int numberOfConstraints
numberOfConstrants is the number of constraint functions reported in the solution.
std::string getSolutionStatusDescription(int solIdx)
Get the [i]th optimization solution status description, where i equals the given solution index...
std::string description
a description of the solution status type
int idx
idx is the index on a constraint
OtherVariableResult ** other
a pointer to an array of other pointer objects for variables
VariableSolution()
Default constructor.
int numberOfObj
record the number of objective rows for which values are given
std::string serviceURI
the serviceURI is the URI of the solver service that did the optimization
bool setJobID(std::string jobID)
Set job id.
The DualVariableValues Class.
OtherObjectiveResult ** other
a pointer to an array of other pointer objects for objective functions
int numberOfVariables
numberOfVariables is the number of variables reported in the solution.
int getNumberOfOtherVariableResults(int solIdx)
Get numberOfOtherVariableResult.
int numberOfOtherConstraintResults
the number of types of constraint function results other than the basic constraint function values ...
bool addTimingInformation(std::string type, std::string category, std::string unit, std::string description, double value)
Add timing information.
std::string category
The category of time (total/input/preprocessing/optimization/postprocessing/output/other) ...
JobResult()
Default constructor.
double value
The time measurement.
~ObjValue()
Class destructor.
~DualVariableValues()
Class destructor.
int getTimeNumber()
Get the number of time measurements.
std::string getServiceURI()
Get service uri.
int numberOfOtherVariableResults
the number of types of variable results other than the value of the variable
int idx
idx is the index on an objective function
std::string type
The type of timer used (cpuTime/elapsedTime/other)
OtherConstraintResult()
Default constructor.
double value
the value of the objective indexed by idx
GeneralStatus()
Default constructor.
int m_iNumberOfOtherVariableResults
m_iNumberOfOtherVariableResults holds the number of OtherVariableResult objects.
std::string jobID
the jobID is the ID associated with the solution of this instance
OptimizationSolution()
Default constructor.
std::string value
value holds a general value associated with a variable, for example, rather than the value of a varia...
OptimizationSolutionStatus * getSolutionStatus(int solIdx)
Get the [i]th optimization solution status, where i equals the given solution index.
int getVariableNumber()
Get variable number.
int m_iConstraintNumber
m_iConstraintNumber holds the constraint number.
double value
value of dual variable on the constraint indexed by idx
~SystemResult()
Class destructor.
OtherConResult()
Default constructor.
int numberOfObjectives
numberOfObjectives is the number of objective functions reported in the solution. ...
int getConstraintNumber()
Get constraint number.
The OtherVariableResult Class.
The ObjectiveSolution Class.
void fint fint fint real fint real * x
OptimizationSolutionStatus()
Default constructor.
std::string description
the description of the status
~OtherObjectiveResult()
Class destructor.