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++){
792 for(
int j = 0; j < iNumberOfVariables; j++){
807 if(iNumberOfConstraints <= 0)
return NULL;
809 for(
int i = 0; i < iSolutions; i++){
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();
867 temp[ nt]->
type = type;
869 temp[ nt]->
unit = unit;
871 temp[ nt]->
value = value;
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++){
The ConstraintSolution Class.
OtherConstraintResult ** other
a pointer to an array of other pointer objects for constraint functions
ConstraintSolution()
Default constructor.
DualVariableValues * dualValues
a pointer to an array of DualVariableValues objects
~ConstraintSolution()
Class destructor.
int numberOfOtherConstraintResults
the number of types of constraint function results other than the basic constraint function values
double lbValue
lbValue is the value of dual variable on the constraint indexed by idx if the constraint is at its lo...
DualVarValue()
Default constructor.
double ubValue
ubValue is the value of dual variable on the constraint indexed by idx if the constraint is at its up...
~DualVarValue()
Class destructor.
double value
value of dual variable on the constraint indexed by idx
int idx
idx is the index on a constraint
The DualVariableValues Class.
~DualVariableValues()
Class destructor.
DualVarValue ** con
con is a vector of DualVarValue objects that give an index and dual variable value for each constrain...
DualVariableValues()
Default constructor.
int numberOfCon
record the number of constraints for which values are given
~GeneralResult()
Class destructor.
GeneralResult()
Default constructor.
std::string serviceURI
the serviceURI is the URI of the solver service that did the optimization
std::string serviceName
the serviceName is the name of the solver service that did the optimization
std::string jobID
the jobID is the ID associated with the solution of this instance
GeneralStatus * generalStatus
a pointer to the GeneralStatus class
std::string instanceName
the name of the instance that was solved
std::string message
any general message associated with the optimization
std::string type
the type of status
~GeneralStatus()
Class destructor.
std::string description
the description of the status
GeneralStatus()
Default constructor.
JobResult()
Default constructor.
TimingInformation * timingInformation
a pointer to the TimingInformation class
~JobResult()
Class destructor.
std::string getServiceName()
Get service name.
bool setNumberOfDualVariableValues(int solIdx, int n)
Set the [i]th optimization solution's number of dual variable values, where i equals the given soluti...
bool setGeneralMessage(std::string message)
Set the general message.
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,...
bool setJobID(std::string jobID)
Set job id.
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...
std::string getGeneralStatusDescription()
Get the general status description.
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.
std::string getSolutionStatusType(int solIdx)
Get the [i]th optimization solution status type, where i equals the given solution index.
OSResult()
Default constructor.
int m_iNumberOfOtherVariableResults
m_iNumberOfOtherVariableResults holds the number of OtherVariableResult objects.
std::string getInstanceName()
Get instance name.
bool setGeneralStatusDescription(std::string description)
Set the general status description.
bool setSolutionNumber(int number)
set the number of solutions.
bool setInstanceName(std::string instanceName)
Set instance name.
GeneralResult * general
general holds the first child of the OSResult specified by the OSrL Schema.
int m_iObjectiveNumber
m_iObjectiveNumber holds the objective number.
std::string getSolutionStatusDescription(int solIdx)
Get the [i]th optimization solution status description, where i equals the given solution index.
bool setNumberOfOtherVariableResults(int solIdx, int numberOfOtherVariableResults)
Set the [i]th optimization solution's other (non-standard/solver specific) variable-related results,...
double * m_mdPrimalValues
m_mdPrimalValues a vector of primal variables.
bool setGeneralStatusType(std::string type)
Set the general status type, which can be: success, error, warning.
ServiceResult * service
service holds the third child of the OSResult specified by the OSrL Schema.
bool setObjectiveNumber(int objectiveNumber)
Set the objective number.
int m_iVariableNumber
m_iVariableNumber holds the variable number.
int getObjectiveNumber()
Get objective number.
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 setNumberOfObjectiveValues(int solIdx, int n)
Set the [i]th optimization solution's number of objective values, where i equals the given solution i...
OptimizationResult * optimization
optimization holds the fifth child of the OSResult specified by the OSrL Schema.
std::string getSolutionMessage(int solIdx)
Get the [i]th optimization solution message, where i equals the given solution index.
bool setGeneralStatus(GeneralStatus *status)
Set the general status.
double * m_mdDualValues
m_mdDualValues a vector of dual 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.
std::vector< IndexValuePair * > getOptimalDualVariableValues(int solIdx)
Get one solution of optimal dual variable values.
bool setServiceName(std::string serviceName)
Set service name.
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::vector< IndexValuePair * > getOptimalPrimalVariableValues(int solIdx)
Get one solution of optimal primal variable values.
OptimizationSolutionStatus * getSolutionStatus(int solIdx)
Get the [i]th optimization solution status, where i equals the given solution index.
int getTimeNumber()
Get the number of time measurements.
bool setVariableNumber(int variableNumber)
Set the variable number.
~OSResult()
Class destructor.
bool setTime(double time)
Set time.
std::string getGeneralMessage()
Get the general message.
int getSolutionNumber()
get the number of solutions.
SystemResult * system
system holds the second child of the OSResult specified by the OSrL Schema.
bool setSolutionObjectiveIndex(int solIdx, int objectiveIdx)
Set the [i]th optimization solution's objective index, where i equals the given solution index.
bool setTimeNumber(int timeNumber)
Set the number of time measurements.
bool setSolutionStatus(int solIdx, std::string type, std::string description)
Set the [i]th optimization solution status, where i equals the given solution index.
double getTimeValue()
Get the time measurement.
GeneralStatus * getGeneralStatus()
Get the general status.
bool addTimingInformation(std::string type, std::string category, std::string unit, std::string description, double value)
Add timing information.
int getConstraintNumber()
Get constraint number.
bool setConstraintNumber(int constraintNumber)
Set the constraint number.
bool setServiceURI(std::string serviceURI)
Set service uri.
int getNumberOfOtherVariableResults(int solIdx)
Get numberOfOtherVariableResult.
int getVariableNumber()
Get variable number.
JobResult * job
job holds the fourth child of the OSResult specified by the OSrL Schema.
std::string getServiceURI()
Get service uri.
std::string getGeneralStatusType()
Get the general status type, which can be: success, error, warning.
int m_iConstraintNumber
m_iConstraintNumber holds the constraint number.
ObjValue()
Default constructor.
~ObjValue()
Class destructor.
double value
the value of the objective indexed by idx
int idx
idx is the index on an objective function
The ObjectiveSolution Class.
OtherObjectiveResult ** other
a pointer to an array of other pointer objects for objective functions
ObjectiveSolution()
Default constructor.
int numberOfOtherObjectiveResults
the number of types of objective function results other than the basic objective function values
~ObjectiveSolution()
Class destructor.
ObjectiveValues * values
a pointer to an array of ObjectiveValues objects
The ObjectiveValues Class.
~ObjectiveValues()
Class destructor.
int numberOfObj
record the number of objective rows for which values are given
ObjValue ** obj
obj is a pointer to an array of ObjValue objects that give an index and objective function value for ...
ObjectiveValues()
Default constructor.
The OptimizationResult Class.
int numberOfSolutions
numberOfSolutions is the number of objective functions reported.
OptimizationResult()
Default constructor.
int numberOfObjectives
numberOfObjectives is the number of objective functions reported in the solution.
int numberOfVariables
numberOfVariables is the number of variables reported in the solution.
OptimizationSolution ** solution
solution is an array of pointers to OptimizationSolution objects
~OptimizationResult()
Class destructor.
int numberOfConstraints
numberOfConstrants is the number of constraint functions reported in the solution.
The OptimizationSolution Class.
VariableSolution * variables
variables holds the solution information for the variables
OptimizationSolution()
Default constructor.
ObjectiveSolution * objectives
objectives holds the solution information for the objectives
int targetObjectiveIdx
the index of the objective function for which we are reporting solution information
~OptimizationSolution()
Class destructor.
ConstraintSolution * constraints
constraints holds the solution information for the constraints
OptimizationSolutionStatus * status
status is a pointer to an OptimizationSolutionStatus object associated with this optimization solutio...
std::string message
a message associated with this solution
The OptimizationSolutionStatus Class.
std::string description
a description of the solution status type
OptimizationSolutionStatus()
Default constructor.
std::string type
the type of solution status
~OptimizationSolutionStatus()
Class destructor.
~OtherConResult()
Class destructor.
OtherConResult()
Default constructor.
OtherConstraintResult()
Default constructor.
~OtherConstraintResult()
Class destructor.
~OtherObjResult()
Class destructor.
OtherObjResult()
Default constructor.
OtherObjectiveResult()
Default constructor.
~OtherObjectiveResult()
Class destructor.
OtherVarResult()
Default constructor.
std::string value
value holds a general value associated with a variable, for example, rather than the value of a varia...
~OtherVarResult()
Class destructor.
int idx
the index of a variable in the solution
The OtherVariableResult Class.
OtherVariableResult()
Default constructor.
~OtherVariableResult()
Class destructor.
std::string description
a brief description of the type of result
std::string name
the name of the result the user is defining
int numberOfVar
the number of variables which have values for this particular type of result
~ServiceResult()
Class destructor.
ServiceResult()
Default constructor.
~SystemResult()
Class destructor.
SystemResult()
Default constructor.
std::string type
The type of timer used (cpuTime/elapsedTime/other)
std::string unit
The unit of time (tick/millisecond/second/minute/hour/day/week/month/year)
std::string description
Further description on the timer used.
double value
The time measurement.
Time()
Default constructor.
std::string category
The category of time (total/input/preprocessing/optimization/postprocessing/output/other)
double value
the number of units
VarValue()
Default constructor.
int idx
idx is the index on variable in the solution
~VarValue()
Class destructor.
The VariableSolution Class.
VariableSolution()
Default constructor.
OtherVariableResult ** other
a pointer to an array of other pointer objects for variables
int numberOfOtherVariableResults
the number of types of variable results other than the value of the variable
~VariableSolution()
Class destructor.
VariableValues * values
a pointer to a VariableValues object
The VariableValues Class.
VariableValues()
Default constructor.
VarValue ** var
a vector of VarValue objects, there will be one for each variable in the solution
int numberOfVar
the number of variable values that are in the solution
~VariableValues()
Class destructor.