Stochastic Vehicle Scheduling
Public
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.StochasticVehicleSchedulingBenchmark
— Typestruct StochasticVehicleSchedulingBenchmark <: AbstractBenchmark
Data structure for a stochastic vehicle scheduling benchmark.
Fields
nb_tasks::Int64
: number of tasks in each instancenb_scenarios::Int64
: number of scenarios in each instance
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.column_generation_algorithm
— Methodcolumn_generation_algorithm(
instance::DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.Instance;
scenario_range,
bounding,
use_convex_resources,
silent,
close_gap
) -> DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.Solution
Solve input instance using column generation.
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.compact_linearized_mip
— Methodcompact_linearized_mip(
instance::DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.Instance;
scenario_range,
model_builder,
silent
) -> Any
Returns the optimal solution of the Stochastic VSP instance, by solving the associated compact MIP. Quadratic constraints are linearized using Mc Cormick linearization. Note: If you have Gurobi, use grb_model
as model_builder
instead of highs_model
.
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.compact_mip
— Methodcompact_mip(
instance::DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.Instance;
scenario_range,
model_builder,
silent
) -> Any
Returns the optimal solution of the Stochastic VSP instance, by solving the associated compact quadratic MIP. Note: If you have Gurobi, use grb_model
as model_builder
instead of highs_model
.
You need to use a solver that supports quadratic constraints to use this method.
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.deterministic_mip
— Methoddeterministic_mip(
instance::DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.Instance;
model_builder,
silent
) -> Any
Solves the deterministic version of the vehicle scheduling problem using a MIP model. Does not take into account the stochastic nature of the problem.
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.evaluate_solution
— Methodevaluate_solution(
path_value::BitMatrix,
instance::DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.Instance
) -> Any
Compute total weighted objective of solution.
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.evaluate_solution
— Methodevaluate_solution(
solution::DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.Solution,
instance::DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.Instance
) -> Any
Compute total weighted objective of solution.
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.is_feasible
— Methodis_feasible(
solution::DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.Solution,
instance::DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.Instance;
verbose
) -> Bool
Check if solution
is an admissible solution of instance
.
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.local_search
— Methodlocal_search(
instance::DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.Instance;
num_iterations
) -> DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.Solution
Very simple heuristic, using local_search
initialised with the solution of the deterministic Linear program
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.plot_instance
— Methodplot_instance(
::StochasticVehicleSchedulingBenchmark,
sample::DataSample{<:DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.Instance{DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.City}};
color_scheme,
kwargs...
) -> Plots.Plot
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.plot_solution
— Methodplot_solution(
::StochasticVehicleSchedulingBenchmark,
sample::DataSample{<:DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.Instance{DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.City}};
kwargs...
) -> Plots.Plot
DecisionFocusedLearningBenchmarks.Utils.generate_dataset
— Methodgenerate_dataset(
benchmark::StochasticVehicleSchedulingBenchmark,
dataset_size::Int64;
compute_solutions,
seed,
rng,
algorithm,
store_city,
kwargs...
) -> Any
Create a dataset of dataset_size
instances for the given StochasticVehicleSchedulingBenchmark
. If you want to not add label solutions in the dataset, set compute_solutions=false
. By default, they will be computed using column generation. Note that computing solutions can be time-consuming, especially for large instances. You can also use instead compact_mip
or compact_linearized_mip
as the algorithm to compute solutions. If you want to provide a custom algorithm to compute solutions, you can pass it as the algorithm
keyword argument. If algorithm
takes keyword arguments, you can pass them as well directly in kwargs...
. If store_city=false
, the coordinates and unnecessary information about instances will not be stored in the dataset.
DecisionFocusedLearningBenchmarks.Utils.generate_maximizer
— Methodgenerate_maximizer(
bench::StochasticVehicleSchedulingBenchmark;
model_builder
) -> DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.StochasticVechicleSchedulingMaximizer{typeof(DecisionFocusedLearningBenchmarks.Utils.highs_model)}
DecisionFocusedLearningBenchmarks.Utils.generate_statistical_model
— Methodgenerate_statistical_model(
::StochasticVehicleSchedulingBenchmark;
seed
) -> Flux.Chain{T} where T<:Tuple{Flux.Dense{typeof(identity), Matrix{Float32}}, typeof(vec)}
Private
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.City
— Typestruct City
Data structure for a city in the vehicle scheduling problem. Contains all the relevant information to build an instance of the problem.
Fields
width::Int64
: city width (in minutes)vehicle_cost::Float64
: cost of a vehicle in the objective functiondelay_cost::Float64
: cost of one minute delay in the objective functionnb_tasks::Int64
: number of tasks to fulfilltasks::Vector{DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.Task}
: tasks list (seeTask
), that should be ordered by start timedistrict_width::Int64
: idth (in minutes) of each districtdistricts::Matrix{DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.District}
: districts matrix (seeDistrict
), indices corresponding to their relative positionsrandom_inter_area_factor::Distributions.LogNormal{Float64}
: a log-normal distribution modeling delay between districtsscenario_inter_area_factor::Matrix{Float64}
: size (nb_scenarios, 24), each row correspond to one scenario, each column to one hour of the day
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.City
— MethodCity(
;
nb_scenarios,
width,
vehicle_cost,
nb_tasks,
tasks,
district_width,
districts,
delay_cost,
random_inter_area_factor,
scenario_inter_area_factor
) -> DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.City
Constructor for City
.
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.District
— Typestruct District
Data structure for a district in the vehicle scheduling problem.
Fields
random_delay::Distributions.LogNormal{Float64}
: log-normal distribution modeling the district delayscenario_delay::Matrix{Float64}
: size (nb_scenarios, 24), observed delays for each scenario and hour of the day
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.District
— MethodDistrict(; random_delay, nb_scenarios)
Constructor for District
. Initialize a district with a given number of scenarios, with zeros in scenario_delay
.
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.Instance
— Typestruct Instance{CC, G<:Graphs.AbstractGraph, M1<:(AbstractMatrix), M2<:(AbstractMatrix), F, C}
Instance of the stochastic VSP problem.
Fields
graph::Graphs.AbstractGraph
: graph computed fromcity
with thecreate_VSP_graph(city::City)
methodfeatures::Matrix
: features matrix computed fromcity
slacks::AbstractMatrix
: slack matrixintrinsic_delays::AbstractMatrix
: intrinsic delays scenario matrixvehicle_cost::Any
: cost of a vehicledelay_cost::Any
: cost of one minute delaycity::Any
: associated city
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.Instance
— MethodInstance(
;
nb_tasks,
nb_scenarios,
rng,
store_city,
kwargs...
)
Constructor for Instance
. Build an Instance
for the stochatsic vehicle scheduling problem, with nb_tasks
tasks and nb_scenarios
scenarios.
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.Point
— Typestruct Point
2D point data structure.
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.Solution
— Typestruct Solution
Should always be associated with an Instance
.
Fields
value::BitVector
: for each graph edge of instance, 1 if selected, else 0path_value::BitMatrix
: each row represents a vehicle, each column a task. 1 if task is done by the vehicle, else 0
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.Solution
— MethodSolution(
path_value::BitMatrix,
instance::DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.Instance
) -> DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.Solution
Create a Solution from a BitMatrix path value.
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.Solution
— MethodSolution(
value::BitVector,
instance::DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.Instance
) -> DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.Solution
Create a Solution from a BitVector value.
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.StochasticVechicleSchedulingMaximizer
— Typestruct StochasticVechicleSchedulingMaximizer{M}
Deterministic vsp maximizer for the StochasticVehicleSchedulingBenchmark.
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.StochasticVechicleSchedulingMaximizer
— MethodApply the maximizer with the stored model builder.
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.Task
— Typestruct Task
Data structure for a task in the vehicle scheduling problem.
Fields
type::DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.TaskType
: type of the task (depot start, job, or depot end)start_point::DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.Point
: starting location of the taskend_point::DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.Point
: end location of the taskstart_time::Float64
: start time (in minutes) of the taskend_time::Float64
: end time (in minutes) of the taskrandom_delay::Distributions.LogNormal{Float64}
: lognormal distribution modeling the task start delayscenario_start_time::Vector{Float64}
: size (nb_scenarios), observed delayed start times for each scenarioscenario_end_time::Vector{Float64}
: size (nb_scenarios), observed delayed end times for each scenario
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.Task
— MethodTask(
;
type,
start_point,
end_point,
start_time,
end_time,
nb_scenarios,
random_delay
)
Constructor for Task
.
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling._local_search
— Method_local_search(
solution::DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.Solution,
instance::DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.Instance;
nb_it
) -> Tuple{DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.Solution, Any, Vector{Int64}, Vector}
Very simple local search heuristic, using the neighborhood defined by move_one_random_task
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.column_generation
— Methodcolumn_generation(instance::Instance)
Note: If you have Gurobi, use grb_model
as model_builder
instead of glpk_model
.
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.compute_delays
— Methodcompute_delays(
city::DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.City
) -> Matrix{Float64}
Compute delays for instance.
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.compute_features
— Methodcompute_features(
city::DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.City
) -> Matrix{Float32}
Returns a matrix of features of size (20, nb_edges). For each edge, compute the following features (in the same order):
- travel time
- vehicle_cost if edge is connected to source, else 0
- 9 deciles of the slack
- cumulative probability distribution of the slack evaluated in [-100, -50, -20, -10, 0, 10, 50, 200, 500]
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.compute_perturbed_end_times!
— Methodcompute_perturbed_end_times!(
city::DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.City
)
Compute the end times of the tasks for each scenario.
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.compute_slacks
— Methodcompute_slacks(
city::DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.City,
graph::Graphs.AbstractGraph
) -> Any
Compute slack for instance. TODO: differentiate from other method
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.compute_slacks
— Methodcompute_slacks(
city::DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.City,
old_task_index::Int64,
new_task_index::Int64
) -> Vector{Float64}
Compute slack for features.
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.compute_solution_from_selected_columns
— Methodcompute_solution_from_selected_columns(
instance::DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.Instance,
paths;
bin,
model_builder,
scenario_range,
silent
) -> Tuple{Float64, Any, Any}
Note: If you have Gurobi, use grb_model
as model_builder
instead od glpk_model
.
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.create_VSP_graph
— Methodcreate_VSP_graph(
city::DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.City
) -> Graphs.SimpleGraphs.SimpleDiGraph{Int64}
Return the acyclic directed graph corresponding to city
. Each vertex represents a task. Vertices are ordered by start time of corresponding task. There is an edge from task u to task v the (end time of u + tie distance between u and v <= start time of v).
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.create_random_city
— Methodcreate_random_city(
;
αᵥ_low,
αᵥ_high,
first_begin_time,
last_begin_time,
district_μ,
district_σ,
task_μ,
task_σ,
seed,
rng,
city_kwargs...
) -> DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.City
- Creates a city from
city_kwargs
- Depot location at city center
- Randomize tasks, and add two dummy tasks : one
source
task at time=0 from the depot, and onedestination
task ending at time=end at depot - Roll every scenario.
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.delay_sum
— Methoddelay_sum(path, slacks, delays)
Evaluate the total delay along path.
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.distance
— Methoddistance(
p₁::DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.Point,
p₂::DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.Point
) -> Float64
Returns euclidean distance between p₁ and p₂.
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.draw_random_point
— Methoddraw_random_point(distrib::Distributions.Distribution; rng)
Returns a Point with random x and y, drawn from distrib.
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.evaluate_scenario
— Methodevaluate_scenario(path_value::BitMatrix, instance::Instance, scenario_index::Int)
Compute total delay of scenario.
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.evaluate_scenario
— Methodevaluate_scenario(
solution::DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.Solution,
instance::DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.Instance,
scenario_index::Int64
) -> Any
Compute total delay of scenario.
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.evaluate_task
— Methodevaluate_task(
i_task::Integer,
instance::DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.Instance,
old_task_index::Integer,
old_delay::Real,
scenario::Int64
) -> Any
Evaluate the total delay of task i_task
in scenario
, knowing that current delay from task old_task_index
is old_delay
.
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.find_first_one
— Methodfind_first_one(A::AbstractVector) -> Int64
Returns index of first non zero element of A.
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.generate_scenarios!
— Methodgenerate_scenarios!(
city::DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.City;
rng
)
Draw all delay scenarios for the city.
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.get_district
— Methodget_district(point::Point, city::City)
Return indices of the city
district containing point
.
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.get_features
— Methodget_features(
instance::DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.Instance
) -> Matrix
Returns the feature matrix associated to instance
.
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.get_nb_scenarios
— Methodget_nb_scenarios(
city::DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.City
) -> Int64
Returns the number of scenarios in city.
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.get_nb_scenarios
— Methodget_nb_scenarios(
instance::DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.Instance
) -> Any
Returns the number of scenarios in instance.
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.get_nb_tasks
— Methodget_nb_tasks(
city::DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.City
) -> Int64
Returns the number of tasks in city.
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.get_nb_tasks
— Methodget_nb_tasks(
instance::DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.Instance
) -> Any
Returns the number of tasks in instance
.
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.get_perturbed_travel_time
— Methodget_perturbed_travel_time(
city::DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.City,
old_task_index::Int64,
new_task_index::Int64,
scenario::Int64
) -> Float64
Compute the achieved travel time of scenario scenario
from old_task_index
to new_task_index
.
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.hour_of
— Methodhour_of(minutes::Real) -> Int64
Returns hour of the day corresponding to minutes amount.
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.init_districts!
— Methodinit_districts!(
city::DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.City,
district_μ::Distributions.Distribution,
district_σ::Distributions.Distribution;
rng
)
Initialize the districts of the city.
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.init_tasks!
— Methodinit_tasks!(
city::DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.City,
αᵥ_low::Real,
αᵥ_high::Real,
first_begin_time::Real,
last_begin_time::Real,
task_μ::Distributions.Distribution,
task_σ::Distributions.Distribution;
rng
)
Draw the tasks of the city.
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.move_one_random_task!
— Methodmove_one_random_task!(
path_value::BitMatrix,
graph::Graphs.AbstractGraph
)
Select one random (uniform) task and move it to another random (uniform) feasible vehicle
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.nb_scenarios
— Methodnb_scenarios(
task::DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.Task
) -> Int64
Return the number of scenarios for the given task.
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.roll
— Methodroll(
district::DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.District,
rng::Random.AbstractRNG
)
Populate scenario_delay
with delays drawn from random_delay
distribution for each (scenario, hour) pair.
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.roll
— Methodroll(
task::DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.Task,
rng::Random.AbstractRNG
)
Populate scenario_start_time
with delays drawn from the random_delay
distribution of the given task for each scenario.
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.scenario_next_delay
— Methodscenario_next_delay(
previous_delay::Real,
random_delay::Distributions.Distribution,
rng::Random.AbstractRNG
) -> Any
Return one scenario of future delay given current delay and delay distribution.
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.solution_from_JuMP_array
— Methodsolution_from_JuMP_array(
x::AbstractArray,
graph::Graphs.AbstractGraph
) -> Any
Create a Solution from a JuMP array.
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.solution_from_paths
— Methodsolution_from_paths(
paths,
instance::DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.Instance
) -> DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.Solution
Create a Solution from routes.
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.solve_deterministic_VSP
— Methodsolve_deterministic_VSP(
instance::DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.Instance;
include_delays,
model_builder,
verbose
) -> Tuple{Union{Float64, Vector{Float64}}, Any}
Return the optimal solution of the deterministic VSP problem associated to instance
. The objective function is vehicle_cost * nb_vehicles + include_delays * delay_cost * sum_of_travel_times
Note: If you have Gurobi, use grb_model
as model_builder
instead od highs_model
.
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.to_array
— Methodto_array(
solution::DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.Solution,
instance::DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.Instance
) -> Any
Returns a BitMatrix, with value true at each index (i, j) if corresponding edge of graph is selected in the solution
DecisionFocusedLearningBenchmarks.StochasticVehicleScheduling.vsp_maximizer
— Methodvsp_maximizer(
θ::AbstractVector;
instance,
model_builder,
silent
)
Given arcs weights θ, solve the deterministic VSP problem associated to instance
.