e03ec1d666c28cbba099269b15edccd603f4ac60
[IRC.git] / Robust / src / Benchmarks / Scheduling / GC / NON_BAMBOO / JGFMonteCarlo / AppDemoRunner.java
1 class AppDemoRunner {
2
3   public String header;
4   public String name;
5   public int startDate;
6   public int endDate;
7   public float dTime;
8   public int returnDefinition;
9   public float expectedReturnRate;
10   public float volatility;
11   public int nTimeSteps;
12   public float pathStartValue;
13
14   int id, nRunsMC, group;
15   //ToInitAllTasks toinitalltasks;
16   public Vector results;
17
18   public AppDemoRunner(int id,
19       int nRunsMC, 
20       int group, 
21       AppDemo ad
22       /*ToInitAllTasks initalltask*/) {
23     this.id = id;
24     this.nRunsMC=nRunsMC;
25     this.group = group;
26     this.results = new Vector();
27
28     //this.header = initalltask.header;
29     this.name = ad.name;
30     this.startDate = ad.startDate;
31     this.endDate = ad.endDate;
32     this.dTime = ad.dTime;
33     this.returnDefinition = ad.returnDefinition;
34     this.expectedReturnRate = ad.expectedReturnRate;
35     this.volatility = ad.volatility;
36     this.nTimeSteps = ad.nTimeStepsMC;
37     this.pathStartValue = ad.pathStartValue;
38   }
39
40   public void run() {
41     // Now do the computation.
42     int ilow, iupper, slice;
43     int gp = this.group;
44     int index = this.id;
45     int nruns = this.nRunsMC;
46
47     slice = (nruns + gp-1)/gp;
48
49     ilow = index*slice;
50     iupper = (index+1)*slice;
51     if (index==gp-1) {
52       iupper=nruns;
53     }
54
55     for(int iRun=ilow; iRun < iupper; iRun++ ) {
56       //String header="MC run "+String.valueOf(iRun);
57       PriceStock ps = new PriceStock();
58       ps.setInitAllTasks(this);
59       ps.setTask(/*header, */(long)iRun*11);
60       ps.run();
61       results.addElement(ps.getResult());
62     }
63   }
64   public static void main(String[] args) {
65     int datasize = 10000;  //should be times of 2
66     int nruns = 62 * 62;  //16 * 16;
67     int group = 62; // 16;
68
69     AppDemo ad = new AppDemo(datasize, nruns, group);
70     ad.initSerial();
71
72     for(int i = 0; i < group; i++) {
73       AppDemoRunner adr = new AppDemoRunner(i, nruns, group, ad);
74       adr.run();
75     }
76   }
77 }