Public Member Functions | |
double | invProdFuncLabor (double e,@GreaterOrApproxZero double q) |
The inverse production function for labor. | |
double | getInitFixedCapitalDepreciationRate (int pIndex) |
Calculating the depreciation rate of fixed capital for a given sector using the relation (1+d(sector))*(1+g)=(1+i(sector)) where d and i are sectorwise depreciaiton and investment rate and g is the growth rate of production. | |
double | getInitNumberWorkers () |
The initial capacity utilization rate is then given by the inverse of. | |
Package Functions | |
Sector (Foundation pFoundation, SectorInitValues pSectorInitValues, int pIndex) | |
The Sector constructor. | |
void | init () throws ValueValidationException, ParameterParserException |
Initialize the Sector. | |
void | initMutateInputCoefficients () |
The circulating-/fixed- and laborInput-coefficients are mutated. | |
Firm | addFirmAtSectorInit (double pDesiredProduction) throws ParameterParserException |
Add a new firm to the sector while the model is initialized. | |
void | firmsCopyTechnologies () |
A number of firms with the lowest profit copy the behaviour from the firm with the highest profit. | |
void | firmsCopyPrices () |
A number of randomly selected firms copy the prices from the observed firm with the most efficient price. | |
void | firmsCopyWages () |
A number of randomly selected firms copy the prices from the observed firm with the best price efficient. | |
void | createNextFirmGeneration () |
Remove or add firms depending on the average profit rate of the sector and the individual profit rates of firms. | |
void | dropUnproductiveFirms () |
Remove Firms that don't produce. | |
void | updateLaborProductivity () |
Calculate the actual labor productivity. | |
void | updateBenchmarkWage () |
Update the benchmark wage. | |
double | calcWorkAmount () |
Calculate the sum of the work amounts of all work contracts with firms in this sector. | |
int | getInitNumFirms () |
Get the initial number of firms. | |
double | getInitInputOutputCirculating (int pIndex) |
Get an entry of the initial inputOutputCirculating matrix. | |
double | getInitInputOutputFixed (int pIndex) |
Get an entry of the initial inputOutputFixed matrix. | |
double | getInitProductionElasticity () |
Get the initial elasticity of production. | |
double | getInitCapitalStock (int pIndex) |
Get an entry of the initial inputCapitalStock matrix. | |
double | getInitAggregateCapitalStock () |
get the aggregate capital stock | |
double | getInitCapitalStockShare () |
Get the initial share of total fixed capital value, assuming all good have initial price 1. | |
double | getInitCapacityUtilizationRate () |
The following is done sectorwise. | |
Private Member Functions | |
double | calcDifference (double[] pNeededCirculating, double[] pNeededFixed) |
Calculate the difference between the given capital stock in pNeededCirculating and pNeededFixed with the circulating and fixed capital stock given in the InitValues. | |
Firm | addFirm (int pPhase, double pDesiredProduction) throws ParameterParserException |
Add a new Firm to the Sector. | |
boolean | dropFirm (Firm pFirm) |
Remove a given Firm from the Sector if there are more then SectorInitValues.numFirmMin firms in the sector. | |
Private Attributes | |
final Stats | stats = new Sector.Stats() |
The Sector Statistics . | |
final Sector.Probe | probe = new Sector.Probe() |
The Sector Probe . | |
final LinkedList< Firm > | firmList = new LinkedList<Firm>() |
A list of all Firms that are currently producing in this Sector. | |
final FirmsWithInventory | firmsWithInventory = new FirmsWithInventory() |
A list of Firms in this Sector, that have a non empty inventory. | |
final FirmsWithExtraSupply | firmsWithExtraSupply = new FirmsWithExtraSupply() |
A list of Firms in this Sector, that have extraSupply. | |
final ImportExport | importExport |
The import/export agent. | |
final SectorInitValues | initValues |
The initialization values for the sectors. | |
double | benchmarkWage |
Benchmark wage of this Sector. | |
double | initAggregateFixedCapitalStock |
Aggregate capital stock after firms init. | |
double | laborProductivity |
Labor productivity of this Sector. | |
double | laborProductivityGrowthRate |
Growth rate of the labor productivity of this Sector. | |
final String | name |
A human readable name of the Sector like "renting_service", which can be used as a debugging help or for the result output. | |
final int | arrayIndex |
The position of this sector in the arrays of the SectorInitValues class. | |
int | numFirmsCreatedInSector |
TODOC. | |
Classes | |
class | FirmsWithExtraSupply |
The FirmWithExtraSupply class exist only because of optimization issues. More... | |
class | FirmsWithInventory |
The FirmWithInventory class exist only because of optimization issues. More... | |
class | Probe |
class | Stats |
Some statics values of a single Sector (as a sum of all Firms in the Sector). More... |
The firms (which are producing only a single type of good) and import/export agents are partitioned corresponding to the good they produce or import. The partitions are also called sectors.
Definition at line 51 of file Sector.java.
Sector | ( | Foundation | pFoundation, | |
SectorInitValues | pSectorInitValues, | |||
int | pIndex | |||
) | [package] |
The Sector constructor.
Definition at line 1470 of file Sector.java.
01470 { 01471 foundation = pFoundation; 01472 arrayIndex = pIndex; 01473 01474 initValues = pSectorInitValues; 01475 01476 name = initValues.getNameArray()[pIndex]; 01477 01478 importExport = new ImportExport(pFoundation, pSectorInitValues.importExportInitValues()); 01479 }
void init | ( | ) | throws ValueValidationException, ParameterParserException [package] |
Initialize the Sector.
Definition at line 1491 of file Sector.java.
Referenced by Sector.init().
01491 { 01492 random = Foundation.getRandomGenerator(); 01493 foundation.getProbeManager().addProbe(probe); 01494 01495 laborProductivity = initValues.getLaborProductivityArray()[arrayIndex]; 01496 initAggregateFixedCapitalStock =0; 01497 benchmarkWage = calcInitWage(); 01498 riskPremium= initValues.getRiskPremiumArray()[arrayIndex]; 01499 if (foundation.isInitEquilibrium()){ 01500 setRiskPremium(getBenchmarkMarkUp()-foundation.getFinancial().getInterestRate()); 01501 } 01502 01503 probe.init(); 01504 01505 // generate the Firms 01506 firmList.clear(); 01507 firmsWithInventory.init(foundation.getStepManager()); 01508 firmsWithExtraSupply.init(foundation.getStepManager()); 01509 01510 01511 final int lNumFirms = getInitNumFirms(); 01512 01513 // calculate the desired production for the firms in this sector 01514 double[] lDesiredProductionArray; 01515 if (Foundation.getInitValues().isFirmsHaveSameSize()) { 01516 lDesiredProductionArray = ArrayTools.createArray(lNumFirms, 01517 getInitProduction() / lNumFirms); 01518 } else { 01519 lDesiredProductionArray = ArrayTools.randomArrayWithSum(random, 01520 lNumFirms, 01521 getInitProduction()); 01522 } 01523 01524 // create and add the firms 01525 for (int i = 0; i < lNumFirms; i++) { 01526 addFirmAtSectorInit(lDesiredProductionArray[i]); 01527 } 01528 initMutateInputCoefficients(); 01529 01530 // register the capital stocks. 01531 for(final Firm lFirm : firmList){ 01532 for (int iSector=0; iSector<foundation.getNumSectors();iSector++ ){ 01533 initAggregateFixedCapitalStock +=lFirm.getFixedCapital()[iSector]; 01534 } 01535 } 01536 01537 stats.init(); // must be initialized after firms are added and initialized themselves 01538 importExport.init(this); 01539 01540 validateInitValues(); 01541 }
void initMutateInputCoefficients | ( | ) | [package] |
The circulating-/fixed- and laborInput-coefficients are mutated.
After the mutation the overall production should be the same, but the algorithm can only approximate the original production. So the best approximation of NUM_INIT_INPUT_COEFF_MUTATIONS passes is selected.
Definition at line 1551 of file Sector.java.
Referenced by Sector.init().
01551 { 01552 final int lNumSectors = foundation.getNumSectors(); 01553 01554 final Map<Firm, ProductionFunction.VariatorResults> lPassVariatorResults = 01555 new HashMap<Firm, ProductionFunction.VariatorResults>(); 01556 Map<Firm, ProductionFunction.VariatorResults> lBestVariatorResults = 01557 new HashMap<Firm, ProductionFunction.VariatorResults>(); 01558 01559 final DoubleInterval[] lCircInCoeffMut = new DoubleInterval[lNumSectors]; 01560 final DoubleInterval[] lFixedInCoeffMut = new DoubleInterval[lNumSectors]; 01561 DoubleInterval lLaborInCoeffMut; 01562 01563 double lMinimalDifference = Double.MAX_VALUE; 01564 01565 for (int iPass = 0; iPass < NUM_INIT_INPUT_COEFF_MUTATIONS; iPass++) { 01566 // init mutation intervals for the iPass-th pass 01567 lLaborInCoeffMut = new DoubleInterval(-getInitLaborMutationRange(), 01568 getInitLaborMutationRange()); 01569 01570 for (int iSector = 0; iSector < lNumSectors; iSector++) { 01571 lCircInCoeffMut[iSector] = new DoubleInterval(-getInitCirculatingMutationRange(), 01572 getInitCirculatingMutationRange()); 01573 lFixedInCoeffMut[iSector] = new DoubleInterval(-getInitFixedMutationRange(), 01574 getInitFixedMutationRange()); 01575 } 01576 01577 double lNeededCirculating[] = new double[lNumSectors]; 01578 double lNeededFixed[] = new double[lNumSectors]; 01579 double lSumProduction = 0.d; 01580 01581 for (final Firm lFirm : firmList) { 01582 final ProductionFunction.VariatorResults lVariatorResults = 01583 lFirm.getProductionFunction().mutateCoefficients(lCircInCoeffMut, 01584 lFixedInCoeffMut, 01585 lLaborInCoeffMut, 01586 foundation.getNumSectors()); 01587 01588 lPassVariatorResults.put(lFirm, lVariatorResults); 01589 01590 lNeededCirculating = ArrayTools.addArrays(lNeededCirculating, 01591 lFirm.invProdFuncCirculating(lFirm.getDesiredProduction(), 01592 lVariatorResults.circulatingInputCoefficientsVariation)); 01593 lNeededFixed = ArrayTools.addArrays(lNeededFixed, 01594 lFirm.invProdFuncFixed(lFirm.getDesiredProduction(), 01595 lVariatorResults.fixedInputCoefficientsVariation)); 01596 lSumProduction += lFirm.getDesiredProduction(); 01597 01598 for (int iSector = 0; iSector < lNumSectors; iSector++) { 01599 if (lNeededCirculating[iSector] < getInitInputOutputCirculating(iSector) * 01600 lSumProduction / getInitProduction()) { 01601 lCircInCoeffMut[iSector].set(0.d, 01602 initValues.getInitialCirculatingInputCoeffMutation()); 01603 } else { 01604 lCircInCoeffMut[iSector].set(-initValues.getInitialCirculatingInputCoeffMutation(), 01605 0.d); 01606 } 01607 01608 if (lNeededFixed[iSector] < 01609 getInitCapitalStock(iSector) * lSumProduction / getInitProduction()) { 01610 lFixedInCoeffMut[iSector].set(0.d, initValues.getInitialFixedInputCoeffMutation()); 01611 } else { 01612 lFixedInCoeffMut[iSector].set(-initValues.getInitialFixedInputCoeffMutation(), 0.d); 01613 } 01614 } 01615 } 01616 01617 if (lMinimalDifference > calcDifference(lNeededCirculating, lNeededFixed)) { 01618 lBestVariatorResults = 01619 new HashMap<Firm, ProductionFunction.VariatorResults>(lPassVariatorResults); 01620 lMinimalDifference = calcDifference(lNeededCirculating, lNeededFixed); 01621 } 01622 } 01623 01624 for (final Firm lFirm : lBestVariatorResults.keySet()) { 01625 final ProductionFunction.VariatorResults lResults = lBestVariatorResults.get(lFirm); 01626 lFirm.setCirculatingInputCoefficients(lResults.circulatingInputCoefficientsVariation); 01627 lFirm.setFixedInputCoefficients(lResults.fixedInputCoefficientsVariation); 01628 lFirm.setLaborInputCoefficient(lResults.laborInputCoefficientVariation); 01629 lFirm.setInitialCirculatingInputCoefficients( 01630 ArrayTools.deepCopy(lResults.circulatingInputCoefficientsVariation)); 01631 lFirm.setInitialFixedInputCoefficients( 01632 ArrayTools.deepCopy(lResults.fixedInputCoefficientsVariation)); 01633 lFirm.setInitialLaborInputCoefficient(lResults.laborInputCoefficientVariation); 01634 01635 double lUnitCost =0.0; 01636 lUnitCost +=lFirm.getLaborInputCoefficient()*calcInitWage(); 01637 for (final Sector lSector : foundation.getSectorList()) { 01638 final int lSectorIndex = lSector.getArrayIndex(); 01639 lUnitCost += lFirm.getCirculatingInputCoefficients()[lSectorIndex]; 01640 lUnitCost += lFirm.getFixedInputCoefficients()[lSectorIndex] * 01641 getInitFixedCapitalDepreciationRate(lSectorIndex); 01642 } 01643 assert (1/lUnitCost-1 >0): "the initial mark-up is negative"; 01644 lFirm.setMarkUp(1/lUnitCost-1); 01645 lFirm.setPrice(lUnitCost*(1+lFirm.getMarkUp())); 01646 assert (lFirm.getPrice()>0); 01647 } 01648 }
double calcDifference | ( | double[] | pNeededCirculating, | |
double[] | pNeededFixed | |||
) | [private] |
Calculate the difference between the given capital stock in pNeededCirculating and pNeededFixed with the circulating and fixed capital stock given in the InitValues.
Definition at line 1654 of file Sector.java.
Referenced by Sector.initMutateInputCoefficients().
01654 { 01655 double lDifference = 0.d; 01656 01657 for (int iSector = 0; iSector < foundation.getNumSectors(); iSector++) { 01658 lDifference += Math.abs(pNeededCirculating[iSector] - getInitInputOutputCirculating(iSector)); 01659 lDifference += Math.abs(pNeededFixed[iSector] - getInitCapitalStock(iSector)); 01660 } 01661 01662 return lDifference; 01663 }
Firm addFirmAtSectorInit | ( | double | pDesiredProduction | ) | throws ParameterParserException [package] |
Add a new firm to the sector while the model is initialized.
T
pDesiredProduction | The initial desired production of the firm. |
ParameterParserException |
Definition at line 1693 of file Sector.java.
Referenced by Sector.init().
01693 { 01694 return addFirm(Firm.ADDED_WHILE_INITIALIZE, pDesiredProduction); 01695 }
void firmsCopyTechnologies | ( | ) | [package] |
A number of firms with the lowest profit copy the behaviour from the firm with the highest profit.
Definition at line 1699 of file Sector.java.
01699 { 01700 // The number of copying Firms and the size of the sample of observations are computed 01701 long lNumCopyFirms = Math.round(getNumFirms() * initValues.getFirmReplacementRate()); 01702 if ((lNumCopyFirms == 0) && (getNumFirms() > 1)) { 01703 lNumCopyFirms = 1; 01704 } 01705 long lNumObservedFirms = Math.round(getNumFirms() * initValues.getFirmSamplingRate()); 01706 if ((lNumObservedFirms == 0) && (getNumFirms() > 1)) { 01707 lNumObservedFirms = 1; 01708 } 01709 01710 assert (lNumObservedFirms <= getNumFirms()): "firmObservationRate is too high"; 01711 assert (lNumCopyFirms <= getNumFirms()): "firmReplacementRate is too high"; 01712 assert (getNumFirms() > 0): "there must be one firm in each sector"; 01713 01714 // We create the list of copying firms 01715 List<Firm> lCopyingFirms = ListTools.sample(firmList, lNumCopyFirms, random); 01716 01717 // Each copying firm observes a sample of firms 01718 final Iterator<Firm> iterFirms = lCopyingFirms.iterator(); 01719 for (int iFirm = 0; iFirm < lNumCopyFirms; iFirm++) { 01720 final Firm lFirm = iterFirms.next(); // we don't need to check hasNext 01721 LinkedList<Firm> lObservedFirms = ListTools.sample(firmList, lNumObservedFirms, random); 01722 lObservedFirms.add(lFirm); 01723 // We sort the lObservedFirms according to the unit cost of their technology 01724 Collections.sort(lObservedFirms, new Firm.CostEfficiencyComparator()); 01725 // and copy if one of the firm has a better technology 01726 lFirm.copyTechnologiesFrom(lObservedFirms.getLast()); 01727 } 01728 }
void firmsCopyPrices | ( | ) | [package] |
A number of randomly selected firms copy the prices from the observed firm with the most efficient price.
Definition at line 1736 of file Sector.java.
01736 { 01737 // The number of copying Firms and the size of the sample of observations are computed 01738 long lNumCopyFirms = Math.round(getNumFirms() * initValues.getFirmReplacementRate()); 01739 if ((lNumCopyFirms == 0) && (getNumFirms() > 1)) { 01740 lNumCopyFirms = 1; 01741 } 01742 long lNumObservedFirms = Math.round(getNumFirms() * initValues.getFirmSamplingRate()); 01743 if ((lNumObservedFirms == 0) && (getNumFirms() > 1)) { 01744 lNumObservedFirms = 1; 01745 } 01746 01747 assert (lNumObservedFirms <= getNumFirms()): "firmObservationRate is too high"; 01748 assert (lNumCopyFirms <= getNumFirms()): "firmReplacementRate is too high"; 01749 assert (getNumFirms() > 0): "there must be one firm in each sector"; 01750 01751 // We create the list of copying firms 01752 List<Firm> lCopyingFirms = ListTools.sample(firmList, lNumCopyFirms, random); 01753 01754 // Each copying firm observes a sample of firms 01755 final Iterator<Firm> iterFirms = lCopyingFirms.iterator(); 01756 int lPeriods =foundation.getInitValues().getFirmEntryAndExitInterval(); 01757 for (int iFirm = 0; iFirm < lNumCopyFirms; iFirm++) { 01758 final Firm lFirm = iterFirms.next(); // we don't need to check hasNext 01759 LinkedList<Firm> lObservedFirms = ListTools.sample(firmList, lNumObservedFirms, random); 01760 01761 lObservedFirms.add(lFirm); 01762 // We sort the lObservedFirms according to the efficiency of their pricing policy 01763 // Collections.sort(lObservedFirms, new Firm.PricingEfficiencyComparator()); 01764 Collections.sort(lObservedFirms, new Firm.PricingEfficiencyComparator()); 01765 01766 /* final int lMemory= foundation.getInitValues().getFirmEntryAndExitInterval(); 01767 Collections.sort(lObservedFirms, new Firm.ProfitRateComparator(1));*/ 01768 // and copy if one of the firm has a better policy 01769 lFirm.copyPricesFrom(lObservedFirms.getLast()); 01770 } 01771 }
void firmsCopyWages | ( | ) | [package] |
A number of randomly selected firms copy the prices from the observed firm with the best price efficient.
In the same manner also wages are observed and copied.
Firm.RecruitmentEfficiencyComparator
Definition at line 1780 of file Sector.java.
01780 { 01781 // The number of copying Firms and the size of the sample of observations are computed 01782 long lNumCopyFirms = Math.round(getNumFirms() * initValues.getFirmReplacementRate()); 01783 if ((lNumCopyFirms == 0) && (getNumFirms() > 1)) { 01784 lNumCopyFirms = 1; 01785 } 01786 long lNumObservedFirms = Math.round(getNumFirms() * initValues.getFirmSamplingRate()); 01787 if ((lNumObservedFirms == 0) && (getNumFirms() > 1)) { 01788 lNumObservedFirms = 1; 01789 } 01790 01791 assert (lNumObservedFirms <= getNumFirms()): "firmObservationRate is too high"; 01792 assert (lNumCopyFirms <= getNumFirms()): "firmReplacementRate is too high"; 01793 assert (getNumFirms() > 0): "there must be one firm in each sector"; 01794 01795 01796 // Same operations are executed on a new set of firms for the wageReference 01797 // We create the list of copying firms 01798 LinkedList<Firm> lCopyingFirmsBis = ListTools.sample(firmList, lNumCopyFirms, random); 01799 01800 // Each copying firm observes a sample of firms 01801 final Iterator<Firm> iterFirmsBis = lCopyingFirmsBis.iterator(); 01802 for (int iFirm = 0; iFirm < lNumCopyFirms; iFirm++) { 01803 final Firm lFirm = iterFirmsBis.next(); // we don't need to check hasNext 01804 LinkedList<Firm> lObservedFirms = ListTools.sample(firmList, lNumObservedFirms, random); 01805 01806 lObservedFirms.add(lFirm); 01807 // We sort the lObservedFirms according to the efficiency of their wage policy 01808 Collections.sort(lObservedFirms, new Firm.RecruitmentEfficiencyComparator()); 01809 // and copy if one of the firm has a better policy 01810 lFirm.copyWagesFrom(lObservedFirms.getLast()); 01811 } 01812 }
void createNextFirmGeneration | ( | ) | [package] |
Remove or add firms depending on the average profit rate of the sector and the individual profit rates of firms.
Definition at line 1822 of file Sector.java.
01822 { 01823 final long lNumFirms = getNumFirms() ; 01824 final double lProfRate = stats.getAverageOverPeriodsProfitRate(); 01825 final double lInterestRate = foundation.getFinancial().getInterestRate(); 01826 int lPeriods =foundation.getInitValues().getFirmEntryAndExitInterval(); 01827 if (lProfRate < lInterestRate+riskPremium) { 01828 // When the average profit rate is below the interest rate, given the mark-up behavior 01829 // one can assume that there is over production. The less profitable firms are deleted. 01830 final double lLastSold = 01831 foundation.getTradeTrace().getOverallQuantitySelledInSector(Sector.this); 01832 double lProductionTarget = stats.getOverallProduction(); 01833 double lMaxNumDestructed = Math.floor(lNumFirms*initValues.getFirmDestructionRate()); 01834 int lDestructed = 0; 01835 while (lProductionTarget > lLastSold && lDestructed++ <= lMaxNumDestructed){ 01836 // We sort the firmList from lowest to highest profit rate... 01837 Collections.sort(firmList, new Firm.ProfitRateComparator(lPeriods)); 01838 // ... aso that the Firm with the lowest profit is the first one 01839 lProductionTarget -= firmList.getFirst().getProducedQuantity(); 01840 dropFirm(firmList.getFirst()); 01841 } 01842 } else if (lNumFirms<MAX_FIRMS_PER_SECTOR && lProfRate> lInterestRate +riskPremium) { 01843 01844 // Firms are created proportionally to the difference between profit and interest rates. 01845 final double lCreationRate =Math.min(initValues.getFirmCreationRate(), 01846 lProfRate - lInterestRate); 01847 final long lNumFirmsToCreate = (long) Math.min(MAX_FIRMS_PER_SECTOR-1-lNumFirms, 01848 Math.ceil(lNumFirms*lCreationRate)); 01849 01850 for (int iFirm = 0; iFirm < lNumFirmsToCreate; iFirm++) { 01851 try { 01852 addFirm(Firm.ADDED_WHILE_RUNNING, 01853 Math.min(stats.getAverageDesiredProduction(), 01854 lCreationRate * stats.getAverageOverPeriodsProduction())); 01855 } catch (final ParameterParserException e) { 01856 e.printStackTrace(); 01857 } 01858 } 01859 01860 assert (getNumFirms() > 0): "there must be one firm in each sector"; 01861 } 01862 01863 // In every case, firms whose profit Rate is less than the interest Rate are bankrupted, 01864 // have their debt cancelled and start anew with optimal characteristics 01865 01866 01867 for (final Firm lFirm : firmList) { 01868 if (lFirm.getProfitRate() <= foundation.getFinancial().getInterestRate() && 01869 lFirm.getPeriodCreated() < foundation.getPeriod()) { 01870 lFirm.bankrupt(); 01871 setBehavioralCharacteristics(lFirm); 01872 final Household lHousehold = foundation.getHouseholds().getRandomHousehold(); 01873 lHousehold.addFirmToProperty(lFirm); 01874 } 01875 } 01876 }
Firm addFirm | ( | int | pPhase, | |
double | pDesiredProduction | |||
) | throws ParameterParserException [private] |
After the initialization of the Firm, it attempts to hire as much Workers as it's targetEmployment parameter. Also a random household is selected as the new owner of this firm.
pPhase | If the firm is added in the initialize phase, this must be ADDED_WHILE_INITIALZE, else ADDED_WHILE_RUNNING | |
pDesiredProduction | The initial desired production of the firm. |
ParameterParserException |
Definition at line 1895 of file Sector.java.
Referenced by Sector.addFirmAtSectorInit(), and Sector.createNextFirmGeneration().
01895 { 01896 final Firm lFirm = new Firm(foundation, initValues.firmInitValues(), this, 01897 numFirmsCreatedInSector++); 01898 01899 firmList.add(lFirm); 01900 assert(firmList.size() < MAX_FIRMS_PER_SECTOR); 01901 01902 // determine the ID of the firm 01903 final int lID = numFirmsCreatedInSector * foundation.getNumSectors() + arrayIndex; 01904 lFirm.init(lID, pPhase, pDesiredProduction); 01905 01906 // determine a random household which owns the firm 01907 if (pPhase == Firm.ADDED_WHILE_INITIALIZE) { 01908 final Household lHousehold = foundation.getHouseholds().getRandomHousehold(); 01909 lHousehold.addFirmToProperty(lFirm); 01910 } else { 01911 // find owner 01912 final LinkedList<Household> lHouseholdList = 01913 foundation.getHouseholds().getCopyAsLinkedList(); 01914 Collections.sort(lHouseholdList, new Household.SavingsComparator()); 01915 final Household lHousehold = lHouseholdList.getLast(); 01916 lHousehold.addFirmToProperty(lFirm); 01917 setBehavioralCharacteristics(lFirm); 01918 01919 01920 lFirm.setDebt(0); 01921 lFirm.setWage(lFirm.getWageReference() *getBenchmarkWage()); 01922 lFirm.setPrice(Math.min((1+lFirm.getMarkUp())*lFirm.getUnitCost(),stats.getAverageSupplyPriceWithoutImport())); 01923 lFirm.setInventory(0); 01924 // initialize the capital stocks 01925 for (int iSector=0 ;iSector<foundation.getNumSectors();iSector++) { 01926 lFirm.setFixedCapital(iSector,0); 01927 lFirm.setCirculatingCapital(iSector,0); 01928 lFirm.setIsInvest(iSector,true); 01929 } 01930 01931 lHousehold.transferSavingsToFirmAndSetProduction(lFirm); 01932 assert lFirm.getWageReference()>0; 01933 } 01934 lFirm.adjustEmployees(); 01935 01936 return lFirm; 01937 }
void dropUnproductiveFirms | ( | ) | [package] |
Remove Firms that don't produce.
Definition at line 1944 of file Sector.java.
01944 { 01945 final LinkedList<Firm> lListOfFirmsToDelete = new LinkedList<Firm>(); 01946 01947 for (final Firm lFirm : firmList) { 01948 if (lFirm.isUnproductive()){ 01949 assert(FloatMath.approxZero(lFirm.getProducedQuantity())); 01950 lListOfFirmsToDelete.add(lFirm); 01951 } 01952 } 01953 01954 for (final Firm lFirm : lListOfFirmsToDelete) { 01955 dropFirm(lFirm); 01956 } 01957 }
boolean dropFirm | ( | Firm | pFirm | ) | [private] |
Remove a given Firm from the Sector if there are more then SectorInitValues.numFirmMin firms in the sector.
pFirm | The Firm that should be removed |
Definition at line 1967 of file Sector.java.
Referenced by Sector.createNextFirmGeneration(), and Sector.dropUnproductiveFirms().
01967 { 01968 if (firmList.size() <= initValues.getNumFirmMin()) { 01969 return false; 01970 } 01971 01972 if (pFirm.calcWorkAmount() > 0) { 01973 pFirm.layoffWorkers(pFirm.calcWorkAmount()); 01974 } 01975 pFirm.bankrupt(); 01976 firmList.remove(pFirm); 01977 pFirm.deInit(); 01978 return true; 01979 }
double invProdFuncLabor | ( | double | e, | |
@GreaterOrApproxZero double | q | |||
) |
The inverse production function for labor.
The function must be linear (using q as free variable) or Firm.calcMaxProduction and Firm.calcNewTargetEmployment must be changed.
See also the mathematical description.
e | The demanded effort | |
q | The quantity that the firm want's to produce |
Definition at line 2020 of file Sector.java.
02021 { 02022 final double nWorkers= getInitNumberWorkers(); 02023 02024 return q *nWorkers / (getInitProduction()*getLaborProductivity() * e); 02025 }
void updateLaborProductivity | ( | ) | [package] |
Calculate the actual labor productivity.
Definition at line 2028 of file Sector.java.
02028 { 02029 02030 double lOldLaborProductivity =laborProductivity; 02031 02032 if (getInitAggregateCapitalStock()> 0) { 02033 laborProductivity= Math.max(laborProductivity, 02034 (stats.getAggregateFixedCapital()/getInitAggregateFixedCapitalStock())); 02035 } 02036 02037 laborProductivityGrowthRate = laborProductivity/lOldLaborProductivity -1; 02038 }
void updateBenchmarkWage | ( | ) | [package] |
Update the benchmark wage.
Definition at line 2062 of file Sector.java.
02062 { 02063 benchmarkWage *= stats.getTotalGrowthFactorLaborProductivity(); 02064 if (foundation.isWagesIndexed()){ 02065 benchmarkWage *=(1+Math.max(0,foundation.getFinancial().getInflationRate())); 02066 } 02067 }
double calcWorkAmount | ( | ) | [package] |
Calculate the sum of the work amounts of all work contracts with firms in this sector.
Definition at line 2076 of file Sector.java.
02076 { 02077 double lSumWorkAmount = 0; 02078 for (final Firm lFirm : firmList) { 02079 lSumWorkAmount += lFirm.calcWorkAmount(); 02080 } 02081 return lSumWorkAmount; 02082 }
int getInitNumFirms | ( | ) | [package] |
Get the initial number of firms.
Definition at line 2096 of file Sector.java.
Referenced by Sector.init().
02096 { 02097 if (Foundation.getInitValues().isSectorsHaveSameNumberOfFirms()) { 02098 return Foundation.getInitValues().getNumFirms() / foundation.getNumSectors(); 02099 } else { 02100 return (int) Math.round(Math.max(initValues.getNumFirmMin(), 02101 Foundation.getInitValues().getNumFirms() * 02102 getInitProduction() / 02103 foundation.getInitOverallProduction())); 02104 } 02105 }
double getInitInputOutputCirculating | ( | int | pIndex | ) | [package] |
Get an entry of the initial inputOutputCirculating matrix.
pIndex | The column of the accessed matrix |
Definition at line 2187 of file Sector.java.
Referenced by Sector.calcDifference(), Firm.initArraysAndMatrices(), and Sector.initMutateInputCoefficients().
02187 { 02188 return initValues.getInputOutputCirculatingMatrix()[pIndex][arrayIndex]; 02189 }
double getInitInputOutputFixed | ( | int | pIndex | ) | [package] |
Get an entry of the initial inputOutputFixed matrix.
pIndex | The column of the accessed matrix |
Definition at line 2197 of file Sector.java.
02197 { 02198 return initValues.getInputOutputFixedMatrix()[pIndex][arrayIndex]; 02199 }
double getInitProductionElasticity | ( | ) | [package] |
Get the initial elasticity of production.
Definition at line 2208 of file Sector.java.
02208 { 02209 return initValues.getProductionElasticity(); 02210 }
double getInitCapitalStock | ( | int | pIndex | ) | [package] |
Get an entry of the initial inputCapitalStock matrix.
Before this method is called, the caller must ensure, that the good produced by the Sector pSector is needed as fixed capital. This restriction is made, because a useful return value for the not needed case is depending on the context of the caller.
pIndex | The column of the accessed matrix |
Definition at line 2222 of file Sector.java.
Referenced by Sector.calcDifference(), Sector.getInitFixedCapitalDepreciationRate(), Firm.initArraysAndMatrices(), and Sector.initMutateInputCoefficients().
02222 { 02223 return initValues.getCapitalStockMatrix()[pIndex][arrayIndex]; 02224 }
double getInitAggregateCapitalStock | ( | ) | [package] |
get the aggregate capital stock
Definition at line 2230 of file Sector.java.
Referenced by Sector.updateLaborProductivity().
02230 { 02231 double lSum=0; 02232 for (int iSector=0; iSector < foundation.getNumSectors(); iSector++){ 02233 lSum+= initValues.getCapitalStockMatrix()[iSector][arrayIndex]; 02234 } 02235 return lSum; 02236 }
double getInitCapitalStockShare | ( | ) | [package] |
Get the initial share of total fixed capital value, assuming all good have initial price 1.
pIndex | The column of the accessed matrix |
Definition at line 2245 of file Sector.java.
Referenced by Firm.init().
02245 { 02246 double lTotalValueFixedCapital=0; 02247 double lSectorValueFixedCapital=0; 02248 for(int iSector=0; iSector <foundation.getNumSectors();iSector++){ 02249 lSectorValueFixedCapital+=initValues.getCapitalStockMatrix()[iSector][arrayIndex]; 02250 for(int jSector=0; jSector <foundation.getNumSectors();jSector++){ 02251 lTotalValueFixedCapital+=initValues.getCapitalStockMatrix()[iSector][jSector]; 02252 } 02253 } 02254 if(lTotalValueFixedCapital>0){ 02255 return lSectorValueFixedCapital/lTotalValueFixedCapital; 02256 } 02257 else{ 02258 return (1/foundation.getNumSectors()); 02259 } 02260 }
double getInitFixedCapitalDepreciationRate | ( | int | pIndex | ) |
Calculating the depreciation rate of fixed capital for a given sector using the relation (1+d(sector))*(1+g)=(1+i(sector)) where d and i are sectorwise depreciaiton and investment rate and g is the growth rate of production.
See also the mathematical description.
pIndex | The column of the accessed matrix. This is the sector, in which a firm is producing, because the row of the matrix (specified by the instance of the Sector object) define the good that is depreciating and the column define the produced good. |
Definition at line 2277 of file Sector.java.
Referenced by Firm.calcUnitProductionCost(), Firm.initArraysAndMatrices(), Sector.initMutateInputCoefficients(), and Firm.productionStep().
02277 { 02278 // todo: optimize (is a constant value) 02279 if (getInitCapitalStock(pIndex) > 0) { 02280 double lInv= getInitGrossInvestmentRate(pIndex); 02281 double lGrowth=getInitGrowthRate(); 02282 assert (lInv>=lGrowth); 02283 02284 return (lInv-lGrowth)/(1+lGrowth); 02285 } else { 02286 return 1; 02287 } 02288 }
double getInitCapacityUtilizationRate | ( | ) | [package] |
The following is done sectorwise.
If a firm has an initial capacity utilization rate c, assuming constant growth rate g (of sales in particular) and depreciation rate d, it will invest (when its capacity utilization rate reaches 1/(1+2g),see update desired production) after j periods where j is such that: c*((1+g)/(1-d))^(j-1) <1/(1+2g)<c*((1+g)/(1-d))^j
That is approximately
j = (ln c + ln (1+2g)) / (ln(1-d)-ln(1+g))
Now, a firm which has initial capacity utilization rate 1/(1+2g) will invest in the first period so as to reach capacity utilization rate 1/(1+r), where r is the capital reserve rate. Hence its next period of investment (as a function of r) is J(r) such that
J(r) = (ln(1/(1+r))+ln(1+2g))/(ln(1-d)-ln(1+g)) J(r)= (ln(1+r)-ln(1+2g))/(ln(1+g)-ln(1-d))
On the other hand, if k is the amount of fixed capital held by firms investing in period 1, and k the total stock of fixed capital, we must have with i the gross investment rate
k*((1+2g)(1+r)-1)= k*(2gr+2g+r) = i K (1)
Or
k = iK/(2gr +2g+r)
In a similar manner, The initial fixed capital of firms investing in period j+1, k_j, must satisfy
(1-d)^j *k_j*((1+2g)(1+r)-1)=(1-d)^j*(2gr+2g+r)*k_j =(1+g)^j *i *K
And hence (2gr+2g+r)*k_j = ((1+g)/(1-d))^j*i*K
k_j = ((1+g)/(1-d))^j * iK/(2gr +2g+r) = ((1+g)/(1-d))^j *k
Therefore the initial capacity utilization rate of firms investing in period j, must be
((1-d)/(1+g))^j *1/(1+2g)
So as to have an average capacity utilization rate of a, one must ensure that the 1/J(R) times the sum from 0 to J(r) of the capacities equal a, that is:
1/1+2g * (1-(1-d/1+g)^(J(r)) / 1-(1-d/1+g))*(1/J(r)) = a
Which yields
a (1+2g)= (1- (1+2g)/(1+r) / 1-(1-d)/(1+g)) *(1/J(r))
a(1+2g) = (r -2g)(1+g) / (J(r)(1+r)*(g+d))
a(1+2g)(g+d)(1+r)J(r) =(r-2g)(1+g)
a(1+2g)(g+d)(1+r)J(r) -r(1+g) -2g(1+g)=0
The method getInvestmentPeriodicity (int lSectorIndex) computes J(r), the method getCapitalReserveRate(int lSectorIndex) solves the equation by dichotomy which allows us to deduce the capital reserve rate
Definition at line 2387 of file Sector.java.
02387 { 02388 02389 return initValues.getCapacityUtilizationRate(); 02390 }
double getInitNumberWorkers | ( | ) |
The initial capacity utilization rate is then given by the inverse of.
1/J(r) sum_{j=0}{J(r)-1} 1/(1+2g)*(1+g)^j/(1-d)^j which gives after summation
lSectorIndex,: | the sector of the capital for which the initial capacity utilization rate |
Definition at line 2516 of file Sector.java.
Referenced by Sector.invProdFuncLabor().
02516 { 02517 final double lUnemploymentRate = Foundation.getInitValues().governmentInitValues(). 02518 getInitUnemploymentRate(); 02519 02520 final double lRealWorldWorkersRatioInSector = 02521 initValues.getCalibrationNumWorkersArray()[arrayIndex] 02522 / ArrayTools.sumDouble(initValues.getCalibrationNumWorkersArray()); 02523 final double lModelWorkersInSector = (1 - lUnemploymentRate)* foundation.getNumHouseholdsTotal() 02524 * lRealWorldWorkersRatioInSector; 02525 02526 return lModelWorkersInSector; 02527 02528 }
The Sector Statistics .
Definition at line 1409 of file Sector.java.
Referenced by Sector.addFirm(), Sector.createNextFirmGeneration(), Sector.init(), Sector.updateBenchmarkWage(), and Sector.updateLaborProductivity().
final Sector.Probe probe = new Sector.Probe() [private] |
A list of all Firms that are currently producing in this Sector.
Definition at line 1413 of file Sector.java.
Referenced by Sector.addFirm(), Sector.Stats.calcCirculatingCapitalStock(), Sector.Stats.calcDesiredProduction(), Sector.Stats.calcFixedCapitalStock(), Sector.Stats.calcPrices(), Sector.calcWorkAmount(), Sector.createNextFirmGeneration(), Sector.dropFirm(), Sector.dropUnproductiveFirms(), Sector.firmsCopyPrices(), Sector.firmsCopyTechnologies(), Sector.firmsCopyWages(), Sector.init(), Sector.initMutateInputCoefficients(), and Sector.Stats.registerCallbacks().
final FirmsWithInventory firmsWithInventory = new FirmsWithInventory() [private] |
A list of Firms in this Sector, that have a non empty inventory.
Definition at line 1415 of file Sector.java.
Referenced by Sector.init().
final FirmsWithExtraSupply firmsWithExtraSupply = new FirmsWithExtraSupply() [private] |
A list of Firms in this Sector, that have extraSupply.
Definition at line 1417 of file Sector.java.
Referenced by Sector.init().
final ImportExport importExport [private] |
The import/export agent.
Definition at line 1419 of file Sector.java.
Referenced by Sector.init(), and Sector.Sector().
final SectorInitValues initValues [private] |
The initialization values for the sectors.
Definition at line 1421 of file Sector.java.
Referenced by Sector.addFirm(), Sector.createNextFirmGeneration(), Sector.dropFirm(), Sector.firmsCopyPrices(), Sector.firmsCopyTechnologies(), Sector.firmsCopyWages(), Sector.getInitAggregateCapitalStock(), Sector.getInitCapacityUtilizationRate(), Sector.getInitCapitalStock(), Sector.getInitCapitalStockShare(), Sector.getInitInputOutputCirculating(), Sector.getInitInputOutputFixed(), Sector.getInitNumberWorkers(), Sector.getInitNumFirms(), Sector.getInitProductionElasticity(), Sector.init(), Sector.initMutateInputCoefficients(), and Sector.Sector().
double benchmarkWage [private] |
Benchmark wage of this Sector.
The benchmark wage has the same growth rate as the labor productivity.
Definition at line 1430 of file Sector.java.
Referenced by Sector.init(), and Sector.updateBenchmarkWage().
double initAggregateFixedCapitalStock [private] |
Aggregate capital stock after firms init.
Definition at line 1441 of file Sector.java.
Referenced by Sector.init().
double laborProductivity [private] |
Labor productivity of this Sector.
Definition at line 1447 of file Sector.java.
Referenced by Sector.init(), and Sector.updateLaborProductivity().
double laborProductivityGrowthRate [private] |
Growth rate of the labor productivity of this Sector.
Definition at line 1453 of file Sector.java.
Referenced by Sector.Stats.registerCallbacks(), and Sector.updateLaborProductivity().
final String name [private] |
A human readable name of the Sector like "renting_service", which can be used as a debugging help or for the result output.
Definition at line 1459 of file Sector.java.
final int arrayIndex [private] |
The position of this sector in the arrays of the SectorInitValues class.
Definition at line 1462 of file Sector.java.
Referenced by Sector.addFirm(), Sector.getInitAggregateCapitalStock(), Sector.getInitCapitalStock(), Sector.getInitCapitalStockShare(), Sector.getInitInputOutputCirculating(), Sector.getInitInputOutputFixed(), Sector.getInitNumberWorkers(), and Sector.init().
int numFirmsCreatedInSector [private] |