- Main Page
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# /home/coin/SVN-release/OS-2.3.5/OS/v2.0/OSResult.cpp

Go to the documentation of this file.

    00001
    00017 #include "OSResult.h"
    00018 #include "OSParameters.h"
    00019 #include "OSErrorClass.h"
    00020
    00021
    00022 #include "OSDataStructures.h"
    00023 #include "OSParameters.h"
    00024 #include "OSCommonUtil.h"
    00025 #include "OSMathUtil.h"
    00026
    00027 #include<iostream>
    00028 #include<sstream>
    00029 #define DEBUG
    00030
    00031 using namespace std;
    00032
    00033 GeneralStatus::GeneralStatus():
    00034         type( ""),
    00035         description( "")
    00036 {
    00037         #ifdef DEBUG
    00038         cout << "Inside GeneralStatus Constructor" << endl;
    00039         #endif
    00040 }// end GeneralStatus constructor
    00041
    00042 GeneralStatus::~GeneralStatus(){
    00043         #ifdef DEBUG
    00044         cout << "GeneralStatus Destructor Called" << endl;
    00045         #endif
    00046 }//end GeneralStatus destructor
    00047
    00048 OSResult::OSResult():
    00049         m_iVariableNumber( -1),
    00050         m_iObjectiveNumber( -1),
    00051         m_iConstraintNumber( -1),
    00052         m_iNumberOfOtherVariableResults( -1),
    00053         m_mdPrimalValues( NULL),
    00054         m_mdDualValues( NULL)
    00055
    00056 {
    00057         #ifdef DEBUG
    00058         cout << "Inside OSResult Constructor" << endl;
    00059         #endif
    00060         this->general = new GeneralResult();
    00061         this->system = new SystemResult();
    00062         this->service = new ServiceResult();
    00063         this->job = new JobResult();
    00064         this->optimization = new OptimizationResult();
    00065 }// end OSResult constructor
    00066
    00067 OSResult::~OSResult(){
    00068         #ifdef DEBUG
    00069         cout << "OSResult Destructor Called" << endl;
    00070         #endif
    00071         // delete the children of OSResult
    00072         // delete general object
    00073         if(general != NULL) delete general;
    00074         general = NULL;
    00075         //delete system object
    00076         if(system != NULL)  delete system;
    00077         system = NULL;
    00078         //delete service object
    00079         if(service != NULL)  delete service;
    00080         service = NULL;
    00081         //delete job object
    00082         if(job != NULL)  delete job;
    00083         job = NULL;
    00084         //delete optimization object
    00085         if(optimization != NULL)  delete optimization;
    00086         optimization = NULL;
    00087
    00088         if(m_mdPrimalValues != NULL) delete[] m_mdPrimalValues;
    00089         m_mdPrimalValues = 0;
    00090         if(m_mdDualValues != NULL) delete[] m_mdDualValues;
    00091         m_mdDualValues = 0;
    00092 }//end OSResult destructor
    00093
    00094
    00095 GeneralResult::GeneralResult():
    00096         serviceURI(""),
    00097         serviceName(""),
    00098         instanceName(""),
    00099         jobID(""),
    00100         time("0.0"),
    00101         message("")
    00102 {
    00103         #ifdef DEBUG
    00104         cout << "Inside the GeneralResult Constructor" << endl;
    00105         #endif
    00106         generalStatus = new GeneralStatus();
    00107 }//end GeneralResult constructor
    00108
    00109
    00110 GeneralResult::~GeneralResult(){
    00111         #ifdef DEBUG
    00112         cout << "Inside the GeneralResult Destructor" << endl;
    00113         #endif
    00114         delete generalStatus;
    00115         generalStatus = NULL;
    00116 }// end GeneralResult destructor
    00117
    00118
    00119 SystemResult::SystemResult()  //:
    00120 {
    00121         #ifdef DEBUG
    00122         cout << "Inside the SystemResult Constructor" << endl;
    00123         #endif
    00124 }//end SystemResult constructor
    00125
    00126
    00127 SystemResult::~SystemResult(){
    00128         #ifdef DEBUG
    00129         cout << "Inside the SystemResult Destructor" << endl;
    00130         #endif
    00131 }// end SystemResult destructor
    00132
    00133
    00134
    00135 ServiceResult::ServiceResult()  //:
    00136 {
    00137         #ifdef DEBUG
    00138         cout << "Inside the ServiceResult Constructor" << endl;
    00139         #endif
    00140 }//end ServiceResult constructor
    00141
    00142
    00143 ServiceResult::~ServiceResult(){
    00144         #ifdef DEBUG
    00145         cout << "Inside the ServiceResult Destructor" << endl;
    00146         #endif
    00147 }// end ServiceResult destructor
    00148
    00149
    00150 Time::Time():
    00151         type("elapsedTime"),
    00152         category("total"),
    00153         unit("second"),
    00154         description(""),
    00155         value(0.0)
    00156 {
    00157         #ifdef DEBUG
    00158         cout << "Inside the Time Constructor" << endl;
    00159         #endif
    00160 }//end Time constructor
    00161
    00162
    00163 Time::~Time(){
    00164         #ifdef DEBUG
    00165         cout << "Inside the Time Destructor" << endl;
    00166         #endif
    00167
    00168 }// end TimingInformation destructor
    00169
    00170 TimingInformation::TimingInformation():
    00171         numberOfTimes(0)
    00172 {
    00173         #ifdef DEBUG
    00174         cout << "Inside the TimingInformation Constructor" << endl;
    00175         #endif
    00176         time = NULL;
    00177 }//end TimingInformation constructor
    00178
    00179
    00180 TimingInformation::~TimingInformation(){
    00181         #ifdef DEBUG
    00182         cout << "Inside the TimingInformation Destructor" << endl;
    00183         #endif
    00184         if (time != NULL)
    00185         {
    00186                 for (int i = 0; i < numberOfTimes; i++)
    00187                 {       delete time[i];
    00188                         time[i] = NULL;
    00189                 }
    00190                 delete [] time;
    00191                 time = NULL;
    00192         }
    00193 }// end TimingInformation destructor
    00194
    00195
    00196 JobResult::JobResult() //:
    00197 {
    00198         #ifdef DEBUG
    00199         cout << "Inside the JobResult Constructor" << endl;
    00200         #endif
    00201         timingInformation = NULL;
    00202 }//end JobResult constructor
    00203
    00204
    00205 JobResult::~JobResult(){
    00206         #ifdef DEBUG
    00207         cout << "Inside the JobResult Destructor" << endl;
    00208         #endif
    00209         if (timingInformation != NULL) delete timingInformation;
    00210         timingInformation = NULL;
    00211 }// end JobResult destructor
    00212
    00213 VarValue::VarValue():
    00214         idx( -1),
    00215         value( 0)
    00216 {
    00217         #ifdef DEBUG
    00218         cout << "Inside the VarValue Constructor" << endl;
    00219         #endif
    00220 }//end VarValue constructor
    00221
    00222
    00223 VarValue::~VarValue(){
    00224         #ifdef DEBUG
    00225         cout << "Inside the VarValue Destructor" << endl;
    00226         #endif
    00227 }// end VarValue destructor
    00228
    00229
    00230 OtherVarResult::OtherVarResult():
    00231         idx( -1),
    00232         value( "")
    00233 {
    00234         #ifdef DEBUG
    00235         cout << "Inside the OtherVarResult Constructor" << endl;
    00236         #endif
    00237 }//end OtherVarResult constructor
    00238
    00239
    00240 OtherVarResult::~OtherVarResult(){
    00241         #ifdef DEBUG
    00242         cout << "Inside the OtherVarResult Destructor" << endl;
    00243         #endif
    00244 }// end OtherVarResult destructor
    00245
    00246
    00247 OtherObjResult::OtherObjResult():
    00248         idx( -1),
    00249         value( "")
    00250 {
    00251         #ifdef DEBUG
    00252         cout << "Inside the OtherObjResult Constructor" << endl;
    00253         #endif
    00254 }//end OtherObjResult constructor
    00255
    00256
    00257 OtherObjResult::~OtherObjResult(){
    00258         #ifdef DEBUG
    00259         cout << "Inside the OtherObjResult Destructor" << endl;
    00260         #endif
    00261 }//end OtherObjResult destructor
    00262
    00263
    00264 OtherConResult::OtherConResult():
    00265         idx( -1),
    00266         value( "")
    00267 {
    00268         #ifdef DEBUG
    00269         cout << "Inside the OtherConResult Constructor" << endl;
    00270         #endif
    00271 }//end OtherConResult constructor
    00272
    00273
    00274 OtherConResult::~OtherConResult(){
    00275         #ifdef DEBUG
    00276         cout << "Inside the OtherConResult Destructor" << endl;
    00277         #endif
    00278 }//end OtherConResult destructor
    00279
    00280
    00281 ObjValue::ObjValue():
    00282         idx( -1),
    00283         value( OSNAN)
    00284 {
    00285         #ifdef DEBUG
    00286         cout << "Inside the ObjValue Constructor" << endl;
    00287         #endif
    00288 }//end ObjValue constructor
    00289
    00290 ObjValue::~ObjValue(){
    00291         #ifdef DEBUG
    00292         cout << "Inside the ObjValue Destructor" << endl;
    00293         #endif
    00294 }// end ObjValue destructor
    00295
    00296 DualVarValue::DualVarValue():
    00297         idx( -1),
    00298         lbValue( 0),
    00299         ubValue( 0),
    00300         value( 0)
    00301 {
    00302         #ifdef DEBUG
    00303         cout << "Inside the DualVarValue Constructor" << endl;
    00304         #endif
    00305 }//end DualVarValue constructor
    00306
    00307
    00308 DualVarValue::~DualVarValue(){
    00309         #ifdef DEBUG
    00310         cout << "Inside the DualVarValue Destructor" << endl;
    00311         #endif
    00312 }// end DualVarValue destructor
    00313
    00314
    00315
    00316 VariableValues::VariableValues() {
    00317         #ifdef DEBUG
    00318         cout << "Inside the VariableValues Constructor" << endl;
    00319         #endif
    00320
    00321 }//end VariableValues constructor
    00322
    00323
    00324 VariableValues::~VariableValues(){
    00325         #ifdef DEBUG
    00326         cout << "Inside the VariableValues Destructor" << endl;
    00327         #endif
    00328         int n = var.size();
    00329         if(n > 0 ){
    00330                 for(int i = 0; i < n; i++){
    00331                         delete var[i];
    00332                         var[i] = NULL;
    00333                 }
    00334         }
    00335         var.clear();
    00336
    00337 }// end VariableValues destructor
    00338
    00339
    00340 OtherVariableResult::OtherVariableResult():
    00341         numberOfVar(-1),
    00342         value(""),
    00343         name(""),
    00344         description("")
    00345 {
    00346         #ifdef DEBUG
    00347         cout << "Inside the OtherVariableResult Constructor" << endl;
    00348         #endif
    00349
    00350 }//end OtherVariableResult constructor
    00351
    00352
    00353 OtherVariableResult::~OtherVariableResult(){
    00354         #ifdef DEBUG
    00355         cout << "Inside the OtherVariableResult Destructor" << endl;
    00356         #endif
    00357         int n = var.size();
    00358         if (n > 0) {
    00359                 for(int i = 0; i < n; i++){
    00360                         delete var[i];
    00361                         var[i] = NULL;
    00362                 }
    00363         }
    00364         var.clear();
    00365         #ifdef DEBUG
    00366         cout << "Inside the OtherVariableResult Destructor - Done" << endl;
    00367         #endif
    00368 }// end OtherVariableResult destructor
    00369
    00370
    00371 OtherObjectiveResult::OtherObjectiveResult():
    00372         name(""),
    00373         description("")
    00374 {
    00375         #ifdef DEBUG
    00376         cout << "Inside the OtherObjectiveResult Constructor" << endl;
    00377         #endif
    00378 }//end OtherObjectiveResult constructor
    00379
    00380
    00381 OtherObjectiveResult::~OtherObjectiveResult(){
    00382         #ifdef DEBUG
    00383         cout << "Inside the OtherObjectiveResult Destructor" << endl;
    00384         #endif
    00385         int n = obj.size();
    00386         if(n > 0) {
    00387                 for(int i = 0; i < n; i++){
    00388                         delete obj[i];
    00389                         obj[i] = NULL;
    00390                 }
    00391         }
    00392         obj.clear();
    00393 }// end OtherObjectiveResult destructor
    00394
    00395
    00396 OtherConstraintResult::OtherConstraintResult():
    00397         name(""),
    00398         description("")
    00399 {
    00400         #ifdef DEBUG
    00401         cout << "Inside the OtherConstraintResult Constructor" << endl;
    00402         #endif
    00403 }//end OtherConstraintResult constructor
    00404
    00405
    00406 OtherConstraintResult::~OtherConstraintResult(){
    00407         #ifdef DEBUG
    00408         cout << "Inside the OtherConstraintResult Destructor" << endl;
    00409         #endif
    00410         int n = con.size();
    00411         if(n > 0){
    00412                 for(int i = 0; i < n; i++){
    00413                         delete con[i];
    00414                         con[i] = NULL;
    00415                 }
    00416         }
    00417         con.clear();
    00418 }// end OtherObjectiveResult destructor
    00419
    00420
    00421 ObjectiveValues::ObjectiveValues() {
    00422         #ifdef DEBUG
    00423         cout << "Inside the ObjectiveValues Constructor" << endl;
    00424         #endif
    00425
    00426 }//end ObjectiveValues constructor
    00427
    00428
    00429 ObjectiveValues::~ObjectiveValues(){
    00430         #ifdef DEBUG
    00431         cout << "Inside the ObjectiveValues Destructor" << endl;
    00432         #endif
    00433         int n = obj.size();
    00434         if(n > 0 ){
    00435                 for(int i = 0; i < n; i++){
    00436                         delete obj[i];
    00437                         obj[i] = NULL;
    00438                 }
    00439         }
    00440         obj.clear();
    00441
    00442 }// end ObjectiveValues destructor
    00443
    00444
    00445
    00446 DualVariableValues::DualVariableValues() {
    00447         #ifdef DEBUG
    00448         cout << "Inside the DualVariableValues Constructor" << endl;
    00449         #endif
    00450
    00451 }//end DualVariableValues constructor
    00452
    00453
    00454 DualVariableValues::~DualVariableValues(){
    00455         #ifdef DEBUG
    00456         cout << "Inside the DualVariableValues Destructor" << endl;
    00457         #endif
    00458         int n = con.size();
    00459         if(n > 0){
    00460                 for(int i = 0; i < n; i++){
    00461                         delete con[i];
    00462                         con[i] = NULL;
    00463                 }
    00464         }
    00465         con.clear();
    00466 }// end DualVariableValues destructor
    00467
    00468
    00469
    00470 VariableSolution::VariableSolution():
    00471         numberOfOtherVariableResults( 0),
    00472         values( NULL),
    00473         other( NULL)
    00474
    00475 {
    00476         #ifdef DEBUG
    00477         cout << "Inside the VariableSolution Constructor" << endl;
    00478         #endif
    00479 }//end VariableSolution constructor
    00480
    00481
    00482 VariableSolution::~VariableSolution(){
    00483         #ifdef DEBUG
    00484         cout << "Inside the VariableSolution Destructor" << endl;
    00485         #endif
    00486         delete  values;
    00487         values = NULL;
    00488         if(numberOfOtherVariableResults > 0 && other != NULL){
    00489                 for(int i = 0; i < numberOfOtherVariableResults; i++){
    00490                         delete other[i];
    00491                         other[i] = NULL;
    00492                 }
    00493         }
    00494         delete[] other;
    00495         other = NULL;
    00496 }// end VariableSolution destructor
    00497
    00498 ObjectiveSolution::ObjectiveSolution():
    00499         numberOfOtherObjectiveResults( 0),
    00500         values( NULL),
    00501         other( NULL)
    00502
    00503 {
    00504         #ifdef DEBUG
    00505         cout << "Inside the ObjectiveSolution Constructor" << endl;
    00506         #endif
    00507 }//end ObjectiveSolution constructor
    00508
    00509
    00510 ObjectiveSolution::~ObjectiveSolution(){
    00511         #ifdef DEBUG
    00512         cout << "Inside the ObjectieSolution Destructor" << endl;
    00513         #endif
    00514         delete  values;
    00515         values = NULL;
    00516         if(numberOfOtherObjectiveResults > 0 && other != NULL){
    00517                 for(int i = 0; i < numberOfOtherObjectiveResults; i++){
    00518                         delete other[i];
    00519                         other[i] = NULL;
    00520                 }
    00521         }
    00522         delete[] other;
    00523         other = NULL;
    00524 }// end ObjectiveSolution destructor
    00525
    00526
    00527
    00528 ConstraintSolution::ConstraintSolution():
    00529         numberOfOtherConstraintResults( 0),
    00530         dualValues( NULL),
    00531         other( NULL)
    00532 {
    00533         #ifdef DEBUG
    00534         cout << "Inside the ConstraintSolution Constructor" << endl;
    00535         #endif
    00536 }//end ConstraintSolution constructor
    00537
    00538
    00539 ConstraintSolution::~ConstraintSolution(){
    00540         #ifdef DEBUG
    00541         cout << "Inside the ConstraintSolution Destructor" << endl;
    00542         #endif
    00543         delete  dualValues;
    00544         dualValues = NULL;
    00545         if(numberOfOtherConstraintResults > 0 && other != NULL){
    00546                 for(int i = 0; i < numberOfOtherConstraintResults; i++){
    00547                         delete other[i];
    00548                         other[i] = NULL;
    00549                 }
    00550         }
    00551         delete[] other;
    00552         other = NULL;
    00553 }// end ConstraintSolution destructor
    00554
    00555
    00556
    00557 OptimizationSolutionStatus::OptimizationSolutionStatus():
    00558         type(""),
    00559         description("")
    00560         //substatus( NULL),
    00561 {
    00562         #ifdef DEBUG
    00563         cout << "Inside the OptimizationSolutionStatus Constructor" << endl;
    00564         #endif
    00565 }//end OptimizationSolutionStatus constructor
    00566
    00567
    00568 OptimizationSolutionStatus::~OptimizationSolutionStatus(){
    00569         #ifdef DEBUG
    00570         cout << "Inside the OptimzationSolutionStatus Destructor" << endl;
    00571         #endif
    00572 }// end OptimizationSolutionStatus destructor
    00573
    00574
    00575 OptimizationSolution::OptimizationSolution():
    00576         targetObjectiveIdx( -1),
    00577         message( ""),
    00578         variables( NULL),
    00579         objectives( NULL),
    00580         constraints( NULL)
    00581         //other(NULL)
    00582 {
    00583         #ifdef DEBUG
    00584         cout << "Inside the OptimizationSolution Constructor" << endl;
    00585         #endif
    00586         status = new OptimizationSolutionStatus();
    00587 }//end OptimizationSolution constructor
    00588
    00589
    00590 OptimizationSolution::~OptimizationSolution(){
    00591         #ifdef DEBUG
    00592         cout << "Inside the OptimzationSolution Destructor" << endl;
    00593         #endif
    00594         if(variables != NULL){
    00595                 delete variables;
    00596                 variables = NULL;
    00597         }
    00598         if(constraints != NULL) {
    00599                 delete constraints;
    00600                 constraints = NULL;
    00601         }
    00602         if(objectives != NULL){
    00603                 delete objectives;
    00604                 objectives = NULL;
    00605         }
    00606         if(status != NULL){
    00607                 delete status;
    00608                 status = NULL;
    00609         }
    00610 }// end OptimizationSolution destructor
    00611
    00612
    00613 OptimizationResult::OptimizationResult():
    00614         numberOfVariables( -1),
    00615         numberOfObjectives( -1),
    00616         numberOfConstraints(-1),
    00617         numberOfSolutions( -1),
    00618         solution(NULL)
    00619 {
    00620         #ifdef DEBUG
    00621         cout << "Inside the OptimizationResult Constructor" << endl;
    00622         #endif
    00623 }//end OptimizationResult constructor
    00624
    00625
    00626 OptimizationResult::~OptimizationResult(){
    00627         #ifdef DEBUG
    00628         cout << "Inside the OptimzationResult Destructor" << endl;
    00629         cout << "Number of solutions = " << this->numberOfSolutions << endl;
    00630         #endif
    00631         if( solution != NULL){
    00632                 for(int i = 0; i < this->numberOfSolutions; i++){
    00633                         delete solution[i];
    00634                         solution[i] = NULL;
    00635                         #ifdef DEBUG
    00636                         cout << "Delelting Solution: " << i << endl;
    00637                         #endif
    00638                         i++;
    00639                 }
    00640         }
    00641         delete[] solution;
    00642         solution = NULL;
    00643 }// end OptimizationResult destructor
    00644
    00645
    00646
    00647 //
    00648 // get methods
    00649
    00650 GeneralStatus* OSResult::getGeneralStatus(){
    00651         return general->generalStatus;
    00652 }//getGeneralStatus
    00653
    00654
    00655 string OSResult::getGeneralStatusType(){
    00656         if(general->generalStatus == NULL) return "";
    00657         return general->generalStatus->type;
    00658 }//getGeneralStatusType
    00659
    00660 string OSResult::getGeneralStatusDescription(){
    00661         if(general->generalStatus == NULL) return NULL;
    00662         return general->generalStatus->description;
    00663 }//getGeneralStatusDescription
    00664
    00665 string OSResult::getServiceName(){
    00666         return general->serviceName;
    00667 }//getServiceName
    00668
    00669 string OSResult::getServiceURI(){
    00670         return general->serviceURI;
    00671 }//getServiceURI
    00672
    00673 string OSResult::getInstanceName(){
    00674         return general->instanceName;
    00675 }//getInstanceName
    00676
    00677 string OSResult::getJobID(){
    00678         return general->jobID;
    00679 }//getJobID
    00680
    00681
    00682 string OSResult::getGeneralMessage(){
    00683         return general->message;
    00684 }//getGeneralMessage
    00685
    00686
    00687 double OSResult::getTimeValue()
    00688 {       if (job == NULL) return 0.0;
    00689         if (job->timingInformation == NULL) return 0.0;
    00690         if (job->timingInformation->numberOfTimes <= 0) return 0.0;
    00691         return job->timingInformation->time[0]->value;
    00692 }//getTime
    00693
    00694
    00695 int OSResult::getTimeNumber()
    00696 {       if (job == NULL) return -1;
    00697         if (job->timingInformation == NULL) return -1;
    00698         return job->timingInformation->numberOfTimes;
    00699 }//getTime
    00700
    00701
    00702 int OSResult::getVariableNumber(){
    00703         if(m_iVariableNumber == -1){
    00704                 if(optimization == NULL) return -1;
    00705                 m_iVariableNumber = optimization->numberOfVariables;
    00706         }
    00707         return m_iVariableNumber;
    00708 }//getVariableNumber
    00709
    00710
    00711
    00712 int OSResult::getObjectiveNumber(){
    00713         if(m_iObjectiveNumber == -1){
    00714                 if(optimization == NULL) return -1;
    00715                 m_iObjectiveNumber = optimization->numberOfObjectives;
    00716         }
    00717         return m_iObjectiveNumber;
    00718 }//getObjectiveNumber
    00719
    00720
    00721 int OSResult::getConstraintNumber(){
    00722         if(m_iConstraintNumber == -1){
    00723                 if(optimization == NULL) return -1;
    00724                 m_iConstraintNumber = optimization->numberOfConstraints;
    00725         }
    00726         return m_iConstraintNumber;
    00727 }//getConstraintNumber
    00728
    00729 int OSResult::getSolutionNumber(){
    00730         if(optimization == NULL) return 0;
    00731         if(optimization->solution == NULL) return 0;
    00732         return optimization->numberOfSolutions;
    00733 }//getSolutionNumber
    00734
    00735
    00736 int OSResult::getNumberOfOtherVariableResults(int solIdx){
    00737         if(m_iNumberOfOtherVariableResults == -1){
    00738                 if(optimization->solution[solIdx]->variables->other == NULL) return -1;
    00739                 m_iNumberOfOtherVariableResults = optimization->solution[solIdx]->variables->numberOfOtherVariableResults;
    00740         }
    00741         return m_iNumberOfOtherVariableResults;
    00742 }//getNumberOfOtherVariableResults
    00743
    00744
    00745 OptimizationSolutionStatus* OSResult::getSolutionStatus( int solIdx){
    00746         if(optimization == NULL || optimization->solution == NULL) return NULL;
    00747         if( optimization->numberOfSolutions <= 0 ||
    00748            solIdx < 0 || solIdx >=  optimization->numberOfSolutions) return NULL;
    00749         if(optimization->solution[solIdx] == NULL) return NULL;
    00750         return optimization->solution[solIdx]->status;
    00751 }//getSolutionStatus
    00752
    00753 string OSResult::getSolutionStatusType(int solIdx){
    00754         if(optimization == NULL || optimization->solution == NULL) return NULL;
    00755         if( optimization->numberOfSolutions <= 0 ||
    00756            solIdx < 0 || solIdx >=  optimization->numberOfSolutions) return NULL;
    00757         if(optimization->solution[solIdx] == NULL) return NULL;
    00758         if(optimization->solution[solIdx]->status == NULL) return NULL;
    00759         return optimization->solution[solIdx]->status->type;
    00760 }//getSolutionStatusType
    00761
    00762 string OSResult::getSolutionStatusDescription(int solIdx){
    00763         if(optimization == NULL || optimization->solution == NULL) return NULL;
    00764         if( optimization->numberOfSolutions <= 0 ||
    00765            solIdx < 0 || solIdx >=  optimization->numberOfSolutions) return NULL;
    00766         if(optimization->solution[solIdx] == NULL) return NULL;
    00767         if(optimization->solution[solIdx]->status == NULL) return NULL;
    00768         return optimization->solution[solIdx]->status->description;
    00769 }//getSolutionStatusDescription
    00770
    00771 string OSResult::getSolutionMessage(int solIdx){
    00772         if(optimization == NULL) return "there is no solution";
    00773         if(optimization->solution == NULL ||
    00774            solIdx < 0 || solIdx >=  optimization->numberOfSolutions) return "there is no solution";
    00775         if(optimization->solution[solIdx] == NULL) return "there is no solution";
    00776         return optimization->solution[solIdx]->message;
    00777 }//getSolutionMessage
    00778
    00779 double* OSResult::getOptimalPrimalVariableValues(int objIdx){
    00780         if(optimization == NULL || optimization->solution == NULL) return NULL;
    00781         int iNumberOfVariables = this->getVariableNumber();
    00782         if(iNumberOfVariables <= 0) return NULL;
    00783         int iSolutions = this->getSolutionNumber();
    00784         for(int i = 0; i < iSolutions; i++){
    00785                 if(optimization->solution[i] == NULL) continue;
    00786                 if(optimization->solution[i]->targetObjectiveIdx != objIdx) continue;
    00787                 if(optimization->solution[i]->variables == NULL) continue;
    00788                 if(optimization->solution[i]->variables->values == NULL) continue;
    00789                 if((optimization->solution[i]->status->type.find("ptimal") != string::npos && m_mdPrimalValues == NULL) ||
    00790                         optimization->solution[i]->status->type.compare("globallyOptimal") == 0){
    00791                         m_mdPrimalValues = new double[iNumberOfVariables];
    00792                         for(int j = 0; j < iNumberOfVariables; j++){
    00793                                 m_mdPrimalValues[ j] = optimization->solution[i]->variables->values->var[j]->value;
    00794                         }
    00795                 }
    00796                 if(optimization->solution[i]->status->type.compare("globallyOptimal") == 0){
    00797                         return m_mdPrimalValues;
    00798                 }
    00799         }
    00800         return m_mdPrimalValues;
    00801 }//getOptimalPrimalVariableValues
    00802
    00803
    00804 double* OSResult::getOptimalDualVariableValues(int objIdx){
    00805         if(optimization == NULL || optimization->solution == NULL) return NULL;
    00806         int iNumberOfConstraints = this->getConstraintNumber();
    00807         if(iNumberOfConstraints <= 0) return NULL;
    00808         int iSolutions = this->getSolutionNumber();
    00809         for(int i = 0; i < iSolutions; i++){
    00810                 if(optimization->solution[i] == NULL) continue;
    00811                 if(optimization->solution[i]->targetObjectiveIdx != objIdx) continue;
    00812                 if(optimization->solution[i]->constraints == NULL) continue;
    00813                 if(optimization->solution[i]->constraints->dualValues == NULL) continue;
    00814                 if((optimization->solution[i]->status->type.find("ptimal") != string::npos && m_mdDualValues == NULL) ||
    00815                         optimization->solution[i]->status->type.compare("globallyOptimal") == 0){
    00816                         m_mdDualValues = new double[iNumberOfConstraints];
    00817                         for(int j = 0; j < iNumberOfConstraints; j++){
    00818                                 m_mdDualValues[ j] = optimization->solution[i]->constraints->dualValues->con[j]->value;
    00819                         }
    00820                 }
    00821                 if(optimization->solution[i]->status->type.compare("globallyOptimal")){
    00822                         return m_mdDualValues;
    00823                 }
    00824         }
    00825         return m_mdDualValues;
    00826 }//getOptimalDualVariableValues
    00827
    00828 // set methods
    00829
    00830 bool OSResult::setGeneralStatus(GeneralStatus *status){
    00831         general->generalStatus = status;
    00832         return true;
    00833 }//setGeneralStatus
    00834
    00835 bool OSResult::setGeneralStatusType(string type){
    00836         if(general->generalStatus == NULL) general->generalStatus = new GeneralStatus();
    00837         general->generalStatus->type = type;
    00838         return true;
    00839 }//setGeneralStatusType
    00840
    00841 bool OSResult::addTimingInformation(std::string type, std::string category,
    00842                                                                         std::string unit, std::string description, double value)
    00843 {       int nt; int i;
    00844         cout << "add timing information: " << endl;
    00845         cout << "type " << type << endl;
    00846         cout << "category " << category << endl;
    00847         cout << "unit " << unit << endl;
    00848         cout << "description " << description << endl;
    00849         cout << "value " << value << endl;
    00850         if (job == NULL) job = new JobResult();
    00851         if (job->timingInformation == NULL) job->timingInformation = new TimingInformation();
    00852
    00853         nt = job->timingInformation->numberOfTimes;
    00854         cout << "allocate new pointers" << endl;
    00855         Time** temp = new Time*[nt+1];  //Allocate the new pointers
    00856         cout << " copy pointers --- " << nt << endl;
    00857         for (i = 0; i < nt; i++)
    00858                 temp[i] = job->timingInformation->time[i];  //copy the pointers
    00859
    00860         cout << "delete old pointers" << endl;
    00861         delete[] job->timingInformation->time; //delete old pointers
    00862
    00863 //      add in the new element
    00864         cout << "add new element" << endl;
    00865         temp[ nt] = new Time();
    00866
    00867         temp[ nt]->type = type;
    00868         temp[ nt]->category = category;
    00869         temp[ nt]->unit = unit;
    00870         temp[ nt]->description = description;
    00871         temp[ nt]->value = value;
    00872
    00873         cout << "hook new pointers into OSResult" << endl;
    00874         job->timingInformation->time = temp;   //hook the new pointers into the data structure
    00875         job->timingInformation->numberOfTimes = ++nt;
    00876
    00877         cout << "done" << endl;
    00878         return true;
    00879 }//addTimingInformation
    00880
    00881
    00882 bool OSResult::setGeneralStatusDescription(string description){
    00883         if(general->generalStatus == NULL) general->generalStatus = new GeneralStatus();
    00884         general->generalStatus->description = description;
    00885         return true;
    00886 }//setGeneralStatusDescription
    00887
    00888
    00889
    00890 bool OSResult::setServiceName(string serviceName){
    00891         general->serviceName = serviceName;
    00892         return true;
    00893 }//setServiceName
    00894
    00895 bool OSResult::setServiceURI(string serviceURI){
    00896         general->serviceURI = serviceURI;
    00897         return true;
    00898 }//setServiceURI
    00899
    00900 bool OSResult::setInstanceName(string instanceName){
    00901         general->instanceName = instanceName;
    00902         return true;
    00903 }//setInstanceName
    00904
    00905 bool OSResult::setJobID(string jobID){
    00906         general->jobID = jobID;
    00907         return true;
    00908 }//setJobID
    00909
    00910 bool OSResult::setTime(double time){
    00911 //      general->time = os_dtoa_format( time);
    00912     return addTimingInformation("elapsedTime", "total", "second", "", time);
    00913 }//setTime
    00914
    00915 bool OSResult::setTimeNumber(int timeNumber)
    00916 {       if (job == NULL) job = new JobResult();
    00917         if (job->timingInformation == NULL) job->timingInformation = new TimingInformation();
    00918     if (timeNumber <= 0) return false;
    00919         job->timingInformation->numberOfTimes = timeNumber;
    00920         return true;
    00921 }//setTimeNumber
    00922
    00923 bool OSResult::setGeneralMessage(string message){
    00924         general->message = message;
    00925         return true;
    00926 }//setGeneralMessage
    00927
    00928 bool OSResult::setVariableNumber(int variableNumber){
    00929         if(variableNumber <= 0){
    00930                 return false;
    00931         }
    00932         if(optimization == NULL) optimization = new OptimizationResult();
    00933         optimization->numberOfVariables = variableNumber;
    00934         return true;
    00935 }//setVariableNumber
    00936
    00937 bool OSResult::setObjectiveNumber(int objectiveNumber){
    00938         if(objectiveNumber < 0){
    00939                 return false;
    00940         }
    00941         if(optimization == NULL) optimization = new OptimizationResult();
    00942         optimization->numberOfObjectives = objectiveNumber;
    00943         return true;
    00944 }//setObjectiveNumber
    00945
    00946 bool OSResult::setConstraintNumber(int constraintNumber){
    00947         if(constraintNumber < 0){
    00948                 return false;
    00949         }
    00950         if(optimization == NULL) optimization = new OptimizationResult();
    00951         optimization->numberOfConstraints = constraintNumber;
    00952         return true;
    00953 }//setConstraintNumber
    00954
    00955 bool OSResult::setSolutionNumber(int number){
    00956         //if(getVariableNumber() <= 0) return false;
    00957         //if(getObjectiveNumber() < 0) return false;
    00958         //if(getConstraintNumber() < 0) return false;
    00959         if(number < 0) return false;
    00960         if(number == 0) return true;
    00961         if(optimization == NULL) optimization = new OptimizationResult();
    00962         optimization->numberOfSolutions = number;
    00963         optimization->solution = new OptimizationSolution*[number];
    00964         for(int i = 0; i < number; i++){
    00965                 std::cout << "CREATING A NEW OPTIMIZATION SOLUTION" << std::endl;
    00966                 optimization->solution[i] = new OptimizationSolution();
    00967                 std::cout << "DONE CREATING A NEW OPTIMIZATION SOLUTION" << std::endl;
    00968         }
    00969         return true;
    00970 }//setSolutionNumber
    00971
    00972 bool OSResult::setSolutionStatus(int solIdx, string type, string description){
    00973         int nSols = this->getSolutionNumber();
    00974         if(optimization == NULL) return false;
    00975         if(nSols <= 0) return false;
    00976         if(optimization->solution == NULL ||
    00977            solIdx < 0 || solIdx >=  nSols) return false;
    00978         if(optimization->solution[solIdx] == NULL){
    00979                 optimization->solution[solIdx] = new OptimizationSolution();
    00980         }
    00981         if(optimization->solution[solIdx]->status == NULL){
    00982                 optimization->solution[solIdx]->status = new OptimizationSolutionStatus();
    00983         }
    00984         // Kipp later when we finalize on type come back and require that the type be correct
    00985         optimization->solution[solIdx]->status->type = type;
    00986         optimization->solution[solIdx]->status->description = description;
    00987         return true;
    00988 }//setSolutionStatus
    00989
    00990 bool OSResult::setSolutionObjectiveIndex(int solIdx, int objectiveIdx){
    00991         int nSols = this->getSolutionNumber();
    00992         if(optimization == NULL) return false;
    00993         if(nSols <= 0) return false;
    00994         if(optimization == NULL) return false;
    00995         if(optimization->solution == NULL ||
    00996            solIdx < 0 || solIdx >=  nSols) return false;
    00997         if(optimization->solution[solIdx] == NULL){
    00998                 optimization->solution[solIdx] = new OptimizationSolution();
    00999         }
    01000         if(objectiveIdx >= 0) return false;
    01001         optimization->solution[solIdx]->targetObjectiveIdx = objectiveIdx;
    01002         return true;
    01003 }//setSolutionObjectiveIndex
    01004
    01005 bool OSResult::setNumberOfPrimalVariableValues(int solIdx, int numberOfVar){
    01006         int nSols = this->getSolutionNumber();
    01007         int nVar  = this->getVariableNumber();
    01008         if (numberOfVar <= 0 || numberOfVar > nVar) return false;
    01009         if(optimization == NULL) return false;
    01010         if(nSols <= 0) return false;
    01011         if(optimization->solution == NULL ||
    01012            solIdx < 0 || solIdx >=  nSols) return false;
    01013         if(optimization->solution[solIdx] == NULL){
    01014                 optimization->solution[solIdx] = new OptimizationSolution();
    01015         }
    01016         if(optimization->solution[solIdx]->variables == NULL){
    01017                 optimization->solution[solIdx]->variables = new VariableSolution();
    01018         }
    01019         if(optimization->solution[solIdx]->variables->values == NULL){
    01020                 optimization->solution[solIdx]->variables->values = new VariableValues();
    01021         }
    01022         optimization->solution[solIdx]->variables->values->numberOfVar = numberOfVar;
    01023 //      optimization->solution[solIdx]->variables->values->var = new VarValue*[numberOfVar];
    01024
    01025         return true;
    01026 }//setNumberOfPrimalVariableValues
    01027
    01028 bool OSResult::setPrimalVariableValues(int solIdx, double *x, int numberOfVar){
    01029         int nSols = this->getSolutionNumber();
    01030         if(optimization == NULL) return false;
    01031         if(nSols <= 0) return false;
    01032         if(optimization->solution == NULL ||
    01033            solIdx < 0 || solIdx >=  nSols) return false;
    01034         if(optimization->solution[solIdx] == NULL){
    01035                 optimization->solution[solIdx] = new OptimizationSolution();
    01036         }
    01037         if(optimization->solution[solIdx]->variables == NULL){
    01038                 optimization->solution[solIdx]->variables = new VariableSolution();
    01039         }
    01040         if(optimization->solution[solIdx]->variables->values == NULL){
    01041                 optimization->solution[solIdx]->variables->values = new VariableValues();
    01042         }
    01043         optimization->solution[solIdx]->variables->values->numberOfVar = numberOfVar;
    01044         if(x == NULL){
    01045                 //optimization->solution[solIdx]->variables->values->var = NULL;
    01046                 return true;
    01047         }
    01048         for(int i = 0; i < numberOfVar; i++){
    01049                 optimization->solution[solIdx]->variables->values->var.push_back(new VarValue());
    01050                 optimization->solution[solIdx]->variables->values->var[i]->idx = i;
    01051                 optimization->solution[solIdx]->variables->values->var[i]->value = x[i];
    01052         }
    01053         return true;
    01054 }//setPrimalVariableValues
    01055
    01056 bool OSResult::setNumberOfOtherVariableResults(int solIdx, int numberOfOtherVariableResults){
    01057         int iNumberOfVariables = this->getVariableNumber();
    01058         if(iNumberOfVariables <= 0) return false;
    01059         int nSols = this->getSolutionNumber();
    01060         if(nSols <= 0) return false;
    01061         if(optimization == NULL) return false;
    01062         if(optimization->solution == NULL ||
    01063            solIdx < 0 || solIdx >=  nSols) return false;
    01064         if(optimization->solution[solIdx] == NULL){
    01065                 optimization->solution[solIdx] = new OptimizationSolution();
    01066         }
    01067         if(optimization->solution[solIdx]->variables == NULL){
    01068                 optimization->solution[solIdx]->variables = new VariableSolution();
    01069         }
    01070         optimization->solution[solIdx]->variables->numberOfOtherVariableResults =  numberOfOtherVariableResults;
    01071         optimization->solution[solIdx]->variables->other = new OtherVariableResult*[ numberOfOtherVariableResults];
    01072         for(int i = 0; i < numberOfOtherVariableResults; i++){
    01073                 optimization->solution[solIdx]->variables->other[ i]  = new OtherVariableResult();
    01074         }
    01075         return true;
    01076 }//setNumberOfOtherVariableResults
    01077
    01078
    01079
    01080 bool OSResult::setAnOtherVariableResult(int solIdx, int otherIdx, string name, string description, int  *indexes,  string *s, int numberOfVar){
    01081         int iNumberOfVariables = numberOfVar;
    01082         if(iNumberOfVariables <= 0) return false;
    01083         int nSols = this->getSolutionNumber();
    01084         if(optimization == NULL) return false;
    01085         if(nSols <= 0) return false;
    01086         if(optimization == NULL) return false;
    01087         if(optimization->solution == NULL ||
    01088            solIdx < 0 || solIdx >=  nSols) return false;
    01089         if(optimization->solution[solIdx] == NULL) return false;
    01090         if(optimization->solution[solIdx]->variables == NULL)return false;
    01091         if(optimization->solution[solIdx]->variables->other == NULL) return false;
    01092         if(optimization->solution[solIdx]->variables->other[ otherIdx] == NULL) return false;
    01093         optimization->solution[solIdx]->variables->other[ otherIdx]->name = name;
    01094         optimization->solution[solIdx]->variables->other[ otherIdx]->description = description;
    01095         optimization->solution[solIdx]->variables->other[ otherIdx]->numberOfVar = numberOfVar;
    01096         for(int i = 0; i < iNumberOfVariables; i++){
    01097                 optimization->solution[solIdx]->variables->other[ otherIdx]->var.push_back(new OtherVarResult());
    01098                 optimization->solution[solIdx]->variables->other[ otherIdx]->var[i]->idx = indexes[ i];
    01099                 optimization->solution[solIdx]->variables->other[ otherIdx]->var[i]->value = s[i];
    01100                 ;
    01101         }
    01102         return true;
    01103 }//setAnOtherVariableResult
    01104
    01105 bool OSResult::setNumberOfObjectiveValues(int solIdx, int numberOfObj){
    01106         int nSols = this->getSolutionNumber();
    01107         int nObj  = this->getObjectiveNumber();
    01108         if (numberOfObj <= 0 || numberOfObj > nObj) return false;
    01109         if(optimization == NULL) return false;
    01110         if(nSols <= 0) return false;
    01111         if(optimization->solution == NULL ||
    01112            solIdx < 0 || solIdx >=  nSols) return false;
    01113         if(optimization->solution[solIdx] == NULL){
    01114                 optimization->solution[solIdx] = new OptimizationSolution();
    01115         }
    01116         if(optimization->solution[solIdx]->objectives == NULL){
    01117                 optimization->solution[solIdx]->objectives = new ObjectiveSolution();
    01118         }
    01119         if(optimization->solution[solIdx]->objectives->values == NULL){
    01120                 optimization->solution[solIdx]->objectives->values = new ObjectiveValues();
    01121         }
    01122         optimization->solution[solIdx]->objectives->values->numberOfObj = numberOfObj;
    01123 //      optimization->solution[solIdx]->objectives->values->obj = new ObjValue*[numberOfObj];
    01124
    01125         return true;
    01126 }//setNumberOfObjectiveValues
    01127
    01128
    01129
    01130 bool OSResult::setObjectiveValues(int solIdx, double *objectiveValues, int numberOfObj){
    01131         int iNumberOfObjectives = numberOfObj;
    01132         if(iNumberOfObjectives < 0) return false;
    01133         if(iNumberOfObjectives == 0) return true;
    01134         if(objectiveValues == NULL) return false;
    01135         int nSols = this->getSolutionNumber();
    01136         if(optimization == NULL) return false;
    01137         if(nSols <= 0) return false;
    01138         if(optimization == NULL) return false;
    01139         if(optimization->solution == NULL ||
    01140            solIdx < 0 || solIdx >=  nSols) return false;
    01141         if(optimization->solution[solIdx] == NULL){
    01142                 optimization->solution[solIdx] = new OptimizationSolution();
    01143         }
    01144         if(optimization->solution[solIdx]->objectives == NULL){
    01145                 optimization->solution[solIdx]->objectives = new ObjectiveSolution();
    01146         }
    01147         if(optimization->solution[solIdx]->objectives->values == NULL){
    01148                 optimization->solution[solIdx]->objectives->values = new ObjectiveValues();
    01149         }
    01150         optimization->solution[solIdx]->objectives->values->numberOfObj = iNumberOfObjectives;
    01151         for(int i = 0; i < iNumberOfObjectives; i++){
    01152                 optimization->solution[solIdx]->objectives->values->obj.push_back( new ObjValue());
    01153                 optimization->solution[solIdx]->objectives->values->obj[i]->idx = -(i+1);
    01154                 optimization->solution[solIdx]->objectives->values->obj[i]->value = objectiveValues[i];
    01155         }
    01156         return true;
    01157 }//setObjectiveValues
    01158
    01159 bool OSResult::setNumberOfDualVariableValues(int solIdx, int numberOfCon){
    01160         int nSols = this->getSolutionNumber();
    01161         int nCon  = this->getConstraintNumber();
    01162         if (numberOfCon <= 0 || numberOfCon > nCon) return false;
    01163         if(optimization == NULL) return false;
    01164         if(nSols <= 0) return false;
    01165         if(optimization->solution == NULL ||
    01166            solIdx < 0 || solIdx >=  nSols) return false;
    01167         if(optimization->solution[solIdx] == NULL){
    01168                 optimization->solution[solIdx] = new OptimizationSolution();
    01169         }
    01170         if(optimization->solution[solIdx]->constraints == NULL){
    01171                 optimization->solution[solIdx]->constraints = new ConstraintSolution();
    01172         }
    01173         if(optimization->solution[solIdx]->constraints->values == NULL){
    01174                 optimization->solution[solIdx]->constraints->values = new DualVariableValues();
    01175         }
    01176         optimization->solution[solIdx]->constraints->values->numberOfCon = numberOfCon;
    01177 //      optimization->solution[solIdx]->constraints->values->con = new DualVarValue*[numberOfCon];
    01178
    01179         return true;
    01180 }//setNumberOfDualVariableValues
    01181
    01182
    01183
    01184 bool OSResult::setDualVariableValues(int solIdx, double *lbValues, double *ubValues, int numberOfCon){
    01185         int iNumberOfConstraints = numberOfCon;
    01186         if(iNumberOfConstraints < 0) return false;
    01187         if(iNumberOfConstraints == 0) return true;
    01188         int nSols = this->getSolutionNumber();
    01189         if(optimization == NULL) return false;
    01190         if(nSols <= 0) return false;
    01191         if(optimization == NULL) return false;
    01192         if(optimization->solution == NULL ||
    01193            solIdx < 0 || solIdx >=  nSols) return false;
    01194         if(optimization->solution[solIdx] == NULL){
    01195                 optimization->solution[solIdx] = new OptimizationSolution();
    01196         }
    01197         if(optimization->solution[solIdx]->constraints == NULL){
    01198                 optimization->solution[solIdx]->constraints = new ConstraintSolution();
    01199         }
    01200         if(optimization->solution[solIdx]->constraints->dualValues == NULL){
    01201                 optimization->solution[solIdx]->constraints->dualValues = new DualVariableValues();
    01202         }
    01203         if(lbValues == NULL && ubValues == NULL){
    01204                 //optimization->solution[solIdx]->constraints->dualValues->con = NULL;
    01205                 return true;
    01206         }
    01207         int iCons = 0;
    01208         if(lbValues == NULL){
    01209                 for(int i = 0; i < iNumberOfConstraints; i++){
    01210                         if(ubValues[i] != 0) iCons++;
    01211                 }
    01212         }
    01213         else if(ubValues == NULL){
    01214                 for(int i = 0; i < iNumberOfConstraints; i++){
    01215                         if(lbValues[i] != 0) iCons++;
    01216                 }
    01217         }
    01218         else{
    01219                 for(int i = 0; i < iNumberOfConstraints; i++){
    01220                         if(lbValues[i] != 0 || ubValues[i] != 0) iCons++;
    01221                 }
    01222         }
    01223
    01224         //optimization->solution[solIdx]->constraints->dualValues->con = new DualVarValue*[iCons];
    01225         optimization->solution[solIdx]->constraints->dualValues->numberOfCon = numberOfCon;
    01226         for(int i = 0; i < iCons; i++) optimization->solution[solIdx]->constraints->dualValues->con.push_back( new DualVarValue());
    01227         int j = 0;
    01228         if(lbValues == NULL){
    01229                 for(int i = 0; i < iNumberOfConstraints; i++){
    01230                         if(ubValues[i] != 0){
    01231                                 optimization->solution[solIdx]->constraints->dualValues->con[j]->idx = i;
    01232                                 optimization->solution[solIdx]->constraints->dualValues->con[j]->ubValue = 0;
    01233                                 optimization->solution[solIdx]->constraints->dualValues->con[j]->ubValue = ubValues[i];
    01234                                 j++;
    01235                         }
    01236                 }
    01237         }
    01238         else if(ubValues == NULL){
    01239                 for(int i = 0; i < iNumberOfConstraints; i++){
    01240                         if(lbValues[i] != 0){
    01241                                 optimization->solution[solIdx]->constraints->dualValues->con[j]->idx = i;
    01242                                 optimization->solution[solIdx]->constraints->dualValues->con[j]->lbValue = lbValues[i];
    01243                                 optimization->solution[solIdx]->constraints->dualValues->con[j]->ubValue = 0;
    01244                                 j++;
    01245                         }
    01246                 }
    01247         }
    01248         else{
    01249                 for(int i = 0; i < iNumberOfConstraints; i++){
    01250                         if(lbValues[i] != 0 || ubValues[i] != 0){
    01251                                 optimization->solution[solIdx]->constraints->dualValues->con[j]->idx = i;
    01252                                 optimization->solution[solIdx]->constraints->dualValues->con[j]->lbValue = lbValues[i];
    01253                                 optimization->solution[solIdx]->constraints->dualValues->con[j]->ubValue = ubValues[i];
    01254                                 j++;
    01255                         }
    01256                 }
    01257         }
    01258         return true;
    01259 }//setDualVariableValues
    01260
    01261 bool OSResult::setDualVariableValues(int solIdx, double *y, int numberOfCon){
    01262         int iNumberOfConstraints = numberOfCon;
    01263         if(iNumberOfConstraints < 0) return false;
    01264         if(iNumberOfConstraints == 0) return true;
    01265         int nSols = this->getSolutionNumber();
    01266         if(optimization == NULL) return false;
    01267         if(nSols <= 0) return false;
    01268         if(optimization == NULL) return false;
    01269         if(optimization->solution == NULL ||
    01270            solIdx < 0 || solIdx >=  nSols) return false;
    01271         if(optimization->solution[solIdx] == NULL){
    01272                 optimization->solution[solIdx] = new OptimizationSolution();
    01273         }
    01274         if(optimization->solution[solIdx]->constraints == NULL){
    01275                 optimization->solution[solIdx]->constraints = new ConstraintSolution();
    01276         }
    01277         if(optimization->solution[solIdx]->constraints->dualValues == NULL){
    01278                 optimization->solution[solIdx]->constraints->dualValues = new DualVariableValues();
    01279         }
    01280         if(y == NULL){
    01281                 optimization->solution[solIdx]->constraints->dualValues = NULL;
    01282                 return true;
    01283         }
    01284         optimization->solution[solIdx]->constraints->dualValues->numberOfCon = numberOfCon;
    01285         for(int i = 0; i < iNumberOfConstraints; i++){
    01286                 optimization->solution[solIdx]->constraints->dualValues->con.push_back( new DualVarValue());
    01287                 optimization->solution[solIdx]->constraints->dualValues->con[i]->idx = i;
    01288                 optimization->solution[solIdx]->constraints->dualValues->con[i]->value = y[i];
    01289         }
    01290         return true;
    01291 }//setDualVariableValues
    01292
    01293 bool OSResult::setConstraintValues(int solIdx, double *dualVarValues, int numberOfCon){
    01294         int iNumberOfConstraints = numberOfCon;
    01295         if(iNumberOfConstraints <= 0) return false;
    01296         int nSols = this->getSolutionNumber();
    01297         if(optimization == NULL) return false;
    01298         if(nSols <= 0) return false;
    01299         if(optimization == NULL) return false;
    01300         if(optimization->solution == NULL ||
    01301            solIdx < 0 || solIdx >=  nSols) return false;
    01302         if(optimization->solution[solIdx] == NULL){
    01303                 optimization->solution[solIdx] = new OptimizationSolution();
    01304         }
    01305         if(optimization->solution[solIdx]->constraints == NULL){
    01306                 optimization->solution[solIdx]->constraints = new ConstraintSolution();
    01307         }
    01308         if(optimization->solution[solIdx]->constraints->dualValues == NULL){
    01309                 optimization->solution[solIdx]->constraints->dualValues = new DualVariableValues();
    01310         }
    01311         if(dualVarValues == NULL){
    01312                 optimization->solution[solIdx]->constraints->dualValues = NULL;
    01313                 return true;
    01314         }
    01315         //optimization->solution[solIdx]->constraints->dualValues->con = new ConValue*[ iNumberOfConstraints];
    01316         optimization->solution[solIdx]->constraints->dualValues->numberOfCon = numberOfCon;
    01317         for(int i = 0; i < iNumberOfConstraints; i++){
    01318                 optimization->solution[solIdx]->constraints->dualValues->con.push_back( new DualVarValue());
    01319                 //optimization->solution[solIdx]->constraints->dualValues->con[i] = new ConValue();
    01320                 optimization->solution[solIdx]->constraints->dualValues->con[i]->idx = i;
    01321                 optimization->solution[solIdx]->constraints->dualValues->con[i]->value = dualVarValues[i];
    01322         }
    01323         return true;
    01324 }//setConstraintValues
    01325
    01326