From 0db1529312642b01a77a99f7dc37b237fd328f37 Mon Sep 17 00:00:00 2001 From: "stefan.schirmeister" Date: Fri, 17 Jan 2025 13:05:48 +0100 Subject: [PATCH] re-assign vehicles after recombination --- data/examples/simba.cfg | 2 +- simba/optimization.py | 2 +- simba/simulate.py | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/data/examples/simba.cfg b/data/examples/simba.cfg index 011f361..d0cb7e1 100644 --- a/data/examples/simba.cfg +++ b/data/examples/simba.cfg @@ -38,7 +38,7 @@ rotation_filter_path = data/examples/rotation_filter.csv # service_optimization finds the largest set of electrified rotations, rotations SOC<0 are removed. # station_optimization finds the set of fewest stations to electrify all rotations. # remove_negative removes all negative rotations. -# recombination splits and merges rotations to use the optimal number of busses +# split_negative_depb splits and merges negative rotations to use the optimal number of busses # report generates simulation output files, including costs. mode = ["sim", "report"] #mode = ["sim", "load_pickle", "neg_depb_to_oppb", "service_optimization", "station_optimization", "remove_negative", "split_negative_depb", "report"] diff --git a/simba/optimization.py b/simba/optimization.py index 678a27c..595cd72 100644 --- a/simba/optimization.py +++ b/simba/optimization.py @@ -291,7 +291,7 @@ def recombination(schedule, args, trips, depot_trips): # first trip of new rotation: generate new rotation rotation = Rotation(id=rot_name, vehicle_type=vt, schedule=schedule) rotation.allow_opp_charging_for_oppb = original_rotation.allow_opp_charging_for_oppb - rotation.vehicle_id = original_rotation.vehicle_id + rotation.vehicle_id = None # must be re-assigned later rotation.set_charging_type(ct) # begin rotation in depot: add initial trip diff --git a/simba/simulate.py b/simba/simulate.py index 29f9e4f..6c474b6 100644 --- a/simba/simulate.py +++ b/simba/simulate.py @@ -259,6 +259,8 @@ def split_negative_depb(schedule, scenario, args, _i): negative_rotations = schedule.get_negative_rotations(scenario) trips, depot_trips = optimization.prepare_trips(schedule, negative_rotations) recombined_schedule = optimization.recombination(schedule, args, trips, depot_trips) + # re-assign vehicles + recombined_schedule.assign_vehicles(args) # re-run schedule scenario = recombined_schedule.run(args) return recombined_schedule, scenario