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
>>> genome.evaluator.set(eval_main, 0.9)
>>> genome.evaluator.add(eval_sec, 0.3)
>>> genome.evaluator.setRandomApply()
In the above example, the function eval_main will be called with 90% of probability and the eval_sec will be called with 30% of probability.
>>> genome.evaluator += eval_func
Parameters: |
|
---|
Used to add a function to the slot
Parameters: |
|
---|
New in version 0.6: The weight parameter.
Apply the index function
Parameters: |
|
---|
Generator to apply all function slots in obj
Parameters: |
|
---|
Used to clear all functions in the slot and add one
Parameters: |
|
---|
New in version 0.6: The weight parameter.
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 |
---|