Class IntersectionSearchSpace
- Namespace
- OptunaSharp.SearchSpace
- Assembly
- OptunaSharp.dll
A class to calculate the intersection search space of a Study.
Port of optuna/search_space/intersection.py: IntersectionSearchSpace.
Intersection search space contains the intersection of parameter distributions that have been suggested in the completed trials of the study so far. If there are multiple parameters that have the same name but different distributions, neither is included in the resulting search space (i.e., the parameters with dynamic value ranges are excluded).
Note that an instance of this class is supposed to be used for only one study. If different studies are passed to Calculate(Study, bool), a ValueError is raised.
public class IntersectionSearchSpace
- Inheritance
-
IntersectionSearchSpace
- Inherited Members
Constructors
IntersectionSearchSpace(bool)
Creates a per-study incremental intersection cache with optional pruned-trial handling.
public IntersectionSearchSpace(bool includePruned = false)
Parameters
includePrunedboolWhether pruned trials should be included in the search space.
Methods
Calculate(Study, bool)
Returns the intersection search space of the Study.
public OrderedDict<string, BaseDistribution> Calculate(Study study, bool useCache = false)
Parameters
studyStudyA study with completed trials. The same study must be passed for one instance of this class through its lifetime.
useCacheboolAn option to use cached trials for each trial.
Returns
- OrderedDict<string, BaseDistribution>
A dictionary containing the parameter names and parameter's distributions sorted by parameter names.
Remarks
The returned dictionary is a new sorted container. Distribution objects are shared with trial snapshots and are treated as immutable.
The trials are read through Study.GetTrialsForSampler: on an in-memory storage that is the
zero-copy view, so a call costs only the trials since the cached trial number, where Optuna copies the
whole history first. The walk below already stops at the cached number; the copy was the part that grew
with the study. Elsewhere the read is Optuna's, cache included.
Exceptions
- ValueError
This cache is reused with a different study identifier.