本文整理汇总了Python中agent.Agent.output_dir_path方法的典型用法代码示例。如果您正苦于以下问题:Python Agent.output_dir_path方法的具体用法?Python Agent.output_dir_path怎么用?Python Agent.output_dir_path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类agent.Agent
的用法示例。
在下文中一共展示了Agent.output_dir_path方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from agent import Agent [as 别名]
# 或者: from agent.Agent import output_dir_path [as 别名]
def run(options):
# get option variables #
final_mode = options.final_mode
combi_mode = options.combination_mode
change_route_mode = options.change_route
# load history data
from_date = '2004/01/01'
to_date = '2016/01/01'
oil_price_history_data = load_monthly_history_data(from_date, to_date)
world_scale_history_data = load_world_scale_history_data(from_date, to_date)
flat_rate_history_data = load_flat_rate_history_data(from_date, to_date)
# generate sinario
base_sinario = Sinario(oil_price_history_data)
# generate world scale
world_scale = WorldScale(world_scale_history_data)
# generate flat rate
flat_rate = FlatRate(flat_rate_history_data)
#flat_rate.draw_multiple_flat_rates()
# draw test market prices
#draw_market_prices(base_sinario, world_scale, flat_rate)
# generate significant motecalro sinario
## {'high': 19917289, 'low': 19962436, 'stage': 19935671}
scenario_seeds = {'high': 19917289, 'low': 19962436, 'stage': 19935671}
if scenario_seeds is None:
scenario_seeds = get_significant_scenarios_seeds(base_sinario, world_scale, flat_rate)
'''
# draw significant scenario
draw_significant_scenario(base_sinario, world_scale, flat_rate, scenario_seeds)
print 'scenario_seeds:'
print scenario_seeds
'''
# initialize directory
output_dir_path = "%s/%s" % (AGNET_LOG_DIR_PATH, generate_timestamp())
initializeDirHierarchy(output_dir_path)
# retrofit mode
# load components list
hull_list = load_hull_list()
engine_list = load_engine_list()
propeller_list = load_propeller_list()
# bow test
#bow_test()
simulation_duration_years = VESSEL_LIFE_TIME
scenario_mode = DERIVE_SINARIO_MODE['binomial']
if final_mode == 'route_fluc':
# init market fluc as middle(stage)
fixed_seed = scenario_seeds['stage']
np.random.seed(fixed_seed)
generate_market_scenarios(base_sinario, world_scale, flat_rate, scenario_mode, simulation_duration_years)
# init parameters
oilprice_mode = "oilprice_middle"
change_route_periods = CHANGE_ROUTE_PERIODS
bf_mode = 'rough'
case_mode = 'middle'
designs = RETROFIT_DESIGNS[bf_mode]
base_design_key = designs[case_mode]
retrofit_design_key = RETROFIT_DESIGNS_FOR_ROUTE_CHANGE[bf_mode][case_mode]
retrofit_mode = RETROFIT_MODE['route_change']
devided_periods = np.array_split(change_route_periods, PROC_NUM)
agent = Agent(base_sinario,
world_scale,
flat_rate,
retrofit_mode,
scenario_mode, BF_MODE[bf_mode])
agent.change_sea_flag = True
agent.output_dir_path = output_dir_path
'''
agent.calc_flexible_design_m_route_change(0, hull_list, engine_list, propeller_list, simulation_duration_years, devided_periods, base_design_key, retrofit_design_key, retrofit_mode)
sys.exit()
'''
# multi processing #
# initialize
pool = mp.Pool(PROC_NUM)
callback = [pool.apply_async(agent.calc_flexible_design_m_route_change, args=(index, hull_list, engine_list, propeller_list, simulation_duration_years, devided_periods, base_design_key, retrofit_design_key, retrofit_mode)) for index in xrange(PROC_NUM)]
pool.close()
pool.join()
# multi processing #
elif final_mode == 'route_fluc_monte':
# init market fluc as middle(stage)
fixed_seed = scenario_seeds['stage']
np.random.seed(fixed_seed)
generate_market_scenarios(base_sinario, world_scale, flat_rate, scenario_mode, simulation_duration_years)
# init parameters
oilprice_mode = "oilprice_middle"
#.........这里部分代码省略.........
示例2: run
# 需要导入模块: from agent import Agent [as 别名]
# 或者: from agent.Agent import output_dir_path [as 别名]
def run(options):
print_with_notice("Program started at %s" % (detailed_datetime_to_human(datetime.datetime.now())))
# get option variables #
initial_hull_id = options.hull_id
initial_engine_id = options.engine_id
initial_propeller_id = options.propeller_id
initial_design = options.initial_design
create_combination = options.create_combination
result_visualize_mode = options.result_visualize_mode
result_dir_path = options.result_dir_path
no_retrofit_ignore = options.no_retrofit_ignore
propeller_retrofit_ignore = options.propeller_retrofit_ignore
propeller_and_engine_retrofit_ignore = options.propeller_and_engine_retrofit_ignore
retrofit_mode = options.retrofit_mode
final_mode = options.final_mode
# load history data
from_date = '2004/01/01'
to_date = '2015/01/01'
oil_price_history_data = load_monthly_history_data(from_date, to_date)
world_scale_history_data = load_world_scale_history_data()
flat_rate_history_data = load_flat_rate_history_data()
# generate sinario
base_sinario = Sinario(oil_price_history_data)
# generate world scale
world_scale = WorldScale(world_scale_history_data)
# generate flat rate
#flat_rate = FlatRate(flat_rate_history_data)
flat_rate = FlatRate(flat_rate_history_data)
#flat_rate.draw_multiple_flat_rates()
# draw multiple scenario part #
# base_sinario.draw_multiple_scenarios(world_scale)
# draw sfoc features
draw_engine_sfoc()
# correlation analysis #
analyze_correlation(oil_price_history_data, world_scale_history_data,
{'start': datetime.datetime(2009, 1, 1), 'end': datetime.datetime.now()})
# initialize directory
output_dir_path = "%s/%s" % (AGNET_LOG_DIR_PATH, generate_timestamp())
initializeDirHierarchy(output_dir_path)
if result_visualize_mode:
if (initial_engine_id is None) or (initial_propeller_id is None):
print "Error: please input engine and propeller ids"
else:
compare_hull_design(npv_result, initial_engine_id, initial_propeller_id)
output_result = {}
for c_key, npv_array in npv_result.items():
if not output_result.has_key(c_key):
output_result[c_key] = {}
output_result[c_key]['npv'] = np.average(npv_array)
output_result[c_key]['std'] = np.std(npv_array)
display_sorted_result(output_result, 3)
sys.exit()
# output result
output_mode_str = re.compile(r'(mode.+)').search(result_dir_path).groups()[0]
output_json_dir = "%s/json" % (RESULT_DIR_PATH)
initializeDirHierarchy(output_json_dir)
output_json_path = "%s/%s.json" % (output_json_dir, output_mode_str)
write_file_as_json(output_result, output_json_path)
column_names = ['c_key', 'ave_npv', 'std']
write_data = [ [c_key, val['npv'], val['std']] for c_key, val in output_result.items()]
write_simple_array_csv(column_names, write_data, './test.csv')
sys.exit()
# display maximum_designs
draw_NPV_for_each3D(results_data, output_dir_path, [0, 900], [190000000, 206000000])
display_maximum_designs(results_data, 10)
draw_whole_NPV(results_data, output_dir_path)
draw_each_NPV_distribution(results_data, output_dir_path)
# for narrow_down result
output_dir_path = "%s/visualization/narrow_down" % (RESULT_DIR_PATH)
initializeDirHierarchy(output_dir_path)
json_dirpath = NARROW_DOWN_RESULT_PATH
if not os.path.exists(json_dirpath):
print "abort: there is no such directory, %s" % (json_dirpath)
sys.exit()
files = os.listdir(json_dirpath)
#draw_NPV_histogram_m(json_filepath, output_filepath)
results_data = {}
for target_filename in files:
try:
combination_key, = re.compile(r'(H.+)\.json').search(target_filename).groups()
except:
continue
target_filepath = "%s/%s" % (json_dirpath, target_filename)
results_data[combination_key] = load_json_file(target_filepath)
#.........这里部分代码省略.........