else: parser.print_help() sys.exit() if os.path.exists(args.config_file): ftot_program_directory = os.path.dirname(os.path.realpath(__file__)) else: print("{} doesn't exist".format(args.config_file)) sys.exit() # set up logging and report run start time # ---------------------------------------------------------------------------------------------- xml_file_location = os.path.abspath(args.config_file) from ftot_supporting import create_loggers logger = create_loggers(os.path.dirname(xml_file_location), args.task) logger.info( "=================================================================================" ) logger.info( "============= FTOT RUN STARTING. Run Option = {:2} ===============================" .format(str(args.task).upper())) logger.info( "=================================================================================" ) # load the ftot scenario # ---------------------------------------------------------------------------------------------- from ftot_scenario import *
def run_test_pulp_optimization(): #below are calls to internal functions to generate all the facilities # and routes required to run a test simulation of the AFTOT without # requiring GIS. # initialize logger # CRITICAL 50 # ERROR 40 # WARNING 30 # RESULT 25 # CONFIG 24 # INFO 20 # DEBUG 10 # DETAILED_DEBUG 5 logger = ftot_supporting.create_loggers(os.getcwd(), "test_pulp") # logger.setLevel(logging.DEBUG) ## logger.basicConfig(filemode='w', level=logging.DEBUG) # generate all test facilities logger.info("START: test_create_all_facilities") all_facilities = _test_create_all_facilities(logger) #assumptions_logger.write("All facilities: \n") #for f in all_facilities: # assumptions_logger.write("{} \n".format(f.asText())) ## if type(f).__name__ == "Intermediate_Processing_Facility": ## assumptions_logger.write("corn quantity {}".format(f.getQuantity(logger, "corn"))) ## assumptions_logger.write("gasoline quantity {}".format(f.getQuantity(logger, "gasoline"))) # get all_routes from route cache logger.info("START: _test_create_all_routes") if scenario == 1: all_routes = _test_create_all_routes(all_facilities) elif scenario == 2: all_routes = _test_create_all_routes_2(all_facilities) elif scenario == 3: all_routes = _test_create_all_routes_3(all_facilities) elif scenario == 4: all_routes = _test_create_all_routes_2(all_facilities) elif scenario == 5: all_routes = _test_create_all_routes_5(all_facilities) elif scenario == 6: all_routes = _test_create_all_routes_6(all_facilities) else: all_routes = _test_create_all_routes(all_facilities) #logger.debug("all routes {}".format(all_routes)) # convert facilities to vertifices and routes to edges logger.info("START: pre_setup_pulp") all_routes, all_edges, vertex_edge_dictionary = \ aftot_pulp.pre_setup_pulp(logger, all_facilities, all_routes) logger.info("START: setup_pulp_problem") prob, flow_vars, unmet_demand_vars = aftot_pulp.setup_pulp_problem(logger, \ all_edges, vertex_edge_dictionary) # print "finished running setup_pulp_problem" # call solve_pulp_problem() logger.info("START: solve_pulp_problem") # solution = aftot_pulp.solve_pulp_problem(prob, logger) aftot_pulp.solve_pulp_problem(prob, flow_vars, unmet_demand_vars, all_edges, logger) # call PuLp post-processing logger.info("POST PROCESSING HOLDER") aftot_route.post_processing() #assumptions_logger.close() pass