discrete_optimization.vrp package
Subpackages
- discrete_optimization.vrp.mutation package
- discrete_optimization.vrp.solver package
- Submodules
- discrete_optimization.vrp.solver.greedy_vrp module
- discrete_optimization.vrp.solver.lp_vrp_iterative module
VRPIterativeLP
VRPIterativeLP.constraint_on_edge
VRPIterativeLP.edges
VRPIterativeLP.edges_in_customers
VRPIterativeLP.edges_in_merged_graph
VRPIterativeLP.edges_out_customers
VRPIterativeLP.edges_out_merged_graph
VRPIterativeLP.edges_warm_set
VRPIterativeLP.init_model()
VRPIterativeLP.model
VRPIterativeLP.problem
VRPIterativeLP.solve()
VRPIterativeLP.x_var
build_graph_pruned_vrp()
build_matrice_distance_np()
build_the_cycles()
build_warm_edges_and_update_graph()
compute_start_end_flows_info()
init_model_lp()
plot_solve()
rebuild_tsp_routine()
reevaluate_solutions()
retrieve_solutions()
update_graph()
update_model_2()
- discrete_optimization.vrp.solver.lp_vrp_iterative_pymip module
VRPIterativeLP_Pymip
VRPIterativeLP_Pymip.constraint_on_edge
VRPIterativeLP_Pymip.edges
VRPIterativeLP_Pymip.edges_in_customers
VRPIterativeLP_Pymip.edges_in_merged_graph
VRPIterativeLP_Pymip.edges_out_customers
VRPIterativeLP_Pymip.edges_out_merged_graph
VRPIterativeLP_Pymip.edges_warm_set
VRPIterativeLP_Pymip.init_model()
VRPIterativeLP_Pymip.model
VRPIterativeLP_Pymip.problem
VRPIterativeLP_Pymip.solve()
VRPIterativeLP_Pymip.x_var
init_model_lp()
retrieve_solutions()
update_model_2()
- discrete_optimization.vrp.solver.solver_ortools module
- discrete_optimization.vrp.solver.vrp_solver module
- Module contents
Submodules
discrete_optimization.vrp.vrp_model module
- class discrete_optimization.vrp.vrp_model.BasicCustomer(name: str | int, demand: float)[source]
Bases:
object
- class discrete_optimization.vrp.vrp_model.Customer2D(name: str | int, demand: float, x: float, y: float)[source]
Bases:
BasicCustomer
- class discrete_optimization.vrp.vrp_model.VrpProblem(vehicle_count: int, vehicle_capacities: List[float], customer_count: int, customers: Sequence[BasicCustomer], start_indexes: List[int], end_indexes: List[int])[source]
Bases:
Problem
- customers: Sequence[BasicCustomer]
- evaluate(variable: VrpSolution) Dict[str, float] [source]
Evaluate a given solution object for the given problem.
This method should return a dictionnary of KPI, that can be then used for mono or multiobjective optimization.
- Parameters:
variable (Solution) – the Solution object to evaluate.
Returns: Dictionnary of float kpi for the solution.
- abstract evaluate_function(var_tsp: VrpSolution) Tuple[List[List[float]], List[float], float, List[float]] [source]
- get_attribute_register() EncodingRegister [source]
Returns how the Solution should be encoded.
Returns (EncodingRegister): content of the encoding of the solution
- get_dummy_solution() VrpSolution [source]
- get_objective_register() ObjectiveRegister [source]
Returns the objective definition.
Returns (ObjectiveRegister): object defining the objective criteria.
- get_solution_type() Type[Solution] [source]
Returns the class implementation of a Solution.
Returns (class): class object of the given Problem.
- get_stupid_solution() VrpSolution [source]
- satisfy(variable: VrpSolution) bool [source]
Computes if a solution satisfies or not the constraints of the problem.
- Parameters:
variable – the Solution object to check satisfability
Returns (bool): boolean true if the constraints are fulfilled, false elsewhere.
- class discrete_optimization.vrp.vrp_model.VrpProblem2D(vehicle_count: int, vehicle_capacities: List[float], customer_count: int, customers: Sequence[Customer2D], start_indexes: List[int], end_indexes: List[int])[source]
Bases:
VrpProblem
- customers: Sequence[Customer2D]
- evaluate_function(vrp_sol: VrpSolution) Tuple[List[List[float]], List[float], float, List[float]] [source]
- class discrete_optimization.vrp.vrp_model.VrpSolution(problem: VrpProblem, list_start_index: List[int], list_end_index: List[int], list_paths: List[List[int]], capacities: List[float] | None = None, length: float | None = None, lengths: List[List[float]] | None = None)[source]
Bases:
Solution
- change_problem(new_problem: Problem) None [source]
If relevant to the optimisation problem, change the underlying problem instance for the solution.
This method can be used to evaluate a solution for different instance of problems.
- Parameters:
new_problem (Problem) – another problem instance from which the solution can be evaluated
Returns: None
- copy() VrpSolution [source]
Deep copy of the solution.
The copy() function should return a new object containing the same input as the current object, that respects the following expected behaviour: -y = x.copy() -if do some inplace change of y, the changes are not done in x.
Returns: a new object from which you can manipulate attributes without changing the original object.
- lazy_copy() VrpSolution [source]
This function should return a new object but possibly with mutable attributes from the original objects.
A typical use of lazy copy is in evolutionary algorithms or genetic algorithm where the use of local move don’t need to do a possibly costly deepcopy.
Returns (Solution): copy (possibly shallow) of the Solution
- discrete_optimization.vrp.vrp_model.build_evaluate_function(vrp_model: VrpProblem) Callable[[VrpSolution], Tuple[List[List[float]], List[float], float, List[float]]] [source]
- discrete_optimization.vrp.vrp_model.compute_length(start_index: int, end_index: int, solution: List[int], list_customers: Sequence[BasicCustomer], method: Callable[[int, int], float]) Tuple[List[float], float, float] [source]
- discrete_optimization.vrp.vrp_model.compute_length_np(start_index: int, end_index: int, solution: List[int] | ndarray, np_points: ndarray) Tuple[List[float] | ndarray, float] [source]
- discrete_optimization.vrp.vrp_model.length(point1: Customer2D, point2: Customer2D) float [source]
- discrete_optimization.vrp.vrp_model.sequential_computing(vrp_sol: VrpSolution, vrp_model: VrpProblem) Tuple[List[List[float]], List[float], float, List[float]] [source]
- discrete_optimization.vrp.vrp_model.stupid_solution(vrp_model: VrpProblem) Tuple[VrpSolution, Dict[str, float]] [source]
- discrete_optimization.vrp.vrp_model.trivial_solution(vrp_model: VrpProblem) Tuple[VrpSolution, Dict[str, float]] [source]
discrete_optimization.vrp.vrp_parser module
- discrete_optimization.vrp.vrp_parser.get_data_available(data_folder: str | None = None, data_home: str | None = None) List[str] [source]
Get datasets available for vrp.
- Params:
- data_folder: folder where datasets for vrp whould be find.
If None, we look in “vrp” subdirectory of data_home.
- data_home: root directory for all datasets. Is None, set by
default to “~/discrete_optimization_data “
- discrete_optimization.vrp.vrp_parser.parse_file(file_path: str, start_index: int = 0, end_index: int = 0, vehicle_count: int | None = None) VrpProblem2D [source]
- discrete_optimization.vrp.vrp_parser.parse_input(input_data: str, start_index: int = 0, end_index: int = 0, vehicle_count: int | None = None) VrpProblem2D [source]
discrete_optimization.vrp.vrp_solvers module
- discrete_optimization.vrp.vrp_solvers.look_for_solver(domain: VrpProblem) List[Type[SolverVrp]] [source]
- discrete_optimization.vrp.vrp_solvers.look_for_solver_class(class_domain: Type[VrpProblem]) List[Type[SolverVrp]] [source]
- discrete_optimization.vrp.vrp_solvers.return_solver(method: Type[SolverVrp], problem: VrpProblem, **kwargs: Any) SolverVrp [source]
- discrete_optimization.vrp.vrp_solvers.solve(method: Type[SolverVrp], problem: VrpProblem, **kwargs: Any) ResultStorage [source]
discrete_optimization.vrp.vrp_toolbox module
- discrete_optimization.vrp.vrp_toolbox.build_graph(vrp_model: VrpProblem) Tuple[Graph, ndarray] [source]
- discrete_optimization.vrp.vrp_toolbox.compute_length_matrix(vrp_model: VrpProblem) Tuple[ndarray, ndarray] [source]
- discrete_optimization.vrp.vrp_toolbox.prune_search_space(vrp_model: VrpProblem, n_shortest: int = 10) Tuple[ndarray, ndarray] [source]