YamlStatistics mostly implemented.
This commit is contained in:
parent
c3eddfbee4
commit
2e1f862718
@ -20,6 +20,7 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
@ -67,27 +68,40 @@ public class Main {
|
||||
final class YamlStatistics implements InterfaceStatistics {
|
||||
private static final Logger LOGGER = Logger.getLogger(YamlStatistics.class.getName());
|
||||
private InterfaceStatisticsParameters statisticsParameters;
|
||||
private List<LinkedHashMap<String, Object>> runs = new ArrayList<>();
|
||||
private List<LinkedHashMap<String, Object>> runs;
|
||||
private LinkedHashMap<String, Object> currentRun;
|
||||
private ArrayList<Map<String, Object>> currentGenerations;
|
||||
private InterfaceOptimizationParameters currentParameters;
|
||||
private int currentGeneration;
|
||||
|
||||
|
||||
public YamlStatistics(InterfaceStatisticsParameters statisticsParameters) {
|
||||
super();
|
||||
this.statisticsParameters = statisticsParameters;
|
||||
this.runs = new ArrayList<>(statisticsParameters.getMultiRuns());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startOptimizationPerformed(String infoString, int runNumber, InterfaceOptimizationParameters params, List<InterfaceAdditionalPopulationInformer> informerList) {
|
||||
|
||||
this.currentRun = new LinkedHashMap<>();
|
||||
this.currentRun.put("name", infoString);
|
||||
this.currentRun.put("runNumber", runNumber + 1);
|
||||
this.currentGenerations = new ArrayList<>();
|
||||
this.currentGeneration = 0;
|
||||
this.currentParameters = params;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopOptimizationPerformed(boolean normal, String stopMessage) {
|
||||
|
||||
this.currentRun.put("stopMessage", stopMessage);
|
||||
this.currentRun.put("totalFunctionCalls", this.currentParameters.getOptimizer().getPopulation().getFunctionCalls());
|
||||
this.currentRun.put("generations", currentGenerations);
|
||||
this.runs.add(currentRun);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDataListener(InterfaceStatisticsListener listener) {
|
||||
|
||||
// We don't support that.
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -97,7 +111,7 @@ final class YamlStatistics implements InterfaceStatistics {
|
||||
|
||||
@Override
|
||||
public void addTextListener(InterfaceTextListener listener) {
|
||||
|
||||
// We don't support that.
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -111,8 +125,14 @@ final class YamlStatistics implements InterfaceStatistics {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createNextGenerationPerformed(PopulationInterface Pop, InterfaceOptimizer opt, List<InterfaceAdditionalPopulationInformer> informerList) {
|
||||
|
||||
public void createNextGenerationPerformed(PopulationInterface pop, InterfaceOptimizer opt, List<InterfaceAdditionalPopulationInformer> informerList) {
|
||||
LinkedHashMap<String, Object> generation = new LinkedHashMap<>();
|
||||
generation.put("bestFitness", pop.getBestFitness());
|
||||
generation.put("meanFitness", pop.getMeanFitness());
|
||||
generation.put("functionCalls", pop.getFunctionCalls());
|
||||
generation.put("generation", currentGeneration);
|
||||
this.currentGenerations.add(generation);
|
||||
this.currentGeneration++;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user