QDpy
Loading...
Searching...
No Matches
qdpy.algorithms.base.AlgWrapper Class Reference
Inheritance diagram for qdpy.algorithms.base.AlgWrapper:
qdpy.algorithms.base.QDAlgorithm qdpy.algorithms.base.QDAlgorithmLike qdpy.base.Summarisable qdpy.base.Saveable qdpy.base.Copyable qdpy.base.CreatableFromConfig qdpy.algorithms.base.AlternatingAlgWrapper qdpy.algorithms.base.SqAlgWrapper qdpy.algorithms.cmame.MEMAPElitesUCB1

Public Member Functions

None reinit (self)
None next (self, bool verbose=False)
 switch_to (self, int idx, bool verbose=False)
IndividualLike best (self)
bool tell (self, IndividualLike individual, Optional[Any] fitness=None, Optional[FeaturesLike] features=None, Optional[ScoresDictLike] scores=None, Optional[float] elapsed=None, bool verbose=False, tell_container=True)
Public Member Functions inherited from qdpy.algorithms.base.QDAlgorithm
Union[str, Sequence[float]] optimisation_task (self)
None optimisation_task (self, Union[str, Sequence[float]] optimisation_task)
int nb_suggestions (self)
int nb_suggestions_in_iteration (self)
int nb_evaluations (self)
int nb_evaluations_in_iteration (self)
int nb_updated (self)
int nb_updated_in_iteration (self)
int batch_size (self)
Union[int, float] nb_max_iter (self)
int current_iter (self)
IndividualLike ask (self)
None tell_container_entries (self, Optional[Container] cont=None)
IndividualLike optimise (self, Callable evaluate, Optional[int] budget=None, bool batch_mode=True, Optional[ExecutorLike] executor=None, bool send_several_suggestions_to_fn=False, int max_nb_suggestions_per_call=10, bool verbose=False)
None add_callback (self, str event, Callable fn)
Public Member Functions inherited from qdpy.base.Summarisable
Mapping[str, Any] __get_summary_state__ (self)
str summary (self, Optional[int] max_depth=None, Optional[int] max_entry_length=250)
Public Member Functions inherited from qdpy.base.Saveable
Mapping[str, Any] __get_saved_state__ (self)
None save (self, str output_path, str output_type="pickle")
Public Member Functions inherited from qdpy.base.CreatableFromConfig
Any from_config (cls, Mapping[str, Any] config, **Any kwargs)

Protected Member Functions

 _check_archive_weights (self)
IndividualLike _internal_ask (self, IndividualLike base_ind)
None _transfer_suggestion (self, IndividualLike individual, IndividualLike evaluated)
 Move proposer ownership to an evaluator's returned individual.
Protected Member Functions inherited from qdpy.algorithms.base.QDAlgorithm
None _attach_evaluation (self, ind, fitness, features, scores, elapsed)
Tuple[MutableMapping[str, Any], bool] _tell_before_container_update (self, IndividualLike individual)
 Read pre-admission state for optimiser feedback.
None _tell_after_container_update (self, IndividualLike individual, bool added, Mapping[str, Any] xattr={})
 Account for a completed tell and send feedback.
None _internal_tell (self, IndividualLike individual, bool added_to_container, Mapping[str, Any] xattr={})
IndividualLike _internal_best (self)
bool _verify_if_finished_iteration (self, float batch_start_time)
None _start_fixed_batch (self, int size)
None _receive_fixed_batch (self, records, verbose, batch_start_time)
 _fixed_batch_plan (self, size, evaluate, packed)

Detailed Description

Coordinate child optimisers under one ask/tell interface.

The active child supplies each ask. Feedback follows the original
proposer even if the active child changes before a result returns.
With ``tell_all``, every child receives feedback and non-proposers
receive copies. Child switching can warm-start the next child from
its archive or the previous child's best candidate.

An explicit container collects all reported candidates and supplies the
result. Otherwise report the active child's archive, or the first
populated child when the active archive is empty.

Definition at line 1025 of file base.py.

Member Function Documentation

◆ _check_archive_weights()

qdpy.algorithms.base.AlgWrapper._check_archive_weights ( self)
protected
Catch conflicting objective directions before proposing or admitting candidates.

Reimplemented from qdpy.algorithms.base.QDAlgorithm.

Definition at line 1101 of file base.py.

◆ _internal_ask()

IndividualLike qdpy.algorithms.base.AlgWrapper._internal_ask ( self,
IndividualLike base_ind )
protected
Internal ask method. To be implemented by subclasses.

Parameters
----------
:param base_ind: IndividualLike
    The base (empty) individual object. The `_internal_ask` method must change
    this object, by filling out the genome and providing other information.

Returns
-------
out: IndividualLike
    The suggested individual.

Reimplemented from qdpy.algorithms.base.QDAlgorithm.

Definition at line 1154 of file base.py.

◆ _transfer_suggestion()

None qdpy.algorithms.base.AlgWrapper._transfer_suggestion ( self,
IndividualLike individual,
IndividualLike evaluated )
protected

Move proposer ownership to an evaluator's returned individual.

Parameters
individualOriginal ask object retained by the scheduler.
evaluatedReplacement object returned by the evaluator.

Propagate the transfer through nested wrappers. Tracking uses object identity, so equal genomes can have distinct owners.

Reimplemented from qdpy.algorithms.base.QDAlgorithm.

Definition at line 1179 of file base.py.

◆ best()

IndividualLike qdpy.algorithms.base.AlgWrapper.best ( self)
Return the best retained candidate.

:raises RuntimeError: If the container has no candidates.

Reimplemented from qdpy.algorithms.base.QDAlgorithm.

Definition at line 1139 of file base.py.

◆ next()

None qdpy.algorithms.base.AlgWrapper.next ( self,
bool verbose = False )
Switch to the next algorithm in Sequence `self.algorithms`, if there is one.

Reimplemented in qdpy.algorithms.base.AlternatingAlgWrapper, qdpy.algorithms.base.SqAlgWrapper, and qdpy.algorithms.cmame.MEMAPElitesUCB1.

Definition at line 1115 of file base.py.

◆ reinit()

None qdpy.algorithms.base.AlgWrapper.reinit ( self)
Reset counters for suggestions, evaluation, and archive updates.

This base method leaves the archive and callbacks in place.
Subclasses may also reset their generator or optimiser state.

Reimplemented from qdpy.algorithms.base.QDAlgorithm.

Reimplemented in qdpy.algorithms.cmame.MEMAPElitesUCB1.

Definition at line 1080 of file base.py.

◆ switch_to()

qdpy.algorithms.base.AlgWrapper.switch_to ( self,
int idx,
bool verbose = False )
Switch to another algorithm of index `idx` in `self.algorithms`.

Definition at line 1123 of file base.py.

◆ tell()

bool qdpy.algorithms.base.AlgWrapper.tell ( self,
IndividualLike individual,
Optional[Any] fitness = None,
Optional[FeaturesLike] features = None,
Optional[ScoresDictLike] scores = None,
Optional[float] elapsed = None,
bool verbose = False,
tell_container = True )
Deliver an evaluation to the proposer, or to every child in tell-all mode.

A manually supplied candidate with no pending ask goes to the active
child. Forward the optional evaluation arguments and update permission
to the child. The wrapper accounts for one evaluation and reports an
update if any child reports one.

Reimplemented from qdpy.algorithms.base.QDAlgorithm.

Definition at line 1185 of file base.py.


The documentation for this class was generated from the following file: