7public class InventoryCRN
extends Inventory {
9 Tally statDiff =
new Tally(
"stats on difference");
11 public InventoryCRN(
double lambda,
double c,
double h,
double K,
double k,
double p) {
12 super(lambda, c, h, K, k, p);
15 public void simulateDiffIRN(
int n,
int m,
int s1,
int S1,
int s2,
int S2) {
17 for (
int i = 0; i < n; i++) {
18 double value1 = simulate(m, s1, S1);
19 double value2 = simulate(m, s2, S2);
20 statDiff.add(value2 - value1);
24 public void simulateDiffCRN(
int n,
int m,
int s1,
int S1,
int s2,
int S2) {
26 streamDemand.resetStartStream();
27 streamOrder.resetStartStream();
28 for (
int i = 0; i < n; i++) {
29 double value1 = simulate(m, s1, S1);
30 streamDemand.resetStartSubstream();
31 streamOrder.resetStartSubstream();
32 double value2 = simulate(m, s2, S2);
33 statDiff.add(value2 - value1);
34 streamDemand.resetNextSubstream();
35 streamOrder.resetNextSubstream();
39 public static void main(String[] args) {
40 InventoryCRN system =
new InventoryCRN(100.0, 2.0, 0.1, 10.0, 1.0, 0.95);
43 system.simulateDiffIRN(500, 2000, 80, 198, 80, 200);
45 System.out.println(system.statDiff.
report(0.9, 3));
46 double varianceIndep = system.statDiff.
variance();
47 System.out.println(
"Total CPU time: " + timer.
format() +
"\n");
50 system.simulateDiffCRN(500, 2000, 80, 198, 80, 200);
51 System.out.println(system.statDiff.
report(0.9, 3));
52 double varianceCRN = system.statDiff.
variance();
53 System.out.println(
"Total CPU time: " + timer.
format());
54 System.out.printf(
"\nVariance ratio: %8.4g%n", varianceIndep / varianceCRN);