def update_routes(self): self.routes, self.depart_info = Dispatcher.read_routes( self.routes_path, read_depart_info=True) for id_ev, m in self.measurements.items(): if m.stopped_at_node_from and m.node_from == 0: m.time_finishing_service = self.depart_info[id_ev][0]
def __init__(self, network_path: str, fleet_path: str, measurements_path: str, routes_path: str, history_path: str, mat_path: str, sample_time: float, main_folder: str = None, std_factor: Tuple = (1., 1.), create_routes_xml: bool = True, create_measurements_xml: bool = True, create_history_xml: bool = True): if main_folder: self.network_path = f'{main_folder}{network_path.split("/")[-1][:-4]}_temp.xml' self.fleet_path = f'{main_folder}{fleet_path.split("/")[-1][:-4]}_temp.xml' else: self.network_path = net_path self.fleet_path = fleet_path self.measurements_path = measurements_path self.history_path = history_path self.mat_path = mat_path self.sample_time = sample_time self.network = Network.from_xml(network_path, instance=False) self.fleet = Fleet.from_xml(fleet_path, assign_customers=False, with_routes=False, instance=False) self.network.write_xml(self.network_path, print_pretty=False) self.fleet.write_xml(self.fleet_path, network_in_file=False, assign_customers=False, with_routes=False, print_pretty=False) self.day_points = int(1440 / self.network.edges[0][0].sample_time) self.data = self.data_from_mat_file() if main_folder: self.routes_path = f'{main_folder}{routes_path.split("/")[-1]}' else: self.routes_path = routes_path self.routes, self.depart_info = Dispatcher.read_routes( routes_path, read_depart_info=True) Dispatcher.write_routes(self.routes_path, self.routes, self.depart_info, write_pretty=False) self.measurements, _ = self.create_measurements_file() self.history = FleetHistory().create_from_routes(self.routes) self.save_history() self.std_factor = std_factor