本文整理汇总了Python中agent.Agent.rules方法的典型用法代码示例。如果您正苦于以下问题:Python Agent.rules方法的具体用法?Python Agent.rules怎么用?Python Agent.rules使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类agent.Agent
的用法示例。
在下文中一共展示了Agent.rules方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from agent import Agent [as 别名]
# 或者: from agent.Agent import rules [as 别名]
#.........这里部分代码省略.........
pool.close()
pool.join()
# multi processing #
elif final_mode == 'route_fluc_prob':
# init retrofit designs
retrofit_designs = RETROFIT_DESIGNS
# initialize parameters
simulation_times = SIMULATE_COUNT
conducted_simulation_count = 0
devided_simulation_times = np.array_split(range(simulation_times)[conducted_simulation_count:], PROC_NUM)
retrofit_mode = RETROFIT_MODE['route_change_merged']
# for single case
trends = [0.05]
deltas = [0.30]
for trend in trends:
for delta in deltas:
dir_name = "trend_%0.2lf_delta%0.2lf" % (trend, delta)
for bf_mode in ['rough']:
designs = retrofit_designs[bf_mode]
case_modes = TARGET_DESIGNS[bf_mode]
for case_mode in case_modes:
base_design_key = designs[case_mode]
retrofit_design_keys = { k:v for k,v in designs.items() if not k == case_mode}
agent = Agent(base_sinario,
world_scale,
flat_rate,
retrofit_mode,
scenario_mode, BF_MODE[bf_mode])
agent.rules = {'trend': trend, 'delta': delta}
agent.output_dir_path = "%s/%s/%s/%s_design" % (output_dir_path, dir_name, bf_mode, case_mode)
# for route change
agent.change_sea_flag = True
agent.change_route_prob = CHANGE_ROUTE_PROB
'''
agent.calc_flexible_design_m(1, hull_list, engine_list, propeller_list, simulation_duration_years, devided_simulation_times, base_design_key, retrofit_design_keys, retrofit_mode)
sys.exit()
'''
# multi processing #
# initialize
pool = mp.Pool(PROC_NUM)
callback = [pool.apply_async(agent.calc_flexible_design_m, args=(index, hull_list, engine_list, propeller_list, simulation_duration_years, devided_simulation_times, base_design_key, retrofit_design_keys, retrofit_mode)) for index in xrange(PROC_NUM)]
pool.close()
pool.join()
# multi processing #
elif final_mode == 'whole_sim':
# initialize parameters
bf_mode = 'rough'
simulation_times = SIMULATE_COUNT
simulation_duration_years = VESSEL_LIFE_TIME
conducted_simulation_count = 0
devided_simulation_times = np.array_split(range(simulation_times)[conducted_simulation_count:], PROC_NUM)
agent = Agent(base_sinario,
world_scale,
flat_rate,
None,
scenario_mode, BF_MODE[bf_mode])
agent.rules = {'trend': 0.05, 'delta': 0.30}
示例2: run
# 需要导入模块: from agent import Agent [as 别名]
# 或者: from agent.Agent import rules [as 别名]
#.........这里部分代码省略.........
retrofit_designs = RETROFIT_DESIGNS
# initialize parameters
simulation_duration_years = VESSEL_LIFE_TIME
simulation_times = 100
devided_simulation_times = np.array_split(range(simulation_times), PROC_NUM)
sinario_mode = DERIVE_SINARIO_MODE['binomial']
retrofit_mode = RETROFIT_MODE['significant_rule']
# create variables
## 10 cases
case_num = 10
trends = np.linspace(BASE_TREND['origin'], BASE_TREND['end'], case_num)
## 10 cases
deltas = np.linspace(BASE_DELTA['origin'], BASE_DELTA['end'], case_num)
# for single case
trends = [0.05, 0.10, 0.15]
deltas = [0.30]
for trend in trends:
for delta in deltas:
dir_name = "trend_%0.2lf_delta%0.2lf" % (trend, delta)
for bf_mode in BF_MODE.keys():
designs = retrofit_designs[bf_mode]
case_modes = designs.keys()
for case_mode in case_modes:
base_design_key = designs[case_mode]
retrofit_design_keys = { k:v for k,v in designs.items() if not k == case_mode}
agent = Agent(base_sinario,
world_scale,
flat_rate,
retrofit_mode,
sinario_mode, BF_MODE[bf_mode])
agent.rules = {'trend': trend, 'delta': delta}
agent.output_dir_path = "%s/%s/%s/%s_design" % (output_dir_path, dir_name, bf_mode, case_mode)
# multi processing #
# initialize
pool = mp.Pool(PROC_NUM)
callback = [pool.apply_async(agent.calc_flexible_design_m, args=(index, hull_list, engine_list, propeller_list, simulation_duration_years, devided_simulation_times, base_design_key, retrofit_design_keys, retrofit_mode)) for index in xrange(PROC_NUM)]
pool.close()
pool.join()
# multi processing #
print_with_notice("Program finished at %s" % (detailed_datetime_to_human(datetime.datetime.now())))
sys.exit()
if final_mode:
significant_modes = ['high', 'low', 'dec', 'inc']
oilprice_modes = [ 'oilprice_' + s for s in significant_modes]
# search initial_design
for bf_mode in BF_MODE.keys():
for oilprice_mode in oilprice_modes:
# generate sinario
sinario, world_scale, flat_rate = generate_final_significant_modes(oilprice_mode,
oil_price_history_data,
world_scale_history_data,
flat_rate_history_data)
# visualize for debug
#sinario.draw_significant_oilprice_modes(oilprice_modes)
#world_scale.draw_significant_oilprice_modes(oilprice_modes, sinario)
# initialize
retrofit_mode = RETROFIT_MODE['none']
agent = Agent(sinario,
world_scale,