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

RegionHandler.h

Go to the documentation of this file.
00001 //------------------------------------------------------------------------------
00002 //
00003 //  Thomas Berger (main author), Pepijn Schreinemachers, and Thorsten Arnold
00004 //
00005 //
00006 //  Hohenheim University (490d)
00007 //  Professorship for Land Use Economics in the Tropics and Subtropics
00008 //
00009 //  May not be distributed without permission by main author
00010 //
00011 //  File:       RegionHandler.h (formerly region.h)
00012 //
00013 //  Contents:   Handles all input files needed to initialize the cellular and
00014 //              agent-based component
00015 //
00016 //
00017 //------------------------------------------------------------------------------
00018 
00019 
00020 #ifndef _RegionHandler_h
00021 #define _RegionHandler_h
00022 
00023 // Libraries C++
00024 #include <iostream>
00025 //using namespace std; // for C++-Compiler, so that cin is not read as std::cin
00026 //#include <fstream>   // new 2005
00027 //#include <string>    // new 2005
00028 
00029 #include "BasicData.h"
00030 
00031 #include "BasicStrings.h"
00032 #include "CatchmentSector.h"
00033 #include "CatchmentSectorSpecific.h"
00034 #include "AgentPopulationHandler.h"
00035 #include "PopulationNetworkSegmentList.h"
00036 #include <sstream>
00037 
00038 #ifdef LP_OLD
00039         //Few things that are only needed when bulit without COIN libraries
00040         #include "lp9.h"
00041 
00042 #endif /* LP_OLD */
00043 
00044 #include "MarketTradablesHandler.h"
00045 #include "CropGrowthHandler.h"
00046 #include "PermanentCropsHandler.h"
00047 #include "PopulationClusterList.h"
00048 #include "LivestockHandler.h"
00049 #include "AgentUserAssociation.h"
00050 class ausgabe;
00051 
00052 // Help class, used to initialize sectors from REGION.dat
00053 class classSectorReadInfoLine
00054 {  public:
00055    string sectorName;
00056    bool active;
00057    bool hasSubsector;
00058    int CatchmentID;
00059         int positionInRegionFile; // not read, but number of file that was read
00060         int strahlerOrder; // currently not read
00061         int routingOrder; // not read, as curently corresponds to order in file
00062         int GISID;
00063         int sectorSeed;
00064         int NumberOfParcels;
00065         bool hasHydroData;
00066 
00067         // EDIC matters
00068         double ReUseCoefficient;
00069         double WaterSystemEfficiency;
00070    double canalEfficiency;
00071         double mergeB;
00072         double mergeG;
00073         MatrixDouble canalCapacity;
00074         MatrixDouble waterRightsByInflow;
00075 
00076 
00077         int numLotteryValues;
00078 
00079 
00080    classSectorReadInfoLine();
00081    virtual ~classSectorReadInfoLine()
00082    {    deallocateAll();
00083    };
00084 
00085 
00086    virtual bool readLine(ifstream& in, int HydroModel, int numInflows,
00087       int valuesPerInflow);
00088 
00089    virtual void printToScreen();
00090 
00091    virtual void writeToFile_Line(ofstream& outStream);
00092    virtual void deallocateAll();
00093 
00094 };
00095 
00096 
00097 class region
00098 {
00099    public:
00100    //
00101    //region(char*, char*);
00102    region();
00103 
00104    virtual ~region()
00105    {  deallocateRegion();
00106       deallocOtherObjects();
00107    }
00108 
00109    virtual void initializeRegionFromFiles(TimeHandler& timeHandle_const);
00110    virtual void initializeRegionStandalone();
00111    
00112    virtual void checkMapAndExportConsistentMaps(double factor, double cutoffsize);
00113    virtual void analyseAllSectorsByContentAndExportHistogram(Content cont);
00114 
00115    // Arnold 080808 -- For Ghana model
00116    virtual void rectifySectorBoundariesFromInflows();
00117 
00118    
00119    virtual void initGlobalPointers();
00120    virtual void readDatFiles();
00121    virtual void readLandscapeFromFiles();
00122    
00123    virtual void createAgents();
00124 
00125 
00126 
00127    virtual void allocateCatchmentsAndSectors(void);
00128 
00130    //virtual void initializeCatchmentEdicAndInflows(void);
00131    // ... updated time handling, otherwise clone
00132    virtual void initializeCatchmentEdicAndInflows_new(void);
00133    
00134 
00135 
00136         virtual void readMonthlyInflowsFromFile(string filename, int mTot, MatrixDouble& infl);
00137         virtual void readMonthlyInflowsFromFile(string filename, int mTot);
00138         virtual void checkConsistencyCatchmentInflows(int mTot, MatrixDouble& infl);
00139         virtual void checkConsistencyRegion();
00140         virtual void analyseAllSectorsAndExportAgentInfo(string fn);
00141 
00142 
00143 
00145    virtual bool readRegionDatFileAndInitSectors(string filename);
00146    
00148    virtual void initializeSectorFromAuxiliaryClass(classSectorReadInfoLine& lineRead);
00149         virtual void initializeUserAssociation(int agentID_, int catchmentID_, int sectorID_,
00150                  int numLotteryValues);
00151 
00153    virtual void writeToFile_RegionTableFrontMatter(ofstream& out, 
00154         int NumSectors, int HydroModel, int OtherModel, int numInflows, int valuesPerInflow);
00155         
00156    virtual void readAllCatchmentsFromRasterFiles();
00157 
00158    // Export monthly and yearly maps
00159    void ExportMapsMonthly(TimeHandler& timeHandle_const);
00160    void ExportMapsAnnual(TimeHandler& timeHandle_const);
00161    void ExportMapsGeneric(bool flagIsAnnual, TimeHandler& timeHandle_const);
00162 
00163 
00164 
00165         //virtual void computeStartValuesForAgentWaterExpectations();// ## H2O
00166         //Arnold2008_0812    
00167    // Local time loop
00168         virtual void computeStartValuesForAgentWaterExpectations_new(TimeHandler& timeHandle_const);// ## H2O
00169    virtual void assignResourcesToAgents();
00170    virtual void writeMapsOnScreen();
00171    virtual void writeSubcatchmentMatrixDimsOnScreen();   
00172 
00173    virtual void deallocateRegion();
00174    virtual void deallocOtherObjects();
00175 
00176    // Calls core function <betriebe[i]->uebergang_periode()>
00177    int AgentsDoExpectationAndPlanning(int year);
00178 
00179 
00181    // ... contains the EDIC function
00182         virtual void wasser_periode(TimeHandler& timeHandle_const);
00183    // ... contains wasim coupling functions
00184    virtual void couplingHydrologyWasimAnnual(TimeHandler& timeHandle_const, ausgabe& outfiles);
00185         virtual void couplingHydrologyWasimMonthly(TimeHandler& timeHandle_const, ausgabe& outfiles);
00186 
00187    void resetEdicAnnualData(TimeHandler& timeHandle_const);
00188       
00189         virtual void updateDynamicInflows(TimeHandler& timeHandle_const);
00190    // From agents SolutionVector, land use is allocated in space
00191         virtual void agentsAllocateSpatiallyLanduse();
00192    // WaterInfo, using CrpMixClass defined in <agentsAllocateSpatiallyLanduse>,
00193    // irrigation water is allocated in space
00194    virtual void agentsIrrigationWater2Landscape(int m);
00195 
00196 
00197    // Test function.
00198    // .. takes content-values from landscape (eventually from sector!), writes them into parcels, 
00199    // .. then into cells (!!) and returns them as joined raster
00200    virtual void allocateSpatiallyContentFromLdsAndReportCells_test(Content cont, Raster2D& rasterLanduse);
00201 
00202         //Arnold2006_31
00203    virtual void joinRegionMap(Content cont, Raster2D& rasterRegion);
00204    virtual void joinRegionMap(Content cont, Raster2D& rasterRegion, int m);
00205    virtual void joinRegionMap(Content cont, Raster2D& rasterRegion, int m, bool flag_foreCell);
00206 
00207    virtual void translateFromParcelCallToRaster(Content cont, Raster2D& test);
00208    //Arnold2006
00209 
00210    // Delete all lands without agents, and
00211    // agents that own area bellow factor_HRB * cutoffsize
00212    virtual void checkConsistencyOfMaps(double factor_HRB, double cutoffsize);
00213 
00214    virtual void printListOfAllAgents();
00215    virtual void print_AllSubcatchs();
00216 
00217    virtual void writeLandMarketsToFile(ausgabe& outfiles);
00218         virtual void outputLanduseByUserAssociation(int type);  //Daten zum Simulationsende
00219 
00220         virtual void printAllAgentsProductions();
00221 
00222 protected:
00223    // If spatial, writes yearly land use map here.
00224    bool landuseWasAllocated;
00225    Raster2D rasterLanduse;
00226    Raster2D rasterIrrigWaterMonthly;
00227    
00228    CropGrowthHandler* p_cropGrowthHandler;
00229 };
00230 
00231 
00232 
00233 
00234 
00235 #endif
00236 
00237 

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