All Downloads are FREE. Search and download functionalities are using the official Maven repository.

exp-examples.robot-vs-nav.txt Maven / Gradle / Ivy

The newest version!
$descBehav1 = ds.e.n.x(of = ds.e.n.finalRobotP(of = ea.f.simOutcome(of = ea.f.quality())))
$descBehav2 = ds.e.n.y(of = ds.e.n.finalRobotP(of = ea.f.simOutcome(of = ea.f.quality())))
$descBody1 = f.avg(of = f.pairFirst(of = ea.f.genotype()))
$descBody2 = f.sd(of = f.pairFirst(of = ea.f.genotype()))
$coDescBody1 = f.avg(of = ea.f.genotype())
$coDescBody2 = f.sd(of = ea.f.genotype())
$descBrainSize1 = ea.f.treeSize(of = f.nTh(of = f.pairSecond(of = ea.f.genotype()); n = 0))
$descBrainSize2 = ea.f.treeSize(of = f.nTh(of = f.pairSecond(of = ea.f.genotype()); n = 1))
$coDescBrainSize1 = ea.f.treeSize(of = f.nTh(of = ea.f.genotype(); n = 0))
$coDescBrainSize2 = ea.f.treeSize(of = f.nTh(of = ea.f.genotype(); n = 1))
$descBrainUsage1 = f.mathOp(of = f.pairSecond(of = ea.f.genotype()); op = add; args = [
  ea.f.treeSize(of = f.nTh(n = 0));
  ea.f.treeSize(of = f.nTh(n = 1))
])
$descBrainUsage2 = f.mathOp(of = f.pairSecond(of = ea.f.genotype()); op = add; args = [
  f.size(of = f.filter(of = f.distinct(of = ea.f.treeLeaves(of = f.nTh(n = 0))); condition = predicate.matches(f = f.toString(); regex = "i[0-9]+")));
  f.size(of = f.filter(of = f.distinct(of = ea.f.treeLeaves(of = f.nTh(n = 1))); condition = predicate.matches(f = f.toString(); regex = "i[0-9]+")))
])
$coDescBrainUsage1 = f.mathOp(of = ea.f.genotype(); op = add; args = [
  ea.f.treeSize(of = f.nTh(n = 0));
  ea.f.treeSize(of = f.nTh(n = 1))
])
$coDescBrainUsage2 = f.mathOp(of = ea.f.genotype(); op = add; args = [
  f.size(of = f.filter(of = f.distinct(of = ea.f.treeLeaves(of = f.nTh(n = 0))); condition = predicate.matches(f = f.toString(); regex = "i[0-9]+")));
  f.size(of = f.filter(of = f.distinct(of = ea.f.treeLeaves(of = f.nTh(n = 1))); condition = predicate.matches(f = f.toString(); regex = "i[0-9]+")))
])
$telegram = ea.c.telegram(botIdFilePath = "/home/eric/Documenti/experiments/tlg.txt"; chatId = "207490209")
$evolutionProblem = ea.p.simTo(
  simulation = ds.s.variableSensorPositionsNavigation(arena = b_maze; nOfSensors = 9; finalT = 20);
  f = ds.e.n.avgD();
  type = minimize
)
$validationProblem = ea.p.simTo(
  simulation = ds.s.variableSensorPositionsNavigation(arena = c_maze; nOfSensors = 9; finalT = 20);
  f = ds.e.n.avgD();
  type = minimize
)
$popSuccess = f.size(of = f.filter(
  of = f.each(
    of = ea.f.all();
    mapF = ds.e.n.finalD(of = ea.f.simOutcome(of = ea.f.quality()))
  );
  condition = predicate.lt(t = 0.05);
  format = "%3d"
))

ea.experiment(
  runs = (randomGenerator = (seed = [1:1:3]) * [m.defaultRG()]) *
  (solver = (nEval = [5000]) * + (strategy = [
    random;
    smoothed_local_best;
    local_best;
    global_best;
    central;
    identity
  ]) * [
    ea.s.coMapElites(
      representation1 = ea.representation.doubleString();
      representation2 = ea.representation.multiSRTree();
      mapper1 = ea.m.identity();
      mapper2 = ea.mapper.nmrfToNds(of = ea.mapper.multiSrTreeToNmrf());
      merger = ea.m.identity();
      neighborRadius = 1.1;
      descriptors1 = [
        ea.s.me.d.descriptor(f = $coDescBody1; min = -1.57; max = 1.57; nOfBins = 10);
        ea.s.me.d.descriptor(f = $coDescBody2; min = 0; max = 3.14; nOfBins = 10)
      ];
      descriptors2 = [
        ea.s.me.d.descriptor(f = $coDescBrainUsage1; min = 0; max = 500; nOfBins = 10);
        ea.s.me.d.descriptor(f = $coDescBrainUsage2; min = 0; max = 20; nOfBins = 10)
      ]
    )
  ] + 0 *
    (mapper = [ea.mapper.pair(second = ea.mapper.nmrfToNds(of = ea.mapper.multiSrTreeToNmrf()))]) * [
    ea.s.ga(
      representation = ea.representation.pair(first = ea.representation.doubleString(); second = ea.representation.multiSRTree())
    );
    ea.s.mapElites(
      name = "me2-pos";
      representation = ea.representation.pair(first = ea.representation.doubleString(); second = ea.representation.multiSRTree());
      descriptors = [
        ea.s.me.d.descriptor(f = $descBehav1; min = 0; max = 1; nOfBins = 10);
        ea.s.me.d.descriptor(f = $descBehav2; min = 0; max = 1; nOfBins = 10)
      ]
    );
    ea.s.mapElites(
      name = "me2-body";
      representation = ea.representation.pair(first = ea.representation.doubleString(); second = ea.representation.multiSRTree());
      descriptors = [
        ea.s.me.d.descriptor(f = $descBody1; min = -1.57; max = 1.57; nOfBins = 10);
        ea.s.me.d.descriptor(f = $descBody2; min = 0; max = 3.14; nOfBins = 10)
      ]
    );
    ea.s.mapElites(
      name = "me2-brain-sizes";
      representation = ea.representation.pair(first = ea.representation.doubleString(); second = ea.representation.multiSRTree());
      descriptors = [
        ea.s.me.d.descriptor(f = $descBrainSize1; min = 10; max = 410; nOfBins = 10);
        ea.s.me.d.descriptor(f = $descBrainSize2; min = 10; max = 410; nOfBins = 10)
      ]
    );
    ea.s.mapElites(
      name = "me2-brain-size-usage";
      representation = ea.representation.pair(first = ea.representation.doubleString(); second = ea.representation.multiSRTree());
      descriptors = [
        ea.s.me.d.descriptor(f = $descBrainUsage1; min = 0; max = 500; nOfBins = 10);
        ea.s.me.d.descriptor(f = $descBrainUsage2; min = 0; max = 20; nOfBins = 10)
      ]
    );
    ea.s.mapElites(
      name = "me4-body+brain-sizes";
      representation = ea.representation.pair(first = ea.representation.doubleString(); second = ea.representation.multiSRTree());
      descriptors = [
        ea.s.me.d.descriptor(f = $descBody1; min = -1.57; max = 1.57; nOfBins = 10);
        ea.s.me.d.descriptor(f = $descBody2; min = 0; max = 3.14; nOfBins = 10);
        ea.s.me.d.descriptor(f = $descBrainSize1; min = 10; max = 410; nOfBins = 10);
        ea.s.me.d.descriptor(f = $descBrainSize2; min = 10; max = 410; nOfBins = 10)
      ]
    );
    ea.s.mapElites(
      name = "me4-body+brain-size-usage";
      representation = ea.representation.pair(first = ea.representation.doubleString(); second = ea.representation.multiSRTree());
      descriptors = [
        ea.s.me.d.descriptor(f = $descBody1; min = -1.57; max = 1.57; nOfBins = 10);
        ea.s.me.d.descriptor(f = $descBody2; min = 0; max = 3.14; nOfBins = 10);
        ea.s.me.d.descriptor(f = $descBrainUsage1; min = 0; max = 500; nOfBins = 10);
        ea.s.me.d.descriptor(f = $descBrainUsage2; min = 0; max = 20; nOfBins = 10)
      ]
    )
  ]) *
  [ea.run(
    problem = $evolutionProblem
  )];
  listeners = [
    ea.l.console(
      functions = [
        ea.f.simQuality(of = ea.f.quality(of = ea.f.best()); format = "%7.5f");
        ds.e.n.finalD(of = ea.f.simOutcome(of = ea.f.quality(of = ea.f.best())); format = "%7.5f");
        $popSuccess
      ];
      onlyLast = true
    );
    ea.l.onRunDone(
      of = ea.acc.lastBest();
      preprocessor = ea.f.toVideo(video = ea.misc.toVideo(drawer = ds.d.navigation()); of = ea.f.simOutcome(of = ea.f.quality()));
      consumers = [
        % $telegram;
        ea.c.saver(path = "../RESULTS/{name}/{startTime}/{run.solver.name}/best-traj-{run.randomGenerator.seed:%03d}")
      ]
    );
    ea.l.onRunDone(
      of = ea.acc.lastBest();
      preprocessor = ea.f.toImage(image = ds.d.navigation(); of = ea.f.simOutcome(of = ea.f.quality()));
      consumers = [
        % $telegram;
        ea.c.saver(path = "../RESULTS/{name}/{startTime}/{run.solver.name}/best-traj-{run.randomGenerator.seed:%03d}")
      ]
    );
    ea.l.savePlotForRun(
      path = "../RESULTS/{name}/{startTime}/{run.solver.name}/evo-vs-validation-{run.randomGenerator.seed:%03d}";
      plot = ea.plot.s.populationValidation(
        q = ea.f.simQuality();
        v = ea.f.fromProblem(problem = $validationProblem)
      );
      processor = ea.f.imagePlotter(secondary = true; independences = [])
    );
    ea.l.saveForRun(
      path = "../RESULTS/{name}/{startTime}/{run.solver.name}/best-validation-traj-{run.randomGenerator.seed:%03d}";
      of = ea.acc.last(eFunction = ea.f.solution(of = ea.f.best()));
      processor = ea.f.toImage(image = ds.d.navigation(); of = ea.f.simOutcome(of = $validationProblem))
    );
    ea.l.saveForRun(
      path = "../RESULTS/{name}/{startTime}/{run.solver.name}/trajs-{run.randomGenerator.seed:%03d}";
      of = ea.acc.bests();
      processor = ea.f.toImagesVideo(image = ds.d.navigation(); of = f.each(mapF = ea.f.simOutcome(of = ea.f.quality())))
    );
    ea.l.saveForRun(
      path = "../RESULTS/{name}/{startTime}/{run.solver.name}/archive-{run.randomGenerator.seed:%03d}";
      of = ea.plot.single.me(q = ea.f.simQuality(); condition = predicate.always());
      processor = ea.f.videoPlotter();
      condition = predicate.matches(f = ea.f.runKey(key = "run.solver.name"); regex = "me2-.*")
    );
    ea.l.savePlotForRun(
      path = "../RESULTS/{name}/{startTime}/{run.solver.name}/archive-{run.randomGenerator.seed:%03d}";
      plot = ea.plot.single.me(q = ea.f.simQuality());
      condition = predicate.matches(f = ea.f.runKey(key = "run.solver.name"); regex = "me2-.*")
    );
    ea.l.savePlotForRun(
      path = "../RESULTS/{name}/{startTime}/{run.solver.name}/archives-{run.randomGenerator.seed:%03d}";
      plot = ea.plot.single.coMe(q = ea.f.simQuality());
      condition = predicate.matches(f = ea.f.runKey(key = "run.solver.name"); regex = "coMe-.*")
    );
    ea.l.savePlotForRun(
      path = "../RESULTS/{name}/{startTime}/{run.solver.name}/come-strategy-{run.randomGenerator.seed:%03d}";
      plot = ea.plot.single.coMeStrategies();
      condition = predicate.matches(f = ea.f.runKey(key = "run.solver.name"); regex = "coMe-.*")
    );
    ea.l.onExpDone(
      of = ea.plot.multi.quality(q = ea.f.simQuality());
      consumers = [
        % $telegram;
        ea.c.saver(path = "../RESULTS/{name}/{startTime}/fitness"; of = ea.f.imagePlotter());
        ea.c.saver(path = "../RESULTS/{name}/{startTime}/fitness"; of = ea.f.csvPlotter())
      ]
    );
    ea.l.savePlotForExp(
      path = "../RESULTS/{name}/{startTime}/final-fitness";
      plot = ea.plot.multi.qualityBoxplot(q = ea.f.simQuality())
    );
    ea.l.savePlotForExp(
      path = "../RESULTS/{name}/{startTime}/coverage";
      plot = ea.plot.multi.xyExp(y = ea.f.archiveCoverage(of = ea.f.meArchive()));
      condition = predicate.matches(f = ea.f.runKey(key = "run.solver.name"); regex = "me.-.*")
    );
    ea.l.savePlotForExp(
      path = "../RESULTS/{name}/{startTime}/pop-success";
      plot = ea.plot.multi.xyExp(y = $popSuccess)
    );
    ea.l.savePlotForExp(
      path = "../RESULTS/{name}/{startTime}/pop-size";
      plot = ea.plot.multi.xyExp(y = f.size(of = ea.f.all()))
    )
  ]
)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy