001 /*
002 * Created on Aug 30, 2007
003 *
004 */
005 package com.x8ing.mc;
006
007 import java.io.PrintStream;
008
009 /**
010 * Simple start up in java standalone mode. Mostly for testing only!
011 *
012 * @author Patrick Heusser
013 */
014 public class Main {
015
016 final static String SEP_COLUMN = "\t";
017
018 final static String SEP_ROW = "\n";
019
020 public static void main(String[] args) {
021
022 if (args == null || args.length == 0) {
023
024 simpleRun();
025
026 } else if ("1".equals(args[0])) {
027
028 resultRunChangeSoftwareNonConformityCostAndTriggerValue(System.out);
029
030 } else if ("2".equals(args[0])) {
031
032 resultRunSingleDeepRun(System.out);
033
034 } else {
035
036 System.err.println("command not found. taking default...");
037 System.out.println("\n\n");
038
039 // do all result gatherings
040 resultRunChangeSoftwareNonConformityCostAndTriggerValue(System.out);
041 resultRunSingleDeepRun(System.out);
042
043 }
044
045 System.out.println("\n\n\n DONE. End of all runs.");
046
047 }
048
049 private static void simpleRun() {
050 System.out.println("START: simpleRun() ");
051
052 Configuration configuration = new Configuration();
053
054 MonteCarloControler mcc = new MonteCarloControler(configuration);
055 mcc.runBusinessProcessSimulation();
056
057 System.out.println(mcc.printDistribiton(100));
058 }
059
060 private static void resultRunSingleDeepRun(PrintStream ret) {
061
062 long t1 = System.currentTimeMillis();
063
064 final int numberOfSimulationDays = 180;
065 final int numberCompleteSimulationLoops = 10000;
066 final double softwareNonConfCost = 400;
067
068 ret.print(SEP_ROW + SEP_ROW + SEP_ROW + "------------------------------------------------------");
069 ret.print(SEP_ROW + "START: resultRunSingleDeepRun() ");
070 ret.print(SEP_ROW + "------------------------------------------------------");
071 ret.print(SEP_ROW + "numberOfSimulationDays=" + numberOfSimulationDays);
072 ret.print(SEP_ROW + "numberCompleteSimulationLoops=" + numberCompleteSimulationLoops);
073 ret.print(SEP_ROW + "softwareNonConfCost =" + softwareNonConfCost);
074 ret.print(SEP_ROW + "------------------------------------------------------");
075
076 Configuration configuration = new Configuration();
077
078 configuration.setNumberOfSimulationDays(numberOfSimulationDays);
079 configuration.setSoftwareInitialNoncCnformityCost(softwareNonConfCost);
080 configuration.setNumberCompleteSimulationLoops(numberCompleteSimulationLoops);
081
082 MonteCarloControler mcc = new MonteCarloControler(configuration);
083 mcc.runBusinessProcessSimulation();
084
085 ret.print(mcc.printDistribiton(100));
086
087 ret.print(SEP_ROW + configuration);
088
089 long dt = System.currentTimeMillis() - t1;
090 ret.print("\n\ntask done... time[ms]=" + dt + " time[min]=" + (dt / 1000 / 60));
091
092 }
093
094 /**
095 * change two params and display as table:
096 *
097 * changing values: softwareNonConfCost and processCostLossTrigger
098 */
099 private static String resultRunChangeSoftwareNonConformityCostAndTriggerValue(PrintStream ret) {
100
101 long t1 = System.currentTimeMillis();
102
103 final int numberOfSimulationDays = 180;
104 final int numberCompleteSimulationLoops = 10000;
105
106 final int softwareNonConfCostFrom = 100;
107 final int softwareNonConfCostTo = 2000;
108 final int softwareNonConfCostStep = 50;
109
110 final int processCostLossTriggerFrom = 100;
111 final int processCostLossTriggerTo = 1200;
112 final int processCostLossTriggerStep = 100;
113
114 ret.print(SEP_ROW + SEP_ROW + SEP_ROW + "------------------------------------------------------");
115 ret.print(SEP_ROW + "START: resultRunChangeSoftwareNonConformityCost() ");
116 ret.print(SEP_ROW + "------------------------------------------------------");
117 ret.print(SEP_ROW + "numberOfSimulationDays=" + numberOfSimulationDays);
118 ret.print(SEP_ROW + "numberCompleteSimulationLoops=" + numberCompleteSimulationLoops);
119 ret.print(SEP_ROW + "------------------------------------------------------");
120
121 // draw header
122 ret.print(SEP_ROW + "softwareNonConfCost");
123 ret.print(SEP_COLUMN);
124 for (int processCostLossTrigger = processCostLossTriggerFrom; processCostLossTrigger <= processCostLossTriggerTo; processCostLossTrigger += processCostLossTriggerStep) {
125 ret.print("processCostLossTrigger=" + processCostLossTrigger);
126 ret.print(SEP_COLUMN);
127 }
128
129 Configuration configuration = null;
130
131 // draw table
132 for (int softwareNonConfCost = softwareNonConfCostFrom; softwareNonConfCost <= softwareNonConfCostTo; softwareNonConfCost += softwareNonConfCostStep) {
133
134 ret.print(SEP_ROW);
135 ret.print(String.valueOf(softwareNonConfCost));
136 ret.print(SEP_COLUMN);
137
138 for (int processCostLossTrigger = processCostLossTriggerFrom; processCostLossTrigger <= processCostLossTriggerTo; processCostLossTrigger += processCostLossTriggerStep) {
139
140 configuration = new Configuration();
141
142 // debug
143 /*
144 * ret.print("(softwareNonConfCost=" + softwareNonConfCost + ", processCostLossTrigger=" +
145 * processCostLossTrigger + ") ");
146 */
147
148 configuration.setNumberOfSimulationDays(numberOfSimulationDays);
149 configuration.setSoftwareInitialNoncCnformityCost(softwareNonConfCost);
150 configuration.setNumberCompleteSimulationLoops(numberCompleteSimulationLoops);
151 configuration.setProcessCostLossTriggerForBugFixing(processCostLossTrigger);
152
153 MonteCarloControler mcc = new MonteCarloControler(configuration);
154 mcc.runBusinessProcessSimulation();
155
156 Statistic statistic = new Statistic(mcc.getBalanceValues());
157
158 ret.print(statistic.getAverage() + SEP_COLUMN);
159
160 }
161
162 }
163
164 // print one last config for an idea about the other params
165 ret.print(SEP_ROW + SEP_ROW + configuration);
166
167 long dt = System.currentTimeMillis() - t1;
168 ret.print("\n\ntask done... time[ms]=" + dt + " time[min]=" + (dt / 1000 / 60));
169
170 return ret.toString();
171 }
172
173 }
|