Search in sources :

Example 6 with StatSummary

use of utilities.StatSummary in project SimpleAsteroids by ljialin.

the class SpaceBattleLinkTest method main.

public static void main(String[] args) {
    StatSummary ss = new StatSummary();
    int nTrials = 10;
    ElapsedTimer t = new ElapsedTimer();
    for (int i = 0; i < nTrials; i++) {
        System.out.println("Trial: " + i);
        ss.add(runTrial(runVisible));
        System.out.println();
    }
    System.out.println(ss);
    System.out.println();
    System.out.println(t);
}
Also used : StatSummary(utilities.StatSummary) ElapsedTimer(utilities.ElapsedTimer)

Example 7 with StatSummary

use of utilities.StatSummary 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 8 with StatSummary

use of utilities.StatSummary in project SimpleAsteroids by ljialin.

the class HyperParamTuneRunner method plotFitnessEvolution.

private void plotFitnessEvolution(EvolutionLogger logger, AnnotatedFitnessSpace eval, int plotChecks) {
    // the idea is to also add a new line group showing how the actual fitness evolved
    // versus the solutions that were sampled
    ArrayList<Double> data = new ArrayList<>();
    data.addAll(logger.fa);
    // System.out.println(data);
    // System.out.println(data.size());
    sampleEvolution.add(data);
    ArrayList<Double> bests = new ArrayList<>();
    // now this will be slow, but for now just sample every now and then ...
    for (int[] solution : logger.bestYetSolutions) {
        // System.out.println(Arrays.toString(solution));
        StatSummary ss = new StatSummary();
        for (int i = 0; i < plotChecks; i++) ss.add(eval.evaluate(solution));
        bests.add(ss.mean());
    }
    if (plotChecks > 0) {
        System.out.println("Bests: " + bests);
        bestGuess.add(bests);
    }
// lineChart.addLine(new LinePlot().setData(data).setRandomColor());
}
Also used : StatSummary(utilities.StatSummary) ArrayList(java.util.ArrayList)

Example 9 with StatSummary

use of utilities.StatSummary in project SimpleAsteroids by ljialin.

the class NTuple method add.

public void add(int[] x, StatSummary ssIncoming) {
    // for each address that occurs, we're going to store something
    StatSummary ss = getStatsForceCreate(x);
    ss.add(ssIncoming);
    nSamples++;
}
Also used : StatSummary(utilities.StatSummary)

Example 10 with StatSummary

use of utilities.StatSummary in project SimpleAsteroids by ljialin.

the class NTuple method printNonEmpty.

public void printNonEmpty() {
    TreeSet<IntArrayPattern> orderedKeys = new TreeSet<>();
    orderedKeys.addAll(ntMap.keySet());
    for (IntArrayPattern key : orderedKeys) {
        StatSummary ss = ntMap.get(key);
        System.out.println(key + "\t " + ss.n() + "\t " + ss.mean() + "\t " + ss.sd());
    }
}
Also used : StatSummary(utilities.StatSummary) TreeSet(java.util.TreeSet)

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