Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

ProblemDescription.h

Go to the documentation of this file.
00001 /*Copyright (C) 2006/2007, Professorship (p.p.) for Land Use Economics in the Tropics and
00002 Subtropics, Institute for Agricultural Economics and Social Sciences in the Tropics
00003 and Subtropics, University of Hohenheim, Stuttgart
00004 Thomas Berger, Lutz Göhring
00005 All rights reserved
00006 */
00007 #ifndef LP_OLD
00008 #ifndef PROBLEMDESCRIPTION_H_
00009 #define PROBLEMDESCRIPTION_H_
00010 
00011 #include "AgentProblem.h"
00012 #include "tableau.h"
00013 #include "BasicEnums.h"
00014 
00016 
00020 class InfoHydro{  
00021 public:
00022         friend class ProblemDescription;
00024 
00025         int getColLP()const;    
00026         int getSclID()const;     
00027         int getIrrPG()const;    
00028         int getIrrME()const;   
00029         double getIrrKR ()const;     
00030         double getIrrKY ()const;    
00031         int getPriCL()const;         
00032         int getYldRW()const;    
00033         double getIrrM(int index)const;
00035         void printStdOut();
00036         void write(FILE* strm);
00037         InfoHydro();
00038         InfoHydro(double initVal);
00039         InfoHydro(const InfoHydro&);
00040         InfoHydro& operator=(const InfoHydro&);
00041         ~InfoHydro();
00042 private:
00043    /* TODO 1 -oBerger -cImplement : LP info related to WASIM */
00045    int colLP;  
00047    int sclID;  
00049    int irrPG;  
00051    int irrME; 
00053    double irrKR ;  
00055    double irrKY ;
00057    int priCL;   
00059    int yldRW;    
00060 
00061    double* irrM;
00062 /*
00063    double irrM0 ;  //m0
00064    double irrM1;  //m1
00065    double irrM2;  //m2
00066    double irrM3;  //m3
00067    double irrM4;  //m4
00068    double irrM5;  //m5
00069    double irrM6;  //m6
00070 */
00071 };
00072 
00074 
00080 class ProblemDescription{
00081         
00082 public:
00084 
00085         int getNumOfNonzeroCols();
00086         int getNumOfNonzeroRows();
00090         int getIndexOfCapacity(CapacityType type);
00091         int getIndexOfCapacity(CapacityType type, const int arrayIndex);
00092         int getNumOfIrrigationActivities();
00093         int getNumOfIrrigationGroups();
00094         infoPerf getCashOnFarm();
00095         infoPerf getCashOffFarm();
00096         infoPerf getHiringTempLaborOnFarm();
00097         infoPerf getHiringTempLaborOffFarm();
00098         infoPerf getHiringPermanentLaborOnFarm();
00099         infoPerf getHiringPermanentLaborOffFarm();
00100         int getNumOfLaborSpans();
00101         int getNumOfCashSpans();
00102         int getFixedBinaryLabor();
00103         int getIndexOfActivity(ActivityType type);
00104         int getIndexOfActivity(ActivityType type, const int arrayIndex);
00105         int getNumOfFixedVariablesConsumption();
00106         const int* getFixedVariablesConsumption() const;
00107         int getNumOfFixedCapacities();
00108         int getNumOfFineTuneParameter();
00109         const infoFine* getFineTuneParameters() const;
00110         infoTSPC getInfoOnActivityCropTSPC(int x, int y);
00111         infoResi getInfoOnActivityCropResiduals(int  arrayIndex);
00112         int getNumOfHydrologyCroppingActivities();
00113         /*
00114          * 
00115         **/
00116         InfoHydro getInfoOnActivityCropHydrology(int  arrayIndex) ;
00118         //-------------------------------------------------------------------------------------------------------------------
00120 
00121         bool getTestFlag();
00122         double getTolearance();
00124         
00126 
00127         virtual void setTestFlag(bool test);
00128         virtual void setTolerance(double eps_);
00130         //-----------------------------------------------------------------------------------------------------------------
00132 
00133 
00134         virtual int read(FILE* datStream, const AgentProblem& agentProblemObject);
00136         
00142         virtual int write(FILE*  datStream);
00144         //-----------------------------------------------------------------------------------------------------------------
00146 
00147 
00148                 ProblemDescription();
00152                 virtual ~ProblemDescription();
00154 //--------------------------------------------------------------------------------------------------------------------
00155         
00156 private:
00158 
00159 
00160         int nncols;     
00162      int nnrows;    
00164      double pfill;   
00166      int capLab;                
00168      int capLiq;        
00170      int *capInv;       
00172      int capWat;                
00174      int numIrrActiv;   
00176      int numIrrGroups;  
00178      int capLnd;                
00180      int capCsh;                
00182      int capAvl;                
00184      int capMac;                
00186           // int capFM1; ##
00188      int actSvg;     
00190      int actExt;            
00192      infoPerf cashOnf;
00194      infoPerf cashOff;
00196      infoPerf tLabOnf;
00198      infoPerf tLabOff;
00200      infoPerf pLabOnf;
00202      infoPerf pLabOff;
00204      int labSpans;    
00206      int cshSpans;     
00208      int  fixLabor;             
00210      int  actFemaY;    
00212      int  actFemaN;   
00214      int  actMaleY;    
00216      int  actMaleN;   
00218      int numFixCaps;    
00220      int  disBinC;     
00222      int  disBinR;     
00224      int  ntrDmdR;              
00226      int  numFixV;     
00228      int* fixCols;              
00230      int  numFine;     
00232      infoFine* actFine;
00234      
00238      infoTSPC** actTSPC;   
00240      infoResi* actResi;   
00242      int colManu;           
00243      /* TODO 1 -oBerger -cImplement : LP info related to WASIM */
00244      
00245      //number of hydrology cropping activities
00246      int numHydro;     
00247      //pointer to crop information used in hydrology model(hydrology cropping activities)
00248      
00253      InfoHydro* actHydro;
00255 
00256 
00257 
00258         double eps;
00260         int test;
00262 
00263         //{@
00265         virtual int writeInfoOnActivityCropTSPC(char* filename);
00266         virtual void writeHydroInfoInFile(char* filename);
00268         void gutsOfConstructor();
00270         void gutsOfDestructor();
00272         template <class Type> int allocateVector(Type*& pointertovector, long int sizeofvector);
00274 
00275 //-------------------------------------------------------------------------------------------------------------------
00276 #if 0
00277         /* TODO -oBerger -cNote : Non-active private functions in problem description.
00278            These function are currently not in use because the problem decription
00279            should not be changed by others. If needed in the furture, they can be easily 
00280            revitalized.  */
00281 
00283 
00284         virtual void setNumOfNonzeroCols(const int nncols_);
00285         
00286         virtual void setNumOfNonzeroRows(const int nnrows_);
00288         
00292         virtual int setIndexOfCapacity(CapacityType type, const int capacityIndex_);
00294         
00298         virtual int setIndexOfCapacity(CapacityType type, const int capacityIndex_, const int arrayIndex);
00299 //      virtual void setIndicesCapacityInvestments();
00300 
00301         virtual void setNumOfIrrigationActivities(const int numIrrActiv_);
00302     
00303         virtual void setNumOfIrrigationGroups(const int numIrrGroups_);
00304      
00305         virtual void setCashOnFarm(const infoPerf cashOnf_);
00306         virtual void setCashOffFarm(const infoPerf cashOff_);  
00307         virtual void setHiringTempLaborOnFarm(const infoPerf tLabOnf_);
00308         virtual void setHiringTempLaborOffFarm(const infoPerf tLabOff_);    
00309         virtual void setHiringPermanentLaborOnFarm(const infoPerf pLabOnf_);   
00310         virtual void setHiringPermanentLaborOffFarm(const infoPerf pLabOff_);
00311         virtual void setNumOfLaborSpans(const int labSpans_);
00312         virtual void setNumOCashSpans(const int cshSpans_);
00313         virtual void setFixedBinaryLabor(const int fixLabor_);   
00317         virtual int setIndexOfActivity(ActivityType type, const int index_);
00321         virtual int setIndexOfActivity(ActivityType type, const int activityIndex_,const int arrayIndex);
00326         virtual int setNumOfFixedVariablesConsumption(const int  numFixV_);
00327         virtual void setNumOfFixedCapacities(const int numFixCaps_);
00328         virtual int setNumOfFineTuneParameter(const int numFine_);
00333         virtual int setInfoOnActivityCropTSPC(infoTSPC activityTSPC, int x, int y);
00337         virtual int setInfoOnActivityCropResiduals(infoResi actResi_, int  arrayIndex);
00341         virtual int setNumOfHydrologyCroppingActivities(const int numHydro_);
00345         virtual int     setInfoOnActivityCropHydrology(InfoHydro actHydro_, int  arrayIndex);
00347         //-----------------------------------------------------------------------------------------------------------------
00348 #endif 
00349 };
00350 
00351 template <class Type>
00352 int ProblemDescription::allocateVector(Type*& pointertovector, long int sizeofvector){
00353         if (sizeofvector > 0)
00354                 if(pointertovector== NULL){
00355                         try{
00356                                 pointertovector = new Type[sizeofvector];
00357 //                              for (int i = 0; i<sizeofvector;i++) pointertovector[i] = NULL;
00358                         }
00359                         catch(exception& exceptionObject){
00360                                 cerr << "Exception: "<< exceptionObject.what()<<endl;
00361                                 cerr << "Error in "<< typeid(*this).name()<<"::allocateVector(): cannot allocate memory for Type"<< typeid(*pointertovector).name()<<"["<<sizeofvector<<"]" << endl;
00362                                 exit(0);
00363                         }
00364                 }
00365                 else {
00366                         delete[] pointertovector;
00367                         pointertovector = NULL;
00368                         try{
00369                                 pointertovector = new Type[sizeofvector];
00370 //                              for (int i = 0; i<sizeofvector;i++) pointertovector[i] = NULL;
00371                         }
00372                         catch(exception& exceptionObject){
00373                                 cerr << "Exception: "<< exceptionObject.what()<<endl;
00374                                 cerr << "Error in "<< typeid(*this).name()<<"::allocateVector(): cannot allocate memory for Type"<< typeid(*pointertovector).name()<<"["<<sizeofvector<<"]" << endl;
00375                                 exit(0);
00376                         }
00377                 }
00378         else {
00379                 if (test) cerr  << "Warning in "<< typeid(*this).name()<<"::allocateVector(): nothing to allocate:"
00380                                                 << "length of array of "<<typeid(*pointertovector).name()<<" is: "<<sizeofvector<<"!" << endl;
00381                 return 0;//failure/warning
00382         }
00383         return 1;//success                              
00384 }
00385 
00386 #endif /*PROBLEMDESCRIPTION_H_*/
00387 #endif /* LP_OLD*/

Generated on Thu Aug 28 12:38:45 2008 for MPMAS by  doxygen 1.3.9.1