Algorithm Class#

class evox.Algorithm[source]#

Base class for all algorithms

__init__()#
ask(state)[source]#

Ask the algorithm

Ask the algorithm for points to explore

Parameters:

state (State) – The state of this algorithm.

Returns:

  • population – The candidate solution.

  • state – The new state of the algorithm.

Return type:

Tuple[Array, State]

init(key=None, no_state=False, re_init=False)#

Initialize this module and all submodules

This method should not be overwritten.

Parameters:
  • key (Array | None) – A PRNGKey.

  • no_state (bool)

  • re_init (bool)

Returns:

The state of this module and all submodules combined.

Return type:

State

parallel_init(key, num_copies, no_state=False)#

Initialize multiple copies of this module in parallel

This method should not be overwritten.

Parameters:
  • key (Array) – A PRNGKey.

  • num_copies (int) – The number of copies to be initialized

  • no_state (bool) – Whether to skip the state initialization

Returns:

The state of this module and all submodules combined, and the last node_id

Return type:

Tuple[State, int]

setup(key)#

Setup mutable state here

The state it self is immutable, but it act as a mutable state by returning new state each time.

Parameters:

key (Array) – A PRNGKey.

Returns:

The state of this module.

Return type:

State

tell(state, fitness)[source]#

Tell the algorithm more information

Tell the algorithm about the points it chose and their corresponding fitness

Parameters:
  • state (State) – The state of this algorithm

  • fitness (Array) – The fitness

Returns:

The new state of the algorithm

Return type:

state