diff --git a/openrouteservice/optimization.py b/openrouteservice/optimization.py index 57b337b..871711c 100644 --- a/openrouteservice/optimization.py +++ b/openrouteservice/optimization.py @@ -283,6 +283,7 @@ def __init__( self, id, profile="driving-car", + description=None, start=None, start_index=None, end=None, @@ -290,6 +291,10 @@ def __init__( capacity=None, skills=None, time_window=None, + speed_factor=None, + max_tasks=None, + max_travel_time=None, + max_distance=None, ): """ Create a Vehicle object for the optimization endpoint. @@ -303,6 +308,9 @@ def __init__( "cycling-electric",]. Default "driving-car". :type profile: str + :param description: A description of the vehicle. + :type description: str + :param start: Coordinate for the vehicle to start from. If not specified, the start location will be the first visited job, determined by the optimization engine. :type start: list of float or tuple of float @@ -327,11 +335,27 @@ def __init__( :param time_window: A time_window object describing working hours for this vehicle. :param time_window: list of int or tuple of int + + :param speed_factor: a double value in the range (0, 5] used to scale all vehicle travel times (defaults to 1.), + the respected precision is limited to two digits after the decimal point + :param speed_factor: float + + :param max_tasks: an integer defining the maximum number of tasks in a route for this vehicle + :param max_tasks: int + + :param max_travel_time: an integer defining the maximum travel time for this vehicle + :param max_travel_time: int + + :param max_distance: an integer defining the maximum distance for this vehicle + :param max_distance: int """ self.id = id self.profile = profile + if description is not None: + self.description = description + if start is not None: self.start = start @@ -352,3 +376,15 @@ def __init__( if time_window is not None: self.time_window = time_window + + if speed_factor is not None: + self.speed_factor = speed_factor + + if max_tasks is not None: + self.max_tasks = max_tasks + + if max_travel_time is not None: + self.max_travel_time = max_travel_time + + if max_distance is not None: + self.max_distance = max_distance diff --git a/test/test_helper.py b/test/test_helper.py index 338c369..f3c26a9 100644 --- a/test/test_helper.py +++ b/test/test_helper.py @@ -6,6 +6,8 @@ PARAM_INT_BIG = 500 PARAM_INT_SMALL = 50 +PARAM_FLOAT_SMALL = 0.5 +PARAM_FLOAT_BIG = 3.5 PARAM_LIST_ONE = [PARAM_INT_SMALL, PARAM_INT_SMALL] PARAM_LIST_TWO = [PARAM_LIST_ONE, PARAM_LIST_ONE] @@ -204,6 +206,7 @@ { "id": 0, "profile": "driving-car", + "description": "vehicle", "start": PARAM_LINE[0], "start_index": 0, "end_index": 0, @@ -211,10 +214,15 @@ "capacity": [PARAM_INT_SMALL], "skills": PARAM_LIST_ONE, "time_window": PARAM_LIST_ONE, + "speed_factor": PARAM_FLOAT_SMALL, + "max_tasks": PARAM_INT_SMALL, + "max_travel_time": PARAM_INT_BIG, + "max_distance": PARAM_INT_BIG, }, { "id": 1, "profile": "driving-car", + "description": "vehicle", "start": PARAM_LINE[1], "start_index": 1, "end_index": 1, @@ -222,6 +230,10 @@ "capacity": [PARAM_INT_SMALL], "skills": PARAM_LIST_ONE, "time_window": PARAM_LIST_ONE, + "speed_factor": PARAM_FLOAT_SMALL, + "max_tasks": PARAM_INT_SMALL, + "max_travel_time": PARAM_INT_BIG, + "max_distance": PARAM_INT_BIG, }, ], "options": {"g": False}, diff --git a/test/test_optimization.py b/test/test_optimization.py index 6db710e..1d01c76 100644 --- a/test/test_optimization.py +++ b/test/test_optimization.py @@ -48,6 +48,7 @@ def _get_params(self): Vehicle( idx, profile="driving-car", + description="vehicle", start=coord, start_index=idx, end=coord, @@ -55,6 +56,10 @@ def _get_params(self): capacity=[PARAM_INT_SMALL], skills=PARAM_LIST_ONE, time_window=PARAM_LIST_ONE, + speed_factor=PARAM_FLOAT_SMALL, + max_tasks=PARAM_INT_SMALL, + max_travel_time=PARAM_INT_BIG, + max_distance=PARAM_INT_BIG, ) )