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

MarketTradablesHandler.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:       MarketTradablesHandler.h (formerly markt9.h)
00012 //
00013 //  Contents:   Market class for tradables, containing time series for input
00014 //              and output prices plus imputed prices (for in-kind consumption)
00015 //
00016 //
00017 //------------------------------------------------------------------------------
00018 
00019 
00020 #ifndef _MarketTradablesHandler_h
00021 #define _MarketTradablesHandler_h
00022 
00023 
00024 
00025 #include "MatrixDouble.h"
00026 
00027 
00028 class markt
00029 {       
00030 public:
00032 
00033 
00034         virtual int getNumberOfSimulationPeriods();
00035         virtual int getNumberOfTradables();
00036         virtual int getNumberOfFuturePrices();
00037         virtual int getNumberOfProductionCosts();
00038         virtual double getPriceForTradable(int period, int prd);
00039 
00041         virtual void readInputFromFile(const char* filename);
00042         virtual void writeInputIntoFile(char* filename);
00043 
00045         virtual double getExtCons();
00046         virtual double getMinCons();
00047         virtual double getForCons();
00048         virtual double calcConsumption(double income, int hhSize);
00049 
00051         virtual int checkTypeOfEarning(int lpCol);
00052         virtual int getIncR(void);
00053         virtual void calcSvgsPart(double hhEgy, MatrixDouble& scolV);
00054         virtual double compZeroSvgs(double hhEgy);
00055         virtual int getsColU(void);
00056         virtual int getsRowB(void);
00057         virtual int getsColB(void);
00058         virtual int getsRowS(void);
00059         virtual int getsColS(void);
00060         virtual int getsNumS(void);
00061 
00062         virtual double calcFNoFPart(double hhEgy, MatrixDouble& fcolV);
00063         virtual int getfNumS(void);
00064         virtual int getfRowS(void);
00065         virtual int getfColS(void);
00066         virtual int getfRowH(void);
00067         virtual int getfColH(void);
00068 
00069         virtual void calcItemPart(int period, double hhEgy,
00070                 MatrixDouble& irowH, MatrixDouble& irowP, MatrixDouble& imatS);
00071         virtual int getiNumF(void);
00072         virtual int getiNumS(void);
00073         virtual int getiRowS(void);
00074         virtual int getiColS(void);
00075         virtual int getiRowP(void);
00076         virtual int getiColP(void);
00077         virtual int getiRowH(void);
00078         virtual int getiColH(void);
00079         virtual int getNumNtr(void);
00080 
00082         virtual void insPriceIndicesNR(double**& ap, int period);
00083         virtual void insActPrInObjFunc(double*& objF, int period);
00084         virtual void insFutPrInObjFunc(double**& ap, int period);
00085 
00086         virtual void makeBackUpOfCostsFromLpMatrix(int averageCashRow, double**& ap);
00087         virtual int getInternalIndexForLpActivity(int lpActivity);
00088 
00089         virtual void retrieveAbsoluteCosts(MatrixDouble& lpIndicesAndAbsoluteCosts, int period);
00090         virtual double getAbsoluteProductionCost(int lpActivity, int period);
00091         virtual double getAbsolutePreHarvestCost(int lpActivity, int period);
00092 
00093         virtual void retrieveRelativeProductionCosts(MatrixDouble& lpIndicesAndRelativeCosts, int period);
00094         virtual double getRelativeProductionCost(int lpActivity, int period);
00095 
00097         virtual void computeMarketEquilibriumPrices(int period);
00099 
00101 
00102         markt();
00103         virtual ~markt()
00104         {       delete [] reservationPrice;
00105                 delete [] priceFlexibility;
00106                 delete [] priceOverallTrend;
00107                 pricePaths.deallokieren();
00108 
00109                 delete [] activityIndexInLp;
00110                 delete [] productionCostInBaseYear;
00111                 delete [] preHarvestCostInBaseYear;
00112                 relativeChangeInCosts.deallocate();
00113                 
00114                 delete [] typeEarning;
00115                 delete [] coLP;
00116                 futP.deallokieren();
00117 
00118                 sVecS.deallokieren();
00119                 fBeta.deallokieren();
00120                 iAlfa.deallokieren();
00121                 iBeta.deallokieren();
00122                 iGamm.deallokieren();
00123                 iDelt.deallokieren();
00124                 pMatP.deallokieren();
00125 
00126                 delete [] pRows;
00127                 delete [] pCols;
00128         }
00129 
00131 
00132 protected:
00133         FILE* strm;
00134 
00136         int numRounds;
00137         int numCommod;
00138 
00140         double* reservationPrice;
00141         double* priceFlexibility;
00142         double* priceOverallTrend;
00143 
00145         MatrixDouble pricePaths;//renamed from <preispfade>
00146 
00148         int numberProductionCosts;
00149         int* activityIndexInLp;
00150         double* productionCostInBaseYear;//= pre-harvest plus harvest costs
00151         double* preHarvestCostInBaseYear;
00152         MatrixDouble relativeChangeInCosts;//for all periods, in relation to base year
00153         
00155         double extCons;//renamed from KONSUMFAKTOR
00156         double minCons;//renamed from MINENTNAHMEN
00157         double forCons;//renamed from VERZICHT
00158 
00160         int* typeEarning;//flags indicating type of earning
00161         int nApp;//number of future prices for permanent crops ("appreciation")
00162         int* coLP;//column indices in MILP
00163         MatrixDouble futP;//expected future prices
00164         int incR;//income transfer row
00165 
00167         int sColU;//col in LP of upper bound on segment0 (=zero-savings)
00168         int sRowB;//row in LP of binary constraint for segment0 (=zero-savings)
00169         int sColB;//col in LP of binary constraint for segment0 (=zero-savings)
00170         int sRowS;//row in LP of savings segments
00171         int sColS;//col in LP of segment1
00172 
00173         int sNumS;//number of other segments in savings model (excl. segment0)
00174         MatrixDouble sVecS;//vector of segment sizes (size: 1 * sNumS)
00175 
00176         double sAlfa;//income coefficient
00177         double sBeta;//squared income coefficient
00178         double sGamm;//household size coefficient
00179         double sDelt;//constant term
00180 
00182         int fNumS;//number of expenditure segments
00183         int fRowS;//row in LP of expenditure segments
00184         int fColS;//col in LP of expenditure segment1
00185         int fRowH;//row in LP of household size coefficient
00186         int fColH;//col in LP of household size coefficient
00187 
00188         double fAlfa;//expenditure coefficient
00189         MatrixDouble fBeta;//vector of income coefficients (size: 1 * fNumS)
00190         double fGamm;//household size coefficient
00191 
00193         int iNumF;//number of food items
00194         int iNumS;//number of expenditure segments
00195         int iRowH;//row in LP of household size coefficient1
00196         int iColH;//col in LP of household size coefficients
00197         int iRowP;//row in LP of price coefficient1
00198         int iColP;//col in LP of price coefficients
00199         int iRowS;//row in LP of expenditure segment1
00200         int iColS;//col in LP of expenditure segment1
00201 
00202         MatrixDouble iAlfa;//vector of expenditure coefficients (size: 1* iNumF)
00203         MatrixDouble iBeta;//MatrixDouble of period-specific expenditures (numRounds * iNumS)
00204         MatrixDouble iGamm;//MatrixDouble of price coefficients (size: numRounds * iNumF)
00205         MatrixDouble iDelt;//vector of household size coefficients (size: 1 * iNumF)
00206 
00208         int  pNumG;//number of goods
00209         int* pRows;//row indices of prices of consumption goods in LP
00210         int* pCols;//column indices of prices of consumption goods in LP
00211         MatrixDouble pMatP;//MatrixDouble of price coefficients (size: numRounds * pNumG)
00212 
00214         int numNtr;
00216 };
00217 
00218 
00219 #endif
00220 
00221 

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