/home/coin/SVN-release/OS-2.0.0/OS/src/OSCommonInterfaces/OSResult.cpp

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

Generated on Mon Aug 3 03:02:23 2009 by  doxygen 1.4.7