Skip to content

Commit b30fe33

Browse files
committed
update
1 parent 20e8a4f commit b30fe33

File tree

5 files changed

+45
-11
lines changed

5 files changed

+45
-11
lines changed

src/DynamicAssortment/DynamicAssortment.jl

Whitespace-only changes.

src/DynamicVehicleScheduling/DynamicVehicleScheduling.jl

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,19 @@ include("maximizer.jl")
5151
$TYPEDEF
5252
5353
Abstract type for dynamic vehicle scheduling benchmarks.
54+
55+
# Fields
56+
$TYPEDFIELDS
5457
"""
5558
@kwdef struct DVSPBenchmark <: AbstractDynamicBenchmark
59+
"todo"
5660
max_requests_per_epoch::Int = 10
61+
"todo"
5762
Δ_dispatch::Float64 = 1.0
63+
"todo"
5864
epoch_duration::Float64 = 1.0
65+
"todo"
66+
two_dimensional_features::Bool = false
5967
end
6068

6169
function Utils.generate_dataset(b::DVSPBenchmark, dataset_size::Int=1)
@@ -74,14 +82,6 @@ function Utils.generate_dataset(b::DVSPBenchmark, dataset_size::Int=1)
7482
]
7583
end
7684

77-
function Utils.generate_scenario_generator(::DVSPBenchmark)
78-
return generate_scenario
79-
end
80-
81-
function Utils.generate_anticipative_solver(::DVSPBenchmark; kwargs...)
82-
return anticipative_solver
83-
end
84-
8585
function Utils.generate_environment(::DVSPBenchmark, instance::Instance; kwargs...)
8686
return DVSPEnv(instance; kwargs...)
8787
end
@@ -90,6 +90,14 @@ function Utils.generate_maximizer(::DVSPBenchmark)
9090
return LinearMaximizer(oracle; g, h)
9191
end
9292

93+
function Utils.generate_scenario_generator(::DVSPBenchmark)
94+
return generate_scenario
95+
end
96+
97+
function Utils.generate_anticipative_solver(b::DVSPBenchmark; kwargs...)
98+
return AnticipativeSolver(b.two_dimensional_features)
99+
end
100+
93101
export DVSPBenchmark #, generate_environment # , generate_sample, generate_anticipative_solver
94102
export run_policy!,
95103
GreedyVSPPolicy, LazyVSPPolicy, KleopatraVSPPolicy, AnticipativeVSPPolicy

src/DynamicVehicleScheduling/algorithms/anticipative_solver.jl

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ Solve the anticipative VSP problem for environment `env`.
4141
For this, it uses the current environment history, so make sure that the environment is terminated before calling this method.
4242
"""
4343
function anticipative_solver(
44-
env::DVSPEnv, scenario=env.scenario; model_builder=highs_model, reset_env=false
44+
env::DVSPEnv,
45+
scenario=env.scenario;
46+
model_builder=highs_model,
47+
reset_env=false,
48+
two_dimensional_features=false,
4549
)
4650
reset_env && reset!(env)
4751
request_epoch = [0]
@@ -180,10 +184,26 @@ function anticipative_solver(
180184
)
181185

182186
# x = compute_2D_features(state, env.instance)
183-
x = compute_features(state, env.instance)
187+
x = if two_dimensional_features
188+
compute_2D_features(state, env.instance)
189+
else
190+
compute_features(state, env.instance)
191+
end
184192

185193
return DataSample(; instance=state, y_true, x)
186194
end
187195

188196
return obj, dataset
189197
end
198+
199+
@kwdef struct AnticipativeSolver
200+
is_2D::Bool = false
201+
end
202+
203+
function (solver::AnticipativeSolver)(env::DVSPEnv, scenario=env.scenario; reset_env=false)
204+
if solver.is_2D
205+
return anticipative_solver(env, scenario; model_builder=highs_model_2d, reset_env)
206+
else
207+
return anticipative_solver(env, scenario; model_builder=highs_model, reset_env)
208+
end
209+
end

src/DynamicVehicleScheduling/environment/plot.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
function plot_instance(env::DVSPEnv; kwargs...)
2+
return plot_instance(env.instance.static_instance; kwargs...)
3+
end
4+
15
# """
26
# $TYPEDSIGNATURES
37

src/Utils/interface.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,11 @@ It follows the same interface as [`AbstractBenchmark`](@ref), with the addition
189189
"""
190190
abstract type AbstractStochasticBenchmark <: AbstractBenchmark end
191191

192+
function generate_scenario end
193+
192194
# only works for exogenous noise
193195
"""
194-
generate_scenario(::AbstractStochasticBenchmark; kwargs...)
196+
generate_scenario_generator(::AbstractStochasticBenchmark; kwargs...)
195197
"""
196198
function generate_scenario_generator end
197199

0 commit comments

Comments
 (0)