Base¶
deap_er.Toolbox()
¶
A container for evolutionary operators.
Registers callables under aliases so algorithms can request
mate, mutate, select, evaluate, and similar tools
without hard-coding implementations.
Register the default clone and map operators.
Source code in deap_er/private/toolbox.py
__getattr__(name)
¶
Resolve aliases bound by register.
register attaches names with setattr. This hook is
for the type checker and for missing aliases at runtime.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Operator alias. |
required |
Raises:
| Type | Description |
|---|---|
AttributeError
|
If |
Source code in deap_er/private/toolbox.py
register(alias, func, *args, **kwargs)
¶
Bind func to alias on this toolbox.
Extra positional and keyword arguments are bound into the registered callable. Callers may still override those bound values when they invoke the alias.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
alias
|
str
|
Name to register. Overwrites an existing alias of the same name. |
required |
func
|
Callable[..., Any]
|
Callable the alias will refer to. |
required |
*args
|
Any
|
Positional arguments bound into |
()
|
**kwargs
|
Any
|
Keyword arguments bound into |
{}
|
Source code in deap_er/private/toolbox.py
unregister(alias)
¶
Remove the operator registered as alias.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
alias
|
str
|
Name of the operator to remove. |
required |
decorate(alias, *decorators)
¶
Wrap the operator alias with one or more decorators.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
alias
|
str
|
Name of a registered operator. |
required |
*decorators
|
Callable[..., Any]
|
Decorators applied left to right. If omitted, the operator is left unchanged. |
()
|
Source code in deap_er/private/toolbox.py
deap_er.Fitness(values=None)
¶
Quality of a solution, compared through weighted objectives.
The class attribute weights must be set before a Fitness object
can be instantiated. A fitness may be created without values, but
it stays invalid until values is assigned a sequence of the
same length as weights.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
values
|
FitnessValues | None
|
Initial objective values. Optional. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
weights |
Sequence[int | float]
|
Shared per fitness type. Each element is a real number for one objective: negative means minimize, positive means maximize. |
See the class docstring.
Source code in deap_er/private/fitness.py
values
deletable
property
writable
¶
Objective values of the individual.
The setter accepts a number, a 0-d NumPy array, or a sequence of numbers. A single number is stored as a one-element sequence. The getter returns a tuple of floats, or an empty tuple when the fitness is invalid. Deleting the property clears the stored values.
Raises:
| Type | Description |
|---|---|
TypeError
|
If the assigned sequence length does not match
|
dominates(other, slc=None)
¶
Return whether this fitness Pareto-dominates other.
Each compared objective of self must be at least as good as
the corresponding objective of other, and at least one must
be strictly better.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
Fitness
|
Fitness to test against. |
required |
slc
|
slice | None
|
Slice of objectives to compare. Optional; all objectives are used when omitted. |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if |
bool
|
fitness is invalid or the compared lengths differ. |
Source code in deap_er/private/fitness.py
is_valid()
¶
Return whether this fitness has a complete set of values.
Returns:
| Type | Description |
|---|---|
bool
|
True if |
bool
|
same length. |
__gt__(other)
¶
__ge__(other)
¶
__le__(other)
¶
__lt__(other)
¶
__eq__(other)
¶
Return whether the two fitnesses compare equal.
__ne__(other)
¶
Return whether the two fitnesses compare unequal.
__len__()
¶
__hash__()
¶
__str__()
¶
__repr__()
¶
__deepcopy__(memo)
¶
Return a new Fitness with the same weighted values.