Search in sources :

Example 16 with StatSummary

use of utilities.StatSummary in project SimpleAsteroids by ljialin.

the class CompactBinaryGA method fitness.

static StatSummary fitness(SolutionEvaluator evaluator, int[] sol, int nSamples) {
    StatSummary ss = new StatSummary();
    for (int i = 0; i < nSamples; i++) {
        double fitness = evaluator.evaluate(sol);
        ss.add(fitness);
    }
    return ss;
}
Also used : StatSummary(utilities.StatSummary)

Example 17 with StatSummary

use of utilities.StatSummary in project SimpleAsteroids by ljialin.

the class ConvNTuple method report.

public void report(SolutionEvaluator evaluator) {
    System.out.println();
    System.out.println("Indexes used: " + sampleDis.statMap.size());
    System.out.println();
    if (!verbose)
        return;
    StatSummary errorStats = new StatSummary();
    RankCorrelation rankCorrelation = new RankCorrelation();
    int index = 0;
    for (int[] p : solutions) {
        // System.out.println(countOnes(p) + " : " + getMeanEstimate(p) + " : " + Arrays.toString(p));
        double fitness = evaluator.evaluate(p);
        double estimate = getMeanEstimate(p);
        errorStats.add(Math.abs(fitness - estimate));
        rankCorrelation.add(index++, fitness, estimate);
    }
    System.out.println("Error Stats");
    System.out.println(errorStats);
    System.out.println();
    rankCorrelation.rankCorrelation();
}
Also used : StatSummary(utilities.StatSummary)

Example 18 with StatSummary

use of utilities.StatSummary in project SimpleAsteroids by ljialin.

the class ConvNTuple method getMeanEstimate.

@Override
public Double getMeanEstimate(int[] x) {
    StatSummary ssTot = new StatSummary("Summary stats exploit");
    for (int[] index : indices) {
        double address = address(x, index);
        StatSummary ss = sampleDis.statMap.get(address);
        if (ss != null && ss.n() > 0) {
            if (useWeightedMean) {
                ssTot.add(ss);
            } else {
                ssTot.add(ss.mean());
            }
        }
    }
    // need to cope with an empty summary
    if (ssTot.n() == 0)
        ssTot.add(defaultMeanEstimate);
    // System.out.println();
    return ssTot.mean();
}
Also used : StatSummary(utilities.StatSummary)

Example 19 with StatSummary

use of utilities.StatSummary in project SimpleAsteroids by ljialin.

the class ConvNTuple method report.

public void report() {
    StatSummary errorStats = new StatSummary();
    for (int[] p : solutions) {
        // System.out.println(countOnes(p) + " : " + getMeanEstimate(p) + " : " + Arrays.toString(p));
        errorStats.add(Math.abs(countOnes(p) - getMeanEstimate(p)));
    }
    // System.out.println("Error Stats");
    // System.out.println(errorStats);
    System.out.println("Indexes used: " + sampleDis.statMap.size());
}
Also used : StatSummary(utilities.StatSummary)

Example 20 with StatSummary

use of utilities.StatSummary in project SimpleAsteroids by ljialin.

the class GeneMeanModel method generate.

public int generate() {
    double alpha = gainFactor / nValues;
    // add the numbers to ...
    StatSummary rangeStats = new StatSummary();
    // find the range
    // but ensure it's not too small
    rangeStats.add(0);
    rangeStats.add(1);
    for (StatSummary ss : stats) {
        if (ss.n() > 0) {
            rangeStats.add(ss.mean());
        }
    }
    // double range = rangeStats.max() - rangeStats.min();
    // having got the range we now map these values in to the new range
    // when computing the softmax function
    RangeMapper map = new RangeMapper(rangeStats.min(), rangeStats.max(), 0, alpha);
    // now put all the numbers through the map
    double totExp = 0;
    for (StatSummary ss : stats) {
        totExp += Math.exp(map.map(safeMean(ss)));
    // System.out.println("Summing exp denom: " + totExp + " <- " + map.map(safeMean(ss)));
    }
    // now pick one
    // System.out.println("Tot exp = " + totExp);
    double x = random.nextDouble() * totExp;
    double tot = 0;
    for (int i = 0; i < nValues; i++) {
        tot += Math.exp(map.map(safeMean(i)));
        if (x <= tot)
            return i;
    }
    throw new RuntimeException("Failed to return a valid option in GenePairedModel");
}
Also used : StatSummary(utilities.StatSummary) RangeMapper(utilities.RangeMapper)

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