package za.redbridge.experiment;

import com.beust.jcommander.JCommander;
import com.beust.jcommander.Parameter;

import org.encog.Encog;
import org.encog.ml.ea.train.EvolutionaryAlgorithm;

import za.redbridge.experiment.MMNEAT.MMNEATPopulation;
import za.redbridge.experiment.MMNEAT.MMNEATUtil;
import za.redbridge.simulator.config.SimConfig;

/**
 * Created by jamie on 2014/09/09.
 */
public class Main {

    public static void main(String[] args) {
        Args options = new Args();
        new JCommander(options, args);

        SimConfig simConfig;
        if (options.configFile != null && !options.configFile.isEmpty()) {
            simConfig = new SimConfig(options.configFile);
        } else {
            simConfig = new SimConfig();
        }

        MMNEATPopulation population = new MMNEATPopulation(4, options.numSensors, 1000);
        population.reset();

        ScoreCalculator calculateScore = new ScoreCalculator(simConfig);

        EvolutionaryAlgorithm train = MMNEATUtil.constructNEATTrainer(population, calculateScore);

        for (int i = 0; i < options.numIterations; i++) {
            train.iteration();
            System.out.println("Epoch #" + train.getIteration() + " Score: "
                    + calculateScore.getLastScore());
        }

        System.out.println("Training complete");
        Encog.getInstance().shutdown();
    }

    private static class Args {
        @Parameter(names = "-c", description = "Simulation config file to load")
        private String configFile = null;

        @Parameter(names = "-i", description = "Number of simulation iterations to train for")
        private int numIterations = 500;

        @Parameter(names = "-s", description = "Number of sensors")
        private int numSensors = 4;

        @Parameter(names = "--ui", description = "Display GUI")
        private boolean ui = false;
    }
}

@@ -792,16 +792,32 @@
 lation =
+%0A               
  new MMN
@@ -834,11 +834,8 @@
 ion(
-4, 
 opti
@@ -854,12 +854,33 @@
 rs, 
-1000
+2, options.populationSize
 );%0A 
@@ -1905,16 +1905,133 @@
 = false;
+%0A%0A        @Parameter(names = %22-p%22, description = %22Initial population size%22)%0A        private int populationSize = 100;
 %0A    %7D%0A%7D

Add parameter for population size, default to 100