00001
00002
00003
00004
00005
00007
00008 package de.pik.lagom.generic.initvalues;
00009
00010 import static de.pik.lagom.annotations.Variability.SIMULATION;
00011
00012 import java.io.Serializable;
00013 import java.util.LinkedList;
00014 import java.util.List;
00015
00016 import de.pik.lagom.annotations.Description;
00017 import de.pik.lagom.annotations.InitValue;
00018 import de.pik.lagom.annotations.NameInUI;
00019 import de.pik.lagom.annotations.Variability;
00020 import de.pik.lagom.exceptions.ValueValidationException;
00021 import de.pik.lagom.generic.productionfunction.ProductionFunctionFactory;
00022 import de.pik.lagom.toolbox.io.initvalues.InitValuesManager;
00023
00024 import net.sf.oval.constraint.NotNegative;
00025
00027 @Variability(SIMULATION)
00028 public class FirmInitValues extends InitValuesWithSectors implements Serializable {
00029 final static int UNKNOWN_PRODUCTION_FUNCTION = -1;
00037 @InitValue(inspector = "Firm", posInInspector = -600)
00038 @NameInUI("Mutation Rate")
00039 @Description("The probability that the firm's operatin characteristics are altered in the" +
00040 " mutation step")
00041 private double mutationRate = 0.01d;
00042
00050 @InitValue(inspector = "Firm", posInInspector = 1102)
00051 @NameInUI("Price Mutation Factor")
00052 @Description("The price is increased or decreased by the actual price multiplied with " +
00053 "this factor ")
00054 private double priceMutationScale = 0.01d;
00055
00060 @InitValue(inspector = "Firm", posInInspector = -700)
00061 @NameInUI("Suppliers sampling rate")
00062 @Description("The number of observed suppliers for is calculated" +
00063 " by multiplying the number of firms in the supplying sector with this quotient")
00064 private double observedFirmsQuotient = 1d;
00065
00067 @InitValue(inspector = "Firm", posInInspector = -250)
00068 @NameInUI("Dividend Rate")
00069 @Description("This rate multiplied with max(money, 0) is payed out as dividend")
00070 private double dividendRate = 0.5d;
00071
00072
00073
00074
00075
00076
00077
00079 @InitValue(inspector = "Firm", posInInspector = -200)
00080 @NameInUI("Inventory/Sales target")
00081 @Description("Target inventory to sales ratio")
00082 private double targetInventoryRatio = 2d;
00083
00084
00086 @InitValue(inspector = "Data", posInInspector = 605)
00087 @NameInUI("Debts")
00088 @Description("The total debt of firms ")
00089 private double debts = 0;
00090
00092 @InitValue(inspector = "Firm", posInInspector = -300)
00093 @NameInUI("sales forecast change rate")
00094 @Description("sales forecast change rate")
00095 private double salesForecastUpdateRate = 0.25d;
00096
00097
00098
00099
00100
00101
00102
00103 @NotNegative
00104 @InitValue(inspector = "Firm", posInInspector = 10, readOnly = true)
00105 @NameInUI("Production Function")
00106 private int productionFunction = UNKNOWN_PRODUCTION_FUNCTION;
00107
00108 @InitValue
00109 @Description("The name of the production function")
00110 private String productionFunctionName = ProductionFunctionFactory.
00111 getDefaultProductionFunctionName();
00112
00113 @NotNegative
00114 @InitValue(inspector = "Firm", posInInspector = -400)
00115 @NameInUI("Minimum labor capacity")
00116 @Description("The minimal labor capacity of the firm in terms of capital stock that can be put to work.")
00117 private double minimumLaborCapacity = 0.8;
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127 FirmInitValues(InitValuesManager pIVM) {
00128 super(pIVM);
00129 setProductionFunctionName(productionFunctionName);
00130 }
00131
00132 @Override
00133 public void validate(List<String> pWarnings) throws ValueValidationException {
00134 if (productionFunction == UNKNOWN_PRODUCTION_FUNCTION) {
00135 throw new ValueValidationException("Unknown Production Function");
00136 }
00137 }
00138
00139
00140 public double getMutationRate() {
00141 return mutationRate;
00142 }
00143
00144 public void setMutationRate(double pMutationRate) {
00145 mutationRate = pMutationRate;
00146 }
00147
00148 public double getPriceMutationScale() {
00149 return priceMutationScale;
00150 }
00151
00152 public void setPriceMutationScale(double pMutationScale) {
00153 priceMutationScale = pMutationScale;
00154 }
00155
00156 public double getObservedFirmsQuotient() {
00157 return observedFirmsQuotient;
00158 }
00159
00160 public void setObservedFirmsQuotient(double pObservedFirmsQuotient) {
00161 observedFirmsQuotient = pObservedFirmsQuotient;
00162 }
00163
00164 public double getDividendRate() {
00165 return dividendRate;
00166 }
00167
00168 public void setDividendRate(double pDividendRate) {
00169 dividendRate = pDividendRate;
00170 }
00171
00172 public double getTargetInventoryRatio() {
00173 return targetInventoryRatio;
00174 }
00175
00176 public void setTargetInventoryRatio(double pTargetInventoryRatio) {
00177 targetInventoryRatio = pTargetInventoryRatio;
00178 }
00179
00180 public List<String> domProductionFunction() {
00181 final LinkedList<String> productionFunctionNames = new LinkedList<String>();
00182 for (final String lPF : ProductionFunctionFactory.getProductionFunctionsNames()) {
00183 productionFunctionNames.add(lPF);
00184 }
00185 return productionFunctionNames;
00186 }
00187
00188 public int getProductionFunction() {
00189 return productionFunction;
00190 }
00191
00192 public void setProductionFunction(int pProductionFunction) {
00193 productionFunction = pProductionFunction;
00194
00195 int lCount = pProductionFunction;
00196 for (final String lPF : ProductionFunctionFactory.getProductionFunctionsNames()) {
00197 productionFunctionName = lPF;
00198 if (--lCount < 0) {
00199 break;
00200 }
00201 }
00202 }
00203
00204 public String getProductionFunctionName() {
00205 int lPFCounter = productionFunction;
00206 for (final String lPF : ProductionFunctionFactory.getProductionFunctionsNames()) {
00207 if (lPFCounter == 0) {
00208 return lPF;
00209 }
00210 lPFCounter--;
00211 }
00212 assert(false);
00213 return "ProductionFunction unknown";
00214 }
00215
00216 public void setProductionFunctionName(String pName) {
00217 productionFunctionName = pName;
00218 int lPFCounter = 0;
00219 for (final String lPF : ProductionFunctionFactory.getProductionFunctionsNames()) {
00220 if (lPF.equals(pName)) {
00221 productionFunction = lPFCounter;
00222 return;
00223 }
00224 lPFCounter++;
00225 }
00226
00227 productionFunction = UNKNOWN_PRODUCTION_FUNCTION;
00228 }
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238 public double getMinimumLaborCapacity() {
00239 return minimumLaborCapacity;
00240 }
00241
00242 public void setMinimumLaborCapacity(double pMinimumLaborCapacity) {
00243 minimumLaborCapacity = pMinimumLaborCapacity;
00244 }
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254 public double getDebts() {
00255 return debts;
00256 }
00257
00258 public void setDebts(double pDebts) {
00259 debts = pDebts;
00260 }
00261
00262 public double getSalesForecastUpdateRate() {
00263 return salesForecastUpdateRate;
00264 }
00265
00266 public void setSalesForecastUpdateRate(double pSalesForecastUpdateRate) {
00267 salesForecastUpdateRate = pSalesForecastUpdateRate;
00268 }
00269 }
00270
00272