Exemplo n.º 1
0
 def inject_real_data_trips(self, real_world_date=selected_date):
     """
     Args:
         real_world_date: date from which the real world data need to be
                         obtained
     """
     if run_mode == RunMode.FULL:
         import pandas as pd
         day = real_world_date.day
         month = real_world_date.month
         month_val, day_val = convert_month_day_num_to_str(
             str(month) + "/" + str(day))
         file_name = trips_directory + month_val + "/" + day_val + "/successful.csv"
         if not os.path.exists(file_name):
             fu_assist = FUAssist(self._dump_util, self._output_dir)
             fu_assist.set_date(real_world_date)
             run_function_generic(self._dump_util,
                                  func=fu_assist.run,
                                  args=("real", ))
         df = pd.read_csv(file_name)
         self._filtered_trip_ids = df["trip_id"].to_list()
Exemplo n.º 2
0
import os
import sys

sys.path.append(os.getcwd())

from algo.gen_algo.GenAlgAssist import create_gen_alg_assist, dump_util
from common.util.common_util import run_function_generic
from common.configs.global_constants import run_mode
from common.mode.RunMode import RunMode
from common.parsers.ArgParser import ConfigParserCommon

gen_alg_assist = create_gen_alg_assist()
if run_mode == RunMode.FULL:
    gen_alg_assist.inject_real_data_trips()
arg_parser = ConfigParserCommon()
args = arg_parser.parse_args().__dict__
args["interface"] = "GAAction"
gen_alg_assist.add_params(args)
suffix = args["suffix"]
if suffix != "":
    gen_alg_assist.set_summary_suffix(suffix)
run_function_generic(dump_util, func=gen_alg_assist.run_multi, args=("gen_alg",))
Exemplo n.º 3
0
import os
import sys

sys.path.append(os.getcwd())

from algo.sim_anneal.SAAssist import create_sim_anneal_assist, dump_util
from common.util.common_util import run_function_generic
from common.configs.global_constants import run_mode
from common.mode.RunMode import RunMode
from common.parsers.ArgParser import ConfigParserCommon

sim_anneal_assist = create_sim_anneal_assist()
if run_mode == RunMode.FULL:
    sim_anneal_assist.inject_real_data_trips()
arg_parser = ConfigParserCommon()
args = arg_parser.parse_args().__dict__
args["interface"] = "SAAction"
sim_anneal_assist.add_params(args)
suffix = args["suffix"]
if suffix != "":
    sim_anneal_assist.set_summary_suffix(suffix)
run_function_generic(dump_util, func=sim_anneal_assist.run_multi, args=("sim_anneal",))
Exemplo n.º 4
0
    "real_ev_assigns,greedy_ev_assigns,sim_anneal_ev_assigns,gen_algo_ev_assigns,"
    "real_cost,greedy_cost,sim_anneal_cost,gen_algo_cost,"
    "real_emission,greedy_emission,sim_anneal_emission,gen_algo_emission\n")
over_all_summary.flush()
os.fsync(over_all_summary.fileno())
while start_date != end_date:
    if start_date.weekday() not in [5, 6]:
        custom_output_dir = "result_{}_{}/output/".format(
            str(start_date.month), str(start_date.day))
        date = start_date.strftime("%Y/%m/%d")

        fu_assist = FUAssist(dump_util_main, custom_output_dir)
        fu_assist.add_params(args)
        fu_assist.update_selected_date(start_date)
        run_function_generic(dump_util_main,
                             func=fu_assist.run_multi,
                             args=("real", ))
        real_assign = fu_assist.get_assignment()
        no_of_trips = str(len(real_assign.get_trips()))
        real_evs = str(real_assign.electric_bus_count())
        real_gvs = str(real_assign.gas_bus_count())
        real_ev_assigns = str(real_assign.electric_assign_count())
        real_cost = str(real_assign.total_energy_cost())
        real_emission = str(real_assign.total_emission())

        greedy_assist = create_greedy_assist()
        greedy_assist.add_params(args)
        greedy_assist.update_output_dir(custom_output_dir)
        greedy_assist.inject_real_data_trips(start_date)
        run_function_generic(dump_util_main,
                             func=greedy_assist.run_multi,
def generic_program(func, args):
    run_function_generic(dump_util, func=func, args=args)