public final class Pipeline extends Pipeline<EmasAgent,Pipeline>
EMAS agent processing definition.
Pipeline is similar to Java Streams, but its methods are executed when called and not lazily computed when needed. This implementation is immutable - each call returns a new pipeline instance or a tuple of new instances.
Pipeline
pipelineFactory, population
Constructor and Description |
---|
Pipeline(io.vavr.collection.List<EmasAgent> population) |
Modifier and Type | Method and Description |
---|---|
io.vavr.Tuple2<Pipeline,Pipeline> |
dieWhen(java.util.function.Predicate<EmasAgent> deathPredicate)
Population splitter for death.
|
Pipeline |
evaluate(PopulationEvaluator<EmasAgent> populationEvaluator)
Evaluates agents in the population.
|
io.vavr.Tuple2<Pipeline,Pipeline> |
migrateWhen(java.util.function.Predicate<EmasAgent> migrationPredicate)
Population splitter for migration.
|
static Pipeline |
on(io.vavr.collection.List<EmasAgent> population)
Create a new pipeline for the given population.
|
Pipeline |
process(java.util.function.Function<io.vavr.collection.Seq<EmasAgent>,io.vavr.collection.Seq<EmasAgent>> populationProcessor)
Processes the whole population, applying a custom function to it.
|
io.vavr.Tuple2<PairPipeline,Pipeline> |
selectPairs(java.util.function.BiFunction<EmasAgent,io.vavr.collection.List<EmasAgent>,io.vavr.Tuple2<EmasAgent,EmasAgent>> selector)
Select pairs from the current population in this pipeline with regards to the given selector function.
|
PairPipeline |
selectPairsWithRepetitions(java.util.function.BiFunction<EmasAgent,io.vavr.collection.List<EmasAgent>,io.vavr.Tuple2<EmasAgent,EmasAgent>> selector)
Select pairs from the current population in this pipeline with regards to the given selector function.
|
private static io.vavr.Tuple2<EmasAgent,EmasAgent> |
selfReproduce(EmasAgent agent,
java.util.function.Predicate<EmasAgent> selfReproductionPredicate,
java.util.function.Function<EmasAgent,io.vavr.Tuple2<EmasAgent,EmasAgent>> selfReproductionStrategy) |
io.vavr.Tuple2<Pipeline,Pipeline> |
selfReproduce(java.util.function.Function<EmasAgent,io.vavr.Tuple2<EmasAgent,EmasAgent>> selfReproductionStrategy)
Self reproduce all agents from this pipeline, using a provided strategy.
|
io.vavr.Tuple2<Pipeline,Pipeline> |
selfReproduce(java.util.function.Predicate<EmasAgent> selfReproductionPredicate,
java.util.function.Function<EmasAgent,io.vavr.Tuple2<EmasAgent,EmasAgent>> selfReproductionStrategy)
Self reproduce agents from this pipeline that meet a given reproduction predicate.
|
Pipeline(io.vavr.collection.List<EmasAgent> population)
public static Pipeline on(io.vavr.collection.List<EmasAgent> population)
Create a new pipeline for the given population.
population
- population of EMAS agents.public PairPipeline selectPairsWithRepetitions(java.util.function.BiFunction<EmasAgent,io.vavr.collection.List<EmasAgent>,io.vavr.Tuple2<EmasAgent,EmasAgent>> selector)
Select pairs from the current population in this pipeline with regards to the given selector function.
selector
- a function of two arguments. The first argument is an agent and the second one - the rest of the current population. The selector should return a pair of agents selected for this agent. Usually it will be the given agent and another one.Selectors
public io.vavr.Tuple2<PairPipeline,Pipeline> selectPairs(java.util.function.BiFunction<EmasAgent,io.vavr.collection.List<EmasAgent>,io.vavr.Tuple2<EmasAgent,EmasAgent>> selector)
Select pairs from the current population in this pipeline with regards to the given selector function.
selector
- a function of two arguments. The first argument is an agent and the second one - the rest of the current population. The selector should return a pair of agents selected for this agent. Usually it will be the given agent and another one.PairPipeline
containing the selected pairs, the second one - pipeline containing all agents which have not been selected.Selectors
public final io.vavr.Tuple2<Pipeline,Pipeline> selfReproduce(java.util.function.Function<EmasAgent,io.vavr.Tuple2<EmasAgent,EmasAgent>> selfReproductionStrategy)
Self reproduce all agents from this pipeline, using a provided strategy.
selfReproductionStrategy
- the self reproduction strategypublic final io.vavr.Tuple2<Pipeline,Pipeline> selfReproduce(java.util.function.Predicate<EmasAgent> selfReproductionPredicate, java.util.function.Function<EmasAgent,io.vavr.Tuple2<EmasAgent,EmasAgent>> selfReproductionStrategy)
Self reproduce agents from this pipeline that meet a given reproduction predicate.
selfReproductionPredicate
- the self reproduction predicateselfReproductionStrategy
- the self reproduction strategyprivate static io.vavr.Tuple2<EmasAgent,EmasAgent> selfReproduce(EmasAgent agent, java.util.function.Predicate<EmasAgent> selfReproductionPredicate, java.util.function.Function<EmasAgent,io.vavr.Tuple2<EmasAgent,EmasAgent>> selfReproductionStrategy)
public final Pipeline evaluate(PopulationEvaluator<EmasAgent> populationEvaluator)
Evaluates agents in the population.
populationEvaluator
- the population evaluatorpublic final Pipeline process(java.util.function.Function<io.vavr.collection.Seq<EmasAgent>,io.vavr.collection.Seq<EmasAgent>> populationProcessor)
Processes the whole population, applying a custom function to it.
populationProcessor
- the function to process the populationpublic io.vavr.Tuple2<Pipeline,Pipeline> migrateWhen(java.util.function.Predicate<EmasAgent> migrationPredicate)
Population splitter for migration.
migrationPredicate
- a predicate that should return true if an agent should be migrated.Predicates
public io.vavr.Tuple2<Pipeline,Pipeline> dieWhen(java.util.function.Predicate<EmasAgent> deathPredicate)
Population splitter for death.
deathPredicate
- a predicate that should return true if an agent should die.Predicates