Skip to content

Commit fb4f992

Browse files
authored
feat: add default erroring anticipative solver generators (#74)
1 parent 761b08c commit fb4f992

1 file changed

Lines changed: 21 additions & 15 deletions

File tree

src/Utils/interface/stochastic_benchmark.jl

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,22 @@ function generate_context(::AbstractStochasticBenchmark, rng, instance_sample::D
9595
return instance_sample
9696
end
9797

98+
"""
99+
objective_value(::ExogenousStochasticBenchmark, sample::DataSample, y, scenario) -> Real
100+
101+
Compute the objective value of solution `y` for a given `scenario`.
102+
Must be implemented by each concrete [`ExogenousStochasticBenchmark`](@ref).
103+
104+
This is the primary evaluation hook for stochastic benchmarks. The 2-arg fallback
105+
`objective_value(bench, sample, y)` dispatches here using the scenario stored in
106+
`sample.extra.scenario` (or averages over `sample.extra.scenarios`).
107+
"""
108+
function objective_value end
109+
98110
"""
99111
generate_anticipative_solver(::AbstractBenchmark) -> callable
100112
101-
Return a callable that computes the anticipative (oracle) solution.
113+
**Optional.** Return a callable that computes the anticipative (oracle) solution.
102114
The calling convention differs by benchmark category:
103115
104116
**Stochastic benchmarks** ([`AbstractStochasticBenchmark`](@ref)):
@@ -110,19 +122,9 @@ Returns `(env; reset_env=true, kwargs...) -> Vector{DataSample}`, a full traject
110122
`reset_env=true` resets the environment before solving (used for initial dataset building);
111123
`reset_env=false` starts from the current environment state (used inside DAgger rollouts).
112124
"""
113-
function generate_anticipative_solver end
114-
115-
"""
116-
objective_value(::ExogenousStochasticBenchmark, sample::DataSample, y, scenario) -> Real
117-
118-
Compute the objective value of solution `y` for a given `scenario`.
119-
Must be implemented by each concrete [`ExogenousStochasticBenchmark`](@ref).
120-
121-
This is the primary evaluation hook for stochastic benchmarks. The 2-arg fallback
122-
`objective_value(bench, sample, y)` dispatches here using the scenario stored in
123-
`sample.extra.scenario` (or averages over `sample.extra.scenarios`).
124-
"""
125-
function objective_value end
125+
function generate_anticipative_solver(b::ExogenousStochasticBenchmark; kwargs...)
126+
return error("generate_anticipative_solver is not implemented for $(typeof(b))")
127+
end
126128

127129
"""
128130
generate_parametric_anticipative_solver(::ExogenousStochasticBenchmark) -> callable
@@ -132,7 +134,11 @@ parametric anticipative subproblem:
132134
133135
argmin_{y ∈ Y(instance)} c(y, scenario) + θᵀy
134136
"""
135-
function generate_parametric_anticipative_solver end
137+
function generate_parametric_anticipative_solver(b::ExogenousStochasticBenchmark; kwargs...)
138+
return error(
139+
"generate_parametric_anticipative_solver is not implemented for $(typeof(b))"
140+
)
141+
end
136142

137143
"""
138144
$TYPEDSIGNATURES

0 commit comments

Comments
 (0)