Skip to content

Commit 773cbe9

Browse files
committed
Switch to horizontal type hierarchy
1 parent 341ed4a commit 773cbe9

16 files changed

Lines changed: 708 additions & 690 deletions

File tree

docs/src/custom_benchmarks.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ problems to the benchmark suite or integrate their own domains.
99
## Type hierarchy
1010

1111
```
12-
AbstractBenchmark
12+
AbstractStaticBenchmark
1313
└── AbstractStochasticBenchmark{exogenous}
1414
└── AbstractDynamicBenchmark{exogenous}
1515
```
1616

1717
| Type | Use case |
1818
|------|----------|
19-
| `AbstractBenchmark` | Static, single-stage optimization (e.g. shortest path, portfolio) |
19+
| `AbstractStaticBenchmark` | Static, single-stage optimization (e.g. shortest path, portfolio) |
2020
| `AbstractStochasticBenchmark{true}` | Single-stage with exogenous uncertainty (scenarios drawn independently of decisions) |
2121
| `AbstractStochasticBenchmark{false}` | Single-stage with endogenous uncertainty |
2222
| `AbstractDynamicBenchmark{true}` | Multi-stage sequential decisions with exogenous uncertainty |
@@ -41,7 +41,7 @@ repeatedly and applies `target_policy` to each result.
4141

4242
---
4343

44-
## `AbstractBenchmark`: required methods
44+
## `AbstractStaticBenchmark`: required methods
4545

4646
### Data generation (choose one strategy)
4747

docs/src/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Where:
4343

4444
The package organizes benchmarks into three main categories based on their problem structure:
4545

46-
### Static Benchmarks (`AbstractBenchmark`)
46+
### Static Benchmarks (`AbstractStaticBenchmark`)
4747
Single-stage optimization problems with no randomness involved:
4848
- [`ArgmaxBenchmark`](@ref): argmax toy problem
4949
- [`Argmax2DBenchmark`](@ref): 2D argmax toy problem

docs/src/using_benchmarks.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This guide covers everything you need to work with existing benchmarks in Decisi
88

99
A benchmark bundles a problem family (an instance generator, a combinatorial solver, and a statistical model architecture) into a single object. It provides everything needed to run a Decision-Focused Learning experiment out of the box, without having to create each component from scratch.
1010
Three abstract types cover the main settings:
11-
- **`AbstractBenchmark`**: static problems (one instance, one decision)
11+
- **`AbstractStaticBenchmark`**: static problems (one instance, one decision)
1212
- **`AbstractStochasticBenchmark{exogenous}`**: stochastic problems (type parameter indicates whether uncertainty is exogenous)
1313
- **`AbstractDynamicBenchmark{exogenous}`**: sequential / multi-stage problems
1414

@@ -65,7 +65,7 @@ sample.scenario # looks up :scenario in context first, then in extra
6565

6666
### Static benchmarks
6767

68-
For static benchmarks (`<:AbstractBenchmark`), `generate_dataset` may compute a default ground-truth label `y` if the benchmark implements it:
68+
For static benchmarks (`<:AbstractStaticBenchmark`), `generate_dataset` may compute a default ground-truth label `y` if the benchmark implements it:
6969

7070
```julia
7171
bench = ArgmaxBenchmark()

src/Argmax/Argmax.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Basic benchmark problem with an argmax as the CO algorithm.
1515
# Fields
1616
$TYPEDFIELDS
1717
"""
18-
struct ArgmaxBenchmark{E} <: AbstractBenchmark
18+
struct ArgmaxBenchmark{E} <: AbstractStaticBenchmark
1919
"instances dimension, total number of classes"
2020
instance_dim::Int
2121
"number of features"

src/Argmax2D/Argmax2D.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Argmax becnhmark on a 2d polytope.
1616
# Fields
1717
$TYPEDFIELDS
1818
"""
19-
struct Argmax2DBenchmark{E,R} <: AbstractBenchmark
19+
struct Argmax2DBenchmark{E,R} <: AbstractStaticBenchmark
2020
"number of features"
2121
nb_features::Int
2222
"true mapping between features and costs"

src/FixedSizeShortestPath/FixedSizeShortestPath.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Data is generated using the process described in: <https://arxiv.org/abs/2307.13
2121
# Fields
2222
$TYPEDFIELDS
2323
"""
24-
struct FixedSizeShortestPathBenchmark <: AbstractBenchmark
24+
struct FixedSizeShortestPathBenchmark <: AbstractStaticBenchmark
2525
"grid graph instance"
2626
graph::SimpleDiGraph{Int64}
2727
"grid size of graphs"

src/PortfolioOptimization/PortfolioOptimization.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Data is generated using the process described in: <https://arxiv.org/abs/2307.13
1919
# Fields
2020
$TYPEDFIELDS
2121
"""
22-
struct PortfolioOptimizationBenchmark <: AbstractBenchmark
22+
struct PortfolioOptimizationBenchmark <: AbstractStaticBenchmark
2323
"number of assets"
2424
d::Int
2525
"size of feature vectors"

src/Ranking/Ranking.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Basic benchmark problem with ranking as the CO algorithm.
1515
# Fields
1616
$TYPEDFIELDS
1717
"""
18-
struct RankingBenchmark{E} <: AbstractBenchmark
18+
struct RankingBenchmark{E} <: AbstractStaticBenchmark
1919
"instances dimension, total number of classes"
2020
instance_dim::Int
2121
"number of features"

src/SubsetSelection/SubsetSelection.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ without knowing their values, but only observing some features.
1818
# Fields
1919
$TYPEDFIELDS
2020
"""
21-
struct SubsetSelectionBenchmark{M} <: AbstractBenchmark
21+
struct SubsetSelectionBenchmark{M} <: AbstractStaticBenchmark
2222
"total number of items"
2323
n::Int
2424
"number of items to select"

src/Utils/Utils.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ include("data_sample.jl")
1515
include("maximizers.jl")
1616
include("environment.jl")
1717
include("policy.jl")
18-
include("interface.jl")
18+
include("interface/abstract_benchmark.jl")
19+
include("interface/static_benchmark.jl")
20+
include("interface/stochastic_benchmark.jl")
21+
include("interface/dynamic_benchmark.jl")
1922
include("grid_graph.jl")
2023
include("misc.jl")
2124
include("model_builders.jl")
@@ -26,7 +29,8 @@ export TopKMaximizer, one_hot_argmax
2629

2730
export AbstractEnvironment, get_seed, is_terminated, observe, reset!, step!
2831

29-
export AbstractBenchmark, AbstractStochasticBenchmark, AbstractDynamicBenchmark
32+
export AbstractBenchmark,
33+
AbstractStaticBenchmark, AbstractStochasticBenchmark, AbstractDynamicBenchmark
3034
export ExogenousStochasticBenchmark,
3135
EndogenousStochasticBenchmark, ExogenousDynamicBenchmark, EndogenousDynamicBenchmark
3236
export generate_instance, generate_sample, generate_dataset

0 commit comments

Comments
 (0)