Example #1
0
 @Override
 public Epoch load(int evolutionId, long epochId, final PopulationConfiguration configuration)
     throws Exception {
   try {
     List<Probe> probes = dao.retrieve(evolutionId, epochId);
     if (probes != null && probes.size() > 0) {
       return Epoch.create(
           probes.get(0).getEpochId(),
           new Population(
               FluentIterable.from(probes)
                   .transform(
                       new Function<Probe, Genome>() {
                         @Override
                         public Genome apply(Probe input) {
                           return new Genome(
                               input.getGenomeId(),
                               input.getGenomeWeights(),
                               configuration.getPerceptronConfiguration());
                         }
                       })
                   .toList(),
               configuration,
               new DefaultPerceptronProvider()));
     } else {
       return null;
     }
   } catch (Exception e) {
     throw new Exception("Loading service failed. Latest epoch hasn't been loaded.", e);
   }
 }
Example #2
0
 @Override
 public void save(int evolutionId, DateTime createdOn, Epoch epoch) throws Exception {
   try {
     Population population = epoch.getPopulation();
     for (Genome g : population.getGenomes()) {
       dao.create(
           new Probe(
               ObjectId.get(),
               evolutionId,
               createdOn,
               epoch.getId(),
               g.getId(),
               g.getFitness(),
               g.getDna()));
     }
   } catch (Exception e) {
     throw new Exception(
         "Saving service failed. Epoch for evolutionId %d and epochId %d hasn't been persisted.",
         e);
   }
 }
Example #3
0
 @Override
 public void clearEvolution(int evolutionId) throws Exception {
   dao.clear(evolutionId);
 }
Example #4
0
 @Override
 public LatestEpochInfo getLatestEpochInfo() throws Exception {
   return dao.getLatestEpochInfo();
 }