/*
* File name: NeuroGPMMaster.java (package eas.users.lukas.evolvableNeuroGPM)
* Author(s): lko
* Java version: 7.0
* Generation date: 02.03.2013 (11:08:11)
*
* (c) This file and the EAS (Easy Agent Simulation) framework containing it
* is protected by Creative Commons by-nc-sa license. Any altered or
* further developed versions of this file have to meet the agreements
* stated by the license conditions.
*
* In a nutshell
* -------------
* You are free:
* - to Share -- to copy, distribute and transmit the work
* - to Remix -- to adapt the work
*
* Under the following conditions:
* - Attribution -- You must attribute the work in the manner specified by the
* author or licensor (but not in any way that suggests that they endorse
* you or your use of the work).
* - Noncommercial -- You may not use this work for commercial purposes.
* - Share Alike -- If you alter, transform, or build upon this work, you may
* distribute the resulting work only under the same or a similar license to
* this one.
*
* + Detailed license conditions (Germany):
* http://creativecommons.org/licenses/by-nc-sa/3.0/de/
* + Detailed license conditions (unported):
* http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en
*
* This header must be placed in the beginning of any version of this file.
*/
package eas.users.lukas.evolvableNeuroGPM;
import java.util.LinkedList;
import java.util.Random;
import eas.math.geometry.Vector2D;
import eas.miscellaneous.StaticMethods;
import eas.plugins.masterScheduler.AbstractDefaultMaster;
import eas.simulation.ConstantsSimulation;
import eas.simulation.Wink;
import eas.simulation.brain.neural.NeuralLinkDummyDouble;
import eas.simulation.brain.neural.NeuroBrain;
import eas.simulation.brain.neural.OldNeuroTranslator;
import eas.simulation.spatial.sim2D.standardEnvironments.AbstractEnvironment2DFast;
import eas.startSetup.ParCollection;
import eas.users.lukas.marbImplicitEvolution.gateEnvironment.GateEnvironment;
/**
* @author lko
*/
public class NeuroGPMMaster extends AbstractDefaultMaster<AbstractEnvironment2DFast<?>> {
/**
*
*/
private static final long serialVersionUID = 6454111675027283098L;
@Override
public AbstractEnvironment2DFast<?>[] generateRunnables(
ParCollection params) {
GateEnvironment env = new GateEnvironment(0, params);
for (int i = 0; i < 15; i++) {
NeuroAgent agent = new NeuroAgent(i, env, params);
NeuroBrain<NeuroAgent> brain = new NeuroBrain<NeuroAgent>(agent, params);
agent.implantBrain(brain);
env.addCollidingAgent(agent, new Vector2D(i * 40 - 500, i * 40 - 500), 10, new Vector2D(20, 20));
}
return new AbstractEnvironment2DFast<?>[] {env};
}
@Override
public String id() {
return ConstantsSimulation.DEFAULT_MASTER_SCHEDULER_ID + "-neuroGPM";
}
@Override
public synchronized void runDuringSimulation(
AbstractEnvironment2DFast<?> env, Wink simZyk, ParCollection params) {
super.runDuringSimulation(env, simZyk, params);
}
public static void main(String[] args) {
Random rand2 = new Random(0);
OldNeuroTranslator trans2 = new OldNeuroTranslator();
System.out.println("\n\n");
for (int i = 0; i < 6; i++) {
for (int j = 0; j < 6; j++) {
// if (i != j) {
NeuralLinkDummyDouble d = new NeuralLinkDummyDouble(i, j, rand2.nextDouble() - 0.5, Integer.MAX_VALUE);
trans2.applyNeuralLinkSoft(d);
// }
}
}
StaticMethods.showImage(trans2.generateNeuroImage(1000), "");
// try {Thread.sleep(1000000000);} catch (InterruptedException e) {}
LinkedList<Double> genome = trans2.translateReverseTranslatorToGenome();
System.out.println(genome);
OldNeuroTranslator trans3 = trans2.translateGenomeToTranslator(genome);
StaticMethods.showImage(trans3.generateNeuroImage(1000), "");
// System.out.println("\n\n" + genome);
// double sum = 0;
// int max = 0;
// int maxNum = 0;
// for (int i = 0; i < 1; i++) {
// NeuroTranslator trans = new NeuroTranslator();
// long seed = System.currentTimeMillis() + i;
// Random rand = new Random(seed);
// System.out.print("\n" + i + " -- " + seed + ": ");
//
// LinkedList<Double> list = new LinkedList<Double>();
// for (int i1 = 0; i1 < 180; i1++) {
// list.add((rand.nextDouble() * 2 - 1));
// }
//
// HashSet<NeuralNetwork> networks = new HashSet<NeuralNetwork>();
//
// int i1;
// for (i1 = 0; i1 < 10; i1++) {
// networks.add(trans);
//// StaticMethods.showImage(trans.generateNeuroImage(700), "(" + trans.getNeuronCount() + " neurons)");
// if (networks.size() != i1 + 1) {
// break;
// }
// trans = trans.translateGenomeToTranslator(list);
// }
//
//
// if (networks.size() > max) {
// max = networks.size();
// maxNum = i;
// }
//
// sum += networks.size();
//
// System.out.print(networks.size() + " (" + max + " (" + maxNum + ")) -- " + sum / i);
// }
}
}