diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e03f4b6a..80ebea22 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,7 @@ repos: rev: 24.8.0 hooks: - id: black - language_version: python3.12 + language_version: python3 - repo: https://github.com/adamchainz/blacken-docs rev: 1.16.0 hooks: diff --git a/src/ridepy/fleet_state.py b/src/ridepy/fleet_state.py index 4bee9294..0dab85e6 100644 --- a/src/ridepy/fleet_state.py +++ b/src/ridepy/fleet_state.py @@ -7,7 +7,7 @@ import operator as op import numpy as np -import random + from abc import ABC, abstractmethod from typing import ( @@ -413,7 +413,6 @@ def _apply_request_solution( Modifies the `.VehicleState` of the vehicle with the least cost inplace. """ - all_solutions = list(all_solutions) ( best_vehicle, min_cost, @@ -424,23 +423,6 @@ def _apply_request_solution( delivery_timewindow_max, ), ) = min(all_solutions, key=op.itemgetter(1)) - all_solutions_equal_min_costs = list( - filter(lambda x: x[1] == min_cost, all_solutions) - ) - - ( - best_vehicle, - min_cost, - ( - pickup_timewindow_min, - pickup_timewindow_max, - delivery_timewindow_min, - delivery_timewindow_max, - ), - ) = random.choice(all_solutions_equal_min_costs) - - # test = list(self.fleet[0].stoplist) - # test1 = list(self.fleet[1].stoplist) logger.debug(f"best vehicle: {best_vehicle}, at min_cost={min_cost}") if min_cost == np.inf: # no solution was found return { diff --git a/src/ridepy/util/dispatchers_cython/dispatchers.pyx b/src/ridepy/util/dispatchers_cython/dispatchers.pyx index a19502d2..ccef9b5b 100644 --- a/src/ridepy/util/dispatchers_cython/dispatchers.pyx +++ b/src/ridepy/util/dispatchers_cython/dispatchers.pyx @@ -47,7 +47,7 @@ cdef class MinimalPassengerTravelTimeDispatcher(Dispatcher): ) elif loc_type == LocType.INT: self.u_dispatcher.dispatcher_int_ptr = ( - new CMinimalPassengerTravelTimeDispatcher[int]() + new CMinimalPassengerTravelTimeDispatcher[uiloc]() ) else: raise ValueError("This line should never have been reached") diff --git a/src/ridepy/util/testing_utils_cython/dispatchers.pyx b/src/ridepy/util/testing_utils_cython/dispatchers.pyx index f6dd0062..d2b80ee2 100644 --- a/src/ridepy/util/testing_utils_cython/dispatchers.pyx +++ b/src/ridepy/util/testing_utils_cython/dispatchers.pyx @@ -101,7 +101,7 @@ cdef class MinimalPassengerTravelTimeDispatcher: bint debug=False ): cdef InsertionResult[R2loc] insertion_result_r2loc - cdef InsertionResult[int] insertion_result_int + cdef InsertionResult[uiloc] insertion_result_int if self.loc_type == LocType.R2LOC: insertion_result_r2loc = c_minimal_passenger_travel_time_dispatcher[R2loc]( @@ -113,8 +113,8 @@ cdef class MinimalPassengerTravelTimeDispatcher: (insertion_result_r2loc.EAST_pu, insertion_result_r2loc.LAST_pu, insertion_result_r2loc.EAST_do, insertion_result_r2loc.LAST_do) elif self.loc_type == LocType.INT: - insertion_result_int = c_minimal_passenger_travel_time_dispatcher[int]( - dynamic_pointer_cast[CTransportationRequest[int], CRequest[int]](cy_request._ureq._req_int), + insertion_result_int = c_minimal_passenger_travel_time_dispatcher[uiloc]( + dynamic_pointer_cast[CTransportationRequest[uiloc], CRequest[uiloc]](cy_request._ureq._req_int), stoplist.ustoplist._stoplist_int, dereference(space.u_space.space_int_ptr), seat_capacity, debug )