Search in sources :

Example 51 with ElapsedTimer

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;
}
Also used : StatSummary(utilities.StatSummary) NTupleSystem(ntuple.NTupleSystem) ElapsedTimer(utilities.ElapsedTimer)

Example 52 with ElapsedTimer

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);
}
Also used : ElapsedTimer(utilities.ElapsedTimer)

Example 53 with ElapsedTimer

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();
}
Also used : ElapsedTimer(utilities.ElapsedTimer)

Example 54 with ElapsedTimer

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);
}
Also used : StatSummary(utilities.StatSummary) ElapsedTimer(utilities.ElapsedTimer)

Example 55 with ElapsedTimer

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);
}
Also used : StatSummary(utilities.StatSummary) ElapsedTimer(utilities.ElapsedTimer)

Aggregations

ElapsedTimer (utilities.ElapsedTimer)63 StatSummary (utilities.StatSummary)27 Random (java.util.Random)12 SimpleRMHC (ga.SimpleRMHC)9 Types (ontology.Types)9 ElapsedCpuTimer (tools.ElapsedCpuTimer)9 EvoAlg (evodef.EvoAlg)7 NTupleBanditEA (ntuple.NTupleBanditEA)7 JEasyFrame (utilities.JEasyFrame)7 ArrayList (java.util.ArrayList)6 AbstractPlayer (core.player.AbstractPlayer)5 Gson (com.google.gson.Gson)4 Agent (controllers.singlePlayer.ea.Agent)4 StateObservationMulti (core.game.StateObservationMulti)4 StateObservation (core.game.StateObservation)3 AbstractMultiPlayer (core.player.AbstractMultiPlayer)3 GameParameters (evogame.GameParameters)3 ConvNTuple (ntuple.ConvNTuple)3 SlidingMeanEDA (ntuple.SlidingMeanEDA)3 SimpleMaxGame (altgame.SimpleMaxGame)2