Search in sources :

Example 1 with NTupleSystem

use of ntuple.NTupleSystem in project SimpleAsteroids by ljialin.

the class HyperParamTuneRunner method runTrials.

public void runTrials(EvoAlg evoAlg, AnnotatedFitnessSpace annotatedFitnessSpace) {
    ElapsedTimer timer = new ElapsedTimer();
    StatSummary ss = new StatSummary("Overall results: " + evoAlg.getClass().getSimpleName());
    for (int i = 0; i < nTrials; i++) {
        System.out.println();
        System.out.println("Running trial: " + (i + 1));
        try {
            ss.add(runTrial(evoAlg, annotatedFitnessSpace));
            System.out.println("Stats so far");
            System.out.println(ss);
            if (verbose) {
                plotFitnessEvolution(annotatedFitnessSpace.logger(), annotatedFitnessSpace, plotChecks);
                // annotatedFitnessSpace.logger()
                // ((NTupleSystem) ((NTupleBanditEA) evoAlg).banditLandscapeModel).printDetailedReport(new EvoAgentSearchSpaceAsteroids().getParams());
                NTupleSystem nTupleSystem = ((NTupleSystem) ((NTupleBanditEA) evoAlg).banditLandscapeModel);
                nTupleSystem.printDetailedReport(annotatedFitnessSpace.getParams());
            // new Plotter().setModel(nTupleSystem).defaultPlot().plot1Tuples();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    if (verbose) {
        lineChart.addLineGroup(sampleEvolution);
        if (plotChecks > 0)
            lineChart.addLineGroup(bestGuess);
        new JEasyFrame(lineChart, "Sample Evolution");
    }
    System.out.println("nEvals per run: " + nEvals);
    System.out.println(ss);
    System.out.println("Total time for experiment: " + timer);
}
Also used : StatSummary(utilities.StatSummary) JEasyFrame(utilities.JEasyFrame) NTupleSystem(ntuple.NTupleSystem) ElapsedTimer(utilities.ElapsedTimer) NTupleBanditEA(ntuple.NTupleBanditEA)

Example 2 with NTupleSystem

use of ntuple.NTupleSystem 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)

Aggregations

NTupleSystem (ntuple.NTupleSystem)2 ElapsedTimer (utilities.ElapsedTimer)2 StatSummary (utilities.StatSummary)2 NTupleBanditEA (ntuple.NTupleBanditEA)1 JEasyFrame (utilities.JEasyFrame)1