Skip to content

Commit 9069660

Browse files
committed
clarify the generate_sample interface
1 parent 01596f2 commit 9069660

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

src/Utils/interface.jl

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ Choose one of three primary implementation strategies:
88
- Implement [`generate_instance`](@ref) (returns a [`DataSample`](@ref) with `y=nothing`).
99
The default [`generate_sample`](@ref) forwards the call directly; [`generate_dataset`](@ref)
1010
applies `target_policy` afterwards if provided.
11-
- Override [`generate_sample`](@ref) directly when the sample requires custom logic.
11+
- Override [`generate_sample`](@ref) directly when the sample requires custom logic
12+
that cannot be expressed via [`generate_instance`](@ref). Applies to static benchmarks
13+
only, stochastic benchmarks should implement the finer-grained hooks instead
14+
([`generate_instance`](@ref), [`generate_context`](@ref), [`generate_scenario`](@ref)).
1215
[`generate_dataset`](@ref) applies `target_policy` to the result after the call returns.
1316
- Override [`generate_dataset`](@ref) directly when samples cannot be drawn independently.
1417
@@ -51,6 +54,12 @@ Calls [`generate_instance`](@ref) and returns the result directly.
5154
5255
Override this method when sample generation requires custom logic. Labeling via
5356
`target_policy` is always applied by [`generate_dataset`](@ref) after this call returns.
57+
58+
!!! note
59+
This is an internal hook called by [`generate_dataset`](@ref). Prefer calling
60+
[`generate_dataset`](@ref) rather than this method directly. For stochastic
61+
benchmarks, implement [`generate_instance`](@ref), [`generate_context`](@ref),
62+
and [`generate_scenario`](@ref) instead of overriding this method.
5463
"""
5564
function generate_sample(bench::AbstractBenchmark, rng; kwargs...)
5665
return generate_instance(bench, rng; kwargs...)
@@ -340,6 +349,14 @@ draws scenarios via [`generate_scenario`](@ref), then:
340349
`target_policy(ctx_sample, scenarios) -> Vector{DataSample}` enables
341350
anticipative labeling (K samples, one per scenario) or SAA (1 sample aggregating all K
342351
scenarios).
352+
353+
!!! note
354+
This is an internal override of [`generate_sample`](@ref) for the stochastic pipeline,
355+
called by [`generate_dataset`](@ref). New stochastic benchmarks should implement
356+
[`generate_instance`](@ref), [`generate_context`](@ref), and [`generate_scenario`](@ref)
357+
rather than overriding this method. Note that the return type is `Vector{DataSample}`
358+
(one per context × scenario combination), unlike the base method which returns a
359+
single `DataSample`.
343360
"""
344361
function generate_sample(
345362
bench::ExogenousStochasticBenchmark,

0 commit comments

Comments
 (0)