use of utilities.ElapsedTimer 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.ElapsedTimer in project SimpleAsteroids by ljialin.
the class RandomGameVisualTest method main.
public static void main(String[] args) {
EvolvableParams evolvableParams = new EvolvableParams();
System.out.println(evolvableParams);
GameParameters params = new GameParameters().injectValues(evolvableParams);
int startLevel = 1;
int nLives = 5;
boolean visible = true;
int nTicks = 10000;
AsteroidsGameState gameState = new AsteroidsGameState().setParams(params).initForwardModel();
Game game = new Game(gameState, visible);
ElapsedTimer t = new ElapsedTimer();
game.run(nTicks);
System.out.println(t);
// System.out.println(gameState.fo);
}
use of utilities.ElapsedTimer in project SimpleAsteroids by ljialin.
the class SimpleEvaluator method evaluateOnce.
public double evaluateOnce(ParamValues evoParams) {
// this evaluator optimises for a high score
// using a particular agent and given a number
// of game ticks
GameParameters params = new GameParameters().injectValues(evoParams);
boolean visible = false;
int nTicks = 1000;
AsteroidsGameState gameState = new AsteroidsGameState().setParams(params).initForwardModel();
Game game = new Game(gameState, visible);
ElapsedTimer t = new ElapsedTimer();
game.run(nTicks);
System.out.println(t);
System.out.println(gameState.getScore());
return gameState.getScore();
}
use of utilities.ElapsedTimer 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);
}
use of utilities.ElapsedTimer in project SimpleAsteroids by ljialin.
the class RMHCMazeTest method main.
public static void main(String[] args) {
int dim = 225;
int nReps = 30;
StatSummary ss = new StatSummary();
ElapsedTimer t = new ElapsedTimer();
for (int i = 0; i < nReps; i++) {
double score = runTest(dim);
System.out.println(i + "\t " + score);
ss.add(score);
}
// BarChart.display(means, "OneMax Scaling");
System.out.println(t);
System.out.println(ss);
}
Aggregations