adjust Size
Sets PanmicticPopulation.size = PanmicticPopulation.size + step
NOTE!
Changing PanmicticPopulation.size will automatically calculate the value of PanmicticPopulation.buffer:
evolve {
var size = population.size // = 100
var buffer = population.buffer // = 50
adjustSize(step = 10)
size = population.size // = 110
buffer = population.buffer // = 40
adjustSize(step = 50)
// buffer limit exceeded, created new array with maxSize = 160
size = population.size // = 160
buffer = population.buffer // = 0 (buffer overflow)
adjustSize(step = -60)
size = population.size // = 100
buffer = population.buffer // = 60 (buffer increased cause overflow)
}
Parameters
step value for new size
set positive value to increase
set negative value to decrease
zero is skipped (no changes)
When decreasing the PanmicticPopulation.size, the array will not be copied. The freed space will be marked as buffer - the value of PanmicticPopulation.buffer will be increased by step
When increasing the value AND new value less or equal to PanmicticPopulation.maxSize - the array will not be copied. Space will be taken from buffer - the value of PanmicticPopulation.buffer will be decreased by -step
When increasing the value AND new value more than PanmicticPopulation.maxSize - the existing population being copied to a new array, which can take a significant amount of time. PanmicticPopulation.buffer will be set to 0
param for optimization. Default value is true for predictable behaviour. If true - execute evaluation by fitnessFunction for new chromosomes in range: oldSize.. No evaluations if newSize is null or newSize less than oldSize Set it to false for optimization by skipping double evaluation in case:evolve {
// other genetic operators
adjustSize(by = 5, evaluateBuffered = false)
// Danger zone: New chromosomes can be not evaluated
evaluation() // evaluates in range 0..<newSize
// Safe zone: all active chromosomes evaluated
// other genetic operators
}
limit of parallel workers
fitnessFunction for evaluation