|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||
java.lang.Object | +--SimulationStats
A class which hold all of the statistics for a Simulation or set of simulations. Provides ways to store the waiting time for all parties, as well as methods to display the results of the experiments
Tester,
Simulation| Field Summary | |
private int[] |
counts
How many of each party size has finished eating. |
private static java.text.DecimalFormat |
formatter
Used for pretty printing. |
private int |
runCount
The number of Simulations this SimulationStats is keeping track of |
private double |
runTime
The total run time for all Simulations this SimulationStats is keeping track of |
private double[][] |
waitTimes
The waiting times for the various parties. |
| Constructor Summary | |
SimulationStats(int[] partyCounts)
Initializes all stat keepers based upon expected party sizes |
|
SimulationStats(SimulationStats set1,
SimulationStats set2)
Creates a new set of SimulationStats by combining two sets of stats. |
|
| Method Summary | |
void |
addRunTime(double time)
Adds the total running time for a Simulation to this set of stats |
void |
addWaitTime(double time,
int partySize)
Adds a new waiting time for a specified party size to the statistics. |
private double |
average(double[] times,
int count)
Computes and returns the average of all values in an array |
private int |
countNonZero(double[] times)
Counts and returns the number of non-zero elements in a specified array |
private double[] |
expand(double[] values,
int multiplier)
Converts an array of values into an expanded array of values by duplicating each value in the array multiplier number of times. |
java.lang.String |
getHeader()
Returns a header which shows the meaning of all output values |
double |
getRunTime()
Returns the run times for this set of statistics |
private void |
insert(double value,
double[] values,
int maxIndex)
Inserts a value into an array of values, such that the array remains in sorted order. |
private double |
median(double[] values,
int count)
Computes and returns the median value in a sorted array of values |
private double[] |
merge(double[] vals1,
int counts1,
double[] vals2,
int counts2)
Merges two arrays, already assumed to be in sorted order, into a larger array in sorted order. |
java.lang.String |
toString()
Returns a summary of all statistics in this set of stats |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
private double[][] waitTimes
private int[] counts
private int runCount
private double runTime
private static java.text.DecimalFormat formatter
| Constructor Detail |
public SimulationStats(int[] partyCounts)
partyCounts - the number of parties of each size expected.
The index number corresponds to the party size
public SimulationStats(SimulationStats set1,
SimulationStats set2)
set1 - the first set of statsset2 - the second set of stats| Method Detail |
private double[] merge(double[] vals1,
int counts1,
double[] vals2,
int counts2)
vals1 - one set of values to mergecounts1 - the number of valid items in vals1. It is
expected that 0 <= counts1 < vals1.lengthvals2 - another set of values to mergecounts1 - the number of valid items in vals2. It is
expected that 0 <= counts2 < vals2.length
public void addWaitTime(double time,
int partySize)
time - the amount of time the party waitedpartySize - the size of the waiting partypublic void addRunTime(double time)
time - the amount of time it took to run the simulationpublic double getRunTime()
private void insert(double value,
double[] values,
int maxIndex)
value - the value to be inserted. the value will be
inserted in the range [0, maxIndex]values - an array of values in sorted ordermaxIndex - the maximum possible index the value could be insertedpublic java.lang.String getHeader()
public java.lang.String toString()
private double[] expand(double[] values,
int multiplier)
and multiplier were 3, the returned array would be
values - an array of values to be expandedmultiplier - how many times to repeat each value in the arrayprivate int countNonZero(double[] times)
private double median(double[] values,
int count)
values - a sorted array of valuescount - the number of valid entries in the array. It is
expected that 0 < count < values.length
private double average(double[] times,
int count)
values - the values in the arraycount - the number of valid entries in the array. It is
expected that 0 < count < values.length
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||