|
QDpy
|
Public Member Functions | |
| float | capacity (self) |
| float | free (self) |
| int | size (self) |
| Any | best (self) |
| Optional[FitnessLike] | best_fitness (self) |
| Optional[FeaturesLike] | best_features (self) |
| int | nb_discarded (self) |
| int | nb_added (self) |
| int | nb_rejected (self) |
| int | nb_operations (self) |
| Optional[Sequence[DomainLike]] | fitness_extrema (self) |
| Optional[Sequence[DomainLike]] | features_extrema (self) |
| Sequence[IndividualLike] | all_parents_inds (self) |
| str | size_str (self) |
| bool | in_bounds (self, Any val, Any domain) |
| FeaturesLike | get_ind_features (self, IndividualLike individual, *args, **kwargs) |
| FitnessLike | get_ind_fitness (self, IndividualLike individual, *args, **kwargs) |
| set_ind_fitness (self, IndividualLike individual, FitnessLike fitness, *args, **kwargs) | |
| Optional[int] | add (self, IndividualLike individual, bool raise_if_not_added_to_parents=False) |
| None | discard (self, IndividualLike individual, bool also_from_parents=False) |
| int | update (self, Iterable iterable, bool ignore_exceptions=True, bool issue_warning=False) |
| None | clear (self, bool also_from_parents=False) |
| None | clear_all (self) |
| novelty (self, IndividualLike individual, **kwargs) | |
| novelty_local_competition (self, IndividualLike individual, **kwargs) | |
| Any | to_grid (self, Union[ShapeLike, int] shape, int max_items_per_bin=1, Optional[float] capacity=None, **Any kwargs) |
| float | qd_score (self, bool normalized=True) |
| 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.CreatableFromConfig | |
| Any | from_config (cls, Mapping[str, Any] config, **Any kwargs) |
Protected Member Functions | |
| Optional[Sequence[DomainLike]] | _float_feature_extrema (self) |
| Tuple[bool, int] | _add_to_collection (self, BackendLike[IndividualLike] collection, IndividualLike individual) |
| None | _check_if_can_be_added (self, IndividualLike individual) |
| Optional[int] | _add_internal (self, IndividualLike individual, bool raise_if_not_added_to_parents, bool only_to_parents, Optional[int] replace_index=None) |
| Commit local storage and eviction after required parent admission. | |
| None | _add_to_parents (self, IndividualLike individual, bool require_admission) |
| Forward a candidate to each immediate parent in order. | |
| _can_undo_parent_appends (self, individual) | |
| _add_to_append_only_parents (self, individual) | |
| Take a short pre-admission record and rebuild a snapshot only after rejection. | |
| _snapshot_parents (self) | |
| None | _discard_by_index (self, IndividualLike individual, Optional[int] idx=None, bool also_from_parents=False) |
Store evaluated candidates subject to capacity and domain bounds.
Each declared objective and descriptor coordinate has a closed
interval. Omit a domain to leave its vector unbounded. An evaluated
candidate needs nonempty fitness without NaN values.
:param iterable: Initial candidates, admitted in order by update.
:param storage_type: Storage implementation or supported storage name.
The default list compares genomes for duplicates. Use ``"orderedset"``
for indexed lookup when candidates are hashable and their genomes
stay unchanged while stored.
:param parents: Archives offered candidates for evaluation history.
:param fitness_domain: One closed interval per objective.
:param features_domain: One closed interval per behaviour descriptor.
:param fitness_score_names: Named scores used as objectives, in order.
:param features_score_names: Named scores used as descriptors, in order.
:param fitness_weights: Comparison weights to apply in this container.
:param capacity: Total local capacity. None allows unbounded storage.
:param name: Display name used by loggers and configuration.
:param only_add_accepted_inds_to_parents: Forward local admissions
only. Otherwise a rejected local candidate can reach the parents.
:param disable_parents_pickling: Omit parent links from result files
by default. Set false to keep the immediate links.
The archive stores candidate objects. Mutate a copy during variation,
and serialise archive updates through the controlling process.
|
protected |
Commit local storage and eviction after required parent admission.
| individual | Candidate passed by the admission policy. |
| raise_if_not_added_to_parents | Whether parent errors must propagate. |
| only_to_parents | Forward the candidate without a local insertion. |
| replace_index | Optional local storage index of the incumbent. |
Stage a new entry before contacting the parents, then update local counters and evict the incumbent after those calls succeed. Restore the prior local best and remove the staged entry on failure. An equal reevaluation needs its incumbent removed before insertion.
Store a candidate and commit any local eviction after parent admission.
Reimplemented in qdpy.algorithms.aurora_xcon._AuroraRepertoire, qdpy.containers.archives.NoveltyArchive, qdpy.containers.grids.Grid, qdpy.containers.pareto.LocalParetoArchive, qdpy.containers.pareto.ParetoGrid, qdpy.containers.populations.Population, qdpy.containers.sliding.SlidingBoundariesGrid, and qdpy.containers.voronoi.VoronoiArchive.
|
protected |
Add ``individual`` to ``collection``. Return a tuple containing (added, index), with ``added`` a bool saying whether ``individual`` was added or not to ``collection``, and ``index`` the index in the ``collection``. ``collection`` can be a MutableSequence or an ordered set implementing Sequence and MutableSet.
|
protected |
Forward a candidate to each immediate parent in order.
| individual | Candidate to offer. |
| require_admission | Whether to raise when a parent insertion fails. |
Restore built-in archives after a failure in a parent graph with multiple branches. Custom parents can have external effects.
|
protected |
|
protected |
Validate the resolved objective and descriptor vectors. Reject invalid fitness and vectors outside declared coordinate bounds. This step runs before storage or parent forwarding.
Reimplemented in qdpy.containers.pareto.LocalParetoArchive, qdpy.containers.pareto.ParetoGrid, qdpy.containers.sliding.SlidingBoundariesGrid, qdpy.containers.t_domino.TDominOGrid, and qdpy.containers.voronoi.VoronoiArchive.
|
protected |
|
protected |
|
protected |
| Optional[int] qdpy.containers.base.Container.add | ( | self, | |
| IndividualLike | individual, | ||
| bool | raise_if_not_added_to_parents = False ) |
Validate one candidate and return its local storage index. An equal entry can return its existing index. Grid and novelty subclasses can decline a candidate locally and return None. Pass ``raise_if_not_added_to_parents=True`` to propagate parent insertion failures and preserve the current local entry. A failure across built-in parents restores the earlier branch contents. Custom parents are responsible for their own external side effects.
Reimplemented from qdpy.containers.base.ContainerLike.
Reimplemented in qdpy.containers.grids.AutoScalingGrid.
| Sequence[IndividualLike] qdpy.containers.base.Container.all_parents_inds | ( | self | ) |
Return immediate parent entries in parent order, including repeated entries.
Reimplemented from qdpy.containers.base.ContainerLike.
| Any qdpy.containers.base.Container.best | ( | self | ) |
Return the best individual.
Reimplemented from qdpy.containers.base.ContainerLike.
| Optional[FeaturesLike] qdpy.containers.base.Container.best_features | ( | self | ) |
Return the features values of the individual with the best quality, or None.
Reimplemented from qdpy.containers.base.ContainerLike.
| Optional[FitnessLike] qdpy.containers.base.Container.best_fitness | ( | self | ) |
Return the fitness values of the individual with the best quality, or None.
Reimplemented from qdpy.containers.base.ContainerLike.
| float qdpy.containers.base.Container.capacity | ( | self | ) |
Return the capacity of the container (i.e. maximal number of items/spots/bins/etc). Can be math.inf.
Reimplemented from qdpy.containers.base.ContainerLike.
| None qdpy.containers.base.Container.clear | ( | self, | |
| bool | also_from_parents = False ) |
Remove all local entries and refresh the cached best. With ``also_from_parents=True``, remove matching local entries from the parents as well. Parent-only entries may remain.
Reimplemented from qdpy.containers.base.ContainerLike.
Reimplemented in qdpy.containers.sliding.SlidingBoundariesGrid, and qdpy.containers.t_domino.TDominOGrid.
| None qdpy.containers.base.Container.clear_all | ( | self | ) |
| None qdpy.containers.base.Container.discard | ( | self, | |
| IndividualLike | individual, | ||
| bool | also_from_parents = False ) |
Remove the matching entry if present. Use ``also_from_parents`` to request removal from parent history as well. Removing the cached best triggers recomputation from the remaining entries.
Reimplemented from qdpy.containers.base.ContainerLike.
Reimplemented in qdpy.containers.grids.Grid, and qdpy.containers.sliding.SlidingBoundariesGrid.
| Optional[Sequence[DomainLike]] qdpy.containers.base.Container.features_extrema | ( | self | ) |
Return the extrema values of the features of the stored individuals.
Reimplemented from qdpy.containers.base.ContainerLike.
| Optional[Sequence[DomainLike]] qdpy.containers.base.Container.fitness_extrema | ( | self | ) |
Return the extrema values of the fitnesses of the stored individuals.
Reimplemented from qdpy.containers.base.ContainerLike.
| float qdpy.containers.base.Container.free | ( | self | ) |
Return the number of free spots in the container. Can be math.inf.
Reimplemented from qdpy.containers.base.ContainerLike.
| FeaturesLike qdpy.containers.base.Container.get_ind_features | ( | self, | |
| IndividualLike | individual, | ||
| * | args, | ||
| ** | kwargs ) |
Resolve the descriptor vector used by this container. Select configured named scores in descriptor order when names are supplied. Otherwise use the candidate's feature object.
Reimplemented from qdpy.containers.base.ContainerLike.
| FitnessLike qdpy.containers.base.Container.get_ind_fitness | ( | self, | |
| IndividualLike | individual, | ||
| * | args, | ||
| ** | kwargs ) |
Resolve the fitness used by this container for admission and ranking. Select named scores in objective order or use the candidate's fitness. When the container applies different weights, return a weighted copy so other archives sharing the same candidate keep their own semantics.
Reimplemented from qdpy.containers.base.ContainerLike.
| bool qdpy.containers.base.Container.in_bounds | ( | self, | |
| Any | val, | ||
| Any | domain ) |
| int qdpy.containers.base.Container.nb_added | ( | self | ) |
Return the number of individuals added into the container since its creation.
Reimplemented from qdpy.containers.base.ContainerLike.
| int qdpy.containers.base.Container.nb_discarded | ( | self | ) |
Return the number of individuals discarded by the container since its creation.
Reimplemented from qdpy.containers.base.ContainerLike.
| int qdpy.containers.base.Container.nb_operations | ( | self | ) |
Return the number of adds, modifications and discards since the creation of this container.
Reimplemented from qdpy.containers.base.ContainerLike.
| int qdpy.containers.base.Container.nb_rejected | ( | self | ) |
Return the number of individuals rejected (when added) by the container since its creation.
Reimplemented from qdpy.containers.base.ContainerLike.
| qdpy.containers.base.Container.novelty | ( | self, | |
| IndividualLike | individual, | ||
| ** | kwargs ) |
Score novelty against immediate parent entries. The metric uses the candidates' feature attributes. At least one parent is required.
Reimplemented from qdpy.containers.base.ContainerLike.
| qdpy.containers.base.Container.novelty_local_competition | ( | self, | |
| IndividualLike | individual, | ||
| ** | kwargs ) |
Score novelty and local competition against immediate parents. Metric options such as ``k`` and ``ignore_first`` are forwarded. At least one parent is required.
Reimplemented from qdpy.containers.base.ContainerLike.
| float qdpy.containers.base.Container.qd_score | ( | self, | |
| bool | normalized = True ) |
Sum quality over all locally stored individuals. With normalisation, measure each objective's improvement from the worst domain endpoint and divide by the interval width. Use the lower endpoint for maximisation and the upper for minimisation. A collapsed interval uses a divisor of one. A populated archive with an infinite fitness bound returns NaN when normalised. An empty archive with a fitness domain has a score of zero. Use ``normalized=False`` to sum raw values without applying weights.
Reimplemented from qdpy.containers.base.ContainerLike.
Reimplemented in qdpy.containers.grids.Grid.
| qdpy.containers.base.Container.set_ind_fitness | ( | self, | |
| IndividualLike | individual, | ||
| FitnessLike | fitness, | ||
| * | args, | ||
| ** | kwargs ) |
Store the raw fitness in the configured location. Write named objective scores when configured. Otherwise replace the candidate's fitness object, applying the container's weights if set.
Reimplemented from qdpy.containers.base.ContainerLike.
| int qdpy.containers.base.Container.size | ( | self | ) |
Return the size of the container (i.e. number of items, spots, bins, etc).
Reimplemented from qdpy.containers.base.ContainerLike.
| str qdpy.containers.base.Container.size_str | ( | self | ) |
| Any qdpy.containers.base.Container.to_grid | ( | self, | |
| Union[ShapeLike, int] | shape, | ||
| int | max_items_per_bin = 1, | ||
| Optional[float] | capacity = None, | ||
| **Any | kwargs ) |
Re-admit the stored entries to a new descriptor grid. Reuse declared domains by default. If absent, use the archive's observed extrema. Supply explicit domains when converting an empty archive. Named score selection and fitness weights are inherited unless overridden. :param shape: Number of cells per descriptor coordinate. :param max_items_per_bin: Maximum number of local entries in one cell. :param capacity: Total capacity override. None leaves it unbounded. :param kwargs: Other Grid options such as domains or storage type. :returns: A new grid containing the entries it admitted.
Reimplemented from qdpy.containers.base.ContainerLike.
| int qdpy.containers.base.Container.update | ( | self, | |
| Iterable | iterable, | ||
| bool | ignore_exceptions = True, | ||
| bool | issue_warning = False ) |
Offer each candidate for insertion and count reported local indexes. The count can include an existing equal entry. Use the change in ``nb_added`` to count actual insertions. With ``ignore_exceptions=True``, validation failures can be offered to parents instead. Set ``issue_warning=True`` to report them. Capacity and parent storage errors can still propagate.
Reimplemented from qdpy.containers.base.ContainerLike.
Reimplemented in qdpy.containers.grids.AutoScalingGrid.