diff --git a/config/platform_demo.yml b/config/platform_demo.yml index 0a2e945..01a37e4 100644 --- a/config/platform_demo.yml +++ b/config/platform_demo.yml @@ -20,10 +20,10 @@ mod_system_config: dispatcher: "OSP" # 3 options: GI, SBA, OSP rebalancer: "NPO" # 2 options: NONE, NPO, RVS fleet_config: - fleet_size: 2000 + fleet_size: 1000 veh_capacity: 6 request_config: - request_density: 1 # <= 1 + request_density: 0.5 # <= 1 max_pickup_wait_time_min: 5 max_onboard_detour: 1.3 # < 2 simulation_config: diff --git a/src/dispatcher/ilp_assign.cpp b/src/dispatcher/ilp_assign.cpp index 695982a..acfbc27 100644 --- a/src/dispatcher/ilp_assign.cpp +++ b/src/dispatcher/ilp_assign.cpp @@ -109,19 +109,14 @@ std::vector IlpAssignment(const std::vector &vehicle_t } } } +// fmt::print("\n[GUROBI] Objective:{}.\n", model.get(GRB_DoubleAttr_ObjVal)); } catch(GRBException e) { - std::cout << "Error code = " << e.getErrorCode() << std::endl; - std::cout << e.getMessage() << std::endl; + fmt::print("\n[GUROBI] Error code = {} ({}).\n", e.getErrorCode(), e.getMessage()); } catch(...) { - std::cout << "Exception during optimization" << std::endl; - } - - - - if (DEBUG_PRINT) { - TIMER_END(t) + fmt::print("Exception during optimization\n"); } + if (DEBUG_PRINT) { TIMER_END(t) } return selected_vehicle_trip_pair_indices; } diff --git a/src/dispatcher/scheduling.cpp b/src/dispatcher/scheduling.cpp index bfd0199..7dc1b00 100644 --- a/src/dispatcher/scheduling.cpp +++ b/src/dispatcher/scheduling.cpp @@ -5,31 +5,29 @@ #include "scheduling.hpp" uint64_t ComputeScheduleCost(const std::vector &schedule, - const std::vector &orders, - const Vehicle &vehicle, - uint64_t system_time_ms) { - auto cost_pickup_ms = 0; - auto cost_dropoff_ms = 0; + const std::vector &orders, + const Vehicle &vehicle, + uint64_t system_time_ms) { auto accumulated_time_ms = vehicle.step_to_pos.duration_ms; + auto cost_pickup_delay_ms = 0; + auto cost_total_delay_ms = 0; for (const auto &wp : schedule) { accumulated_time_ms += wp.route.duration_ms; } - return accumulated_time_ms; -// for (const auto &wp : schedule) { -// accumulated_time_ms += wp.route.duration_ms; -// if (wp.op == WaypointOp::PICKUP) { -// cost_pickup_ms += system_time_ms + accumulated_time_ms - orders[wp.order_id].request_time_ms; -// assert(system_time_ms + accumulated_time_ms - orders[wp.order_id].request_time_ms >= 0); -// } -// if (wp.op == WaypointOp::DROPOFF) { -// cost_dropoff_ms += system_time_ms + accumulated_time_ms - -// (orders[wp.order_id].request_time_ms + orders[wp.order_id].shortest_travel_time_ms); -// assert(system_time_ms + accumulated_time_ms - -// (orders[wp.order_id].request_time_ms + orders[wp.order_id].shortest_travel_time_ms) >= 0); -// } -// } -// auto cost_ms = cost_pickup_ms + cost_dropoff_ms; -// return cost_ms; + for (const auto &wp : schedule) { + accumulated_time_ms += wp.route.duration_ms; + if (wp.op == WaypointOp::PICKUP) { + cost_pickup_delay_ms += system_time_ms + accumulated_time_ms - orders[wp.order_id].request_time_ms; + assert(system_time_ms + accumulated_time_ms - orders[wp.order_id].request_time_ms >= 0); + } + if (wp.op == WaypointOp::DROPOFF) { + cost_total_delay_ms += system_time_ms + accumulated_time_ms - + (orders[wp.order_id].request_time_ms + orders[wp.order_id].shortest_travel_time_ms); + assert(system_time_ms + accumulated_time_ms - + (orders[wp.order_id].request_time_ms + orders[wp.order_id].shortest_travel_time_ms) >= 0); + } + } + return cost_total_delay_ms; } \ No newline at end of file diff --git a/src/dispatcher/scheduling_impl.hpp b/src/dispatcher/scheduling_impl.hpp index 2bb8a14..bf58015 100644 --- a/src/dispatcher/scheduling_impl.hpp +++ b/src/dispatcher/scheduling_impl.hpp @@ -24,9 +24,9 @@ SchedulingResult ComputeScheduleOfInsertingOrderToVehicle(const Order &order, int violation_type; for (const auto &sub_schedule: sub_schedules) { const auto num_wps = sub_schedule.size(); - // insert the order's pickup point + // Insert the order's pickup point. for (int pickup_idx = 0; pickup_idx <= num_wps; pickup_idx++) { - // insert the order's drop-off point + // Insert the order's drop-off point. for (int dropoff_idx = pickup_idx; dropoff_idx <= num_wps; dropoff_idx++) { auto new_schedule = GenerateScheduleFromSubSchedule( order, vehicle, sub_schedule, pickup_idx, dropoff_idx, router_func); @@ -40,10 +40,6 @@ SchedulingResult ComputeScheduleOfInsertingOrderToVehicle(const Order &order, } scheduling_result.success = true; scheduling_result.feasible_schedules.push_back(std::move(new_schedule)); - -// // for gi debug -// assert(scheduling_result.best_schedule_idx == 0 && scheduling_result.feasible_schedules.size() == 1); -// return scheduling_result; } if (violation_type > 0) { break; } } diff --git a/src/simulator/types.hpp b/src/simulator/types.hpp index 7330c29..e84e955 100644 --- a/src/simulator/types.hpp +++ b/src/simulator/types.hpp @@ -129,7 +129,7 @@ struct Waypoint { enum class VehicleStatus { IDLE, // the vehicle has no task and stays stationary WORKING, // the vehicle is serving orders - REBALANCING // the vehicle is moving towards a high demand area + REBALANCING // the vehicle is moving towards a reposition location to improve future performance }; inline std::string vehicle_status_to_string(const VehicleStatus &s) {