discrete_optimization.vrp package

Subpackages

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]
abstract evaluate_function_indexes(index_1: int, index_2: int) 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]
evaluate_function_indexes(index_1: int, index_2: int) 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]

Module contents