Foundation Class Reference

The Foundation is sort of a basis where the model is built upon. More...

Collaboration diagram for Foundation:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 Foundation (int pSeed, ProbeManager pProbeManager)
 The constructor of the Foundation class.
synchronized void advanceOnePeriod ()
 Calculate a complete period.
void preparatoryStep ()
 Reset the "per period" counters to 0.
void exchangeStep ()
 The firms and household are trying to buy their demands (which are calculated in the trade method itself).
void updateBenchmarkWage ()
 Update for every sector the benchmark wage.
void householdsAdjustEmployment ()
 After every FoundationInitValues.adjustEmploymentPeriod periods all employed Households first check their employment status.
void firmsAdjustWorkforce ()
 After every FoundationInitValues.adjustEmploymentPeriod periods all Firms adjust their number of employees.
void updateLaborProductivity ()
 Update for every sector the labor productivity.
void production ()
 Each firm produces.
void consumption ()
 Each household consumes.
void firmAccounting ()
 All firms account.
void householdsAccounting ()
 After the government calculated the actual unemployment insurance, the households receive their income (from different source).
void importExportAccounting ()
 The ImportExport agent account his tradings.
void firmsPriceUpdating ()
 Firm updates its price using a mark-up over costs.
void firmsDesiredProductionUpdating ()
 Firm updates its desired production according to the demand it faces.
void settingInterestRate ()
 Call Financial.updateInterestRate() each initValues.getInterestRateInterval() periods.
void geneticEvolutionOfTechnologies ()
 Firms and Households copy (imitate) and mutate their technologies.
void firmsEntryAndExit ()
 For each Sector drop unproductive firms and check the creation of new on each FoundationInitValues.firmEntryAndExitInterval periods.
void geneticEvolutionOfPrices ()
 Firms copy and mutate their prices.
void geneticEvolutionOfWages ()
 Firms copy and mutate their prices and wages.
List< Household.Probe > generateHouseholdProbeList ()
 Generate a list of probes of all Households.
List< Sector.Probe > generateSectorProbeList ()
 Generate a list of probes of all Sectors.
List< ImportExport.Probe > generateImportExportProbeList ()
 Generate a list of probes of all ImportExport agents.
LinkedList< Firm.Probe > generateFirmProbeList ()
 Generate a list of probes of all Firms.

Package Functions

void initMutateConsumptionTechnology ()
 The consumption technology coefficients of the household are mutated.
double initialDesiredWage ()
 Calculate the initial desired wage in the economy.
double calcUnemploymentRate ()
 Calculate the actual unemployment rate.
double calcNumHouseholdsEmployed ()
 Calculate the sum of the work amounts of all work contracts.
LinkedList< FirmgenerateFirmList ()
 Generate a list of all Firms.
double[] generatePriceVector ()
 Create an array (with the size equals the number of sectors) which contain the actual average trade prices of all sectors.

Private Member Functions

void initHouseholds () throws ParameterParserException
 Construct, initialize and mutate all households.
double calcDifference (double[] pConsumption)
 Calculate the difference between the consumption pConsumption and the consumption given in the sectorInitValues.
void constructSectors ()
 Generate the sectors and add them to the Sector list.
void initSectors () throws ValueValidationException, ParameterParserException
 Initialize the sectors.
void initTradeNetwork ()
 initialize the trade network

Private Attributes

final EmissionProbe emissionProbe = new EmissionProbe()
 Statistics about the CO2 emission caused by production and trading.
TradeTrace tradeTrace = new TradeTrace(Foundation.this)
 List of all trades in a single period.
Government government
 The Government.
Financial financial
 The financial system.
final LinkedList< SectorsectorList = new LinkedList<Sector>()
 The list of all Sectors in the Foundation.
int period
 A counter that is registering how often the method step() was called.
final HouseholdSet households = new HouseholdSet()
 The list contain all households in the foundation.

Static Private Attributes

static final int NUM_INIT_CONSUMPTION_TECHNOLOGY_MUTATIONS = 10
 
See also:
Foundation.initMutateConsumptionTechnology

static final boolean USE_PROFILER = false
 The StepManager has an inbuilt profiler, that measure the time user for each step.
static RandomGenerator random
 The instance of our random generator, which is part of our toolbox package.
static ProductionFunctionFactory productionFunctionFactory
 Factory (Design pattern) for creating the production function of a firm.
static ConsumptionTechnologyFactory consumptionTechnologyFactory
 Factory (Design pattern) for creating the consumption technology of a household.
static FoundationInitValues initValues
 The initialization values for the Foundation.

Classes

class  EmissionProbe
 Based on the carbon intensity coefficient, which is calculated in Sector.calcCiCoef, the EmissionProbe reports about the C02 emissions created by the production process and the C02 that was needed for the production of the goods that was traded in this period. More...
class  HouseholdSet
 The HouseholdSet is a wrapper for the list of households. More...


Detailed Description

The Foundation is sort of a basis where the model is built upon.

It's the only class that must be instantiated from the model driver itself, the rest of the model will be then build up from the Foundation itself. See Structure for more details about the model structure.

After construction and initialization each time the model driver call advanceOnePeriod() the next period is calculated. Afterwards the model driver can collecting the results of this calculation via reflecting the Probe classes. See Executing the Model for more details about the model driver.

Definition at line 156 of file Foundation.java.


Constructor & Destructor Documentation

Foundation ( int  pSeed,
ProbeManager  pProbeManager 
)

The constructor of the Foundation class.

Parameters:
pSeed The seed for our RandomGenerator instance, which is constructed in Foundation.init.

Definition at line 405 of file Foundation.java.

00405                                                            {
00406     super(pSeed, pProbeManager);
00407   }


Member Function Documentation

void initHouseholds (  )  throws ParameterParserException [private]

Construct, initialize and mutate all households.

Definition at line 477 of file Foundation.java.

00477                                                                 {
00478     households.clear();
00479 
00480     final int lNumHouseholds = getNumHouseholdsTotal();
00481     for (int i = 0; i < lNumHouseholds; i++)
00482     {
00483       final Household lHousehold = new Household(this, initValues.householdInitValues());
00484       households.add(lHousehold);
00485     }
00486 
00487     for (final Household lHousehold : households) {
00488       lHousehold.init();
00489     }
00490 
00491     initMutateConsumptionTechnology();
00492   }

void initMutateConsumptionTechnology (  )  [package]

The consumption technology coefficients of the household are mutated.

After the mutation the overall consumption should be the same, but the algorithm can only approximate the original consumption. So the best approximation of NUM_INIT_CONSUMPTION_TECHNOLOGY_MUTATIONS passes is selected.

Definition at line 501 of file Foundation.java.

Referenced by Foundation.initHouseholds().

00501                                          {
00502     final int lNumSectors = getNumSectors();
00503 
00504     // The map contains the consumption technology coefficients of all household of a
00505     // single mutation pass.
00506     final Map<Household, double[]> lPassVariatorResults = new HashMap<Household, double[]>();
00507     // This map contains the mutation that has the lowest difference to the original consumption
00508     Map<Household, double[]> lBestVariatorResults = new HashMap<Household, double[]>();
00509 
00510     final DoubleInterval[] lTechnologyMutation = new DoubleInterval[lNumSectors];
00511     final double[] lPrices = ArrayTools.createArray(lNumSectors, 1.d);
00512 
00513     double lMinimalDifference = Double.MAX_VALUE;
00514     final double lMutationLevel = initValues.householdInitValues().
00515                                              getInitialConsumptionTechnologyMutation();
00516 
00517     // mutate the households NUM_INIT_CONSUMPTION_TECHNOLOGY_MUTATIONS times
00518     for (int iPass = 0; iPass < NUM_INIT_CONSUMPTION_TECHNOLOGY_MUTATIONS; iPass++) {
00519       // init mutation intervals for the iPass-th pass. They are modified after a households
00520       // coefficients were mutated for a better approximation of the orignal consumption   
00521       for (int iSector = 0; iSector < lNumSectors; iSector++) {
00522         lTechnologyMutation[iSector] = new DoubleInterval(-lMutationLevel, lMutationLevel);
00523       }
00524 
00525       double lSumMutatedConsumption[] = new double[lNumSectors];
00526       int lNumHouseholdsMutated = 0;
00527 
00528       // mutate the single households
00529       for (final Household lHousehold : households) {
00530         lNumHouseholdsMutated++;
00531 
00532         final double[] lMutatedResults =
00533                 lHousehold.getConsumptionTechnology().mutateCoefficients(lTechnologyMutation,
00534                                                                          getNumSectors());
00535 
00536         // store the result of the mutation
00537         lPassVariatorResults.put(lHousehold, lMutatedResults);
00538 
00539         // add the consumption of the mutated household to the consumption of all mutated
00540         // households
00541         lSumMutatedConsumption = ArrayTools.addArrays(lSumMutatedConsumption, 
00542                                                    lHousehold.calcDemand(lHousehold.getMoney(),
00543                                                                          lPrices,
00544                                                                          lMutatedResults));
00545 
00546         // compare for each sector the average of the mutated consumption with the average
00547         // of the original consumption. If it's higher, mutate the coefficients of the following
00548         // household only to higher values (with will lower the demand), if it's lower, lower
00549         // the coefficients.
00550         for (int iSector = 0; iSector < lNumSectors; iSector++) {
00551           if (lSumMutatedConsumption[iSector] < 
00552                                 initValues.sectorInitValues().getConsumptionArray()[iSector] *
00553                                               lNumHouseholdsMutated / getNumHouseholdsTotal()) {
00554             lTechnologyMutation[iSector].set(0.d, lMutationLevel);
00555           } else {
00556             lTechnologyMutation[iSector].set(-lMutationLevel, 0.d);
00557           }
00558         }
00559       }
00560 
00561       // check the consumption difference between the mutated and original consumption and
00562       // store the mutation with the lowest difference.
00563       if (lMinimalDifference > calcDifference(lSumMutatedConsumption)) {
00564         lBestVariatorResults = new HashMap<Household, double[]>(lPassVariatorResults);
00565         lMinimalDifference = calcDifference(lSumMutatedConsumption);
00566       }
00567     }
00568 
00569     // after all passes take the best mutation and set the consumption technology coefficients
00570     // of the households to the values of this mutation
00571     for (final Household lHousehold : lBestVariatorResults.keySet()) {
00572       final double[] lVariatorResults = lBestVariatorResults.get(lHousehold);
00573       lHousehold.setConsumptionTechnologyCoefficients(lVariatorResults);
00574     }
00575   }

double calcDifference ( double[]  pConsumption  )  [private]

Calculate the difference between the consumption pConsumption and the consumption given in the sectorInitValues.

Definition at line 581 of file Foundation.java.

Referenced by Foundation.initMutateConsumptionTechnology().

00581                                                        {
00582     double lDifference = 0;
00583     for (final Sector lSector : sectorList) {
00584       lDifference += Math.abs(pConsumption[lSector.getArrayIndex()] -
00585                   initValues.sectorInitValues().getConsumptionArray()[lSector.getArrayIndex()]);
00586     }
00587     return lDifference;
00588   }

void constructSectors (  )  [private]

Generate the sectors and add them to the Sector list.

The number of sectors can be set as an initialization value of the Foundation. The initialization of the sectors is done in initSectors() afterwards.

Definition at line 637 of file Foundation.java.

00637                                   {
00638     sectorList.clear();
00639     final int lNumSectors = initValues.sectorInitValues().getNumSectors();
00640     assert (lNumSectors > 0): "There must be at least one Sector";
00641     for (int i = 0; i < lNumSectors; i++)
00642     {
00643       final Sector lSector = new Sector(this, initValues.sectorInitValues(), i);
00644       sectorList.add(lSector);
00645     }
00646   }

void initSectors (  )  throws ValueValidationException, ParameterParserException [private]

Initialize the sectors.

See also:
Sector.init()

Definition at line 653 of file Foundation.java.

00653                                                                                        {
00654     for (final Sector lSector : sectorList) {
00655       lSector.init();
00656     }
00657   }

void initTradeNetwork (  )  [private]

initialize the trade network

Definition at line 663 of file Foundation.java.

00663                                  {
00664     for (final Sector lSector : sectorList) {
00665       // construct a list of all buyers
00666       final List<IBuyer> lBuyersList = new LinkedList<IBuyer>();
00667       final List<Firm> lFirms = generateFirmList();
00668       final List<Household> lHouseholds = households.getCopyAsLinkedList();
00669       lBuyersList.addAll(lFirms);
00670       lBuyersList.addAll(lHouseholds);
00671       lBuyersList.add(lSector.getImportExport());
00672       // construct a list of all sellers
00673       final List<ISeller> lSellersList= new LinkedList<ISeller>();
00674       lSellersList.addAll(lSector.getFirmList());
00675       lSellersList.add(lSector.getImportExport());
00676       // compute total demand
00677       double lTotalDemand =0;
00678       for (final IBuyer lBuyer : lBuyersList){
00679         lTotalDemand += lBuyer.getBenchmarkDemand(lSector);
00680       }
00681       // compute total supply
00682       double lTotalSupply =0;
00683       for (final ISeller lSeller : lSellersList){
00684         lTotalSupply += lSeller.getBenchmarkSupply();
00685       }
00686       // the demand/supply ratio 
00687       final double lDemandSupplyRatio= lTotalDemand/lTotalSupply;
00688       
00689       random.shuffle(lBuyersList);
00690       final Iterator<ISeller> iterSellers= lSellersList.iterator();
00691       ISeller lSeller=iterSellers.next();
00692       double lSupply = lDemandSupplyRatio*lSeller.getBenchmarkSupply();
00693       for (final IBuyer lBuyer : lBuyersList){
00694         lBuyer.getSuppliers(lSector).getAvailableSuppliers().addAll(lSellersList);
00695         assert(lBuyer.getSuppliers(lSector).getAvailableSuppliers().contains(lSeller));
00696         double lDemand = lBuyer.getBenchmarkDemand(lSector);
00697         while(!FloatMath.lowerOrApproxZero(lDemand) && lBuyer.getSuppliers(lSector).canExtraSuppliers() &&
00698             (lSupply>0 || iterSellers.hasNext())){
00699           assert(lBuyer.getSuppliers(lSector).getAvailableSuppliers().contains(lSeller));
00700           double lMin =Math.min(lDemand, lSupply);
00701           lDemand-= lMin;
00702           lSupply-=lMin;
00703           lBuyer.getSuppliers(lSector).addSeller(lSeller);
00704           if(FloatMath.lowerOrApproxZero(lSupply) && iterSellers.hasNext()){
00705             lSeller=iterSellers.next();
00706             lSupply=  lDemandSupplyRatio*lSeller.getBenchmarkSupply();
00707           }
00708         }
00709         if ( lBuyer.getBenchmarkDemand(lSector)>0){
00710         assert(lBuyer.getSuppliers(lSector).getNumFoundSuppliers()>0);
00711         }
00712         assert(!iterSellers.hasNext() || FloatMath.lowerOrApproxZero(lDemand)); 
00713         
00714     }
00715 
00716 
00717     }   
00718 
00719   } 

synchronized void advanceOnePeriod (  ) 

Calculate a complete period.

Definition at line 724 of file Foundation.java.

00724                                               {
00725     if (!isInitialized) {
00726       assert(false) : "Initialize the model via start()";
00727     }
00728 
00729     period++;
00730 
00731     stepManager.executeStep(PREPARATORY_STEP);
00732     stepManager.executeStep(EXCHANGE_STEP);
00733     stepManager.executeStep(UPDATE_BENCHMARK_WAGE_STEP);
00734     stepManager.executeStep(HOUSEHOLDS_ADJUST_EMPLOYMENT_STEP);
00735     stepManager.executeStep(FIRMS_ADJUST_WORKFORCE_STEP);
00736     stepManager.executeStep(UPDATE_LABOR_PRODUCTIVITY_STEP);
00737     stepManager.executeStep(PRODUCTION_STEP);
00738     stepManager.executeStep(CONSUMPTION_STEP);
00739     stepManager.executeStep(FIRM_ACCOUNTING_STEP);
00740     stepManager.executeStep(HOUSEHOLD_ACCOUNTING_STEP);
00741     stepManager.executeStep(IMPORTEXPORT_ACCOUNTING_STEP);
00742     stepManager.executeStep(FIRMS_PRICE_UPDATING_STEP);
00743     stepManager.executeStep(FIRMS_DESIRED_PRODUCTION_UPDATING_STEP);
00744     stepManager.executeStep(SETTING_INTEREST_RATE_STEP);
00745     stepManager.executeStep(GENETIC_EVOLUTION_OF_TECHNOLOGIES_STEP);
00746     stepManager.executeStep(GENETIC_EVOLUTION_OF_PRICES_STEP);
00747     stepManager.executeStep(GENETIC_EVOLUTION_OF_WAGES_STEP);
00748     stepManager.executeStep(FIRMS_ENTRY_AND_EXIT_STEP);
00749   }

void preparatoryStep (  ) 

Reset the "per period" counters to 0.

Definition at line 754 of file Foundation.java.

00754                                 {
00755     for (final Firm lFirm : generateFirmList()) {
00756       lFirm.setProfit(0.d);
00757       lFirm.setSoldQuantity(0.d);
00758       lFirm.setCosts(0.d);
00759       lFirm.setSalesValue(0.d);
00760       lFirm.setIntermediaryConsumptionValue(0.d);
00761       lFirm.setInvestmentValue(0.d);
00762       assert (lFirm.getOwner() != null);
00763     }
00764     
00765     for (final Household lHousehold : getHouseholds()) {
00766       lHousehold.setEmploymentIncome(0.d);
00767     }
00768   }

void exchangeStep (  ) 

The firms and household are trying to buy their demands (which are calculated in the trade method itself).

After firms and household has trade, the ImportExport agent export part of the remaining inventory. Also the inflation rate is updated.

Definition at line 775 of file Foundation.java.

00775                              {
00776     final List<IBuyer> lFirmAndHouseholds = new LinkedList<IBuyer>();
00777     final List<Firm> lFirms = generateFirmList();
00778     final List<Household> lHouseholds = households.getCopyAsLinkedList();
00779     // bring the collection into a random order
00780     if (initValues.isRandomTradeOrder()) {
00781       lFirmAndHouseholds.addAll(lFirms);
00782       lFirmAndHouseholds.addAll(lHouseholds);
00783       random.shuffle(lFirmAndHouseholds);
00784     } else { // first the firms, then the households
00785       random.shuffle(lFirms);
00786       lFirmAndHouseholds.addAll(lFirms);
00787       random.shuffle(lHouseholds);
00788       lFirmAndHouseholds.addAll(lHouseholds);
00789     }
00790 
00791     for (final IBuyer lTrader : lFirmAndHouseholds) {
00792       lTrader.trade();
00793     }
00794 
00795     for (final Sector lSector : getSectorList()) {
00796       lSector.getImportExport().trade();
00797     }
00798 
00799     financial.updateInflationRate();
00800 
00801     // Each firm stores the state of its inventory
00802     for (final Firm lFirm : generateFirmList()) {
00803       lFirm.storeInventoryAfterTrade();
00804     }
00805   }

void updateBenchmarkWage (  ) 

Update for every sector the benchmark wage.

See also:
Sector.updateLaborProductivity

Definition at line 812 of file Foundation.java.

00812                                     {
00813     if ((period % initValues.getBenchmarkWageInterval()) == 0) {
00814       for (final Sector lSector : sectorList) {
00815         lSector.updateBenchmarkWage();
00816       }
00817     }
00818   }

void householdsAdjustEmployment (  ) 

After every FoundationInitValues.adjustEmploymentPeriod periods all employed Households first check their employment status.

See also:
Household.adjustEmploymentStatus

Definition at line 826 of file Foundation.java.

00826                                            {
00827 
00828     if ((period % initValues.getAdjustEmploymentInterval()) == 0) {
00829       final List<Household> lHouseholds = households.getCopyAsLinkedList();
00830       random.shuffle(lHouseholds);
00831       for (final Household lHousehold : lHouseholds) {
00832         lHousehold.adjustEmploymentStatus();
00833       }
00834     }
00835   }

void firmsAdjustWorkforce (  ) 

After every FoundationInitValues.adjustEmploymentPeriod periods all Firms adjust their number of employees.

See also:
Firm.adjustEmployees

Definition at line 843 of file Foundation.java.

00843                                      {
00844     if ((period % initValues.getAdjustEmploymentInterval()) == 0) {
00845       final List<Firm> lFirms = generateFirmList();
00846       random.shuffle(lFirms);
00847 
00848       for (final Firm lFirm : lFirms) {
00849         lFirm.adjustEmployees();
00850       }
00851     }
00852   }

void updateLaborProductivity (  ) 

Update for every sector the labor productivity.

See also:
Sector.updateLaborProductivity

Definition at line 859 of file Foundation.java.

00859                                         {
00860     if (initValues.isLaborProductivityUpdating()) {
00861       for (final Sector lSector : sectorList) {
00862         lSector.updateLaborProductivity();
00863       }
00864     }
00865     else{
00866       double lRate= initValues.getExogenousLaborProductivityGrowthRate();
00867       for (final Sector lSector : sectorList) {
00868         double lLaborProductivity = lSector.getLaborProductivity() ;
00869         lSector.setLaborProductivity(lLaborProductivity*(1+lRate));
00870       }
00871     }
00872   }

void production (  ) 

Each firm produces.

See also:
Firm.productionStep

Definition at line 879 of file Foundation.java.

00879                            {
00880     for (final Firm lFirm : generateFirmList()) {
00881       lFirm.productionStep();
00882     }
00883   }

void consumption (  ) 

Each household consumes.

See also:
Household.consume

Definition at line 890 of file Foundation.java.

00890                             {
00891     for (final Household lHousehold : getHouseholds()) {
00892       lHousehold.consume();
00893     }
00894   }

void firmAccounting (  ) 

All firms account.

See also:
Firm.account

Definition at line 901 of file Foundation.java.

00901                                {
00902     for (final Firm lFirm : generateFirmList()) {
00903       lFirm.account();
00904     }
00905   }

void householdsAccounting (  ) 

After the government calculated the actual unemployment insurance, the households receive their income (from different source).

See also:
Government.calcWage

Household.account

Definition at line 914 of file Foundation.java.

00914                                      {
00915     government.calcWage();
00916 
00917     for (final Household lHousehold : getHouseholds()) {
00918       lHousehold.account();
00919     }
00920   }

void importExportAccounting (  ) 

The ImportExport agent account his tradings.

See also:
ImportExport.account

Definition at line 927 of file Foundation.java.

00927                                        {
00928     for (final Sector lSector : getSectorList()) {
00929       lSector.getImportExport().account();
00930     }
00931   }

void firmsPriceUpdating (  ) 

Firm updates its price using a mark-up over costs.

See also:
Firm.updatePrice

Definition at line 938 of file Foundation.java.

00938                                    {
00939     if ((period % initValues.getPriceInterval()) == 0) {
00940       for (final Firm lFirm : generateFirmList()) {
00941         lFirm.updatePrice();
00942       }
00943     }
00944   }

void firmsDesiredProductionUpdating (  ) 

Firm updates its desired production according to the demand it faces.

See also:
Firm.updateDesiredProduction

Definition at line 951 of file Foundation.java.

00951                                                {
00952     for (final Firm lFirm : generateFirmList()) {
00953       lFirm.updateDesiredProduction();
00954     }
00955   } 

void settingInterestRate (  ) 

Call Financial.updateInterestRate() each initValues.getInterestRateInterval() periods.

See also:
Financial.updateInterestRate

Definition at line 962 of file Foundation.java.

00962                                     {
00963     if ((period % initValues.getInterestRateInterval()) == 0) {
00964       financial.updateInterestRate();
00965     }
00966   }

void geneticEvolutionOfTechnologies (  ) 

Firms and Households copy (imitate) and mutate their technologies.

See also:
Sector.firmsCopyTechnologies

Firm.copyTechnologiesFrom

Firm.mutateInputCoefficients

Household.imitate

Household.mutateTechnologies

Definition at line 977 of file Foundation.java.

00977                                                {
00978     if ((period % initValues.getGeneticEvolutionTechnologiesInterval()) == 0) {
00979       // firms copy technologies
00980       for (final Sector lSector : sectorList) {
00981         lSector.firmsCopyTechnologies();
00982       }
00983 
00984       // firms mutate technologies
00985       for (final Firm lFirm : generateFirmList()) {
00986         if (getRandomGenerator().nextFloat() <
00987             initValues.sectorInitValues().firmInitValues().getMutationRate())
00988         {
00989           lFirm.mutateInputCoefficients();
00990         }
00991       }
00992       
00993       assert (getNumHouseholdsTotal() > 0): "there must be one Household in each sector";
00994       // households copy technologies
00995       // We create the list of copying Households   
00996       List<Household> lCopyingHouseholds = ListTools.sample(households.householdList, 
00997                                                           initValues.calcNumHouseholdsCopying(), 
00998                                                           random);
00999     
01000       // Each copying Household observes a sample of lNumObservedHouseholds Households 
01001       for (Household lHousehold : lCopyingHouseholds) {
01002         LinkedList<Household> lObservedHouseholds = 
01003                                         ListTools.sample(households.householdList, 
01004                                                          initValues.calcNumHouseholdsObserved(), 
01005                                                          random);
01006 
01007         // We add the observing household to the list, so that it "imitate" itself, if it has
01008         // already a better policy then the observed households
01009         lObservedHouseholds.add(lHousehold);
01010 
01011         // We sort the lObservedHouseholds according to the efficiency of their pricing policy 
01012         Household.UtilityComparator lUtilityComparator = lHousehold.new UtilityComparator();
01013         Collections.sort(lObservedHouseholds, lUtilityComparator);
01014       
01015         // and copy if one of the Household has a better policy
01016         lHousehold.imitate(lObservedHouseholds.getLast().getConsumptionTechnologyCoefficients());
01017       }
01018 
01019       // households mutate technologies
01020       for (final Household lHousehold : getHouseholds()) {
01021         lHousehold.mutateTechnologies();
01022       }
01023     }
01024   }

void firmsEntryAndExit (  ) 

For each Sector drop unproductive firms and check the creation of new on each FoundationInitValues.firmEntryAndExitInterval periods.

See also:
Sector.dropUnproductiveFirm

Sector.createNextFirmGeneration

Definition at line 1032 of file Foundation.java.

01032                                   {
01033     for (final Sector lSector : sectorList) {
01034       lSector.dropUnproductiveFirms();
01035     }
01036 
01037     if ((period % initValues.getFirmEntryAndExitInterval()) == 0) {
01038       for (final Sector lSector : sectorList) {
01039         lSector.createNextFirmGeneration();
01040       }
01041     }
01042   }

void geneticEvolutionOfPrices (  ) 

Firms copy and mutate their prices.

See also:
Sector.firmCopyPrices

Firm.copyPricesFrom

Firm.mutatePrice

Definition at line 1051 of file Foundation.java.

01051                                          {
01052     if ((period % initValues.getGeneticEvolutionPricesInterval()) == 0) {
01053       // firms copy prices (mark-ups and wage references)
01054       for (final Sector lSector : sectorList) {
01055         lSector.firmsCopyPrices();
01056       }
01057       
01058     // firms mutate prices (mark-ups and wage references)
01059       for (final Firm lFirm : generateFirmList()) {
01060 
01061         if (getRandomGenerator().nextFloat() <
01062             initValues.sectorInitValues().firmInitValues().getMutationRate())
01063         {
01064           lFirm.mutatePrice();
01065         }
01066       }
01067     }
01068   }

void geneticEvolutionOfWages (  ) 

Firms copy and mutate their prices and wages.

See also:
Sector.firmCopyWages

Firm.copyWagesFrom

Firm.mutateWageReference

Definition at line 1077 of file Foundation.java.

01077                                         {
01078     if ((period % initValues.getGeneticEvolutionWagesInterval()) == 0) {
01079       // firms copy prices (mark-ups and wage references)
01080       for (final Sector lSector : sectorList) {
01081         lSector.firmsCopyWages();
01082       }
01083       
01084     // firms mutate prices (mark-ups and wage references)
01085       for (final Firm lFirm : generateFirmList()) {
01086 
01087         if (getRandomGenerator().nextFloat() <
01088             initValues.sectorInitValues().firmInitValues().getMutationRate())
01089         {
01090           lFirm.mutateWageReference();
01091         }
01092       }
01093     }
01094   }

double initialDesiredWage (  )  [package]

Calculate the initial desired wage in the economy.

Definition at line 1097 of file Foundation.java.

01097                               {
01098     double lSum = 0d;
01099     for (final Sector lSector : sectorList) {
01100       lSum += lSector.getInitConsumption();
01101     }
01102     return lSum / getNumHouseholdsTotal();
01103   }

double calcUnemploymentRate (  )  [package]

Calculate the actual unemployment rate.

Definition at line 1108 of file Foundation.java.

01108                                 {
01109     return (1.d - (calcNumHouseholdsEmployed() / getNumHouseholdsTotal()));
01110   }

double calcNumHouseholdsEmployed (  )  [package]

Calculate the sum of the work amounts of all work contracts.

Definition at line 1116 of file Foundation.java.

Referenced by Foundation.calcUnemploymentRate().

01116                                      {
01117     double lSumEmployment = 0.d;
01118 
01119     for (final Household lHousehold : getHouseholds()) {
01120       lSumEmployment += lHousehold.calcWorkAmount();
01121     }
01122 
01123     return lSumEmployment;
01124   }

LinkedList<Firm> generateFirmList (  )  [package]

Generate a list of all Firms.

Definition at line 1127 of file Foundation.java.

Referenced by Household.adjustEmploymentStatus(), Foundation.exchangeStep(), Foundation.firmAccounting(), Foundation.firmsAdjustWorkforce(), Foundation.firmsDesiredProductionUpdating(), Foundation.firmsPriceUpdating(), Foundation.geneticEvolutionOfPrices(), Foundation.geneticEvolutionOfTechnologies(), Foundation.geneticEvolutionOfWages(), Foundation.initTradeNetwork(), Foundation.preparatoryStep(), and Foundation.production().

01127                                       {
01128     final LinkedList<Firm> lFirms = new LinkedList<Firm>();
01129     for (final Sector lSector : sectorList) {
01130       lFirms.addAll(lSector.getFirmList());
01131     }
01132     return lFirms;
01133   }

List<Household.Probe> generateHouseholdProbeList (  ) 

Generate a list of probes of all Households.

Definition at line 1136 of file Foundation.java.

01136                                                             {
01137     final List<Household.Probe> lProbeList = new LinkedList<Household.Probe>();
01138 
01139     for (final Household lHousehold : getHouseholds()) {
01140       lProbeList.add(lHousehold.getProbe());
01141     }
01142 
01143     return lProbeList;
01144   }

List<Sector.Probe> generateSectorProbeList (  ) 

Generate a list of probes of all Sectors.

Definition at line 1147 of file Foundation.java.

01147                                                       {
01148     final List<Sector.Probe> lProbeList = new LinkedList<Sector.Probe>();
01149 
01150     for (final Sector lSector : getSectorList()) {
01151       lProbeList.add(lSector.getProbe());
01152     }
01153 
01154     return lProbeList;
01155   }

List<ImportExport.Probe> generateImportExportProbeList (  ) 

Generate a list of probes of all ImportExport agents.

Definition at line 1158 of file Foundation.java.

01158                                                                   {
01159     final List<ImportExport.Probe> lProbeList = new LinkedList<ImportExport.Probe>();
01160 
01161     for (final Sector lSector : getSectorList()) {
01162       lProbeList.add(lSector.getImportExport().getProbe());
01163     }
01164 
01165     return lProbeList;
01166   }

LinkedList<Firm.Probe> generateFirmProbeList (  ) 

Generate a list of probes of all Firms.

Definition at line 1169 of file Foundation.java.

01169                                                         {
01170     final LinkedList<Firm.Probe> lProbeList = new LinkedList<Firm.Probe>();
01171 
01172     for (final Sector lSector : getSectorList()) {
01173       for (final Firm lFirm : lSector.getFirmList()) {
01174         lProbeList.add(lFirm.getProbe());
01175       }
01176     }
01177 
01178     return lProbeList;
01179   }

double [] generatePriceVector (  )  [package]

Create an array (with the size equals the number of sectors) which contain the actual average trade prices of all sectors.

Returns:
An array with the actual average trade prices.

Definition at line 1190 of file Foundation.java.

01190                                  {
01191     final double[] lPriceVector = new double[getNumSectors()];
01192 
01193     for (final Sector lSector : sectorList) {
01194       lPriceVector[lSector.getArrayIndex()] = lSector.getStats().getAverageTradePrice();
01195     }
01196 
01197     return lPriceVector;
01198   }


Member Data Documentation

final int NUM_INIT_CONSUMPTION_TECHNOLOGY_MUTATIONS = 10 [static, private]

See also:
Foundation.initMutateConsumptionTechnology

Definition at line 340 of file Foundation.java.

Referenced by Foundation.initMutateConsumptionTechnology().

final boolean USE_PROFILER = false [static, private]

The StepManager has an inbuilt profiler, that measure the time user for each step.

Set this field to true to enable this feature.

Definition at line 347 of file Foundation.java.

RandomGenerator random [static, private]

The instance of our random generator, which is part of our toolbox package.

Definition at line 351 of file Foundation.java.

Referenced by Foundation.exchangeStep(), Foundation.firmsAdjustWorkforce(), Foundation.geneticEvolutionOfTechnologies(), Foundation.householdsAdjustEmployment(), and Foundation.initTradeNetwork().

final EmissionProbe emissionProbe = new EmissionProbe() [private]

Statistics about the CO2 emission caused by production and trading.

Definition at line 355 of file Foundation.java.

TradeTrace tradeTrace = new TradeTrace(Foundation.this) [private]

List of all trades in a single period.

Definition at line 360 of file Foundation.java.

ProductionFunctionFactory productionFunctionFactory [static, private]

Initial value:

      new ProductionFunctionFactory()
Factory (Design pattern) for creating the production function of a firm.

Definition at line 365 of file Foundation.java.

ConsumptionTechnologyFactory consumptionTechnologyFactory [static, private]

Initial value:

      new ConsumptionTechnologyFactory()
Factory (Design pattern) for creating the consumption technology of a household.

Definition at line 371 of file Foundation.java.

Government government [private]

The Government.

Definition at line 375 of file Foundation.java.

Referenced by Foundation.householdsAccounting().

Financial financial [private]

The financial system.

Definition at line 378 of file Foundation.java.

final LinkedList<Sector> sectorList = new LinkedList<Sector>() [private]

The list of all Sectors in the Foundation.

The number of Sectors can be set in FoundationInitValues.

Definition at line 384 of file Foundation.java.

FoundationInitValues initValues [static, private]

The initialization values for the Foundation.

Definition at line 387 of file Foundation.java.

Referenced by Foundation.calcDifference(), Foundation.constructSectors(), Foundation.exchangeStep(), Foundation.firmsAdjustWorkforce(), Foundation.firmsEntryAndExit(), Foundation.firmsPriceUpdating(), Foundation.geneticEvolutionOfPrices(), Foundation.geneticEvolutionOfTechnologies(), Foundation.geneticEvolutionOfWages(), Foundation.householdsAdjustEmployment(), Foundation.initHouseholds(), Foundation.initMutateConsumptionTechnology(), Foundation.settingInterestRate(), Foundation.updateBenchmarkWage(), and Foundation.updateLaborProductivity().

int period [private]

A counter that is registering how often the method step() was called.

Definition at line 391 of file Foundation.java.

final HouseholdSet households = new HouseholdSet() [private]

The list contain all households in the foundation.

The households are constructed in Foundation.initHouseholds() and added their to the list.

Definition at line 397 of file Foundation.java.

Referenced by Foundation.exchangeStep(), Foundation.geneticEvolutionOfTechnologies(), Foundation.householdsAdjustEmployment(), Foundation.initHouseholds(), Foundation.initMutateConsumptionTechnology(), and Foundation.initTradeNetwork().


The documentation for this class was generated from the following file:
Generated on Tue Sep 14 11:11:49 2010 for lagom_generiC by  doxygen 1.5.4