use of utilities.StatSummary in project SimpleAsteroids by ljialin.
the class GameActionSpaceAdapterMulti method reset.
@Override
public void reset() {
// no action is needed apart from resetting the count;
// the state is defined by the stateObservation that is passed to this
logger.reset();
deltas = new StatSummary();
linePlots = new ArrayList<>();
nEvals = 0;
}
use of utilities.StatSummary in project SimpleAsteroids by ljialin.
the class TestEA method runTrials.
public static StatSummary runTrials(EvoAlg ea, SolutionEvaluator evaluator, SolutionEvaluator noiseFree, int nTrials, int nFitnessEvals) {
// record the time stats
StatSummary ss = new StatSummary();
ssOpt = new StatSummary();
nOpt = new StatSummary();
ntOpt = new StatSummary();
ntPerf = new StatSummary();
for (int i = 0; i < nTrials; i++) {
ElapsedTimer t = new ElapsedTimer();
evaluator.reset();
NTupleSystem nts = new NTupleSystem();
nts.setSearchSpace(evaluator.searchSpace());
ea.setModel(nts);
ea.runTrial(evaluator, nFitnessEvals);
// System.out.println("Ran the trial");
// System.out.println(t);
// foundOpt is 1 if the optimum was visted, zero otherwise
int foundOpt = evaluator.logger().nOptimal() > 0 ? 1 : 0;
// evaluator.logger().nOptimal() );
nOpt.add(foundOpt);
// System.out.println(t);
// evaluator.logger().report();
// System.out.println();
double trueFit = noiseFree.evaluate(evaluator.logger().finalSolution());
// System.out.println("\t True fit = " + trueFit);
ss.add(trueFit);
ssOpt.add(trueFit == evaluator.searchSpace().nDims() ? 1 : 0);
// nts.printDetailedReport();
if (nts != null) {
double ntFit = noiseFree.evaluate(nts.getBestSolution());
ntPerf.add(ntFit == evaluator.searchSpace().nDims() ? 1 : 0);
ntOpt.add(ntFit);
}
// System.out.println("Retrieved from the N-Tuple");
// System.out.println(t);
// System.out.println();
// System.out.println();
}
return ss;
}
use of utilities.StatSummary in project SimpleAsteroids by ljialin.
the class TestFHT method resetStats.
public void resetStats() {
trueFit = new StatSummary("true fitness stats");
nTrueOpt = new StatSummary("n true optima");
nFalseOpt = new StatSummary("FHT optima");
}
use of utilities.StatSummary in project SimpleAsteroids by ljialin.
the class TestFHT method main.
public static void main(String[] args) {
int nSamples = 1;
SimpleRMHC rmhc = new SimpleRMHC(nSamples);
// now perform the evaluation with and without FHT
// in order to do this we need access to the solution
int nDims = 10;
// make this 2 for bit strings
int mValues = 2;
double noise = 1.0;
NoisySolutionEvaluator evaluator = new EvalMaxM(nDims, mValues, noise);
// evaluator = new EvalNoisyWinRate(nDims, mValues, noise);
int nReps = 10000;
int nFitnessEvals = 500;
TestFHT testFHT = new TestFHT(evaluator, nFitnessEvals);
DefaultMutator.defaultPointProb = 1;
// DefaultMutator.flipAtLeastOneValueDefault = false;
System.out.println("Problem: " + evaluator.getClass().getSimpleName());
System.out.println("N Fitness Evals: " + nFitnessEvals);
System.out.println("Noise: " + noise);
System.out.println("N Dimensions: " + nDims);
System.out.println("n Resamples: " + nSamples);
System.out.println("Algorithm: " + rmhc.getClass().getSimpleName());
System.out.println("Flip at least one? " + DefaultMutator.flipAtLeastOneValueDefault);
System.out.println("Mutation probability: " + DefaultMutator.defaultPointProb);
StatSummary nEvals = new StatSummary("nEvals");
for (int i = 0; i < nReps; i++) {
// System.out.println("Trial: " + i);
foundOpt = false;
testFHT.runTrial(rmhc);
nEvals.add(evaluator.nEvals());
check.add(foundOpt ? 1 : 0);
// System.out.println(testFHT.nTrueOpt);
// System.out.println(testFHT.trueFit);
// System.out.println(testFHT.nFalseOpt);
// System.out.println();
}
System.out.println(nEvals);
System.out.println("Final results:");
System.out.println(testFHT.trueFit);
System.out.println(testFHT.nTrueOpt);
System.out.println();
System.out.println(testFHT.nFalseOpt);
System.out.println();
System.out.println(check);
}
use of utilities.StatSummary in project SimpleAsteroids by ljialin.
the class ShortestPathTest method main.
public static void main(String[] args) {
int n = 16;
int nReps = 5;
StatSummary ssTimes = new StatSummary();
StatSummary ssResults = new StatSummary();
for (int i = 0; i < nReps; i++) {
ElapsedTimer et = new ElapsedTimer();
Integer shortest = runOnce(n);
if (shortest != null)
ssResults.add(shortest);
ssTimes.add(et.elapsed());
}
System.out.println("Results");
System.out.println(ssResults);
System.out.println("Times");
System.out.println(ssTimes);
}
Aggregations