Skip to content

Interface overhaul #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from
Draft

Interface overhaul #30

wants to merge 15 commits into from

Conversation

BatyLeo
Copy link
Member

@BatyLeo BatyLeo commented Jul 3, 2025

The goal of this PR is to increase the expressivity of the benchmarks interface, to allow for easy implmentations of stochastic and dynamic benchmark problems, as well as their associated learning algorithms.

New abstract types

For this, we define two new sub abstract types of AbstractBenchmark:

AbstractDynamicBenchmark <: AbstractStochasticBenchmark <: AbstractBenchmark

This assumes any dynamic problem is also stochastic.

New interface methods

For AbstractBenchmark

Implementing the full generate_dataset method can in practice be a bit tedious and verbose for no reason. While keeping the option to implement it for some applications where it makes sense, we propose an alternative where the user only needs to implement a generate_sample method that outputs a single DataSample instead of a full dataset:

generate_sample(::AbstractBenchmark, rng::AbstractRNG; kwargs...) -> DataSample

For AbstractStochasticBenchmark

We need two new methods, one for generating scenarios, and one for computing anticipative decisions:

generate_scenario_generator(::AbstractStochasticBenchmark; kwargs...)
generate_anticipative_solver(::AbstractStochasticBenchmark; kwargs...)

Note that in both cases this only applies to problems with exogenous noise.

generate_scenario_generator should output a callable that takes as input an instance, along with optional seed and rng as kwargs, and outputs a scenario, which can be a custom type depending on the benchmark.

generate_anticipative_solver should output a callable that takes as input an instance and a scenario (generated by the scenario generator), and outputs the corresponding anticipative decision.

For AbstractDynamicBenchmark

For dynamic problems, we mainly need to instantiate environments from instances. For this, we define the generate_environment and generate_environments methods. Similarly to generate_sample and generate_datasets, one may only need to implement the first one, that takes as inpout an instance and outputs an environment. If needed, this environment type can be defined as a subtype of AbstractEnv from CommonRLInterface.jl for better integration and compatibility in the ecosystem.

Additionally, we may want to apply RL algorithms to non-dynamic benchmarks, by considering them as dynamic problems with time horizon of length 1. We therefore propose a StaticEnv <: AbstractEnv wrapper around static instances for this.

New Benchmark problems

Currently, the Dynamic vehicle scheduling problem is implemented with thuis interface.
We plan to additionally implement the Dynamic VRP as well as the dynamic Inventory routing.

Points I'm unsure about

  • having generator for scenario generator is a bit weird, there might be a better way to have a cleaner interface from the user point iof view
  • currently, the two new abstract types are not that useful, they mainly exist to separate the interface but there is not much methods that dispatch on these types currently (the only one is generate_environments)
  • for implementing mirror descent algorihms on single stage stochastic benchmarks we will need additional maximizers, not sure where they belong in this interface, it may become a bit messy if we have too many generators
  • what about endogenous noise problems?

TODO:

  • transform the stochastic VSP benchmark into a AbstractStochasticBenchmark
  • implement the StaticEnv wrapper
  • implement DVRP
  • implement DIRP

Copy link

codecov bot commented Jul 3, 2025

Codecov Report

Attention: Patch coverage is 7.41990% with 549 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ehicleScheduling/algorithms/anticipative_solver.jl 0.00% 104 Missing ⚠️
src/DynamicVehicleScheduling/environment/state.jl 0.00% 85 Missing ⚠️
src/DynamicVehicleScheduling/static_vsp/parsing.jl 0.00% 75 Missing ⚠️
...hicleScheduling/algorithms/prize_collecting_vsp.jl 0.00% 59 Missing ⚠️
...ynamicVehicleScheduling/environment/environment.jl 0.00% 24 Missing ⚠️
src/DynamicVehicleScheduling/learning/features.jl 0.00% 24 Missing ⚠️
...c/DynamicVehicleScheduling/environment/scenario.jl 0.00% 23 Missing ⚠️
src/DynamicVehicleScheduling/maximizer.jl 0.00% 16 Missing ⚠️
...rc/DynamicVehicleScheduling/static_vsp/solution.jl 0.00% 16 Missing ⚠️
...micVehicleScheduling/policy/abstract_vsp_policy.jl 0.00% 14 Missing ⚠️
... and 14 more
Files with missing lines Coverage Δ
src/Argmax/Argmax.jl 100.00% <100.00%> (ø)
src/FixedSizeShortestPath/FixedSizeShortestPath.jl 93.87% <100.00%> (-0.13%) ⬇️
src/Ranking/Ranking.jl 100.00% <100.00%> (ø)
...cheduling/solution/algorithms/column_generation.jl 86.90% <100.00%> (ø)
...cheduling/solution/algorithms/deterministic_mip.jl 100.00% <100.00%> (ø)
...icleScheduling/solution/algorithms/local_search.jl 97.40% <100.00%> (ø)
...hasticVehicleScheduling/solution/algorithms/mip.jl 100.00% <100.00%> (ø)
src/SubsetSelection/SubsetSelection.jl 100.00% <100.00%> (ø)
src/Utils/data_sample.jl 9.52% <ø> (ø)
src/Utils/model_builders.jl 100.00% <ø> (ø)
... and 25 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@BatyLeo BatyLeo changed the title Interface overhaul for stochastic and dynamic benchmarks Interface overhaul Jul 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant