Class SuccessiveHalvingPruner
- Namespace
- OptunaSharp.Pruners
- Assembly
- OptunaSharp.dll
Pruner using Asynchronous Successive Halving Algorithm.
Port of optuna/pruners/_successive_halving.py: SuccessiveHalvingPruner.
Successive Halving is a bandit-based algorithm to identify the best one among multiple configurations. This class implements an asynchronous version of Successive Halving (ASHA).
Note that this class does not take care of the parameter for the maximum resource, referred to as R in the paper. The maximum resource allocated to a trial is typically limited inside the objective function.
public class SuccessiveHalvingPruner : BasePruner
- Inheritance
-
SuccessiveHalvingPruner
- Inherited Members
Constructors
SuccessiveHalvingPruner(long?, int, int, int)
Configures asynchronous rung promotion and its minimum resource budget.
public SuccessiveHalvingPruner(long? minResource = null, int reductionFactor = 4, int minEarlyStoppingRate = 0, int bootstrapCount = 0)
Parameters
minResourcelong?The minimum resource allocated to a trial (
rin the paper), ornullfor Optuna's"auto": the value is determined based on a heuristic that looks at the number of required steps for the first trial to complete.reductionFactorintReduction factor of promotable trials (
etain the paper). At the completion point of each rung, about1/reductionFactortrials will be promoted.minEarlyStoppingRateintThe minimum early-stopping rate (
sin the paper).bootstrapCountintMinimum number of trials that need to complete a rung before any trial is considered for promotion into the next rung.
Exceptions
- ValueError
The minimum resource is below one, the reduction factor is below two, an early-stopping/bootstrap count is negative, or positive bootstrap is combined with automatic minimum resource.
Methods
Prune(Study, FrozenTrial)
Judge whether the trial should be pruned based on the reported values.
Note that this method is not supposed to be called by library users. Instead, Report(double, long) and ShouldPrune() provide user interfaces to implement pruning mechanism in an objective function.
public override bool Prune(Study study, FrozenTrial trial)
Parameters
studyStudyStudy object of the target study.
trialFrozenTrialFrozenTrial object of the target trial. Take a copy before modifying this object.
Returns
- bool
A boolean value representing whether the trial should be pruned.
Exceptions
- RuntimeError
The study has multiple objectives and the pruning rule requests its scalar direction.