public class TestSPTsSimulation {
public static void main(String[] args) throws IOException {
RandomGenerator rg = new Well44497b(31);
RandomDataImpl rng = new RandomDataImpl(rg);
// warm up RNG to avoid overlap of the Table-2 job
Timer timer = new Timer();
int upperBound = Combination.choose(26, 5).intValue() - 1;
for (int i = 0; i < 130000000; ++i) {
for(int j=0; j<100; ++j){
rng.nextInt(0, upperBound);
}
}
timer.stop();
System.out.println("Warm-up is done. The time used is " + timer.getElapsedTime()/60000d + " minutes.");
// -------------------------------------------------------------
int numberOfTests = 10000;
int sizeOfFirstGroup = 8;
int sizeOfSecondGroup = 8;
int sequentialTerminationCriteria = 10;
int numberOfPermutations = 1000 - 1;
int numberOfSimulations = 1000;
// ---------- Table 3 ----------------------------
int numberOfTrueNulls = 7500;
// -----------------------------
int lambda = 1;
SPTsSimulation spt = new SPTsSimulation(rng, numberOfTests,
numberOfTrueNulls, lambda, sizeOfFirstGroup, sizeOfSecondGroup,
sequentialTerminationCriteria, numberOfPermutations,
numberOfSimulations);
String outputFile = "i-999-10-" + numberOfTrueNulls + "-" + lambda
+ ".bin";
timer.start();
spt.parSimulateIndependent(outputFile);
// spt.simulateIndependent(outputFile);
timer.stop();
System.out.println(outputFile + " is done. The time used is: "+timer.getElapsedTime()/60000d+" minutes.");
// ---------------------------------
lambda = 2;
spt.setLambda(lambda);
outputFile = "i-999-10-" + numberOfTrueNulls + "-" + lambda + ".bin";
timer.start();
spt.parSimulateIndependent(outputFile);
// spt.simulateIndependent(outputFile);
timer.stop();
System.out.println(outputFile + " is done. The time used is: "+timer.getElapsedTime()/60000d+" minutes.");
// ----------------------------------
lambda = 3;
spt.setLambda(lambda);
outputFile = "i-999-10-" + numberOfTrueNulls + "-" + lambda + ".bin";
timer.start();
spt.parSimulateIndependent(outputFile);
// spt.simulateIndependent(outputFile);
timer.stop();
System.out.println(outputFile + " is done. The time used is: "+timer.getElapsedTime()/60000d+" minutes.");
// ----------------------------------
numberOfTrueNulls = 9000;
spt.setNumberOfTrueNulls(numberOfTrueNulls);
// -----------------------
lambda = 1;
spt.setLambda(lambda);
outputFile = "i-999-10-" + numberOfTrueNulls + "-" + lambda + ".bin";
timer.start();
spt.parSimulateIndependent(outputFile);
// spt.simulateIndependent(outputFile);
timer.stop();
System.out.println(outputFile + " is done. The time used is: "+timer.getElapsedTime()/60000d+" minutes.");
// ---------------------------------
lambda = 2;
spt.setLambda(lambda);
outputFile = "i-999-10-" + numberOfTrueNulls + "-" + lambda + ".bin";
timer.start();
spt.parSimulateIndependent(outputFile);
// spt.simulateIndependent(outputFile);
timer.stop();
System.out.println(outputFile + " is done. The time used is: "+timer.getElapsedTime()/60000d+" minutes.");
// -----------------------------------
lambda = 3;
spt.setLambda(lambda);
outputFile = "i-999-10-" + numberOfTrueNulls + "-" + lambda + ".bin";
timer.start();
spt.parSimulateIndependent(outputFile);
// spt.simulateIndependent(outputFile);
timer.stop();
System.out.println(outputFile + " is done. The time used is: "+timer.getElapsedTime()/60000d+" minutes.");
// //////////////////////////////////////////////////////////////////////////////
// ------------------------ Table 4 ------------------------------
String inputFile = "/home/adu/research/nettleton/spt/mean/jdata/data-base.bin";
String falseNullsFile;
double[][] baseData = BinaryReader.readDouble(inputFile, 10000, 21);
double[] sds = standardDeviations(baseData);
// ---------------------------------------------------------------
numberOfTrueNulls = 7500;
spt.setNumberOfTrueNulls(numberOfTrueNulls);
// ------------------------------------------
lambda = 1;
spt.setLambda(lambda);
outputFile = "d-999-10-" + numberOfTrueNulls + "-" + lambda + ".bin";
falseNullsFile = "f-999-10-" + numberOfTrueNulls + "-" + lambda
+ ".bin";
timer.start();
spt.parSimulateDependent(outputFile, falseNullsFile, baseData, sds);
// spt.simulateIndependent(outputFile);
timer.stop();
System.out.println(outputFile + " is done. The time used is: "+timer.getElapsedTime()/60000d+" minutes.");
// ------------------------------------------
lambda = 2;
spt.setLambda(lambda);
outputFile = "d-999-10-" + numberOfTrueNulls + "-" + lambda + ".bin";
falseNullsFile = "f-999-10-" + numberOfTrueNulls + "-" + lambda
+ ".bin";
timer.start();
spt.parSimulateDependent(outputFile, falseNullsFile, baseData, sds);
// spt.simulateIndependent(outputFile);
timer.stop();
System.out.println(outputFile + " is done. The time used is: "+timer.getElapsedTime()/60000d+" minutes.");
// -----------------------------------------------
lambda = 3;
spt.setLambda(lambda);
outputFile = "d-999-10-" + numberOfTrueNulls + "-" + lambda + ".bin";
falseNullsFile = "f-999-10-" + numberOfTrueNulls + "-" + lambda
+ ".bin";
timer.start();
spt.parSimulateDependent(outputFile, falseNullsFile, baseData, sds);
// spt.simulateIndependent(outputFile);
timer.stop();
System.out.println(outputFile + " is done. The time used is: "+timer.getElapsedTime()/60000d+" minutes.");
// -----------------------------------------------------------------
numberOfTrueNulls = 9000;
spt.setNumberOfTrueNulls(numberOfTrueNulls);
// ---------------------------------------------
lambda = 1;
spt.setLambda(lambda);
outputFile = "d-999-10-" + numberOfTrueNulls + "-" + lambda + ".bin";
falseNullsFile = "f-999-10-" + numberOfTrueNulls + "-" + lambda
+ ".bin";
timer.start();
spt.parSimulateDependent(outputFile, falseNullsFile, baseData, sds);
// spt.simulateIndependent(outputFile);
timer.stop();
System.out.println(outputFile + " is done. The time used is: "+timer.getElapsedTime()/60000d+" minutes.");
// ------------------------------------------
lambda = 2;
spt.setLambda(lambda);
outputFile = "d-999-10-" + numberOfTrueNulls + "-" + lambda + ".bin";
falseNullsFile = "f-999-10-" + numberOfTrueNulls + "-" + lambda
+ ".bin";
timer.start();
spt.parSimulateDependent(outputFile, falseNullsFile, baseData, sds);
// spt.simulateIndependent(outputFile);
timer.stop();
System.out.println(outputFile + " is done. The time used is: "+timer.getElapsedTime()/60000d+" minutes.");
// -----------------------------------------------
lambda = 3;
spt.setLambda(lambda);
outputFile = "d-999-10-" + numberOfTrueNulls + "-" + lambda + ".bin";
falseNullsFile = "f-999-10-" + numberOfTrueNulls + "-" + lambda
+ ".bin";
timer.start();
spt.parSimulateDependent(outputFile, falseNullsFile, baseData, sds);
// spt.simulateIndependent(outputFile);
timer.stop();
System.out.println(outputFile + " is done. The time used is: "+timer.getElapsedTime()/60000d+" minutes.");
// /////////////////////////////////////////////////////////////////////////
// ------------------ more dependent simulation
// --------------------------
numberOfTrueNulls = 7500;
spt.setNumberOfTrueNulls(numberOfTrueNulls);
lambda = 2;
spt.setLambda(lambda);
// ------------------------------------------------
sequentialTerminationCriteria = 10;
spt.setSequentialTerminationCriteria(sequentialTerminationCriteria);
// ---------------------------------
numberOfPermutations = 5000 - 1;
spt.setNumberOfPermutations(numberOfPermutations);
outputFile = "d-" + numberOfPermutations + "-"
+ sequentialTerminationCriteria + "-7500-2.bin";
falseNullsFile = "f-" + numberOfPermutations + "-" + sequentialTerminationCriteria + "-7500-2.bin";
timer.start();
spt.parSimulateDependent(outputFile, falseNullsFile, baseData, sds);
// spt.simulateIndependent(outputFile);
timer.stop();
System.out.println(outputFile + " is done. The time used is: "+timer.getElapsedTime()/60000d+" minutes.");
// ---------------------------------
numberOfPermutations = 10000 - 1;
spt.setNumberOfPermutations(numberOfPermutations);
outputFile = "d-" + numberOfPermutations + "-"
+ sequentialTerminationCriteria + "-7500-2.bin";
falseNullsFile = "f-" + numberOfPermutations + "-" + sequentialTerminationCriteria + "-7500-2.bin";
timer.start();
spt.parSimulateDependent(outputFile, falseNullsFile, baseData, sds);
// spt.simulateIndependent(outputFile);
timer.stop();
System.out.println(outputFile + " is done. The time used is: "+timer.getElapsedTime()/60000d+" minutes.");
// ---------------------------------------------------------------
sequentialTerminationCriteria = 50;
spt.setSequentialTerminationCriteria(sequentialTerminationCriteria);
// -----------------------------------------------------------------
numberOfPermutations = 1000 - 1;
spt.setNumberOfPermutations(numberOfPermutations);
outputFile = "d-" + numberOfPermutations + "-"
+ sequentialTerminationCriteria + "-7500-2.bin";
falseNullsFile = "f-" + numberOfPermutations + "-" + sequentialTerminationCriteria + "-7500-2.bin";
timer.start();
spt.parSimulateDependent(outputFile, falseNullsFile, baseData, sds);
// spt.simulateIndependent(outputFile);
timer.stop();
System.out.println(outputFile + " is done. The time used is: "+timer.getElapsedTime()/60000d+" minutes.");
// -----------------------------------------------------------------
numberOfPermutations = 5000 - 1;
spt.setNumberOfPermutations(numberOfPermutations);
outputFile = "d-" + numberOfPermutations + "-"
+ sequentialTerminationCriteria + "-7500-2.bin";
falseNullsFile = "f-" + numberOfPermutations + "-" + sequentialTerminationCriteria + "-7500-2.bin";
timer.start();
spt.parSimulateDependent(outputFile, falseNullsFile, baseData, sds);
// spt.simulateIndependent(outputFile);
timer.stop();
System.out.println(outputFile + " is done. The time used is: "+timer.getElapsedTime()/60000d+" minutes.");
// -----------------------------------------------------------------
numberOfPermutations = 10000 - 1;
spt.setNumberOfPermutations(numberOfPermutations);
outputFile = "d-" + numberOfPermutations + "-"
+ sequentialTerminationCriteria + "-7500-2.bin";
falseNullsFile = "f-" + numberOfPermutations + "-" + sequentialTerminationCriteria + "-7500-2.bin";
timer.start();
spt.parSimulateDependent(outputFile, falseNullsFile, baseData, sds);
// spt.simulateIndependent(outputFile);
timer.stop();
System.out.println(outputFile + " is done. The time used is: "+timer.getElapsedTime()/60000d+" minutes.");
// ------------------------------------------------------------------
sequentialTerminationCriteria = 100;
spt.setSequentialTerminationCriteria(sequentialTerminationCriteria);
// -----------------------------------------------------------------
numberOfPermutations = 1000 - 1;
spt.setNumberOfPermutations(numberOfPermutations);
outputFile = "d-" + numberOfPermutations + "-"
+ sequentialTerminationCriteria + "-7500-2.bin";
falseNullsFile = "f-" + numberOfPermutations + "-" + sequentialTerminationCriteria + "-7500-2.bin";
timer.start();
spt.parSimulateDependent(outputFile, falseNullsFile, baseData, sds);
// spt.simulateIndependent(outputFile);
timer.stop();
System.out.println(outputFile + " is done. The time used is: "+timer.getElapsedTime()/60000d+" minutes.");
// -----------------------------------------------------------------
numberOfPermutations = 5000 - 1;
spt.setNumberOfPermutations(numberOfPermutations);
outputFile = "d-" + numberOfPermutations + "-"
+ sequentialTerminationCriteria + "-7500-2.bin";
falseNullsFile = "f-" + numberOfPermutations + "-" + sequentialTerminationCriteria + "-7500-2.bin";
timer.start();
spt.parSimulateDependent(outputFile, falseNullsFile, baseData, sds);
// spt.simulateIndependent(outputFile);
timer.stop();
System.out.println(outputFile + " is done. The time used is: "+timer.getElapsedTime()/60000d+" minutes.");
// -----------------------------------------------------------------
numberOfPermutations = 10000 - 1;
spt.setNumberOfPermutations(numberOfPermutations);
outputFile = "d-" + numberOfPermutations + "-"
+ sequentialTerminationCriteria + "-7500-2.bin";
falseNullsFile = "f-" + numberOfPermutations + "-" + sequentialTerminationCriteria + "-7500-2.bin";
timer.start();
spt.parSimulateDependent(outputFile, falseNullsFile, baseData, sds);
// spt.simulateIndependent(outputFile);
timer.stop();
System.out.println(outputFile + " is done. The time used is: "+timer.getElapsedTime()/60000d+" minutes.");
}