Public Member Functions | |
void | trade () |
Implementation of the exchange step for the firm. | |
boolean | isNeededCirculatingCapital (int pIndex) |
Check the the good produced by the Sector pSector is needed as circulating capital. | |
boolean | isNeededFixedCapital (int pIndex) |
Check the the good produced by the Sector pSector is needed as fixed capital. | |
void | sell (@GreaterOrApproxZero double pTraded) |
The Firm sells some units of the produced good. | |
void | bankrupt () |
The available money is used to reimburse part of the debt or goes to the owner. | |
boolean | isUnproductive () |
Check whether the firm is unproductive. | |
double | getInventory () |
The actual inventory of the agent. | |
double | getBAUSupply () |
A firm supplies to its regular consumers not more than what it can at most produce next period, in order to be able to maintain its target inventory, see Firm.updateDesiredProduction(). | |
double | getExtraSupply () |
A firm supplies to new consumers not more than the margin by which it can increase its production next period, in order to be able to maintain its target inventory and the supply to its regular consumers, see Firm.updateDesiredProduction(). | |
double | getPrice () |
The price for which the agent is willing to sell one unit of good. | |
Sector | getProductionSector () |
The Sector in which the agent produces. | |
Protected Attributes | |
Map< Household, WorkContract > | workerList |
The list of the Households that are on the payroll of this firm including their WorkContract. | |
Package Functions | |
Firm (Foundation pFoundation, FirmInitValues pInitValues, Sector pSector, int pIndexFirmInSector) | |
The Constructor for the Firm agent. | |
void | init (int pId, int pPhase, double pDesiredProduction) throws ParameterParserException |
Initialize the Firm. | |
double[] | getDemandCirculating (double pProduction) |
Calculate the demand of circulating capital. | |
double[] | getDemandFixed (double pProduction) |
Calculate the demand of fixed capital. | |
void | storeInventoryAfterTrade () |
Store the state of the Inventory. | |
void | adjustEmployees () |
The firm first calculate the actual demand of workers and then tries to match the number of employed workers to his demand. | |
double | calcWorkAmount () |
Calculate the sum of the work amounts of all work contracts of this firm. | |
void | productionStep () |
Produce, consume the circulating capital, depreciate the fixed capital stock and the product stock. | |
double[] | invProdFuncCirculating (double pQuantity, double[] pCirculatingInputCoefficients) |
The inverse production function for circulation capital. | |
double[] | invProdFuncFixed (double pQuantity, double[] pFixedInputCoefficients) |
The inverse production function for fixed capital. | |
double[] | invProdFuncFixed (double pQuantity) |
Calculate the inverse production function using the fixed input coefficients of the firm itself. | |
double | prodFuncLabor (double pQuantity) |
The production function for labor. | |
double | invProdFuncLabor (double pQuantity) |
The inverse production function for labor. | |
void | account () |
Pay wages, update the debt (or the savings), reinitialize the money holdings, compute the net profit and distribute a dividend if the net wealth is positive. | |
void | updateDesiredProduction () |
Update the desired production. | |
void | updatePrice () |
Update the price. | |
double | hireWorkers (@NotNegative double pAmountWorkToAdd) |
The firms try to increase the overall work amount of their work contracts by pAmountWorkToAdd. | |
void | layoffWorkers (double pWorkAmountToReduce) |
The Firm fires some of its employed Workers. | |
void | mutatePrice () |
Mutate the price at which the good is offered by mutating the mark-up used. | |
void | mutateWageReference () |
Mutate the wage reference. | |
void | mutateInputCoefficients () |
Mutate the input coefficients (technology) of the firm. | |
void | householdAcceptWorkContract (Household pHousehold, WorkContract pContract) |
Add a new contract to the workerList. | |
void | workerQuitJob (@NotNull Household pWorker) |
A hired worker quits his job. | |
WorkContract | constructActualWorkContract () |
A household can call this method as a kind of speculative application. | |
void | copyTechnologiesFrom (Firm pArchetype) |
The firm copies the technologies of the Firm pArchetype. | |
void | copyPricesFrom (Firm pArchetype) |
The firm copies the mark-up to calculate the price from the Firm pArchetype. | |
void | copyWagesFrom (Firm pArchetype) |
The firm copies the wage-reference to calculate wages from the Firm pArchetype. | |
double | calcNeededMoneyForProduction (double pProductionLevel) |
Assuming that the needed goods can be bought at their average prices and that the production coefficients are not changed, calculate the money needed for buying the additional capital to produce pProductionLevel units of the produced good. | |
double | calcUnitProductionCost () |
Computes the unit production cost at the average price. | |
Static Package Attributes | |
static final int | ADDED_WHILE_INITIALIZE = 0 |
Constant used in Firm.addFirm and in Firm.init. | |
static final int | ADDED_WHILE_RUNNING = 1 |
Constant used in Firm.addFirm and in Firm.init. | |
Private Member Functions | |
void | initArraysAndMatrices () |
Initialize the supplier and capital stock arrays. | |
double | calcNewTargetEmployment () |
Calculate the amount of work for which the firm wants to have work contracts. | |
double | calcMaxProduction (int pLimitation, double[] pCirculatingCapital,@GreaterOrApproxZero double[] pFixedCapital) |
Calculate the maximal production that can be done by the circulating/fixed capital and household restraints. | |
double | calcMaxProductionInclSupply () |
Calculate the maximal production that can be done by the circulating/fixed capital constraints, with the best possible allocation of the supplied goods. | |
double | calcMaxProductionFromFixed (@GreaterOrApproxZero double[] pFixedCapital) |
Calculate the maximal production that can be produced from fixed capital. | |
double[] | invProdFuncCirculating (double pQuantity) |
Calculate the inverse production function using the circulating input coefficients of the firm itself. | |
Private Attributes | |
int | id |
The id of the firm. | |
final FirmInitValues | initValues |
The initialization Values of the Firms. | |
final Sector | productionSector |
The Sector in which the firm produces. | |
Household | owner |
The owner of the firm. | |
double | wage |
The current offered wage of new work contracts. | |
double | wageReference |
The share of the benchmark wage initially offered by the firm. | |
double | price = 1.d |
The price currently demanded for the produced good. | |
double | inventory |
The inventory of the produced good. | |
double | inventoryAfterTrade |
The inventory of the produced good registered after trading. | |
double | producedQuantity |
The quantity of good produced during the period. | |
double | rateProductionUp |
The rate at which desired production changes. | |
boolean[] | isInvest |
A marker which assesses whether the conditions to invest are satisfied. | |
double | soldQuantity = 0.d |
The quantity of good sold during the period. | |
double | profitRate = 0.d |
The current profit rate. | |
double | profit = 0.d |
The current profit. | |
double | costs = 0.d |
The current production costs. | |
double | benchmarkCosts = 0.d |
The benchmark production costs, computed using wageReference equal to one. | |
double | markUp = 0.15d |
The current mark-up over costs. | |
double | sumProfitsMemory = 0.d |
The sum of profits since last copy step. | |
double | money = 0.d |
The money holdings of the Firm. | |
double | moneyVariation = 0.d |
The variation of the money holdings of the Firm. | |
double | intermediaryConsumptionValue = 0.d |
The value spent on intermediary consumption. | |
double | salesValue = 0.d |
The value of sales. | |
double | investmentValue = 0.d |
The value spent on investment. | |
double | wagesPaid = 0.d |
The wages paid. | |
double | interestsOnDebt = 0.d |
The interest paid on debt. | |
double | debt = 0.d |
The debt of the Firm. | |
double | debtVariation = 0.d |
The variation of the debt of the Firm. | |
double | targetEmployment |
The amount of work the Firm needs for the desired production. | |
double | laborCapacity |
The percentage of its target employment the firm currently employs. | |
double | laborInputCoefficient |
The input coefficient for labor. | |
double[] | circulatingCapital |
The current stock of goods used as circulating capital. | |
double[] | circulatingInputCoefficients |
The vector of input coefficients for circulating capital. | |
double[] | fixedCapital |
The current stock of the goods used as fixed capital. | |
double[] | fixedInputCoefficients |
The vector of input coefficients for fixed capital. | |
Suppliers | suppliers [] |
An array of Suppliers, with the size of numSectors. | |
double | desiredProduction |
The desired level of production. | |
double | dividend |
The dividend payed by this firm for this period. | |
int | periodCreated |
The period in which the firm was added to the foundation. | |
double[] | rationing |
The difference between quantity demanded and actual supply. | |
double | salesForecast = 0.d |
The current forecast of sales. | |
double | salesTrendForecast = 0.d |
The current forecast of trends in sales. | |
double[] | targetInvestment |
The actual stock of the goods used as fixed capital. | |
double | productionGap = 0 |
The differencce between produced quantity and desiredProduction. | |
Static Private Attributes | |
static final int | MAXPRODUCTION_CAPITAL = 0 |
Constant used in Firm.calcMaxProductionInclSupply as described there. | |
static final int | MAXPRODUCTION_CAPITAL_AND_LABOR = 1 |
Constant used in Firm.calcMaxProductionInclSupply as described there. | |
static final int | MAXPRODUCTION_FIXED_CAPITAL_ONLY = 2 |
Constant used in Firm.calcMaxProductionInclSupply as described there. | |
Classes | |
class | CostEfficiencyComparator |
This Comparator can be used to sort firms in function of their unit production costs. | |
class | DebtComparator |
This Comparator can be used to sort firms in dependency of their debts. | |
class | GrowthRateSalesComparator |
This Comparator can be used to sort firms as a function of the growth rate of their sales. | |
class | InventoryComparator |
This Comparator can be used to sort firms as a function of their mark-up. | |
class | MarkUpComparator |
This Comparator can be used to sort firms as a function of their mark-up. | |
class | PricingEfficiencyComparator |
This Comparator compares the efficiency of a pricing policy in function of the profit rate and of the growth rate of total profits. | |
class | Probe |
class | ProfitComparator |
This Comparator can be used to sort firms in dependency of their profits. | |
class | ProfitRateComparator |
This Comparator can be used to sort firms in dependency of their rate of profit. | |
class | RecruitmentEfficiencyComparator |
This Comparator can be used to sort firms in function of the ratio workforce/targetworkforce. | |
class | Stats |
class | WageReferenceComparator |
This Comparator can be used to sort firms in dependency of their wage reference. |
Definition at line 62 of file Firm.java.
Firm | ( | Foundation | pFoundation, | |
FirmInitValues | pInitValues, | |||
Sector | pSector, | |||
int | pIndexFirmInSector | |||
) | [package] |
The Constructor for the Firm agent.
pFoundation | The model foundation | |
pInitValues | The init values of the Firm | |
pSector | The Sector where the Firm is part of | |
pIndexFirmInSector | The firm is the pIndexFirmInSector -th firm in his sector |
Definition at line 1111 of file Firm.java.
01112 { 01113 foundation = pFoundation; 01114 random = Foundation.getRandomGenerator(); 01115 initValues = pInitValues; 01116 productionSector = pSector; 01117 01118 probe.indexFirmInSector = pIndexFirmInSector; 01119 }
void init | ( | int | pId, | |
int | pPhase, | |||
double | pDesiredProduction | |||
) | throws ParameterParserException [package] |
Initialize the Firm.
pId | The id of the firm, can be used for ordering the firm probes. | |
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 |
Definition at line 1132 of file Firm.java.
Referenced by Sector.addFirm(), and Firm.init().
01132 { 01133 // At initialization no Workers are employed 01134 workerList.clear(); 01135 rateProductionUp =productionSector.getInitGrowthRate(); 01136 profit=0; 01137 profitRate=0; 01138 producedQuantity =pDesiredProduction; 01139 desiredProduction = (1+rateProductionUp)*pDesiredProduction; 01140 salesForecast=pDesiredProduction; 01141 salesTrendForecast=rateProductionUp; 01142 rationing= new double[foundation.getNumSectors()]; 01143 01144 if (pPhase == ADDED_WHILE_INITIALIZE) { 01145 //wageReference = 1.0 - foundation.getInitWageVariation()*random.inRangeDouble(0,1); 01146 wageReference = 1.0; 01147 assert(wageReference>0); 01148 wage = wageReference * productionSector.getBenchmarkWage(); 01149 assert(wage>0); 01150 inventory = initValues.getTargetInventoryRatio()*pDesiredProduction; 01151 debt= (pDesiredProduction/productionSector.getInitProduction())* 01152 productionSector.getInitCapitalStockShare()*initValues.getDebts(); 01153 } 01154 // And also initialize the Supplier inner class instances and the capital stocks... 01155 initArraysAndMatrices(); 01156 // ... the probe can't initialized before the supplier instances 01157 probe.init(); 01158 foundation.getProbeManager().addProbe(probe); 01159 01160 stats.init(foundation.getStepManager()); 01161 01162 // set productionFunction etc. 01163 productionFunction = ProductionFunctionFactory.buildProductionFunctionWithName( 01164 initValues.getProductionFunctionName(), 01165 this, 01166 foundation.getNumSectors()); 01167 }
void initArraysAndMatrices | ( | ) | [private] |
Initialize the supplier and capital stock arrays.
The first time at which the firm will invest is drawn uniformly in 0..investmentPeriodicity-1, and the fixed capital is initialized accordingly (see comments to Sector.getInvestmentPeriodicity()
Definition at line 1170 of file Firm.java.
Referenced by Firm.init().
01170 { 01171 final int lNumSectors = foundation.getNumSectors(); 01172 final double lMaxNumberSuppliersRatio=0.5; 01173 01174 // first create ... 01175 suppliers = new Suppliers[lNumSectors]; 01176 for (int iSector = 0; iSector < lNumSectors; iSector++) { 01177 suppliers[iSector] = new Suppliers(); 01178 } 01179 01180 //... and initialize the Suppliers 01181 int iSector = 0; 01182 for (final Sector lSector : foundation.getSectorList()) { 01183 suppliers[iSector++].init(foundation, this, lSector, lMaxNumberSuppliersRatio); 01184 } 01185 01186 // then the capital stock arrays 01187 circulatingCapital = new double[lNumSectors]; 01188 fixedCapital = new double[lNumSectors]; 01189 targetInvestment = new double[lNumSectors]; 01190 isInvest = new boolean[lNumSectors]; 01191 Arrays.fill(isInvest, false); 01192 Arrays.fill(circulatingCapital, 0d); 01193 laborInputCoefficient = productionSector.getBenchmarkLaborInputCoefficient(); 01194 assert (laborInputCoefficient>ProductionFunction.MIN_COEFF_FOR_NEEDED_LABOR) ; 01195 initialLaborInputCoefficient = laborInputCoefficient; 01196 01197 circulatingInputCoefficients = new double[lNumSectors]; 01198 fixedInputCoefficients = new double[lNumSectors]; 01199 Arrays.fill(circulatingInputCoefficients , 0d); 01200 Arrays.fill(fixedInputCoefficients , 0d); 01201 for (final Sector lSector : foundation.getSectorList()) { 01202 final int lSectorIndex=lSector.getArrayIndex(); 01203 if (productionSector.getInitInputOutputCirculating(lSector.getArrayIndex()) >0){ 01204 circulatingInputCoefficients[lSectorIndex] =productionSector.getBenchmarkCirculatingInputCoefficient(lSectorIndex); 01205 01206 } 01207 01208 if (productionSector.getInitCapitalStock(lSector.getArrayIndex()) >0){ 01209 01210 fixedInputCoefficients[lSectorIndex] =productionSector.getBenchmarkFixedInputCoefficient(lSectorIndex); 01211 01215 final double lGrowthRate = productionSector.getInitGrowthRate(); 01216 final double lDepRate= productionSector.getInitFixedCapitalDepreciationRate(lSectorIndex); 01217 final double lFactor = (1+lGrowthRate)/(1-lDepRate); 01218 final double lPeriodicity=productionSector.getInvestmentPeriodicity(lSectorIndex); 01219 final double lInvestTime = Math.floor(random.inRangeDouble(0,lPeriodicity-1)); 01220 fixedCapital[lSectorIndex]= Math.pow(lFactor,lInvestTime)*invProdFuncFixed(desiredProduction)[lSectorIndex]; 01221 isInvest[lSectorIndex] =(lInvestTime<1); 01222 assert (!Double.isNaN(fixedCapital[lSectorIndex])); 01223 if (isInvest[lSectorIndex]){ 01224 fixedCapital[lSectorIndex]= invProdFuncFixed(desiredProduction)[lSectorIndex]/(1-lDepRate); 01225 } 01226 01227 01228 /* final double lFactor = (1+lDepRate)*(1+lGrowthRate); 01229 final double lInitCapacityRate = 1/Math.pow(lFactor, lInvestTime); 01230 fixedCapital[lSectorIndex]= invProdFuncFixed(desiredProduction)[lSectorIndex]/lInitCapacityRate;*/ 01231 01232 } 01233 } 01234 01235 01236 initialCirculatingInputCoefficients = ArrayTools.deepCopy(circulatingInputCoefficients); 01237 initialFixedInputCoefficients = ArrayTools.deepCopy(fixedInputCoefficients); 01238 double ls = ArrayTools.sumDouble(circulatingInputCoefficients)+ ArrayTools.sumDouble(fixedInputCoefficients); 01239 assert(ls>0); 01240 01241 // initialize the target employment 01242 targetEmployment = desiredProduction*laborInputCoefficient; 01243 01244 // construct the MutationIntervals 01245 laborInputCoeffMutation = new DoubleInterval(-productionSector.getInitLaborMutationRange(), 01246 productionSector.getInitLaborMutationRange()); 01247 circulatingInputCoeffMutation = new DoubleInterval[lNumSectors]; 01248 fixedInputCoeffMutation = new DoubleInterval[lNumSectors]; 01249 for (iSector = 0; iSector < lNumSectors; iSector++) { 01250 circulatingInputCoeffMutation[iSector] = new DoubleInterval( 01251 -productionSector.getInitCirculatingMutationRange(), 01252 productionSector.getInitCirculatingMutationRange()); 01253 fixedInputCoeffMutation[iSector] = new DoubleInterval( 01254 -productionSector.getInitFixedMutationRange(), 01255 productionSector.getInitFixedMutationRange()); 01256 01257 } 01258 }
void trade | ( | ) |
Implementation of the exchange step for the firm.
See also the mathematical description.
Implements IBuyer.
Definition at line 1272 of file Firm.java.
01272 { 01273 // observe the current state of suppliers 01274 for (int iSector = 0; iSector < foundation.getNumSectors(); iSector++) { 01275 suppliers[iSector].updateSuppliers(Suppliers.SellerSet.INCLUDE_IMPORT); 01276 } 01277 01278 double[] lDemand= new double[foundation.getNumSectors()]; 01279 01280 // In case of rationing, add new suppliers, compute the level of rationing 01281 for (int iSector = 0; iSector < foundation.getNumSectors(); iSector++) { 01282 lDemand[iSector] += getDemandCirculating(desiredProduction)[iSector]; 01283 lDemand[iSector] += Math.max(0,(isInvest[iSector]? 1:0)*getDemandFixed(desiredProduction)[iSector]); 01284 suppliers[iSector].addSuppliers(lDemand[iSector],Suppliers.SellerSet.INCLUDE_IMPORT); 01285 rationing[iSector]=Math.max(0,lDemand[iSector]-suppliers[iSector].maxSupply()); 01286 } 01287 01288 01289 // compute the maximal feasible production 01290 final double lMaxProduction = calcMaxProductionInclSupply(); 01291 final double lProduction = Math.min(desiredProduction,lMaxProduction); 01292 if (ArrayTools.allValuesAreLower(rationing,0)){ 01293 //assert(FloatMath.greaterOrApproxEqual(lProduction,desiredProduction,0.1)); 01294 } 01295 01296 01297 // calculate the demand 01298 final double[] acquireCirculating =getDemandCirculating(lProduction); 01299 final double[] acquireFixed = new double[foundation.getNumSectors()]; 01300 for (int iSector = 0; iSector < foundation.getNumSectors(); iSector++) { 01301 acquireFixed[iSector] = (isInvest[iSector] ?1:0)*getDemandFixed(lProduction)[iSector]; 01302 assert ( acquireFixed[iSector]>=0); 01303 targetInvestment[iSector]=acquireFixed[iSector]; 01304 // assert (FloatMath.lowerOrApproxEqual(acquireCirculating[iSector], suppliers[iSector].maxSupply())); 01305 } 01306 01307 01308 // buy the goods. The Math.min(Suppliers...) is a hack in order to correct the fact that invProdFuncFixed and CalcMaxProd 01309 // are not perfect inverse if one takes into account approximation errors. 01310 for (int iSector = 0; iSector < foundation.getNumSectors(); iSector++) { 01311 final double lCost = suppliers[iSector].buy( 01312 Math.min(suppliers[iSector].maxSupply(), 01313 acquireCirculating[iSector])); 01314 money -= lCost; 01315 costs += lCost; 01316 intermediaryConsumptionValue+= lCost; 01317 01318 } 01319 01320 for (int iSector = 0; iSector < foundation.getNumSectors(); iSector++) { 01321 if (suppliers[iSector].maxSupply()>0){ 01322 if (ArrayTools.allValuesAreLower(rationing,0) && isInvest[iSector]){ 01323 assert(FloatMath.lowerOrApproxEqual(targetInvestment[iSector],suppliers[iSector].maxSupply())); 01324 } 01325 final double lCost = suppliers[iSector].buy( 01326 Math.min(suppliers[iSector].maxSupply(), acquireFixed[iSector])); 01327 money -= lCost; 01328 investmentValue+= lCost; 01329 isInvest[iSector]=FloatMath.greaterOrApproxEqual(getDemandFixed(desiredProduction)[iSector], 01330 fixedCapital[iSector]); 01331 01332 } 01333 } 01334 01335 01336 // update the stocks 01337 //TODO: check the consistency. 01338 circulatingCapital = ArrayTools.addArrays(circulatingCapital, acquireCirculating); 01339 fixedCapital = ArrayTools.addArrays(fixedCapital, acquireFixed); 01340 for (int iSector = 0; iSector < foundation.getNumSectors(); iSector++) { 01341 assert (!Double.isNaN(fixedCapital[iSector])); 01342 } 01343 01344 }
double [] getDemandCirculating | ( | double | pProduction | ) | [package] |
Calculate the demand of circulating capital.
pProduction | the target production |
Definition at line 1353 of file Firm.java.
Referenced by Firm.trade().
01353 { 01354 01355 return ArrayTools.maxArray(0.d, 01356 ArrayTools.subtractArrays(invProdFuncCirculating(pProduction), circulatingCapital)); 01357 }
double [] getDemandFixed | ( | double | pProduction | ) | [package] |
Calculate the demand of fixed capital.
pProduction | the target production |
Definition at line 1365 of file Firm.java.
Referenced by Firm.trade().
01365 { 01366 double[] lDemand = new double [foundation.getNumSectors()]; 01367 01368 for (int iSector = 0; iSector < foundation.getNumSectors(); iSector++) { 01369 double lAmount= (1+productionSector.getCapitalReserveRate(iSector))*invProdFuncFixed(pProduction)[iSector]; 01370 lDemand[iSector]=Math.max(0,lAmount-fixedCapital[iSector]); 01371 assert (lDemand[iSector]>=0); 01372 } 01373 01374 return lDemand; 01375 }
void storeInventoryAfterTrade | ( | ) | [package] |
Store the state of the Inventory.
Definition at line 1378 of file Firm.java.
01378 { 01379 inventoryAfterTrade = inventory; 01380 }
void adjustEmployees | ( | ) | [package] |
The firm first calculate the actual demand of workers and then tries to match the number of employed workers to his demand.
See also the mathematical description.
Definition at line 1390 of file Firm.java.
Referenced by Sector.addFirm().
01390 { 01391 targetEmployment = calcNewTargetEmployment(); 01392 assert (FloatMath.greaterOrApproxEqual(prodFuncLabor(targetEmployment), desiredProduction)); 01393 wage = wageReference * productionSector.getBenchmarkWage(); 01394 01395 final double lInitWorkAmount = calcWorkAmount(); 01396 if (targetEmployment >= lInitWorkAmount) { 01397 hireWorkers(targetEmployment - lInitWorkAmount); 01398 } else if (targetEmployment < lInitWorkAmount){ 01399 layoffWorkers(lInitWorkAmount - targetEmployment); 01400 } 01401 double lWorkforce=calcWorkAmount(); 01402 01403 // if (foundation.getGovernment().getUnemploymentRate()>0.03){ 01404 // assert(FloatMath.greaterOrApproxEqual(lWorkforce,targetEmployment)); 01405 // } 01406 01407 if (targetEmployment>0){ 01408 laborCapacity= lWorkforce/targetEmployment; 01409 } 01410 else { 01411 laborCapacity=0; 01412 } 01413 }
double calcWorkAmount | ( | ) | [package] |
Calculate the sum of the work amounts of all work contracts of this firm.
Definition at line 1424 of file Firm.java.
Referenced by Firm.adjustEmployees(), Firm.calcMaxProduction(), Sector.calcWorkAmount(), Firm.constructActualWorkContract(), and Sector.dropFirm().
01424 { 01425 double lSumAmount = 0.d; 01426 for (final WorkContract lWorkContract : workerList.values()) { 01427 lSumAmount += lWorkContract.getAmount(); 01428 } 01429 01430 return lSumAmount; 01431 }
double calcNewTargetEmployment | ( | ) | [private] |
Calculate the amount of work for which the firm wants to have work contracts.
Definition at line 1439 of file Firm.java.
Referenced by Firm.adjustEmployees().
01439 { 01440 double lMaxProduction = getMaxProductionFromFixed(); 01441 double lBenchmarkProduction =Math.max(desiredProduction,initValues.getMinimumLaborCapacity()*lMaxProduction); 01442 return invProdFuncLabor(lBenchmarkProduction); 01443 }
void productionStep | ( | ) | [package] |
Produce, consume the circulating capital, depreciate the fixed capital stock and the product stock.
See also the mathematical description.
Definition at line 1457 of file Firm.java.
01457 { 01458 producedQuantity = Math.min(desiredProduction, 01459 calcMaxProduction(MAXPRODUCTION_CAPITAL_AND_LABOR, circulatingCapital, fixedCapital)); 01460 productionGap= desiredProduction-producedQuantity; 01461 01462 //assert (FloatMath.approxEqual(producedQuantity,desiredProduction)); 01463 //assert(FloatMath.approxEqual(producedQuantity,desiredProduction)); 01464 // depreciate product stock and add production 01465 inventory = (1d - productionSector.getInitInventoryDepreciationRate()) * inventory + 01466 producedQuantity; 01467 01468 // consume circulating capital 01469 final double[] lUsedCirculating = invProdFuncCirculating(producedQuantity); 01470 for (final Sector lSector : foundation.getSectorList()) { 01471 final int lIndex = lSector.getArrayIndex(); 01472 circulatingCapital[lIndex] = 01473 (1d - lSector.getInitInventoryDepreciationRate()) * 01474 (circulatingCapital[lIndex] - lUsedCirculating[lIndex]); 01475 } 01476 01477 // depreciate fixed capital and add the depreciation to the costs 01478 final double[] lUsedFixed = invProdFuncFixed(producedQuantity); 01479 for (final Sector lSector : foundation.getSectorList()) { 01480 final double lDepreciation = productionSector.getInitFixedCapitalDepreciationRate(lSector.getArrayIndex()); 01481 fixedCapital[lSector.getArrayIndex()] -= lDepreciation*lUsedFixed[lSector.getArrayIndex()]; 01482 final double lPrice = lSector.getStats().getAverageTradePrice(); 01483 costs += lPrice*lDepreciation*lUsedFixed[lSector.getArrayIndex()]; 01484 } 01485 for (int iSector = 0; iSector < foundation.getNumSectors(); iSector++) { 01486 assert (!Double.isNaN(fixedCapital[iSector])); 01487 } 01488 }
double calcMaxProduction | ( | int | pLimitation, | |
double[] | pCirculatingCapital, | |||
@GreaterOrApproxZero double[] | pFixedCapital | |||
) | [private] |
Calculate the maximal production that can be done by the circulating/fixed capital and household restraints.
The implementation depends on the implementation of Firm.invProdFuncCirculating, Firm.invProdFuncFixed and Sector.invProdLabor.
See also the mathematical description.
pInclLaborLimitation | If pLimitation is set to MAXPRODUCTION_CAPITAL, the calculated maximal production depends only on the capital limitation, in this case we assume, that the firm can employ the amount of workers that is needed for this production. If pLimitation is set to MAXPRODUCTION_CAPITAL_AND_HOUSEHOLD also the actual amount of workers are respected for the calculation. MAXPRODUCTION_FIXED_CAPITAL_ONLY can be used, if only the fixed capital should be limit the calculation. | |
pCirculatingCapital | The amount of circulating capital the calculation is based upon. | |
pFixedCapital | The amount of fixed capital the calculation is based upon. |
Definition at line 1515 of file Firm.java.
Referenced by Firm.calcMaxProductionFromFixed(), Firm.calcMaxProductionInclSupply(), and Firm.productionStep().
01517 { 01518 final int lNumSectors = foundation.getNumSectors(); 01519 01520 double lFactor = Double.MAX_VALUE; 01521 for (int iSector = 0; iSector < lNumSectors; iSector++) { 01522 // first check the fixed capital, this is done always 01523 final double lLimitationFixed = isNeededFixedCapital(iSector) 01524 ? pFixedCapital[iSector] / fixedInputCoefficients[iSector] 01525 : Double.MAX_VALUE; 01526 lFactor = Math.min(lLimitationFixed, lFactor); 01527 01528 // the check the circulating capital, in case that this is needed 01529 if (pLimitation != MAXPRODUCTION_FIXED_CAPITAL_ONLY) { 01530 final double lLimitationCirculating = isNeededCirculatingCapital(iSector) 01531 ? pCirculatingCapital[iSector] /circulatingInputCoefficients[iSector] 01532 : Double.MAX_VALUE; 01533 lFactor = Math.min(lLimitationCirculating, lFactor); 01534 } 01535 } 01536 01537 // and also check the labor, if requested 01538 if (pLimitation == MAXPRODUCTION_CAPITAL_AND_LABOR) { 01539 final double lLabor =calcWorkAmount(); 01540 final double lLimitationLabor = prodFuncLabor(lLabor); 01541 lFactor = Math.min(lFactor, lLimitationLabor); 01542 assert (!Double.isNaN(lFactor)); 01543 01544 } 01545 01546 return lFactor; 01547 }
double calcMaxProductionInclSupply | ( | ) | [private] |
Calculate the maximal production that can be done by the circulating/fixed capital constraints, with the best possible allocation of the supplied goods.
The implementation depends on the implementation of Firm.invProdFuncCirculating, Firm.invProdFuncFixed and Sector.invProdLabor.
Definition at line 1561 of file Firm.java.
Referenced by Firm.trade().
01561 { 01562 final double[] lCirculating = ArrayTools.deepCopy(circulatingCapital); 01563 final double[] lFixed = ArrayTools.deepCopy(fixedCapital); 01564 01565 // we have one suppliers instance per sector, and the best allocation (between 01566 // fixed and circulating capital) of the goods that the firm can be acquire 01567 // is sector independent, so we iterate over each suppliers instance 01568 for (final Suppliers lSuppliers : suppliers) { 01569 final int iSector = lSuppliers.getInputSector().getArrayIndex(); 01570 final double lSupply = lSuppliers.maxSupply(); 01571 if (FloatMath.greaterZero(lSupply)) { 01572 double lAlpha; 01573 if (isNeededFixedCapital(iSector)) { 01574 // to find the best distribution, we solve: 01575 // (circCapital + alpha * supply) / circCoef = 01576 // (fixedCapital + (1 - alpha) * supply) / fixedCoef 01577 lAlpha = 01578 (circulatingInputCoefficients[iSector] * (fixedCapital[iSector] + lSupply) - 01579 fixedInputCoefficients[iSector] * circulatingCapital[iSector]) / 01580 ((circulatingInputCoefficients[iSector] + fixedInputCoefficients[iSector]) * lSupply); 01581 01582 // alpha must be in the interval [0...1], we can't shift existing circulatingCapital 01583 // to fixed or vice versa 01584 lAlpha = Math.min(lAlpha, 1.d); 01585 lAlpha = Math.max(lAlpha, 0.d); 01586 } else { 01587 // the good is not needed as fixed capital, so we add the supply to the 01588 // circulating capital 01589 lAlpha = 1.d; 01590 } 01591 01592 // and the possible allocation with the found distribution to the current stock 01593 lCirculating[iSector] += lAlpha * lSupply; 01594 lFixed[iSector] += (1 - lAlpha) * lSupply; 01595 } 01596 } 01597 01598 if (ArrayTools.allValuesAreLower(rationing,0)){ 01599 double lTest =calcMaxProduction(MAXPRODUCTION_CAPITAL, lCirculating, lFixed); 01600 // assert(FloatMath.greaterOrApproxEqual(lTest,desiredProduction,0.1)); 01601 } 01602 01603 return calcMaxProduction(MAXPRODUCTION_CAPITAL, lCirculating, lFixed); 01604 }
double calcMaxProductionFromFixed | ( | @GreaterOrApproxZero double[] | pFixedCapital | ) | [private] |
Calculate the maximal production that can be produced from fixed capital.
Definition at line 1611 of file Firm.java.
01611 { 01612 return calcMaxProduction(MAXPRODUCTION_FIXED_CAPITAL_ONLY, null, pFixedCapital); 01613 }
double [] invProdFuncCirculating | ( | double | pQuantity, | |
double[] | pCirculatingInputCoefficients | |||
) | [package] |
The inverse production function for circulation capital.
The function can't be changed without changing Firm.calcMaxProduction and Firm.calcMaxProductionInclSupply too.
See also the mathematical description.
pQuantity | The quantity that the firm want's to produce | |
pCirculatingInputCoefficients | The circulating input coefficients, that should be used for the calculation |
Definition at line 1632 of file Firm.java.
Referenced by Firm.calcNeededMoneyForProduction(), Firm.getDemandCirculating(), Firm.invProdFuncCirculating(), and Firm.productionStep().
01632 { 01633 final double[] lNeeded = new double[foundation.getNumSectors()]; 01634 for (int iSector = 0; iSector < foundation.getNumSectors(); iSector++) { 01635 lNeeded[iSector] = isNeededCirculatingCapital(iSector) ? 01636 pQuantity * pCirculatingInputCoefficients[iSector] : 0d; 01637 } 01638 return lNeeded; 01639 }
double [] invProdFuncCirculating | ( | double | pQuantity | ) | [private] |
Calculate the inverse production function using the circulating input coefficients of the firm itself.
Definition at line 1646 of file Firm.java.
01646 { 01647 return invProdFuncCirculating(pQuantity, circulatingInputCoefficients); 01648 }
double [] invProdFuncFixed | ( | double | pQuantity, | |
double[] | pFixedInputCoefficients | |||
) | [package] |
The inverse production function for fixed capital.
The function can't be changed without changing Firm.calcMaxProduction and Firm.calcMaxProductionInclSupply too.
See also the mathematical description.
pQuantity | The quantity that the firm want's to produce | |
pFixedInputCoefficients | The fixed input coefficients, that should be used for the calculation |
Definition at line 1666 of file Firm.java.
Referenced by Firm.calcNeededMoneyForProduction(), Firm.getDemandFixed(), Firm.initArraysAndMatrices(), Firm.invProdFuncFixed(), and Firm.productionStep().
01666 { 01667 final double[] lNeeded = new double[foundation.getNumSectors()]; 01668 for (int iSector = 0; iSector < foundation.getNumSectors(); iSector++) { 01669 lNeeded[iSector] = isNeededFixedCapital(iSector) ? 01670 pQuantity * pFixedInputCoefficients[iSector] : 0d; 01671 } 01672 return lNeeded; 01673 }
double [] invProdFuncFixed | ( | double | pQuantity | ) | [package] |
Calculate the inverse production function using the fixed input coefficients of the firm itself.
Definition at line 1680 of file Firm.java.
01680 { 01681 return invProdFuncFixed(pQuantity, fixedInputCoefficients); 01682 }
double prodFuncLabor | ( | double | pQuantity | ) | [package] |
The production function for labor.
Definition at line 1686 of file Firm.java.
Referenced by Firm.adjustEmployees(), and Firm.calcMaxProduction().
01686 { 01687 double lLimit= productionSector.getLaborProductivity() * pQuantity / laborInputCoefficient; 01688 assert(!Double.isNaN(lLimit)); 01689 01690 return lLimit; 01691 }
double invProdFuncLabor | ( | double | pQuantity | ) | [package] |
The inverse production function for labor.
Definition at line 1695 of file Firm.java.
Referenced by Firm.calcNewTargetEmployment().
01695 { 01696 return pQuantity * laborInputCoefficient/ productionSector.getLaborProductivity(); 01697 }
boolean isNeededCirculatingCapital | ( | int | pIndex | ) |
Check the the good produced by the Sector pSector is needed as circulating capital.
pIndex | The column of the accessed matrix |
Definition at line 1707 of file Firm.java.
Referenced by Firm.calcMaxProduction(), and Firm.invProdFuncCirculating().
01707 { 01708 return (circulatingInputCoefficients[pIndex] > 0); 01709 }
boolean isNeededFixedCapital | ( | int | pIndex | ) |
Check the the good produced by the Sector pSector is needed as fixed capital.
pIndex | The column of the accessed matrix |
Definition at line 1719 of file Firm.java.
Referenced by Firm.calcMaxProduction(), Firm.calcMaxProductionInclSupply(), and Firm.invProdFuncFixed().
01719 { 01720 return (fixedInputCoefficients[pIndex] > 0); 01721 }
void account | ( | ) | [package] |
Pay wages, update the debt (or the savings), reinitialize the money holdings, compute the net profit and distribute a dividend if the net wealth is positive.
See also the mathematical description.
Definition at line 1731 of file Firm.java.
01731 { 01732 final double lInterestRate = foundation.getFinancial().getInterestRate(); 01733 final double lOldInventory =stats.getSoldQuantityLastPeriod(); 01734 final double lOldProducedQuantity =stats.getProducedQuantityLastPeriod(); 01735 final double lOldSoldQuantity =stats.getSoldQuantityLastPeriod(); 01736 final double lOldCosts =stats.getCostsLastPeriod(); 01737 01738 01739 // pay wages 01740 /* wagesPaid = 0.d; 01741 for (final WorkContract lWorkContract : workerList.values()) { 01742 wagesPaid += lWorkContract.getWageCurrentWorkAmount(); 01743 }*/ 01744 wagesPaid=0.d; 01745 double lNormalizedWages=0; 01746 final LinkedList<Household> lWorkers = new LinkedList<Household>(workerList.keySet()); 01747 for (final Household lHousehold : lWorkers) { 01748 double lWage = workerList.get(lHousehold).getWageCurrentWorkAmount(); 01749 wagesPaid +=lWage; 01750 lNormalizedWages+=lWage/wageReference; 01751 assert (lWage>0); 01752 } 01753 // add wages to the costs for this period. 01754 benchmarkCosts=costs+lNormalizedWages; 01755 costs += wagesPaid; 01756 01757 interestsOnDebt=lInterestRate * debt; 01758 money -= (wagesPaid + interestsOnDebt); 01759 double lOldDebt= debt; 01760 if (money < 0) { 01761 if (foundation.getFinancial().askForDebt(this, -money) < -money) { 01762 // we didn't got the needed debt, we are dead! 01763 } 01764 } 01765 01766 if (money>=debt){ 01767 money-=debt; 01768 debt=0; 01769 } 01770 else{ 01771 debt-=money; 01772 money=0; 01773 } 01774 01775 debtVariation= debt -lOldDebt; 01776 01777 // the income is computed as the sales of last period production 01778 //profit = Math.min(profit, price * lOldProducedQuantity); 01779 01780 /* plus the increase in inventories if those are low (future sales anticipated) 01781 * 01782 */ 01783 if (initValues.getTargetInventoryRatio()*lOldSoldQuantity>lOldInventory){ 01784 profit += 0; 01785 } 01786 01787 01788 01789 if (lOldCosts > 0.d){ 01790 profit -= lOldCosts; 01791 profitRate = (profit / lOldCosts); 01792 assert (!Double.isNaN(profitRate)); 01793 } 01794 // else we are in the first period, and we use the following approximation of costs, based on the 01795 //assumption that all prices were equal to one. 01796 else if (producedQuantity>0 && markUp<1){ 01797 final double lCosts=(1-markUp)*producedQuantity; 01798 profit-=lCosts; 01799 profitRate=profit/lCosts; 01800 } 01801 01802 sumProfitsMemory += profit; 01803 01804 // distribute a dividend 01805 if (money > 0) { 01806 dividend = getInitDividendRate() * money; 01807 money -= dividend; 01808 } else { 01809 dividend = 0; 01810 } 01811 /* if (money > 0 && profit>0) { 01812 dividend = Math.min(profit*getInitDividendRate(), money); 01813 money -= dividend; 01814 } else { 01815 dividend = 0; 01816 }*/ 01817 /* if (profit>0) { 01818 dividend = profit*getInitDividendRate(); 01819 money -= dividend; 01820 } else { 01821 dividend = 0; 01822 } 01823 */ 01824 01825 moneyVariation = money - stats.getMoneyLastPeriod(); 01826 }
void updateDesiredProduction | ( | ) | [package] |
Update the desired production.
See also the mathematical description.
Definition at line 1836 of file Firm.java.
01836 { 01837 //ForecastTools.updateHolt(salesForecast, salesTrendForecast, soldQuantity); 01838 double lOldBase=salesForecast; 01839 double lOldTrend=salesTrendForecast; 01840 double lRate=initValues.getSalesForecastUpdateRate(); 01841 01842 /* double lSoldInSector= foundation.getStats().getTradeTrace().getOverallQuantitySelledInSector(productionSector); 01843 double lDemandInSector= lSoldInSector + productionSector.getStats().getRationing(); 01844 assert(lDemandInSector>=lSoldInSector); 01845 double lDemand= soldQuantity*Math.min(lDemandInSector/lSoldInSector,(1+initValues.getMaxRateProdUp())); 01846 assert(lDemand>=soldQuantity); 01847 salesForecast=Math.max(0,(1-lRate)*(lOldBase+lOldTrend)+lRate*lDemand); 01848 salesTrendForecast=(1-lRate)*lOldTrend+lRate*(salesForecast-lOldBase);*/ 01849 01850 salesForecast=Math.max(0,(1-lRate)*(lOldBase+lOldTrend)+lRate*soldQuantity); 01851 salesTrendForecast=Math.max(0,(1-lRate)*lOldTrend+lRate*(salesForecast-lOldBase)); 01852 //salesTrendForecast=(1-lRate)*lOldTrend+lRate*(salesForecast-lOldBase); 01853 desiredProduction= Math.max(0,Math.min(getMaxProductionFromFixed(),salesForecast+salesTrendForecast)); 01854 for (int iSector = 0; iSector < foundation.getNumSectors(); iSector++) { 01855 isInvest[iSector] = FloatMath.greaterOrApproxEqual((salesTrendForecast+salesForecast)*fixedInputCoefficients[iSector], 01856 fixedCapital[iSector]); 01857 } 01858 if (producedQuantity>0){ 01859 rateProductionUp= (desiredProduction/producedQuantity)-1; 01860 } 01861 assert (!Double.isNaN(desiredProduction)); 01862 }
void updatePrice | ( | ) | [package] |
Update the price.
See also the mathematical description.
Definition at line 1873 of file Firm.java.
01873 { 01874 double lOldPrice=price; 01875 if (producedQuantity > 0 && (benchmarkCosts>0)){ 01876 price = Math.min((1+markUp)*benchmarkCosts/producedQuantity,productionSector.getStats().getAverageTradePrice()*2); 01877 //price = Math.min((1+markUp)*costs/producedQuantity,productionSector.getStats().getAverageTradePrice()*2); 01878 01879 } 01880 price=0.95*lOldPrice+0.05*price; 01881 01882 assert (!Double.isNaN(price)); 01883 assert(price>0); 01884 }
double hireWorkers | ( | @NotNegative double | pAmountWorkToAdd | ) | [package] |
The firms try to increase the overall work amount of their work contracts by pAmountWorkToAdd.
pAmountWorkToAdd | The amount of work that should be added to the workforce |
Definition at line 1901 of file Firm.java.
Referenced by Firm.adjustEmployees().
01901 { 01902 // first try to increase the work amount of already employed workers 01903 final LinkedList<Household> lWorkers = new LinkedList<Household>(workerList.keySet()); 01904 Collections.sort(lWorkers, new FallbackComparator()); 01905 01906 final Iterator<Household> iterWorkers = lWorkers.iterator(); 01907 01908 // Iterate over the workers sorted by increasing Fallback and get their actual work amount 01909 while (iterWorkers.hasNext() && (pAmountWorkToAdd > 0.d)) { 01910 final Household lWorker = iterWorkers.next(); 01911 01912 // create and offer a work contract offer with the current operation characteristics 01913 final WorkContract lWorkContract = new WorkContract(this,Math.min(pAmountWorkToAdd, 1.d)); 01914 final double lWorkAmountOfWorkerBeforeOffer = workerList.get(lWorker).getAmount(); 01915 final WorkContract lAcceptedWorkContract = lWorker.checkWorkContractOffer(lWorkContract); 01916 01917 // check the response 01918 if (lAcceptedWorkContract.getStatus() == WorkContract.Status.ACCEPTED) { 01919 // if the household was already employed, the old work amount must be added to the 01920 // searched work amount, because the work amount in the accepted work contract describes 01921 // the new total work amount for this household and not the difference from the old 01922 // to the new one 01923 pAmountWorkToAdd -= lAcceptedWorkContract.getAmount() - lWorkAmountOfWorkerBeforeOffer; 01924 01925 householdAcceptWorkContract(lWorker, lAcceptedWorkContract); 01926 } 01927 } 01928 01929 // then try to hire new workers, starting with those with most free time available. 01930 final Iterator<Household> iterWorkers2 = foundation.getHouseholds(). 01931 workAmountSortedIterator(); 01932 // Iterate over the sorted workers and get their actual work amount 01933 while (iterWorkers2.hasNext() && (pAmountWorkToAdd > 0.d)) { 01934 final Household lWorker = iterWorkers2.next(); 01935 // households that already work for the firm are skipped because they got an offer before 01936 if (workerList.containsKey(lWorker)) { 01937 continue; 01938 } 01939 01940 // create and offer a work contract offer with the current operation characteristics 01941 final WorkContract lWorkContract = 01942 new WorkContract(this,Math.min(pAmountWorkToAdd, 1.d)); 01943 final WorkContract lAcceptedWorkContract = lWorker.checkWorkContractOffer(lWorkContract); 01944 01945 // check the response 01946 if (lAcceptedWorkContract.getStatus() == WorkContract.Status.ACCEPTED) { 01947 pAmountWorkToAdd -= lAcceptedWorkContract.getAmount(); 01948 householdAcceptWorkContract(lWorker, lAcceptedWorkContract); 01949 } 01950 } 01951 01952 return pAmountWorkToAdd; 01953 }
void layoffWorkers | ( | double | pWorkAmountToReduce | ) | [package] |
The Firm fires some of its employed Workers.
pWorkAmountToReduce |
Definition at line 1968 of file Firm.java.
Referenced by Firm.adjustEmployees(), and Sector.dropFirm().
01968 { 01969 //we sort the workers by their Fallback, from high to low, so that the workers who are 01970 //"least satisfied" with their wage are layed off first 01971 final LinkedList<Household> lHouseholds = new LinkedList<Household>(workerList.keySet()); 01972 Collections.sort(lHouseholds, new InverseFallbackComparator()); 01973 01974 final Iterator<Household> iterHouseholds = lHouseholds.iterator(); 01975 while (FloatMath.greaterZero(pWorkAmountToReduce)) { 01976 final Household lHousehold = iterHouseholds.next(); 01977 final WorkContract lWorkContract = workerList.get(lHousehold); 01978 01979 if (pWorkAmountToReduce >= lWorkContract.getAmount()) { 01980 // When the household works less than the amount the firm wants to reduce, fire 01981 // him completely ... 01982 lHousehold.removeEmployment(this); 01983 workerList.remove(lHousehold); 01984 pWorkAmountToReduce -= lWorkContract.getAmount(); 01985 } else { 01986 // ... else just reduce the his amount of work 01987 lWorkContract.setAmount(lWorkContract.getAmount() - pWorkAmountToReduce); 01988 lHousehold.addEmployment(lWorkContract); 01989 workerList.put(lHousehold, lWorkContract); 01990 break; 01991 } 01992 } 01993 }
void mutatePrice | ( | ) | [package] |
void mutateWageReference | ( | ) | [package] |
Mutate the wage reference.
Definition at line 2005 of file Firm.java.
02005 { 02006 wageReference += (random.nextBoolean(0.5) ? 1 : -1) * foundation.getInitWageVariation() * 02007 wageReference; 02008 wageReference = Math.max(wageReference, 0.d); 02009 wageReference =Math.min(wageReference, 16); 02010 }
void mutateInputCoefficients | ( | ) | [package] |
Mutate the input coefficients (technology) of the firm.
Definition at line 2014 of file Firm.java.
02014 { 02015 final ProductionFunction.VariatorResults lVariatorResults = 02016 productionFunction.mutateCoefficients(circulatingInputCoeffMutation, 02017 fixedInputCoeffMutation, 02018 laborInputCoeffMutation, 02019 foundation.getNumSectors()); 02020 02021 circulatingInputCoefficients = lVariatorResults.circulatingInputCoefficientsVariation; 02022 fixedInputCoefficients = lVariatorResults.fixedInputCoefficientsVariation; 02023 laborInputCoefficient = lVariatorResults.laborInputCoefficientVariation; 02024 }
void householdAcceptWorkContract | ( | Household | pHousehold, | |
WorkContract | pContract | |||
) | [package] |
Add a new contract to the workerList.
pHousehold | The household who accepted a work contract offer | |
pContract | The accepted contract. |
Definition at line 2039 of file Firm.java.
Referenced by Household.adjustEmploymentStatus(), and Firm.hireWorkers().
02039 { 02040 workerList.put(pHousehold, pContract); 02041 }
void workerQuitJob | ( | @NotNull Household | pWorker | ) | [package] |
A hired worker quits his job.
pWorker | The household who quits his job. |
Definition at line 2049 of file Firm.java.
02049 { 02050 workerList.remove(pWorker); 02051 }
void sell | ( | @GreaterOrApproxZero double | pTraded | ) |
The Firm sells some units of the produced good.
The caller of this method must ensure, that pTraded <= inventory.
pTraded | The number of units traded. |
Definition at line 2061 of file Firm.java.
02061 { 02062 assert(FloatMath.lowerOrApproxEqual(pTraded, inventory)) : 02063 "Firm can't sell more units then it has in the inventory"; 02064 02065 inventory -= pTraded; 02066 money += price * pTraded; 02067 profit += price * pTraded; 02068 salesValue += price * pTraded; 02069 soldQuantity += pTraded; 02070 }
WorkContract constructActualWorkContract | ( | ) | [package] |
A household can call this method as a kind of speculative application.
The constructed WorkContract can be used (with a lower work amount, if necessery) to call Firm.workerAcceptWorkContract.
Definition at line 2079 of file Firm.java.
Referenced by Household.adjustEmploymentStatus().
02079 { 02080 final double lWorkAmountMissing = targetEmployment - calcWorkAmount(); 02081 final WorkContract lActualWorkContract = new WorkContract(this, 02082 Math.max(0.d, lWorkAmountMissing)); 02083 02084 if (FloatMath.approxZero(lWorkAmountMissing)) { 02085 lActualWorkContract.setStatus(WorkContract.Status.NO_OFFER); 02086 } 02087 02088 return lActualWorkContract; 02089 }
void copyTechnologiesFrom | ( | Firm | pArchetype | ) | [package] |
The firm copies the technologies of the Firm pArchetype.
pArchetype | The firm, from which the technologies are copied. |
Definition at line 2096 of file Firm.java.
Referenced by Sector.firmsCopyTechnologies().
02096 { 02097 double lOldValue=productionFunction.compute(circulatingInputCoefficients, fixedInputCoefficients,laborInputCoefficient, 02098 foundation.getNumSectors()); 02099 laborInputCoefficient = pArchetype.getLaborInputCoefficient(); 02100 ArrayTools.deepCopyFromTo(pArchetype.getFixedInputCoefficients(), fixedInputCoefficients); 02101 ArrayTools.deepCopyFromTo(pArchetype.getCirculatingInputCoefficients(), 02102 circulatingInputCoefficients); 02103 02104 double lNormalize=productionFunction.compute(circulatingInputCoefficients, fixedInputCoefficients,laborInputCoefficient, 02105 foundation.getNumSectors()); 02106 02107 ArrayTools.deepCopyFromTo(ArrayTools.multiplyArray(lOldValue/lNormalize,circulatingInputCoefficients),circulatingInputCoefficients); 02108 ArrayTools.deepCopyFromTo(ArrayTools.multiplyArray(lOldValue/lNormalize,fixedInputCoefficients),fixedInputCoefficients); 02109 laborInputCoefficient*=lOldValue/lNormalize; 02110 02111 02112 double lNewValue=productionFunction.compute(circulatingInputCoefficients, fixedInputCoefficients,laborInputCoefficient, 02113 foundation.getNumSectors()); 02114 02115 assert(FloatMath.approxEqual(lOldValue, lNewValue, 0.1)); 02116 02117 }
void copyPricesFrom | ( | Firm | pArchetype | ) | [package] |
The firm copies the mark-up to calculate the price from the Firm pArchetype.
pArchetype | The firm, from which the price mark-up is copied. |
Definition at line 2124 of file Firm.java.
Referenced by Sector.firmsCopyPrices().
02124 { 02125 markUp = pArchetype.getMarkUp(); 02126 }
void copyWagesFrom | ( | Firm | pArchetype | ) | [package] |
The firm copies the wage-reference to calculate wages from the Firm pArchetype.
pArchetype | The firm, from which the wage reference is copied. |
Definition at line 2133 of file Firm.java.
Referenced by Sector.firmsCopyWages().
02133 { 02134 wageReference = pArchetype.getWageReference(); 02135 wage = wageReference * productionSector.getBenchmarkWage(); 02136 }
double calcNeededMoneyForProduction | ( | double | pProductionLevel | ) | [package] |
Assuming that the needed goods can be bought at their average prices and that the production coefficients are not changed, calculate the money needed for buying the additional capital to produce pProductionLevel units of the produced good.
pProductionLevel | The number of units that should be produced. |
Definition at line 2147 of file Firm.java.
02147 { 02148 final double[] lNeededFixedCapital = ArrayTools.maxArray(0.d, 02149 ArrayTools.subtractArrays(invProdFuncFixed(pProductionLevel), fixedCapital)); 02150 final double[] lNeededCirculatingCapital = ArrayTools.maxArray(0.d, 02151 ArrayTools.subtractArrays(invProdFuncCirculating(pProductionLevel), circulatingCapital)); 02152 02153 double lNeededMoney = 0.d; 02154 for (final Sector lSector : foundation.getSectorList()) { 02155 lNeededMoney += lSector.getStats().getAverageSupplyPriceWithoutImport() * 02156 (lNeededFixedCapital[lSector.getArrayIndex()] + 02157 lNeededCirculatingCapital[lSector.getArrayIndex()]); 02158 } 02159 02160 lNeededMoney += pProductionLevel* laborInputCoefficient * wage; 02161 02162 return lNeededMoney; 02163 }
double calcUnitProductionCost | ( | ) | [package] |
Computes the unit production cost at the average price.
Definition at line 2168 of file Firm.java.
02168 { 02169 double lUnitCost = 0.d; 02170 for (final Sector lSector : foundation.getSectorList()) { 02171 int iSector=lSector.getArrayIndex(); 02172 lUnitCost += lSector.getStats().getAverageSupplyPriceWithoutImport() * 02173 (circulatingInputCoefficients[iSector] + 02174 productionSector.getInitFixedCapitalDepreciationRate(iSector) * 02175 fixedInputCoefficients[iSector]); 02176 } 02177 02178 lUnitCost += laborInputCoefficient * wage/productionSector.getLaborProductivity(); 02179 return lUnitCost; 02180 }
void bankrupt | ( | ) |
The available money is used to reimburse part of the debt or goes to the owner.
The debt and money holdings are set to zero. The firm is deleted from the property of the owner.
Definition at line 2187 of file Firm.java.
Referenced by Sector.dropFirm().
02187 { 02188 if (money >= debt){ 02189 debt = 0; 02190 money -= debt; 02191 getOwner().setMoney(getOwner().getMoney() + money); 02192 money = 0; 02193 } 02194 else{ 02195 debt -= money; 02196 money = 0; 02197 foundation.getFinancial().addToLiquidationMissingDebts(debt); 02198 debt = 0; 02199 } 02200 getOwner().removeFirmFromProperty(this); 02201 }
boolean isUnproductive | ( | ) |
Check whether the firm is unproductive.
Definition at line 2204 of file Firm.java.
02204 { 02205 return 02206 (FloatMath.approxZero(stats.getAverageProducedQuantity(10)) 02207 && (FloatMath.approxZero(producedQuantity))); 02208 }
double getInventory | ( | ) |
double getBAUSupply | ( | ) |
A firm supplies to its regular consumers not more than what it can at most produce next period, in order to be able to maintain its target inventory, see Firm.updateDesiredProduction().
Implements ISeller.
Definition at line 2228 of file Firm.java.
Referenced by Firm.getExtraSupply().
02228 { 02229 double lMaxProduction= Math.max(producedQuantity,getMaxProductionFromFixed()); 02230 return Math.min(inventory,Math.max(0, lMaxProduction-soldQuantity)); 02231 //return inventory; 02232 }
double getExtraSupply | ( | ) |
A firm supplies to new consumers not more than the margin by which it can increase its production next period, in order to be able to maintain its target inventory and the supply to its regular consumers, see Firm.updateDesiredProduction().
Implements ISeller.
Definition at line 2238 of file Firm.java.
02238 { 02239 double lMaxProduction= Math.max(producedQuantity,getMaxProductionFromFixed()); 02240 return Math.min(getBAUSupply(),lMaxProduction-producedQuantity); 02241 //return inventory; 02242 02243 }
double getPrice | ( | ) |
Sector getProductionSector | ( | ) |
The Sector in which the agent produces.
Implements ISeller.
Definition at line 2249 of file Firm.java.
02249 { 02250 return productionSector; 02251 }
final int ADDED_WHILE_INITIALIZE = 0 [static, package] |
Constant used in Firm.addFirm and in Firm.init.
The owner and some other characteristics of the firm are determined randomly, respectively as a random mutation of given init values if the firm is created at the initialization of the model.
Definition at line 66 of file Firm.java.
Referenced by Firm.init().
final int ADDED_WHILE_RUNNING = 1 [static, package] |
final int MAXPRODUCTION_CAPITAL = 0 [static, private] |
Constant used in Firm.calcMaxProductionInclSupply as described there.
Definition at line 74 of file Firm.java.
Referenced by Firm.calcMaxProductionInclSupply().
final int MAXPRODUCTION_CAPITAL_AND_LABOR = 1 [static, private] |
Constant used in Firm.calcMaxProductionInclSupply as described there.
Definition at line 76 of file Firm.java.
Referenced by Firm.calcMaxProduction(), and Firm.productionStep().
final int MAXPRODUCTION_FIXED_CAPITAL_ONLY = 2 [static, private] |
Constant used in Firm.calcMaxProductionInclSupply as described there.
Definition at line 78 of file Firm.java.
Referenced by Firm.calcMaxProduction(), and Firm.calcMaxProductionFromFixed().
final FirmInitValues initValues [private] |
The initialization Values of the Firms.
Definition at line 709 of file Firm.java.
Referenced by Firm.account(), Firm.calcNewTargetEmployment(), Firm.Firm(), Firm.init(), Firm.mutatePrice(), and Firm.updateDesiredProduction().
final Sector productionSector [private] |
The Sector in which the firm produces.
Definition at line 716 of file Firm.java.
Referenced by Firm.adjustEmployees(), Firm.calcUnitProductionCost(), Firm.copyWagesFrom(), Firm.Firm(), Firm.getDemandFixed(), Firm.getProductionSector(), Firm.init(), Firm.initArraysAndMatrices(), Firm.invProdFuncLabor(), Firm.prodFuncLabor(), Firm.productionStep(), and Firm.updatePrice().
Map<Household, WorkContract > workerList [protected] |
Initial value:
new LinkedHashMap<Household, WorkContract>()
Definition at line 735 of file Firm.java.
Referenced by Firm.account(), Firm.calcWorkAmount(), Firm.hireWorkers(), Firm.householdAcceptWorkContract(), Firm.init(), Firm.layoffWorkers(), and Firm.workerQuitJob().
double wage [private] |
The current offered wage of new work contracts.
The payed wages of existing work contracts can be different (for each Household).
Definition at line 772 of file Firm.java.
Referenced by Firm.adjustEmployees(), Firm.calcNeededMoneyForProduction(), Firm.calcUnitProductionCost(), Firm.copyWagesFrom(), and Firm.init().
double wageReference [private] |
The share of the benchmark wage initially offered by the firm.
Definition at line 780 of file Firm.java.
Referenced by Firm.account(), Firm.adjustEmployees(), Firm.copyWagesFrom(), Firm.init(), and Firm.mutateWageReference().
double price = 1.d [private] |
The price currently demanded for the produced good.
Definition at line 787 of file Firm.java.
Referenced by Firm.getPrice(), Firm.sell(), and Firm.updatePrice().
double inventory [private] |
The inventory of the produced good.
Definition at line 795 of file Firm.java.
Referenced by Firm.getBAUSupply(), Firm.getInventory(), Firm.init(), Firm.productionStep(), Firm.sell(), and Firm.storeInventoryAfterTrade().
double inventoryAfterTrade [private] |
The inventory of the produced good registered after trading.
Definition at line 803 of file Firm.java.
Referenced by Firm.storeInventoryAfterTrade().
double producedQuantity [private] |
The quantity of good produced during the period.
Definition at line 811 of file Firm.java.
Referenced by Firm.account(), Firm.getBAUSupply(), Firm.getExtraSupply(), Firm.init(), Firm.isUnproductive(), Firm.productionStep(), Firm.updateDesiredProduction(), and Firm.updatePrice().
double rateProductionUp [private] |
The rate at which desired production changes.
Definition at line 819 of file Firm.java.
Referenced by Firm.init(), and Firm.updateDesiredProduction().
boolean [] isInvest [private] |
A marker which assesses whether the conditions to invest are satisfied.
Definition at line 825 of file Firm.java.
Referenced by Firm.initArraysAndMatrices(), Firm.trade(), and Firm.updateDesiredProduction().
double soldQuantity = 0.d [private] |
The quantity of good sold during the period.
Definition at line 833 of file Firm.java.
Referenced by Firm.getBAUSupply(), Firm.sell(), and Firm.updateDesiredProduction().
double profitRate = 0.d [private] |
The current profit rate.
Definition at line 840 of file Firm.java.
Referenced by Firm.account(), and Firm.init().
double profit = 0.d [private] |
The current profit.
Definition at line 847 of file Firm.java.
Referenced by Firm.account(), Firm.init(), and Firm.sell().
double costs = 0.d [private] |
The current production costs.
Definition at line 854 of file Firm.java.
Referenced by Firm.account(), Firm.productionStep(), and Firm.trade().
double benchmarkCosts = 0.d [private] |
The benchmark production costs, computed using wageReference equal to one.
Definition at line 861 of file Firm.java.
Referenced by Firm.account(), and Firm.updatePrice().
double markUp = 0.15d [private] |
The current mark-up over costs.
The mark-up is (price-productionCost)/productionCost, that is the margin above production cost the producer uses to set its price.
Definition at line 875 of file Firm.java.
Referenced by Firm.account(), Firm.copyPricesFrom(), Firm.mutatePrice(), and Firm.updatePrice().
double sumProfitsMemory = 0.d [private] |
The sum of profits since last copy step.
Definition at line 882 of file Firm.java.
Referenced by Firm.account().
double money = 0.d [private] |
The money holdings of the Firm.
Definition at line 889 of file Firm.java.
Referenced by Firm.account(), Firm.bankrupt(), Firm.sell(), and Firm.trade().
double moneyVariation = 0.d [private] |
The variation of the money holdings of the Firm.
Definition at line 895 of file Firm.java.
Referenced by Firm.account().
double intermediaryConsumptionValue = 0.d [private] |
The value spent on intermediary consumption.
Definition at line 902 of file Firm.java.
Referenced by Firm.trade().
double salesValue = 0.d [private] |
double investmentValue = 0.d [private] |
The value spent on investment.
Definition at line 916 of file Firm.java.
Referenced by Firm.trade().
double wagesPaid = 0.d [private] |
double interestsOnDebt = 0.d [private] |
double debt = 0.d [private] |
The debt of the Firm.
Definition at line 937 of file Firm.java.
Referenced by Firm.account(), Firm.bankrupt(), and Firm.init().
double debtVariation = 0.d [private] |
The variation of the debt of the Firm.
Definition at line 944 of file Firm.java.
Referenced by Firm.account().
double targetEmployment [private] |
The amount of work the Firm needs for the desired production.
Definition at line 952 of file Firm.java.
Referenced by Firm.adjustEmployees(), Firm.constructActualWorkContract(), and Firm.initArraysAndMatrices().
double laborCapacity [private] |
The percentage of its target employment the firm currently employs.
Definition at line 960 of file Firm.java.
Referenced by Firm.adjustEmployees().
double laborInputCoefficient [private] |
The input coefficient for labor.
Definition at line 968 of file Firm.java.
Referenced by Firm.calcNeededMoneyForProduction(), Firm.calcUnitProductionCost(), Firm.copyTechnologiesFrom(), Firm.initArraysAndMatrices(), Firm.invProdFuncLabor(), Firm.mutateInputCoefficients(), and Firm.prodFuncLabor().
double [] circulatingCapital [private] |
The current stock of goods used as circulating capital.
()
Definition at line 983 of file Firm.java.
Referenced by Firm.calcMaxProductionInclSupply(), Firm.calcNeededMoneyForProduction(), Firm.getDemandCirculating(), Firm.initArraysAndMatrices(), Firm.productionStep(), and Firm.trade().
double [] circulatingInputCoefficients [private] |
The vector of input coefficients for circulating capital.
()
Definition at line 992 of file Firm.java.
Referenced by Firm.calcMaxProduction(), Firm.calcMaxProductionInclSupply(), Firm.calcUnitProductionCost(), Firm.copyTechnologiesFrom(), Firm.initArraysAndMatrices(), Firm.invProdFuncCirculating(), Firm.isNeededCirculatingCapital(), and Firm.mutateInputCoefficients().
double [] fixedCapital [private] |
The current stock of the goods used as fixed capital.
()
Definition at line 1007 of file Firm.java.
Referenced by Firm.calcMaxProductionInclSupply(), Firm.calcNeededMoneyForProduction(), Firm.getDemandFixed(), Firm.initArraysAndMatrices(), Firm.productionStep(), Firm.trade(), and Firm.updateDesiredProduction().
double [] fixedInputCoefficients [private] |
The vector of input coefficients for fixed capital.
()
Definition at line 1016 of file Firm.java.
Referenced by Firm.calcMaxProduction(), Firm.calcMaxProductionInclSupply(), Firm.calcUnitProductionCost(), Firm.copyTechnologiesFrom(), Firm.initArraysAndMatrices(), Firm.invProdFuncFixed(), Firm.isNeededFixedCapital(), Firm.mutateInputCoefficients(), and Firm.updateDesiredProduction().
An array of Suppliers, with the size of numSectors.
Definition at line 1048 of file Firm.java.
Referenced by Firm.calcMaxProductionInclSupply(), Firm.initArraysAndMatrices(), and Firm.trade().
double desiredProduction [private] |
The desired level of production.
Definition at line 1056 of file Firm.java.
Referenced by Firm.adjustEmployees(), Firm.calcNewTargetEmployment(), Firm.init(), Firm.initArraysAndMatrices(), Firm.productionStep(), Firm.trade(), and Firm.updateDesiredProduction().
double dividend [private] |
The dividend payed by this firm for this period.
Definition at line 1064 of file Firm.java.
Referenced by Firm.account().
int periodCreated [private] |
double [] rationing [private] |
The difference between quantity demanded and actual supply.
Definition at line 1085 of file Firm.java.
Referenced by Firm.calcMaxProductionInclSupply(), Firm.init(), and Firm.trade().
double salesForecast = 0.d [private] |
The current forecast of sales.
Definition at line 1089 of file Firm.java.
Referenced by Firm.init(), and Firm.updateDesiredProduction().
double salesTrendForecast = 0.d [private] |
The current forecast of trends in sales.
Definition at line 1093 of file Firm.java.
Referenced by Firm.init(), and Firm.updateDesiredProduction().
double [] targetInvestment [private] |
The actual stock of the goods used as fixed capital.
()
Definition at line 1097 of file Firm.java.
Referenced by Firm.initArraysAndMatrices(), and Firm.trade().
double productionGap = 0 [private] |
The differencce between produced quantity and desiredProduction.
Definition at line 1101 of file Firm.java.
Referenced by Firm.productionStep().