src/de/pik/lagom/generic/initvalues/FoundationInitValues.java

00001 
00002 // Copyright 2010 by Carlo Jaeger, Antoine Mandel, Steffen Fuerst and European Climate Forum
00003 // Licensed under the Open Software License version 3.0
00004 // See the file "License-OSL-3.0.txt" in the distribution for more information
00005 // The License text can be also found under http://www.opensource.org/licenses/osl-3.0.php
00007 
00008 package de.pik.lagom.generic.initvalues;
00009 
00010 import static de.pik.lagom.annotations.Variability.SIMULATION;
00011 
00012 import java.io.Serializable;
00013 import java.util.List;
00014 
00015 import de.pik.lagom.annotations.Description;
00016 import de.pik.lagom.annotations.InitValue;
00017 import de.pik.lagom.annotations.NameInUI;
00018 import de.pik.lagom.annotations.Variability;
00019 import de.pik.lagom.exceptions.ValueValidationException;
00020 import de.pik.lagom.toolbox.ArrayTools;
00021 import de.pik.lagom.toolbox.io.initvalues.InitValuesManager;
00022 
00029 @Variability(SIMULATION)
00030 public class FoundationInitValues extends InitValuesWithSectors implements Serializable {
00032   private final SectorInitValues sectorInitValues;
00034   private final GovernmentInitValues governmentInitValues;
00036   private final FinancialInitValues financialInitValues;
00038   private final HouseholdInitValues householdInitValues;
00039 
00041   @InitValue(priority = 1000, showWarningIfMissing = false, setToDefaultIfMissing = true)
00042   private String description = "";
00043 
00048   @InitValue(inspector = "Foundation", posInInspector = 101)
00049   @NameInUI("Random Trade Order")
00050   @Description("If disabled, first the firms are trading then the households")
00051   private boolean randomTradeOrder = true;
00052 
00054   @InitValue(inspector = "Foundation", posInInspector = 102)
00055   @NameInUI("Update Benchmark Wage Every n Periods")
00056   @Description("The benchmark wage is updated every n periods (if the adjustment process " +
00057                "isn't disabled)")
00058   private int benchmarkWageInterval = 5;
00059 
00061   @InitValue(inspector = "Foundation", posInInspector = 103)
00062   @NameInUI("Firms Adjust Workforce")
00063   @Description("If disabled, the workforce of the firms is constant")
00064   private boolean firmAdjustWorkforce = true;
00065 
00067   @InitValue(inspector = "Foundation", posInInspector = 104)
00068   @NameInUI("Households Adjust Workforce")
00069   @Description("If disabled, households only react on job offers")
00070   private boolean householdAdjustEmployment = true;
00071   
00073   @InitValue(inspector = "Foundation", posInInspector = 105)
00074   @NameInUI("Wages Indexation")
00075   @Description("If enabled, the benchmark wage is indexed on inflation, on top of productivity ")
00076   private boolean wagesIndexed =false;
00077   
00079   @InitValue(inspector = "Foundation", posInInspector = 105)
00080   @NameInUI("Equilibrium Initialization")
00081   @Description("If enabled, the risk premium is mark-up-interest rate ")
00082   private boolean initEquilibrium =false;
00083 
00085   @InitValue(inspector = "Foundation", posInInspector = 105)
00086   @NameInUI("Adjust Employment Every n Periods")
00087   @Description("Firms and households adjust their employment status every n periods " + 
00088                "(if the adjustment process isn't disabled)")
00089   private int adjustEmploymentInterval = 5;
00090 
00092   @InitValue(inspector = "Firm", posInInspector = 910)
00093   @NameInUI("Wage Mutation Factor")
00094   @Description("The initial wage is set to (1 + random[-value,value]) multiplied with a "
00095                + "calibration factor")
00096   private double wageVariation = 0.01d;
00097 
00098 
00100   @InitValue(inspector = "Firm", posInInspector = 13)
00101   @NameInUI("Firms Adjust Price and Production")
00102   @Description("If disabled, the supply price and desired production of the firms is constant")
00103   private boolean firmsBeliefUpdating = true;
00104 
00106   @InitValue(inspector = "Foundation", posInInspector = 106)
00107   @NameInUI("Update Price Every n Periods")
00108   @Description("The firms update their prices every n periods")
00109   private int priceInterval = 1;
00110 
00120   @InitValue(inspector = "Core", posInInspector = 10002)
00121   @NameInUI("Update Labor Productivity")
00122   @Description("If enabled, the labor productivity is updated proportionally to the rate " +
00123                "of net investment. If disabled the labor productivity is updated according " +
00124                "to the Exogenous Productivity Increase Rate.")
00125   private boolean laborProductivityUpdating = true;
00126   
00133   @InitValue(inspector = "Core", posInInspector = 10001)
00134   @NameInUI("Exogenous Productivity Growth Rate")
00135   @Description("Mainly used for the Solow like one sector model. If it's set to 0.0 and " +
00136                "Update Labor Productivity is disabled, the labor productivity is constant.")
00137   private double exogenousLaborProductivityGrowthRate = 0.0;
00138   
00140   @InitValue(inspector = "Financial", posInInspector = -1)
00141   @NameInUI("Update Interest Rate")
00142   @Description("If disabled, the interest rate is constant")
00143   private boolean financialSettingTheInterestRate = true;
00144 
00146   @InitValue(inspector = "Financial", posInInspector = 0)
00147   @NameInUI("Update Interest Rate Every n Periods")
00148   @Description("The Financial System calculates a new interest rate every n periods " + 
00149                "(if the updateing process isn't disabled above)")
00150   private int interestRateInterval = 5;
00151 
00153   @InitValue(inspector = "Foundation", posInInspector = 107)
00154   @NameInUI("Entry and Exit of Firms")
00155   @Description("If disabled, the number of firms per sector is constant")
00156   private boolean firmEntryAndExit = false;
00157 
00163   @InitValue(inspector = "Foundation", posInInspector = 108)
00164   @NameInUI("Entry and Exit of Firms Every n Periods")
00165   @Description("A new firm generation is calculated everny n periods (if the entry and exit isn't disabled above)")
00166   private int firmEntryAndExitInterval = 5;
00167 
00169   @InitValue(inspector = "Foundation", posInInspector = 109)
00170   @NameInUI("Genetic Evolution of Technologies")
00171   @Description("trigger random evolution of agents'technologies")
00172   private boolean geneticEvolutionTechnologies = true;
00173 
00175   @InitValue(inspector = "Foundation", posInInspector = 110)
00176   @NameInUI("Genetic Evolution of Prices")
00177   @Description("trigger random evolution of prices")
00178   private boolean geneticEvolutionPrices = true;
00179   
00181   @InitValue(inspector = "Foundation", posInInspector = 110)
00182   @NameInUI("Genetic Evolution of Wages")
00183   @Description("trigger random evolution of prices")
00184   private boolean geneticEvolutionWages = true;
00185 
00186   @InitValue(inspector = "Foundation", posInInspector = 111)
00187   @NameInUI("Periodicity of Prices Evolution")
00188   @Description(" random evolution of prices is triggered every n periods")
00189   private int geneticEvolutionPricesInterval = 1;
00190   
00191   @InitValue(inspector = "Foundation", posInInspector = 111)
00192   @NameInUI("Periodicity of Technologies Evolution")
00193   @Description(" random evolution of technologies is triggered every n periods")
00194   private int geneticEvolutionTechnologiesInterval = 1;
00195   
00196   @InitValue(inspector = "Foundation", posInInspector = 111)
00197   @NameInUI("Periodicity of Wages Evolution")
00198   @Description(" random evolution of technologies is triggered every n periods")
00199   private int geneticEvolutionWagesInterval = 1;
00200 
00202   @InitValue(inspector = "Foundation", posInInspector = 3)
00203   @NameInUI("Number of Firms")
00204   @Description("The total number of firms")
00205   private int numFirms = 100;
00206 
00208   @InitValue(inspector = "Foundation", posInInspector = 4)
00209   @NameInUI("Firms Have Same Size")
00210   @Description("If enabled, all firms of a sector have the same production level after "
00211                + "initialization")
00212   private boolean firmsHaveSameSize = false;
00213 
00216   @InitValue(inspector = "Foundation", posInInspector = 2)
00217   @NameInUI("Sectors Have Same Size")
00218   @Description("If enabled, all sectors have the same number of firms, else the number" +
00219                "depends on the initial production level of the sectors")
00220   private boolean sectorsHaveSameNumberOfFirms = false;
00221 
00223   @InitValue(inspector = "Foundation", posInInspector = 6)
00224   @NameInUI("Number of Households")
00225   @Description("The total number of households")
00226   private int numHouseholds = 500;
00227   
00229   @InitValue(inspector = "Household", posInInspector = 104)
00230   @NameInUI("Household Imitation Rate")
00231   @Description("The fraction of households that will imitate the behaviour of others.")
00232   private double householdReplacementRate = 0.25;
00233   
00235   @InitValue(inspector = "Household", posInInspector = 300)
00236   @NameInUI("Peers Sampling Rate")
00237   @Description("The fraction of households that will be observed for imitation")
00238   private double householdSamplingRate = 0.1;
00239     
00241   @InitValue(priority = 30)
00242   private int seed;
00243 
00256   @InitValue(inspector = "Foundation", posInInspector = 300)
00257   @NameInUI("Simulation Starts in Year")
00258   @Description("Simulation starts in year")
00259   private int startingYear = 1978;
00260 
00266   @InitValue(inspector = "Foundation", posInInspector = 301)
00267   @NameInUI("Number of Periods per Year")
00268   @Description("The number of periods  are representing a 'real-world' year")
00269   private int numPeriodsPerYear = 12;
00270 
00271   public FoundationInitValues(InitValuesManager pIVM) {
00272     super(pIVM);
00273     sectorInitValues = new SectorInitValues(pIVM);
00274     governmentInitValues = new GovernmentInitValues(pIVM);
00275     financialInitValues = new FinancialInitValues(pIVM);
00276     householdInitValues = new HouseholdInitValues(pIVM);
00277   }
00278 
00279   @Override
00280   public void validate(List<String> pWarnings) throws ValueValidationException {
00281     if (sectorsHaveSameNumberOfFirms) {
00282       if ((numFirms % sectorInitValues.getNumSectors()) != 0) {
00283         throw new ValueValidationException("Number of firms must be a multiple of " +
00284             "the number of Sectors, or disable the sectorHaveSameNumberOfFirms option.");
00285       }
00286     } else {
00287       for (int iSector = 0; iSector < sectorInitValues.getNumSectors(); iSector++) {
00288         final int lAdditionalFirmsNeeded =
00289           (int)  Math.round(sectorInitValues.getNumFirmMin() -
00290                             (numFirms *
00291                                 (sectorInitValues.getProductionArray()[iSector] /
00292                                     overallProduction())));
00293 
00294         if (lAdditionalFirmsNeeded > 0) {
00295           pWarnings.add("Number of firms will be higher then " + numFirms + " because sector " +
00296                         sectorInitValues.getNameArray()[iSector] + " needs " +
00297                         lAdditionalFirmsNeeded + " additional firms to match numFirmsMin");
00298         }
00299       }
00300     }
00301   }
00302   
00306   public long calcNumHouseholdsCopying(){
00307     long lNumCopyHouseholds = Math.round(numHouseholds * householdReplacementRate);
00308     if (numHouseholds == 1) {
00309       lNumCopyHouseholds = 0;
00310     } else if (lNumCopyHouseholds == 0) {
00311       lNumCopyHouseholds = 1;
00312     }
00313     assert (lNumCopyHouseholds <= numHouseholds): "HouseholdsReplacementRate is too high";
00314 
00315     return lNumCopyHouseholds;
00316   } 
00317 
00321   public long calcNumHouseholdsObserved(){
00322     long lNumObservedHouseholds = Math.round(numHouseholds * householdSamplingRate);
00323     if (numHouseholds == 1) {
00324       lNumObservedHouseholds = 0;
00325     } else if (lNumObservedHouseholds == 0) {
00326       lNumObservedHouseholds = 1;
00327     }
00328     assert (lNumObservedHouseholds <= numHouseholds): "HouseholdsObservationRate is too high";
00329 
00330     return lNumObservedHouseholds;    
00331   }   
00332 
00333   // getter/setter methods
00334   public SectorInitValues sectorInitValues() {
00335     return sectorInitValues;
00336   }
00337 
00338   public GovernmentInitValues governmentInitValues() {
00339     return governmentInitValues;
00340   }
00341 
00342   public FinancialInitValues financialInitValues() {
00343     return financialInitValues;
00344   }
00345 
00346   public HouseholdInitValues householdInitValues() {
00347     return householdInitValues;
00348   }
00349 
00350   public String getDescription() {
00351     return description;
00352   }
00353 
00354   public void setDescription(String pDescription) {
00355     description = pDescription;
00356   }
00357 
00358   public boolean isRandomTradeOrder() {
00359     return randomTradeOrder;
00360   }
00361 
00362   public void setRandomTradeOrder(boolean pRandomTradeOrder) {
00363     randomTradeOrder = pRandomTradeOrder;
00364   }
00365 
00366   public int getBenchmarkWageInterval() {
00367     return benchmarkWageInterval;
00368   }
00369 
00370   public void setBenchmarkWageInterval (int pBenchmarkWageInterval) {
00371     benchmarkWageInterval = pBenchmarkWageInterval;
00372   }
00373 
00374   public boolean isHouseholdAdjustEmployment() {
00375     return householdAdjustEmployment;
00376   }
00377 
00378   public void setHouseholdAdjustEmployment(boolean pAdjustEmployment) {
00379     householdAdjustEmployment = pAdjustEmployment;
00380   }
00381 
00382   public boolean isWagesIndexed() {
00383     return wagesIndexed;
00384   }
00385 
00386   public void setWagesIndexed(boolean pWagesIndexed) {
00387     wagesIndexed = pWagesIndexed;
00388   }
00389 
00390   public boolean isFirmAdjustWorkforce() {
00391     return firmAdjustWorkforce;
00392   }
00393 
00394   public void setFirmAdjustWorkforce(boolean pAdjustEmployment) {
00395     firmAdjustWorkforce = pAdjustEmployment;
00396   }
00397 
00398   public int getAdjustEmploymentInterval() {
00399     return adjustEmploymentInterval;
00400   }
00401 
00402   public double getWageVariation() {
00403     return wageVariation;
00404   }
00405 
00406 
00407   public void setWageVariation(double pWageVariation) {
00408     wageVariation = pWageVariation;
00409   }
00410 
00411   public void setAdjustEmploymentInterval(int pAdjustEmploymentPeriod) {
00412     adjustEmploymentInterval = pAdjustEmploymentPeriod;
00413   }
00414 
00415   public boolean isFirmsBeliefUpdating() {
00416     return firmsBeliefUpdating;
00417   }
00418 
00419   public void setFirmsBeliefUpdating(boolean pFirmsBeliefUpdating) {
00420     firmsBeliefUpdating = pFirmsBeliefUpdating;
00421   }
00422 
00423   public boolean isLaborProductivityUpdating() {
00424     return laborProductivityUpdating;
00425   }
00426 
00427   public void setLaborProductivityUpdating(boolean pLaborProductivityUpdating) {
00428     laborProductivityUpdating = pLaborProductivityUpdating;
00429   }
00430 
00431   public void setExogenousLaborProductivityGrowthRate(double pExogenousLaborProductivityGrowthRate) {
00432     exogenousLaborProductivityGrowthRate = pExogenousLaborProductivityGrowthRate;
00433   }
00434   
00435   public boolean isFinancialSettingTheInterestRate() {
00436     return financialSettingTheInterestRate;
00437   }
00438 
00439   public void setFinancialSettingTheInterestRate(
00440                                                  boolean pFinancialSettingTheInterestRate) {
00441     financialSettingTheInterestRate = pFinancialSettingTheInterestRate;
00442   }
00443 
00444   public int getInterestRateInterval() {
00445     return interestRateInterval;
00446   }
00447 
00448   public void setInterestRateInterval(int pInterestRateInterval) {
00449     interestRateInterval = pInterestRateInterval;
00450   }
00451 
00452   public boolean isFirmEntryAndExit() {
00453     return firmEntryAndExit;
00454   }
00455 
00456   public void setFirmEntryAndExit(boolean pFirmEntryAndExit) {
00457     firmEntryAndExit = pFirmEntryAndExit;
00458   }
00459 
00460   public int getFirmEntryAndExitInterval() {
00461     return firmEntryAndExitInterval;
00462   }
00463 
00464   public void setFirmEntryAndExitInterval(int pFirmEntryAndExitInterval) {
00465     firmEntryAndExitInterval = pFirmEntryAndExitInterval;
00466   }
00467 
00468   public void setSeed(int pSeed) {
00469     seed = pSeed;
00470   }
00471 
00472   public int getSeed() {
00473     return seed;
00474   }
00475 
00476   public int getNumFirms() {
00477     return numFirms;
00478   }
00479 
00480   public void setNumFirms(int pNumFirms) {
00481     numFirms = pNumFirms;
00482   }
00483 
00484   public boolean isSectorsHaveSameNumberOfFirms() {
00485     return sectorsHaveSameNumberOfFirms;
00486   }
00487 
00488   public void setSectorsHaveSameNumberOfFirms(boolean pSectorsHaveSameNumberOfFirms) {
00489     sectorsHaveSameNumberOfFirms = pSectorsHaveSameNumberOfFirms;
00490   }
00491 
00492   public boolean isFirmsHaveSameSize() {
00493     return firmsHaveSameSize;
00494   }
00495 
00496   public void setFirmsHaveSameSize(boolean pFirmsHaveSameSize) {
00497     firmsHaveSameSize = pFirmsHaveSameSize;
00498   }
00499 
00500   public int getNumHouseholds() {
00501     return numHouseholds;
00502   }
00503 
00504   public void setNumHouseholds(int pNumHouseholds) {
00505     numHouseholds = pNumHouseholds;
00506   }
00507 
00508   public int getStartingYear() {
00509     return startingYear;
00510   }
00511 
00512   public void setStartingYear(int pStartingYear) {
00513     startingYear = pStartingYear;
00514   }
00515 
00516   public double periodLength() {
00517     return 1. / numPeriodsPerYear;
00518   }
00519 
00520   public int getNumPeriodsPerYear() {
00521     return numPeriodsPerYear;
00522   }
00523 
00524   public void setNumPeriodsPerYear(int pNumPeriodsPerYear) {
00525     numPeriodsPerYear = pNumPeriodsPerYear;
00526   }
00527 
00528   public double overallConsumption() {
00529     return ArrayTools.sumDouble(sectorInitValues.getConsumptionArray());
00530   }
00531 
00532   public double overallProduction() {
00533     return ArrayTools.sumDouble(sectorInitValues.getProductionArray());
00534   }
00535 
00536   public int getPriceInterval() {
00537     return priceInterval;
00538   }
00539 
00540   public void setPriceInterval(int pPriceInterval) {
00541     priceInterval = pPriceInterval;
00542   }
00543 
00544   public boolean isGeneticEvolutionTechnologies() {
00545     return geneticEvolutionTechnologies;
00546   }
00547 
00548   public void setGeneticEvolutionTechnologies(boolean pGeneticEvolutionTechnologies) {
00549     geneticEvolutionTechnologies = pGeneticEvolutionTechnologies;
00550   }
00551 
00552   public boolean isGeneticEvolutionPrices() {
00553     return geneticEvolutionPrices;
00554   }
00555 
00556   public void setGeneticEvolutionPrices(boolean pGeneticEvolutionPrices) {
00557     geneticEvolutionPrices = pGeneticEvolutionPrices;
00558   }
00559 
00560   public int getGeneticEvolutionPricesInterval() {
00561     return geneticEvolutionPricesInterval;
00562   }
00563 
00564   public void setGeneticEvolutionPricesInterval(int pGeneticEvolutionPricesInterval) {
00565     geneticEvolutionPricesInterval = pGeneticEvolutionPricesInterval;
00566   }
00567   
00568 
00569   public double getExogenousLaborProductivityGrowthRate() {
00570     return exogenousLaborProductivityGrowthRate;
00571   }
00572 
00573   public double getHouseholdReplacementRate() {
00574     return householdReplacementRate;
00575   }
00576 
00577   public void setHouseholdReplacementRate(double pHouseholdReplacementRate) {
00578     householdReplacementRate = pHouseholdReplacementRate;
00579   }
00580 
00581   public double getHouseholdSamplingRate() {
00582     return householdSamplingRate;
00583   }
00584 
00585   public void setHouseholdSamplingRate(double pHouseholdSamplingRate) {
00586     householdSamplingRate = pHouseholdSamplingRate;
00587   }
00588 
00589   public int getGeneticEvolutionTechnologiesInterval() {
00590     return geneticEvolutionTechnologiesInterval;
00591   }
00592 
00593   public void setGeneticEvolutionTechnologiesInterval(int pGeneticEvolutionTechnologiesInterval) {
00594     geneticEvolutionTechnologiesInterval = pGeneticEvolutionTechnologiesInterval;
00595   }
00596 
00597   public boolean isInitEquilibrium() {
00598     return initEquilibrium;
00599   }
00600 
00601   public void setInitEquilibrium(boolean pInitEquilibrium) {
00602     initEquilibrium = pInitEquilibrium;
00603   }
00604 
00605   public boolean isGeneticEvolutionWages() {
00606     return geneticEvolutionWages;
00607   }
00608 
00609   public void setGeneticEvolutionWages(boolean pGeneticEvolutionWages) {
00610     geneticEvolutionWages = pGeneticEvolutionWages;
00611   }
00612 
00613   public int getGeneticEvolutionWagesInterval() {
00614     return geneticEvolutionWagesInterval;
00615   }
00616 
00617   public void setGeneticEvolutionWagesInterval(int pGeneticEvolutionWagesInterval) {
00618     geneticEvolutionWagesInterval = pGeneticEvolutionWagesInterval;
00619   }
00620 }
00621 
00623 // EOF

Generated on Tue Sep 14 11:11:48 2010 for lagom_generiC by  doxygen 1.5.4