Benchmark
BenchmarkConfig(n_hubs, n_nodes_range, n_clients_range, methods, random_nodes=True, random_n_clients_route=False, alpha=0.7, min_budget_factor=0.2, max_budget_factor=5.0, time_limit=3600, mip_gap=0.0001, int_feas_tol=1e-09, benchmark_type='n_nodes', file_name='benchmark_results', output_dir='benchmark_results', seed_dict=(lambda: {run: run for run in (range(1, 11))})(), n_runs=10, scaling=True, scaling_factor=1000)
dataclass
¶
Benchmark job configuration.
Holds everything needed to describe a single benchmark queue entry: what ranges to sweep, which methods to run, and how results are saved.
BenchmarkResult(n_nodes, n_hubs, alpha, method, total_time, solving_time, lagrange_time, optimal, gap, node_count, n_clients, n_clients_route, random_n_clients_route, min_budget_factor, max_budget_factor, run_number, seed, sanctioned=False)
dataclass
¶
Stores the result of a single benchmark solve.
Captures the configuration parameters (nodes, hubs, clients, seed) together with the solution metrics returned by a specific model/solver run (solving time, optimality gap, node count, etc.).
from_solution(solution, config, n_nodes, n_clients, run, method)
classmethod
¶
Construct from a
[BaseModelSolution][bilevelpy.solution.core.BaseModelSolution]
and benchmark configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
solution
|
BaseModelSolution
|
The solution returned by the solver. |
required |
config
|
BenchmarkConfig
|
The benchmark configuration. |
required |
n_nodes
|
int
|
Number of nodes in the instance. |
required |
n_clients
|
int
|
Number of clients per route. |
required |
run
|
int
|
Run number (1-indexed, for seed lookup). |
required |
method
|
str
|
Method string key (e.g. |
required |
Source code in src/oracle_paper/benchmark/result.py
sanctioned_method(config, method, n_nodes, n_clients, run)
classmethod
¶
Create a placeholder result for a sanctioned (skipped) method.
Source code in src/oracle_paper/benchmark/result.py
BenchmarkResults(save=False)
¶
Manages a collection of
BenchmarkResult
instances.
Provides utilities to add results, export to CSV, filter, and iterate.
Source code in src/oracle_paper/benchmark/results.py
BenchmarkResultsSaver(bench_config)
¶
Saves raw benchmark results to timestamped folders.
File paths are constructed from benchmark configuration and the current date/time.
Source code in src/oracle_paper/benchmark/results_saver.py
save_benchmark_raw_results(benchmark_results)
¶
Save raw benchmark results to CSV.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
benchmark_results
|
BenchmarkResults
|
The results collection to persist. |
required |
Source code in src/oracle_paper/benchmark/results_saver.py
BenchmarkRunner(config)
¶
Runs benchmark experiments from a
BenchmarkConfig.
For each scenario (varying n_nodes or n_clients), it calls
PaperModelProvider.build_and_solve for every method × run
combination, collects
BenchmarkResult
entries, and streams raw results to disk after each solve.
Supports optional progress and result callbacks for live UIs.
Source code in src/oracle_paper/benchmark/runner.py
add_callback(callback_fn)
¶
run()
¶
Execute the full benchmark grid.
Source code in src/oracle_paper/benchmark/runner.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | |
set_progress_callback(callback)
¶
Register a progress callback: fn(current, total, status_text).
PaperModelProvider(config)
¶
Bases: ModelProvider
Builds datasets and instantiates models for benchmark runs.
Handles the full pipeline for each of the four models studied in the paper. For a given scenario (nodes, clients, hubs), it:
- Builds the dataset via the standard pipeline (CAB loader → node selection → cost scaling → client generation → client ranking).
- Runs the appropriate calculators (Lagrange and/or recursive Lagrange) depending on the model.
- Instantiates the model with the configured parameters.
- Solves and returns the solution with metadata attached.
Source code in src/oracle_paper/benchmark/model_provider.py
build_and_solve(model_name, scenario, run_idx, seed)
¶
Build dataset, instantiate model, solve, and return the solution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_name
|
ModelMetaData
|
Which model to run (from
|
required |
scenario
|
Dict[str, Any]
|
Dict with |
required |
run_idx
|
int
|
Zero-based run index (for dataset seed offset). |
required |
seed
|
int
|
Random seed for reproducibility. |
required |
Returns:
| Type | Description |
|---|---|
BaseModelSolution
|
The solution produced by |
BaseModelSolution
|
[ |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/oracle_paper/benchmark/model_provider.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | |
main()
¶
Launch the Streamlit benchmark UI.