Beispiel #1
0
def location2conflict(simulation_period, input_file, output_file):
    ig = InputGeography.InputGeography()

    ig.ReadLocationsFromCSV(input_file)

    file = open(output_file, "w")

    output_header_string = "#Day,"

    for l in ig.locations:
        output_header_string += " %s," % (l[0])

    output_header_string += "\n"
    file.write(output_header_string)

    for t in range(0, simulation_period):

        output = "%s" % t

        for l in ig.locations:
            # print(l)
            if l[4] == "conflict_zone":
                confl_date = int(l[5])
                if confl_date <= t:
                    output += ", 1"
                else:
                    output += ", 0"
            else:
                output += ", 0"

        output += "\n"
        file.write(output)

    file.close()
Beispiel #2
0
def run_flare(config_dir, flare_out_dir,
              simulation_period=100, file_suffix=""):

    ig = InputGeography.InputGeography()

    ig.ReadLocationsFromCSV("%s/locations%s.csv" % (config_dir, file_suffix))

    ig.ReadLinksFromCSV("%s/routes%s.csv" % (config_dir, file_suffix))

    e = Ecosystem.Ecosystem()

    lm = e.StoreInputGeographyInEcosystem(ig)

    # print("Network data loaded")

    print("output file -> %s" % (flare_out_dir))
    file = open("%s" % flare_out_dir, "w")

    output_header_string = "#Day,"

    for l in e.locations:
        output_header_string += " %s," % (l.name)

    output_header_string += "\n"
    file.write(output_header_string)

    for t in range(0, simulation_period):

        e.evolve()

        output = "%s" % t

        for l in e.locations:
            if l.flare:
                output += ",1"
            else:
                output += ",0"

        output += "\n"
        file.write(output)

    file.close()
Beispiel #3
0
  if len(sys.argv)<4:
    print("Please run using: python3 run.py <your_csv_directory> <your_refugee_data_directory> <duration in days> <optional: simulation_settings.csv> > <output_directory>/<output_csv_filename>")

  input_csv_directory = sys.argv[1]
  validation_data_directory = sys.argv[2]
  if int(sys.argv[3]) > 0:
    end_time = int(sys.argv[3])

  if len(sys.argv)==5:
    flee.SimulationSettings.ReadFromCSV(sys.argv[4])
  flee.SimulationSettings.FlareConflictInputFile = "%s/conflicts.csv" % input_csv_directory

  e = flee.Ecosystem()

  ig = InputGeography.InputGeography()

  ig.ReadFlareConflictInputCSV(flee.SimulationSettings.FlareConflictInputFile)

  ig.ReadLocationsFromCSV("%s/locations.csv" % input_csv_directory)

  ig.ReadLinksFromCSV("%s/routes.csv" % input_csv_directory)

  ig.ReadClosuresFromCSV("%s/closures.csv" % input_csv_directory)

  e,lm = ig.StoreInputGeographyInEcosystem(e)

  d = handle_refugee_data.RefugeeTable(csvformat="generic", data_directory=validation_data_directory, start_date=start_date, data_layout="data_layout.csv")

  d.ReadL1Corrections("%s/registration_corrections.csv" % input_csv_directory)