Class CSVEvolutionListener<T extends Comparable<T>,U>
java.lang.Object
net.bmahe.genetics4j.extras.evolutionlisteners.CSVEvolutionListener<T,U>
- Type Parameters:
T
- Fitness typeU
- Data type written to the CSV
- All Implemented Interfaces:
EvolutionListener<T>
- Direct Known Subclasses:
ImmutableCSVEvolutionListener
@Immutable
public abstract class CSVEvolutionListener<T extends Comparable<T>,U>
extends Object
implements EvolutionListener<T>
Evolution Listener which writes the output of each generation to a CSV file
- Author:
- bruno
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
CSVEvolutionListener.Builder<T extends Comparable<T>,
U> -
Field Summary
Modifier and TypeFieldDescriptionprivate org.apache.commons.csv.CSVPrinter
static final boolean
static final org.apache.logging.log4j.Logger
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Whether or not the CSV writer has auto flush enabled.abstract List
<ColumnExtractor<T, U>> List of Column Extractors.User defined function to provide some additional information when computing the value to write.abstract String
filename()
Destination file name for the CSV fileFunction
<Stream<EvolutionStep<T, U>>, Stream<EvolutionStep<T, U>>> filter()
Users can supply an optional set of filters to control which individuals get written and in which order.static <T extends Comparable<T>,
U>
CSVEvolutionListener<T, U> of
(String filename, Iterable<? extends ColumnExtractor<T, U>> columnExtractors) static <T extends Comparable<T>,
U>
CSVEvolutionListener<T, U> of
(String filename, List<ColumnExtractor<T, U>> columnExtractors) static <T extends Comparable<T>,
U>
CSVEvolutionListener<T, U> of
(String filename, GenerationFunction<T, U> evolutionContextSupplier, Iterable<? extends ColumnExtractor<T, U>> columnExtractors) static <T extends Comparable<T>,
U>
CSVEvolutionListener<T, U> of
(String filename, GenerationFunction<T, U> evolutionContextSupplier, Iterable<? extends ColumnExtractor<T, U>> columnExtractors, int skipN) static <T extends Comparable<T>,
U>
CSVEvolutionListener<T, U> ofTopN
(String filename, GenerationFunction<T, U> evolutionContextSupplier, Iterable<? extends ColumnExtractor<T, U>> columnExtractors, int topN) static <T extends Comparable<T>,
U>
CSVEvolutionListener<T, U> ofTopN
(String filename, GenerationFunction<T, U> evolutionContextSupplier, Iterable<? extends ColumnExtractor<T, U>> columnExtractors, Comparator<T> comparator, int topN) void
onEvolution
(long generation, List<Genotype> population, List<T> fitness, boolean isDone) protected org.apache.commons.csv.CSVPrinter
int
skipN()
How many generations to skip between each writes.
-
Field Details
-
logger
public static final org.apache.logging.log4j.Logger logger -
DEFAULT_AUTO_FLUSH
public static final boolean DEFAULT_AUTO_FLUSH- See Also:
-
csvPrinter
private org.apache.commons.csv.CSVPrinter csvPrinter
-
-
Constructor Details
-
CSVEvolutionListener
public CSVEvolutionListener()
-
-
Method Details
-
openPrinter
protected org.apache.commons.csv.CSVPrinter openPrinter() -
autoFlush
@Default public boolean autoFlush()- Returns:
-
evolutionContextSupplier
User defined function to provide some additional information when computing the value to write. Defaults to null- Returns:
-
skipN
@Default public int skipN()How many generations to skip between each writes. Defaults to writing every generations- Returns:
-
filter
Users can supply an optional set of filters to control which individuals get written and in which order. Default to have no impact.- Returns:
-
filename
Destination file name for the CSV file- Returns:
-
columnExtractors
List of Column Extractors. They specify how and what to write from each individual at a given generation- Returns:
-
onEvolution
public void onEvolution(long generation, List<Genotype> population, List<T> fitness, boolean isDone) - Specified by:
onEvolution
in interfaceEvolutionListener<T extends Comparable<T>>
-
of
public static <T extends Comparable<T>,U> CSVEvolutionListener<T,U> of(String filename, List<ColumnExtractor<T, U>> columnExtractors) -
of
public static <T extends Comparable<T>,U> CSVEvolutionListener<T,U> of(String filename, Iterable<? extends ColumnExtractor<T, U>> columnExtractors) -
of
public static <T extends Comparable<T>,U> CSVEvolutionListener<T,U> of(String filename, GenerationFunction<T, U> evolutionContextSupplier, Iterable<? extends ColumnExtractor<T, U>> columnExtractors) -
of
public static <T extends Comparable<T>,U> CSVEvolutionListener<T,U> of(String filename, GenerationFunction<T, U> evolutionContextSupplier, Iterable<? extends ColumnExtractor<T, U>> columnExtractors, int skipN) -
ofTopN
public static <T extends Comparable<T>,U> CSVEvolutionListener<T,U> ofTopN(String filename, GenerationFunction<T, U> evolutionContextSupplier, Iterable<? extends ColumnExtractor<T, U>> columnExtractors, Comparator<T> comparator, int topN) -
ofTopN
public static <T extends Comparable<T>,U> CSVEvolutionListener<T,U> ofTopN(String filename, GenerationFunction<T, U> evolutionContextSupplier, Iterable<? extends ColumnExtractor<T, U>> columnExtractors, int topN)
-