evox.core.components
¶
Module Contents¶
Classes¶
API¶
- class evox.core.components.Algorithm[source]¶
Bases:
evox.core.module.ModuleBase
,abc.ABC
Base class for all algorithms
Initialization
Initialize the ModuleBase.
- Parameters:
*args – Variable length argument list, passed to the parent class initializer.
**kwargs – Arbitrary keyword arguments, passed to the parent class initializer.
Attributes: static_names (list): A list to store static member names.
- init_step() None [source]¶
Initialize the algorithm and execute the algorithm procedure for the first step.
- class evox.core.components.Problem[source]¶
Bases:
evox.core.module.ModuleBase
,abc.ABC
Base class for all problems
Initialization
Initialize the ModuleBase.
- Parameters:
*args – Variable length argument list, passed to the parent class initializer.
**kwargs – Arbitrary keyword arguments, passed to the parent class initializer.
Attributes: static_names (list): A list to store static member names.
- evaluate(pop: torch.Tensor) torch.Tensor [source]¶
Evaluate the fitness at given points
- Parameters:
pop – The population.
- Returns:
The fitness.
Notice
If this function contains external evaluations that cannot be compiled by
torch.compile
, please wrap it withtorch.compiler.disable
or useevox.utils.register_vmap_op
to register external functions as operators.
- class evox.core.components.Workflow(*args, **kwargs)[source]¶
Bases:
evox.core.module.ModuleBase
,abc.ABC
The base class for workflow.
Initialization
Initialize the ModuleBase.
- Parameters:
*args – Variable length argument list, passed to the parent class initializer.
**kwargs – Arbitrary keyword arguments, passed to the parent class initializer.
Attributes: static_names (list): A list to store static member names.
- class evox.core.components.Monitor(*args, **kwargs)[source]¶
Bases:
evox.core.module.ModuleBase
,abc.ABC
The monitor base class.
Monitors are used to monitor the evolutionary process. They contains a set of callbacks, which will be called at specific points during the execution of the workflow. Monitor itself lives outside the main workflow, so jit is not required.
To implements a monitor, implement your own callbacks and override the hooks method. The hooks method should return a list of strings, which are the names of the callbacks. Currently the supported callbacks are:
post_ask
,pre_eval
,post_eval
, andpre_tell
.Initialization
Initialize the ModuleBase.
- Parameters:
*args – Variable length argument list, passed to the parent class initializer.
**kwargs – Arbitrary keyword arguments, passed to the parent class initializer.
Attributes: static_names (list): A list to store static member names.
- set_config(**config) evox.core.components.Monitor [source]¶
Set the static variables according to
config
.- Parameters:
config – The configuration.
- Returns:
This module.
- record_auxiliary(aux: Dict[str, torch.Tensor]) None [source]¶
Record the auxiliary information.
- Parameters:
aux – The auxiliary information.
- post_ask(candidate_solution: torch.Tensor) None [source]¶
The hook function to be executed before the solution transformation.
- Parameters:
candidate_solution – The population (candidate solutions) before the solution transformation.
- pre_eval(transformed_candidate_solution: Any) None [source]¶
The hook function to be executed after the solution transformation.
- Parameters:
transformed_candidate_solution – The population (candidate solutions) after the solution transformation.