PineForge HPO 1.11.0
Native hyperparameter optimization for PineForge strategies
Loading...
Searching...
No Matches
pruner.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstddef>
4#include <optional>
5#include <vector>
6
7namespace pineforge::hpo {
8
10enum class PrunerKind { None, Median, Halving };
11
15class Pruner final {
16public:
18 Pruner(PrunerKind kind, std::vector<double> rungs, unsigned eta, bool minimize);
20 std::vector<std::size_t> bar_counts(std::size_t full_size) const;
22 std::vector<std::optional<double>> cuts() const;
24 void observe(const std::vector<std::optional<double>>& scores);
26 bool prune(double score, std::optional<double> cut) const noexcept;
27
28private:
29 PrunerKind kind_;
30 std::vector<double> rungs_;
31 unsigned eta_;
32 bool minimize_;
33 std::vector<std::vector<double>> history_;
34 std::vector<std::size_t> cursors_;
35};
36
37} // namespace pineforge::hpo
Coordinator-owned rung history.
Definition pruner.hpp:15
Pruner(PrunerKind kind, std::vector< double > rungs, unsigned eta, bool minimize)
Validates increasing fractions in (0, 1) and an elimination factor >= 2.
std::vector< std::optional< double > > cuts() const
Returns cuts based only on observations already committed by the coordinator.
bool prune(double score, std::optional< double > cut) const noexcept
Strictly losing scores are pruned; ties and missing cuts survive.
std::vector< std::size_t > bar_counts(std::size_t full_size) const
Returns prefix lengths, including the full window, without duplicates.
void observe(const std::vector< std::optional< double > > &scores)
Adds finite rung observations after an entire batch has finished.
@ None
Evaluation succeeded.
PrunerKind
Prefix pruning policy; disabled by default in the native runner.
Definition pruner.hpp:10