API Reference
Index
StochasticVehicleScheduling.CityStochasticVehicleScheduling.CompactInstanceStochasticVehicleScheduling.CompactInstanceStochasticVehicleScheduling.DistrictStochasticVehicleScheduling.DistrictStochasticVehicleScheduling.InstanceStochasticVehicleScheduling.InstanceStochasticVehicleScheduling.PipelineStochasticVehicleScheduling.SolutionStochasticVehicleScheduling.SolutionStochasticVehicleScheduling.SolutionStochasticVehicleScheduling.TaskStochasticVehicleScheduling.TrainerStochasticVehicleScheduling.basic_solutionStochasticVehicleScheduling.cbc_modelStochasticVehicleScheduling.column_generationStochasticVehicleScheduling.compute_delaysStochasticVehicleScheduling.compute_featuresStochasticVehicleScheduling.compute_slacksStochasticVehicleScheduling.compute_slacksStochasticVehicleScheduling.compute_solution_from_selected_columnsStochasticVehicleScheduling.compute_μ_σStochasticVehicleScheduling.create_VSP_graphStochasticVehicleScheduling.create_random_cityStochasticVehicleScheduling.create_random_compact_instanceStochasticVehicleScheduling.create_random_instanceStochasticVehicleScheduling.delay_sumStochasticVehicleScheduling.distanceStochasticVehicleScheduling.draw_random_pointStochasticVehicleScheduling.easy_problemStochasticVehicleScheduling.evaluate_scenarioStochasticVehicleScheduling.evaluate_scenarioStochasticVehicleScheduling.evaluate_solutionStochasticVehicleScheduling.evaluate_solutionStochasticVehicleScheduling.evaluate_taskStochasticVehicleScheduling.find_first_oneStochasticVehicleScheduling.generate_datasetStochasticVehicleScheduling.generate_samplesStochasticVehicleScheduling.get_districtStochasticVehicleScheduling.get_nb_scenariosStochasticVehicleScheduling.get_nb_scenariosStochasticVehicleScheduling.get_nb_tasksStochasticVehicleScheduling.get_nb_tasksStochasticVehicleScheduling.get_perturbed_travel_timeStochasticVehicleScheduling.get_routesStochasticVehicleScheduling.glpk_modelStochasticVehicleScheduling.heuristic_solutionStochasticVehicleScheduling.highs_modelStochasticVehicleScheduling.hour_ofStochasticVehicleScheduling.is_admissibleStochasticVehicleScheduling.local_searchStochasticVehicleScheduling.move_one_random_task!StochasticVehicleScheduling.normalize_data!StochasticVehicleScheduling.read_configStochasticVehicleScheduling.recursive_convertStochasticVehicleScheduling.recursive_namedtupleStochasticVehicleScheduling.reduce_data!StochasticVehicleScheduling.rollStochasticVehicleScheduling.rollStochasticVehicleScheduling.save_configStochasticVehicleScheduling.save_configStochasticVehicleScheduling.scenario_next_delayStochasticVehicleScheduling.solution_from_JuMP_arrayStochasticVehicleScheduling.solution_from_pathsStochasticVehicleScheduling.solve_deterministic_VSPStochasticVehicleScheduling.solve_scenariosStochasticVehicleScheduling.to_array
Reference
StochasticVehicleScheduling.City — TypeCityContains all the relevant information for an instance of the stochastic VSP problem.
Fields
width::Int: 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::Int: number of tasks to fulfilltasks::Vector{Task}: tasks list (seeTask), that should be ordered by start timedistrict_width::Int: width (in minutes) of each districtdistricts::Matrix{District}: districts matrix (seeDistrict), indices corresponding to their relative positionsrandom_inter_area_factor::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
StochasticVehicleScheduling.CompactInstance — TypeCompactInstance{G<:AbstractGraph,M1,M2,C}Instance of the stochastic VSP problem.
Fields
graph::G: graph computed fromcitywith thecreate_VSP_graph(city::City)method.features::Matrix{Float64}: features matrix computed fromcityslacksdelays
StochasticVehicleScheduling.CompactInstance — MethodCompactInstance(city::City)Build a CompactInstance from a City, by computing its graph, features, slacks and delays.
StochasticVehicleScheduling.District — TypeDistrictFields
random_delay::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
StochasticVehicleScheduling.District — MethodDistrict(; random_delay::LogNormal{Float64}, nb_scenarios::Int)Initialize a district with a given number of scenarios, with zeros in scenario_delay.
StochasticVehicleScheduling.Instance — TypeInstance{G<:AbstractGraph,M1,M2,C}Instance of the stochastic VSP problem.
Fields
city::Citygraph::G: graph computed fromcitywith thecreate_VSP_graph(city::City)method.features::Matrix{Float64}: features matrix computed fromcityslacksdelays
StochasticVehicleScheduling.Instance — MethodInstance(city::City)Build an Instance from a City, by computing its graph, features, slacks and delays.
StochasticVehicleScheduling.Pipeline — TypePipelineInferOpt pipeline container an encoder and a maximizer
StochasticVehicleScheduling.Solution — TypeSolutionShould 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
StochasticVehicleScheduling.Solution — MethodSolution(value::BitVector, instance::AbstractInstance)Create a Solution from a BitMatrix path value.
StochasticVehicleScheduling.Solution — MethodSolution(value::BitVector, instance::AbstractInstance)Create a Solution from a BitVector value.
StochasticVehicleScheduling.Task — TypeTaskFields
type::TaskTypestart_point::Point: starting location of the taskend_point::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::LogNormal{Float64}: lognormal distribution modeling the task start delayscenario_start_time::Vector{Float64}: size (nb_scenarios), realized delayed start times for each scenarioscenario_end_time::Vector{Float64}: size (nb_scenarios), realized delayed end times for each scenario
StochasticVehicleScheduling.Trainer — TypeTrainerMain structure used for training an InferOpt model.
StochasticVehicleScheduling.basic_solution — Methodbasic_solution(graph::AbstractGraph)Create a solution with one vehicle per task.
StochasticVehicleScheduling.cbc_model — Methodcbc_model()Initialiaze a Cbc model with disabled logging.
StochasticVehicleScheduling.column_generation — Methodcolumn_generation(instance::Instance)Note: If you have Gurobi, use grb_model as model_builder instead of glpk_model.
StochasticVehicleScheduling.compute_delays — Methodcompute_delays(city)Compute delays for instance.
StochasticVehicleScheduling.compute_features — Methodcompute_features(city::City)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]
StochasticVehicleScheduling.compute_slacks — Methodcompute_slacks(city)Compute slack for instance. TODO: differentiate from other method
StochasticVehicleScheduling.compute_slacks — Methodcompute_slacks(city, old_task_index, new_task_index)Compute slack for features.
StochasticVehicleScheduling.compute_solution_from_selected_columns — Methodcompute_solution_from_selected_columns(instance::AbstractInstance, paths[; bin=true])Note: If you have Gurobi, use grb_model as model_builder instead od glpk_model.
StochasticVehicleScheduling.compute_μ_σ — Methodcompute_μ_σ(X::Vector{Instance})Compute mean, standard deviation, and max values for each features in X instances.
StochasticVehicleScheduling.create_VSP_graph — Methodcreate_VSP_graph(city::City)Return a MetaDiGraph computed from 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). Every (u, v) edge has a :travel_time property, corresponding to time istance between u and v.
StochasticVehicleScheduling.create_random_city — Methodcreate_random_city(;
αᵥ_low=default_αᵥ_low,
αᵥ_high=default_αᵥ_high,
first_begin_time=default_first_begin_time,
last_begin_time=default_last_begin_time,
district_μ=default_district_μ,
district_σ=default_district_σ,
task_μ=default_task_μ,
task_σ=default_task_σ,
city_kwargs...
)- Create a city from
city_kwargs - Depot location at city center
- Randomize tasks, and add two dummy tasks : one
sourcetask at time=0 from the depot, and onedestinationtask ending at time=end at depot - Roll every scenario.
StochasticVehicleScheduling.create_random_compact_instance — Methodcreate_random_instance([; city_kwargs])Returns a random instance created with city_kwargs.
StochasticVehicleScheduling.create_random_instance — Methodcreate_random_instance([; city_kwargs])Returns a random instance created with city_kwargs.
StochasticVehicleScheduling.delay_sum — Methoddelay_sum(path, slacks, delays)Evaluate the total delay along path.
StochasticVehicleScheduling.distance — Methoddistance(p₁, p₂)Returns euclidean distance between p₁ and p₂.
StochasticVehicleScheduling.draw_random_point — Methoddraw_random_point(distrib)Returns a Point with random x and y, drawn from distrib.
StochasticVehicleScheduling.easy_problem — Methodeasy_problem(θ[; instance::AbstractInstance, model_builder])Solves the easy problem of the learning pipeline given arcs weights θ. Note: If you have Gurobi, use grb_model as model_builder instead od cbc_model.
StochasticVehicleScheduling.evaluate_scenario — Methodevaluate_scenario(path_value::BitMatrix, instance::AbstractInstance, scenario_index::Int)Compute total delay of scenario.
StochasticVehicleScheduling.evaluate_scenario — Methodevaluate_scenario(solution::Solution, instance::AbstractInstance, scenario_index::Int)Compute total delay of scenario.
StochasticVehicleScheduling.evaluate_solution — Methodevaluate_scenario(path_value::BitMatrix, instance::AbstractInstance, scenario_index::Int)Compute total weighted objective of solution.
StochasticVehicleScheduling.evaluate_solution — Methodevaluate_scenario(path_value::BitMatrix, instance::AbstractInstance, scenario_index::Int)Compute total weighted objective of solution.
StochasticVehicleScheduling.evaluate_task — Methodevaluate_task(
i_task::Integer,
instance::AbstractInstance,
old_task_index::Integer,
old_delay::Real,
scenario::Int,
)Evaluate the total delay of task i_task in scenario, knowing that current delay from task old_task_index is old_delay.
StochasticVehicleScheduling.find_first_one — Methodfind_first_one(A)Returns index of first non zero element of A.
StochasticVehicleScheduling.generate_dataset — Methodgenerate_dataset(
dataset_folder::String,
nb_train_samples::Integer,
nb_val_samples::Integer,
nb_test_samples::Integer;
random_seed=67,
labeled=true,
heuristic=true,
city_kwargs,
)Create a dataset in dataset_folder, train/validation/test samples, one file per subdataset. Also create a config file in the same location with some information.
StochasticVehicleScheduling.generate_samples — Methodgenerate_samples(nb_samples::Integer[; heuristic=true, labeled=true, city_kwargs])Generate nb_samples random instances with city_kwargs. If labeled, compute associated solutions for each instance: use local search if heuristic, else compute optimal solution.
StochasticVehicleScheduling.get_district — Methodget_district(point::Point, city::City)Return indices of the city district containing point.
StochasticVehicleScheduling.get_nb_scenarios — Methodget_nb_scenarios(instance::AbstractInstance)Returns the number of scenarios in instance.
StochasticVehicleScheduling.get_nb_scenarios — Methodget_nb_scenarios(city::City)Returns the number of scenarios in city.
StochasticVehicleScheduling.get_nb_tasks — Methodget_nb_tasks(instance::AbstractInstance)Returns the number of tasks in instance.
StochasticVehicleScheduling.get_nb_tasks — Methodget_nb_tasks(city::City)Returns the number of tasks in city.
StochasticVehicleScheduling.get_perturbed_travel_time — Methodget_perturbed_travel_time(city::City, old_task_index::Int, new_task_index::Int, scenario::Int)Compute the achieved travel time of scenario scenario from old_task_index to new_task_index.
StochasticVehicleScheduling.get_routes — Methodget_routes(solution::Solution)Compute routes of solution.
StochasticVehicleScheduling.glpk_model — Methodglpk_model()Initialize a GLPK model (with disabled logging).
StochasticVehicleScheduling.heuristic_solution — Methodheuristic_solution(instance::AbstractInstance; nb_it=100)Very simple heuristic, using local_search initialised with the solution of the deterministic Linear program
StochasticVehicleScheduling.highs_model — Methodhighs_model()Initialize a HiGHS model (with disabled logging).
StochasticVehicleScheduling.hour_of — Methodhour_of(minutes::Real)::IntReturns hour of the day corresponding to minutes amount.
StochasticVehicleScheduling.is_admissible — Methodis_admissible(solution::Solution, instance::AbstractInstance)Check if solution is an admissible solution of instance.
StochasticVehicleScheduling.local_search — Methodlocal_search(solution::Solution, instance::AbstractInstance; nb_it::Integer=100)Very simple local search heuristic, using the neighborhood defined by move_one_random_task
StochasticVehicleScheduling.move_one_random_task! — Methodmove_one_random_task!(path_value::BitMatrix, graph::AbstractGraph)Select one random (uniform) task and move it to another random (uniform) feasible vehicle
StochasticVehicleScheduling.normalize_data! — Methodnormalize_data!(X, μ, σ)Standardize each feature of X by centering and reducing with μ and σ.
StochasticVehicleScheduling.read_config — Methodread_config(config_file::String)Read a Yaml config into a NamedTuple.
StochasticVehicleScheduling.recursive_convert — Methodrecursive_convert(x)Convert recursively a NamedTuple to a Dict.
StochasticVehicleScheduling.recursive_namedtuple — Methodrecursive_namedtuple(x)Convert recursively a Dict to a NamedTuple.
StochasticVehicleScheduling.reduce_data! — Methodreduce_data!(X, σ)Reduce X with σ, without centering it.
StochasticVehicleScheduling.roll — Methodroll(task)Populate scenario_delay with delays drawn from random_delay distribution for each (scenario, hour) pair.
StochasticVehicleScheduling.roll — Methodroll(task)Populate scenario_start_time with delays drawn from random_delay distribution for each scenario.
StochasticVehicleScheduling.save_config — Methodsave_config(config::Dict, save_path::String)Save Dict config to yaml file.
StochasticVehicleScheduling.save_config — Methodsave_config(config::NamedTuple, save_path::String)Save a NamedTuple config to yaml file.
StochasticVehicleScheduling.scenario_next_delay — Methodscenario_next_delay(previous_delay, random_delay)Return one scenario of future delay given current delay and delay distribution.
StochasticVehicleScheduling.solution_from_JuMP_array — Methodsolution_from_paths(paths, instance::AbstractInstance)Create a Solution from a JuMP array.
StochasticVehicleScheduling.solution_from_paths — Methodsolution_from_paths(paths, instance::AbstractInstance)Create a Solution from routes.
StochasticVehicleScheduling.solve_deterministic_VSP — Methodsolve_deterministic_VSP(instance::Instance; include_delays=true)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 cbc_model.
StochasticVehicleScheduling.solve_scenarios — Methodsolve_scenarios(instance::AbstractInstance; model_builder)Returns the optimal solution of the Stochastic VSP instance, by solving the associated MIP. Note: If you have Gurobi, use grb_model as model_builder instead od cbc_model.
StochasticVehicleScheduling.to_array — Methodto_array(solution::Solution, instance::AbstractInstance)Returns a BitMatrix, with value true at each index (i, j) if corresponding edge of graph is selected in the solution