resize
Sets PanmicticPopulation.size and PanmicticPopulation.buffer of population.
Prefer adjustSize over resize to increase or decrease only size by step.
Prefer adjustBuffer over resize to increase or decrease only buffer by step.
NOTE!
Changing only newSize (newBuffer is null) will automatically calculate the value of PanmicticPopulation.buffer:
evolve {
var size = population.size // = 100
var buffer = population.buffer // = 50
resize(newSize = size + 10)
size = population.size // = 110
buffer = population.buffer // = 40
resize(newSize = size + 50)
// buffer limit exceeded, created new array with maxSize = 160
size = population.size // = 160
buffer = population.buffer // = 0 (buffer overflow)
resize(newSize = size - 60)
size = population.size // = 100
buffer = population.buffer // = 60 (buffer increased cause overflow)
}
Parameters
Set as new PanmicticPopulation.size value if not null.
Always must be positive
When decreasing the value, the array will not be copied. The freed space will be marked as buffer - the value of PanmicticPopulation.buffer will be increased by oldSize - newSize
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 newSize - oldSize
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
Set as new PanmicticPopulation.buffer value if not null. But PanmicticPopulation.buffer can be changed by changing PanmicticPopulation.size, see above.
Always must be positive or zero
Manual changing PanmicticPopulation.buffer will copy the existing population to a new array, which can take a significant amount of time
When manual increasing the value - its generate new chromosomes with Population.factory
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
resize(newSize = size + 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