The function slot concept is large used by Pyevolve, the idea is simple, each genetic operator or any operator, can be assigned to a slot, by this way, we can add more than simple one operator, we can have for example, two or more mutator operators at same time, two or more evaluation functions, etc. In this FunctionSlot module, you’ll find the class FunctionSlot.FunctionSlot, which is the slot class.
FunctionSlot Class - The function slot
>>> genome.evaluator.set(eval_func)
>>> genome.evaluator[0]
<function eval_func at 0x018C8930>
>>> genome.evaluator
Slot [Evaluation Function] (Count: 1)
Name: eval_func
>>> genome.evaluator.clear()
>>> genome.evaluator
Slot [Evaluation Function] (Count: 0)
No function
| Parameters: |
|
|---|
Used to add a function to the slot
| Parameter: | func – the function to be added in the slot |
|---|
Apply the index function
| Parameters: |
|
|---|
Generator to apply all function slots in obj
| Parameters: |
|
|---|
Return the function handle at index
| Parameter: | index – the index of the function |
|---|
Used to clear all functions in the slot and add one
| Parameter: | func – the function to be added in the slot |
|---|
Note
the method set of the function slot remove all previous functions added to the slot.
Sets the random function application, in this mode, the function will randomly choose one slot to apply
| Parameter: | flag – True or False |
|---|