T
- The payload class.public class EvolutionaryProcess<T extends Payload<U>,U> extends Object implements org.apache.hadoop.io.Writable, Closeable
Modifier and Type | Class and Description |
---|---|
static interface |
EvolutionaryProcess.Function<T> |
Constructor and Description |
---|
EvolutionaryProcess() |
EvolutionaryProcess(int threadCount,
int populationSize,
State<T,U> seed)
Creates an evolutionary optimization framework with specified threadiness,
population size and initial state.
|
Modifier and Type | Method and Description |
---|---|
void |
add(State<T,U> value) |
void |
close() |
List<State<T,U>> |
getPopulation() |
int |
getPopulationSize() |
int |
getThreadCount() |
void |
mutatePopulation(int survivors)
Nuke all but a few of the current population and then repopulate with
variants of the survivors.
|
State<T,U> |
parallelDo(EvolutionaryProcess.Function<Payload<U>> fn)
Execute an operation on all of the members of the population with many threads.
|
void |
readFields(DataInput input) |
void |
setThreadCount(int threadCount) |
void |
write(DataOutput out) |
public EvolutionaryProcess()
public EvolutionaryProcess(int threadCount, int populationSize, State<T,U> seed)
threadCount
- How many threads to use in parallelDopopulationSize
- How large a population to useseed
- An initial population memberpublic void mutatePopulation(int survivors)
survivors
- How many survivors we want to keep.public State<T,U> parallelDo(EvolutionaryProcess.Function<Payload<U>> fn) throws InterruptedException, ExecutionException
fn
- What to do on each member. Gets payload and the mapped parameters as args.InterruptedException
- Shouldn't happen.ExecutionException
- If fn throws an exception, that exception will be collected
and rethrown nested in an ExecutionException.public void setThreadCount(int threadCount)
public int getThreadCount()
public int getPopulationSize()
public void close()
close
in interface Closeable
close
in interface AutoCloseable
public void write(DataOutput out) throws IOException
write
in interface org.apache.hadoop.io.Writable
IOException
public void readFields(DataInput input) throws IOException
readFields
in interface org.apache.hadoop.io.Writable
IOException
Copyright © 2008–2017 The Apache Software Foundation. All rights reserved.