|
73 | 73 | """ |
74 | 74 | $TYPEDSIGNATURES |
75 | 75 |
|
76 | | -Create a dataset of `dataset_size` instances for the given `StochasticVehicleSchedulingBenchmark`. |
77 | | -If you want to not add label solutions in the dataset, set `compute_solutions=false`. |
| 76 | +Generate a sample for the given `StochasticVehicleSchedulingBenchmark`. |
| 77 | +If you want to not add label solutions in the sample, set `compute_solutions=false`. |
78 | 78 | By default, they will be computed using column generation. |
79 | 79 | Note that computing solutions can be time-consuming, especially for large instances. |
80 | 80 | You can also use instead `compact_mip` or `compact_linearized_mip` as the algorithm to compute solutions. |
81 | 81 | If you want to provide a custom algorithm to compute solutions, you can pass it as the `algorithm` keyword argument. |
82 | 82 | If `algorithm` takes keyword arguments, you can pass them as well directly in `kwargs...`. |
83 | | -If `store_city=false`, the coordinates and unnecessary information about instances will not be stored in the dataset. |
| 83 | +If `store_city=false`, the coordinates and unnecessary information about instances will not be stored in the sample. |
84 | 84 | """ |
85 | | -function Utils.generate_dataset( |
| 85 | +function Utils.generate_sample( |
86 | 86 | benchmark::StochasticVehicleSchedulingBenchmark, |
87 | | - dataset_size::Int; |
| 87 | + rng::AbstractRNG; |
| 88 | + store_city=true, |
88 | 89 | compute_solutions=true, |
89 | | - seed=nothing, |
90 | | - rng=MersenneTwister(0), |
91 | 90 | algorithm=column_generation_algorithm, |
92 | | - store_city=true, |
93 | 91 | kwargs..., |
94 | 92 | ) |
95 | 93 | (; nb_tasks, nb_scenarios) = benchmark |
96 | | - Random.seed!(rng, seed) |
97 | | - instances = [ |
98 | | - Instance(; nb_tasks, nb_scenarios, rng, store_city) for _ in 1:dataset_size |
99 | | - ] |
100 | | - features = get_features.(instances) |
101 | | - if compute_solutions |
102 | | - solutions = [algorithm(instance; kwargs...).value for instance in instances] |
103 | | - return [ |
104 | | - DataSample(; x=feature, instance, y_true=solution) for |
105 | | - (instance, feature, solution) in zip(instances, features, solutions) |
106 | | - ] |
| 94 | + instance = Instance(; nb_tasks, nb_scenarios, rng, store_city) |
| 95 | + x = get_features(instance) |
| 96 | + y_true = if compute_solutions |
| 97 | + algorithm(instance; kwargs...).value # TODO: modify algorithms to directly return the solution |
| 98 | + else |
| 99 | + nothing |
107 | 100 | end |
108 | | - # else |
109 | | - return [ |
110 | | - DataSample(; x=feature, instance) for |
111 | | - (instance, feature) in zip(instances, features) |
112 | | - ] |
| 101 | + return DataSample(; x, instance, y_true) |
113 | 102 | end |
114 | 103 |
|
115 | 104 | """ |
|
126 | 115 | $TYPEDSIGNATURES |
127 | 116 | """ |
128 | 117 | function Utils.generate_maximizer( |
129 | | - bench::StochasticVehicleSchedulingBenchmark; model_builder=highs_model |
| 118 | + ::StochasticVehicleSchedulingBenchmark; model_builder=highs_model |
130 | 119 | ) |
131 | 120 | return StochasticVechicleSchedulingMaximizer(model_builder) |
132 | 121 | end |
|
0 commit comments