Skip to content

Commit

Permalink
Bugfixes after merge with main
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex020796 committed Dec 12, 2024
1 parent ab31371 commit d7b47fa
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
20 changes: 1 addition & 19 deletions src/ridepy/fleet_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import operator as op

import numpy as np
import random


from abc import ABC, abstractmethod
from typing import (
Expand Down Expand Up @@ -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,
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/ridepy/util/dispatchers_cython/dispatchers.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
6 changes: 3 additions & 3 deletions src/ridepy/util/testing_utils_cython/dispatchers.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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](
Expand All @@ -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
)
Expand Down

0 comments on commit d7b47fa

Please sign in to comment.