Skip to content

Commit

Permalink
change schedule cost to travel delay
Browse files Browse the repository at this point in the history
  • Loading branch information
Leot6 committed Jun 29, 2021
1 parent 2691198 commit 50591e1
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 39 deletions.
4 changes: 2 additions & 2 deletions config/platform_demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
13 changes: 4 additions & 9 deletions src/dispatcher/ilp_assign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,19 +109,14 @@ std::vector<size_t> IlpAssignment(const std::vector<SchedulingResult> &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;
}

Expand Down
40 changes: 19 additions & 21 deletions src/dispatcher/scheduling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,29 @@
#include "scheduling.hpp"

uint64_t ComputeScheduleCost(const std::vector<Waypoint> &schedule,
const std::vector<Order> &orders,
const Vehicle &vehicle,
uint64_t system_time_ms) {
auto cost_pickup_ms = 0;
auto cost_dropoff_ms = 0;
const std::vector<Order> &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;
}
8 changes: 2 additions & 6 deletions src/dispatcher/scheduling_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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; }
}
Expand Down
2 changes: 1 addition & 1 deletion src/simulator/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 50591e1

Please sign in to comment.