Search in sources :

Example 71 with StatSummary

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

Example 72 with StatSummary

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

Example 73 with StatSummary

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

Example 74 with StatSummary

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

Example 75 with StatSummary

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

Aggregations

StatSummary (utilities.StatSummary)88 ElapsedTimer (utilities.ElapsedTimer)27 ArrayList (java.util.ArrayList)10 JEasyFrame (utilities.JEasyFrame)8 SimpleRMHC (ga.SimpleRMHC)7 NTupleBanditEA (ntuple.NTupleBanditEA)6 EvoAlg (evodef.EvoAlg)4 Random (java.util.Random)4 LineChart (plot.LineChart)4 LineChartAxis (plot.LineChartAxis)4 StateObservationMulti (core.game.StateObservationMulti)3 DefaultMutator (evodef.DefaultMutator)3 TreeSet (java.util.TreeSet)3 Types (ontology.Types)3 LineGroup (plot.LineGroup)3 ElapsedCpuTimer (tools.ElapsedCpuTimer)3 Gson (com.google.gson.Gson)2 GsonBuilder (com.google.gson.GsonBuilder)2 AbstractMultiPlayer (core.player.AbstractMultiPlayer)2 ShortestPathTest (evomaze.ShortestPathTest)2