Struct CostProblem
pub struct CostProblem { /* private fields */ }Expand description
A cost-varying two-objective problem for the CARBS oracle: a bowl in the tuning parameters whose loss is bought down by a resource knob that also makes each evaluation more expensive.
The point is that cost varies across the space and cost-awareness pays
(docs/design/09-implementation.md §8.3). Concretely, over tuning parameters
x0..x{d-1} ∈ [-5, 5] and a resource r ∈ [0, 1]:
- performance loss (minimize):
f(x, r) = Σ (xᵢ − cᵢ)² − gain·r. The bowl is shifted off the Sobol grid (cᵢalternating+1.234 / −2.345, the §8.3 vacuous-oracle guard), and more resource lowers the loss — so the global optimum sits at the most expensive cornerr = 1. - cost (minimize):
cost(r) = exp(cost_rate·r), independent ofx, growing from1atr = 0toexp(cost_rate)atr = 1.
A cost-blind optimizer chases the global loss optimum and is drawn to the
expensive r → 1 corner; a cost-aware one (CARBS) discovers that a
well-tuned x at small r is nearly as good for a fraction of the cost, and
concentrates there. The efficiency metric that separates them is
capped_best_perf: the best loss reached among
trials whose cost stays under cost_cap (here the cost at
r = 0.25). A cost-aware search fills the cheap region with well-tuned points
and wins it; a cost-blind search wastes its budget above the cap.
Implementations§
§impl CostProblem
impl CostProblem
pub fn resource_bowl(tuning_dims: usize) -> Self
pub fn resource_bowl(tuning_dims: usize) -> Self
The canonical resource-bowl instance: tuning_dims tuning axes, a gain of
5, a cost rate of ln(20) (cost ranges 1..20), and an affordability cap
at r = 0.25.
pub fn schema(&self) -> Result<SpaceSchema>
pub fn schema(&self) -> Result<SpaceSchema>
The search space: one linear float per tuning axis (x0..), then the
resource r ∈ [0, 1].
§Errors
Error::InvalidSpace if a bound is not
finite — which never happens for the built-in instance.
pub fn eval(&self, assignment: &Assignment) -> (f64, f64)
pub fn eval(&self, assignment: &Assignment) -> (f64, f64)
Evaluates the problem at assignment, returning (performance loss, cost)
— both minimized.
A coordinate this problem declared but the assignment does not bind is a
wiring mistake, not a search outcome: it trips a debug assertion rather
than becoming a NaN row that merely never wins. Release builds keep
the total NaN contract: an unbound coordinate reads as NaN and the
row is scored as one, rather than aborting a benchmark sweep.
pub fn cost_cap(&self) -> f64
pub fn cost_cap(&self) -> f64
The affordability cap on cost: the cost at the cap_resource
level. A trial is “cheap” iff its cost does not exceed this.
pub fn capped_best_perf(&self, records: &[(f64, f64)]) -> f64
pub fn capped_best_perf(&self, records: &[(f64, f64)]) -> f64
The best (lowest) performance loss among (perf, cost) records whose cost
is within cost_cap — the performance-per-cost metric the
CARBS ablation is scored on. f64::INFINITY if no record is affordable.
Trait Implementations§
§impl Clone for CostProblem
impl Clone for CostProblem
§fn clone(&self) -> CostProblem
fn clone(&self) -> CostProblem
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for CostProblem
impl RefUnwindSafe for CostProblem
impl Send for CostProblem
impl Sync for CostProblem
impl Unpin for CostProblem
impl UnsafeUnpin for CostProblem
impl UnwindSafe for CostProblem
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T, U> Imply<T> for U
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more