|
| None | reinit (self) |
| 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) |
| 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) |
| None | tell_container_entries (self, Optional[Container] cont=None) |
| IndividualLike | best (self) |
| 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) |
| Mapping[str, Any] | __get_summary_state__ (self) |
| str | summary (self, Optional[int] max_depth=None, Optional[int] max_entry_length=250) |
| Mapping[str, Any] | __get_saved_state__ (self) |
| None | save (self, str output_path, str output_type="pickle") |
| Any | from_config (cls, Mapping[str, Any] config, **Any kwargs) |
|
| | _check_archive_weights (self) |
| IndividualLike | _internal_ask (self, IndividualLike base_ind) |
| 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 | _transfer_suggestion (self, IndividualLike individual, IndividualLike evaluated) |
| | Transfer coordinator-side metadata when evaluation returns a new object.
|
| None | _start_fixed_batch (self, int size) |
| None | _receive_fixed_batch (self, records, verbose, batch_start_time) |
| | _fixed_batch_plan (self, size, evaluate, packed) |
Combine a candidate generator, an evaluation budget, and an archive.
The container resolves objective and descriptor vectors and controls
admission. The optimiser generates genomes and consumes feedback.
Ask and tell support an application-managed evaluator. Optimise adds
scheduling, timing, and callbacks to the same protocol.
:param container: Archive used for admission and best-candidate queries.
:param budget: Candidate evaluations available to each managed run.
:param batch_size: Candidates in one iteration and maximum number
pending at once. Defaults to the budget.
:param dimension: Genome length for algorithms that generate vectors.
:param nb_objectives: Objective count. When omitted, infer it from
the container's fitness domain or use one objective.
:param optimisation_task: Minimise, maximise, or supply one finite
comparison weight per objective.
:param base_ind_gen: Iterator supplying a fresh candidate for each ask.
:param tell_container_at_init: Feed stored entries to the algorithm
when true or ``"yes"``. Use ``"parents"`` to feed entries from
immediate parents and pass their child membership to the hook.
:param add_default_logger: Attach the shared console logger.
:param name: Name for callbacks, logs, and saved result metadata.
Definition at line 244 of file base.py.
| Tuple[MutableMapping[str, Any], bool] qdpy.algorithms.base.QDAlgorithm._tell_before_container_update |
( |
| self, |
|
|
IndividualLike | individual ) |
|
protected |
Read pre-admission state for optimiser feedback.
- Parameters
-
| individual | Candidate with its reported evaluation attached. |
- Returns
- A metadata mapping and a flag permitting archive admission.
Improvement emitters read the incumbent here so the signed gain is measured against the previous cell quality.
Called by the ``tell`` method before adding the individual to the container. Can be used to compile
a dictionary of information about the individual or container before the update operation occurs.
Return a dictionary of extended attributes and a boolean flag indicating whether the algorithm is allowed to tell the
individual or not.
Parameters
----------
:param individual: IndividualLike
The `individual` provided to the algorithm.
Reimplemented in qdpy.algorithms.cmame.CMAMEImprovementEmitter, and qdpy.algorithms.gram_elites.GramElites.
Definition at line 610 of file base.py.
| None qdpy.algorithms.base.QDAlgorithm.add_callback |
( |
| self, |
|
|
str | event, |
|
|
Callable | fn ) |
Attach a callable `fn` to the optimiser. `fn` will be called each time the event specified in `event` occurs.
Parameters
----------
:param event: str
The event triggering the callback. Can be either 'ask', 'tell', 'iteration' (when an iteration finishes)
'started_optimisation', or 'finished_optimisation'.
:param fn: Callable
The callback function called when the event specified in `event` occurs.
Reimplemented from qdpy.algorithms.base.QDAlgorithmLike.
Definition at line 934 of file base.py.
Return the next candidate for evaluation.
Create the base individual, let the subclass propose its genome,
assign a name if empty, increment the suggestion counters, and
invoke ask callbacks. Keep the suggested object available when
sending feedback to a wrapper with multiple emitters.
Reimplemented from qdpy.algorithms.base.QDAlgorithmLike.
Reimplemented in qdpy.algorithms.modern._FixedGeneration.
Definition at line 481 of file base.py.
| None qdpy.algorithms.base.QDAlgorithm.optimisation_task |
( |
| self, |
|
|
Union[str, Sequence[float]] | optimisation_task ) |
Update the kind of optimisation task performed by this `QDAlgorithm`.
Parameters
----------
:param optimisation_task: Union[str, Sequence[float]]
The kind of optimisation task to perform for all objectives of the fitness functions.
If `optimisation_task` is a string, it can take the following values:
- for minimising all fitness objectives: 'minimisation', 'minimization', 'minimise', 'minimize', 'min'
- for maximising all fitness objectives: 'maximisation', 'maximization', 'maximise', 'maximize', 'max'
If `optimisation_task` is a Sequence of floats, its length corresponds to the number of objectives, and each
entry is a weight to apply to each objective score.
Maximised objectives have a corresponding weight > 0 while minimised objectives have weights < 0.
The length of this Sequence must be same as the length of the `self.container.fitness_domain` attribute.
Definition at line 390 of file base.py.
| IndividualLike qdpy.algorithms.base.QDAlgorithm.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 ) |
Manage evaluation and return the best candidate in the archive.
A single-candidate evaluator can return a fitness and descriptor
pair, that pair followed by named scores, or an evaluated individual.
Return an empty sequence after updating the supplied object in place
during in-process execution. A packed evaluator receives a list and
returns one such result per candidate in the same order.
Both the budget and batch size count candidates. A failed evaluation or
malformed group consumes its dispatched slots. Results are consumed in
completion order, which can affect archive-dependent searches.
Iteration callbacks run after full batches.
:param evaluate: Callable executed for each candidate or packed group.
:param budget: Optional override of the configured budget.
:param batch_mode: Wait for the current batch before asking for the
next one. In steady state, refill available slots as work completes.
:param executor: Evaluation executor. Defaults to in-process sequential
execution. The caller manages any supplied executor's lifetime.
:param send_several_suggestions_to_fn: Pass a list per evaluator call.
:param max_nb_suggestions_per_call: Positive cap on a packed call.
:param verbose: Emit archive validation warnings.
:returns: The best retained candidate after the run.
:raises RuntimeError: If no candidate is available to return.
:raises ValueError: If the budget is missing or a positive run has an
invalid batch size or packed-call limit.
Reimplemented from qdpy.algorithms.base.QDAlgorithmLike.
Reimplemented in qdpy.algorithms.boil.BOIL, qdpy.algorithms.modern._FixedGeneration, qdpy.algorithms.occupancy_me._TrajectoryMAPElites, and qdpy.algorithms.sampling.SamplingDecorator.
Definition at line 776 of file base.py.
| bool qdpy.algorithms.base.QDAlgorithm.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 ) |
Report an evaluated candidate and offer it to the container.
A call updates the candidate's supplied evaluation attributes. The
container applies comparison weights to raw objective values. The
algorithm's pre-admission hook may add feedback metadata or decline
insertion. Feedback and evaluation counters still run when archive
insertion is disabled.
:param individual: Candidate associated with this evaluation.
:param fitness: Objective values or a fitness object. If omitted,
use the candidate's existing or named fitness.
:param features: Descriptor values or a descriptor object.
:param scores: Named scores to store on the candidate first.
:param elapsed: Evaluation duration in seconds.
:param verbose: Report archive validation warnings.
:param tell_container: Permit an archive update.
:returns: Whether the container reported a local update.
:raises ValueError: If the objective count differs from the configured count.
Reimplemented from qdpy.algorithms.base.QDAlgorithmLike.
Reimplemented in qdpy.algorithms.base.AlgWrapper, qdpy.algorithms.bayesian.BOPElites, and qdpy.algorithms.sampling.SamplingDecorator.
Definition at line 532 of file base.py.