本文整理汇总了Python中schedule.Schedule.write_audit_file方法的典型用法代码示例。如果您正苦于以下问题:Python Schedule.write_audit_file方法的具体用法?Python Schedule.write_audit_file怎么用?Python Schedule.write_audit_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类schedule.Schedule
的用法示例。
在下文中一共展示了Schedule.write_audit_file方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_schedule
# 需要导入模块: from schedule import Schedule [as 别名]
# 或者: from schedule.Schedule import write_audit_file [as 别名]
def make_schedule(team_counts, league, sch_tries=500, seed=None, debug=True, reffing=True,
save_play_schedule=False):
from schedule import Schedule
from random import choice, randrange
import random
import pickle
start = datetime.datetime.now()
if seed != None:
random.seed(seed)
try:
if save_play_schedule and os.path.isfile(play_schedule_pkl_path()):
sch = get_schedules(play_schedule_pkl_path())[0]
mut_idx = 0
else:
facilities = league.days
sch = Schedule(league, team_counts, facilities)
#print([num / 4.0 for num in sch.get_game_div_count_list()])
# add play schedule
for div_idx in range(5): # todo: if kept, make this dynamic
for mut_idx in range(sch_tries):
if True:
sch.try_remake_a_few_random_days(div_idx, 1)
sch.try_remake_a_few_random_days(div_idx, randrange(1, sch.daycount+1))
if debug:
print(sch.solution_debug_data(mut_idx, div_idx))
if (sch.fitness_div_list()[div_idx] == 0):
if debug:
print("correct schedule found for division {}!!!!!".format(div_idx))
break
else:
print(sch.solution_debug_data(1))
print(sch.get_audit_text())
raise(FailedToConverge("main make_schedule routine failed to generate schedule in " +
"{} tries.".format(sch_tries)))
if save_play_schedule and not os.path.isfile(play_schedule_pkl_path()):
save_schedules([sch], play_schedule_pkl_path())
# add reffing duties
if reffing:
sch.add_reffing(debug=debug)
if debug:
print(sch.solution_debug_data(mut_idx))
delta = (datetime.datetime.now() - start).total_seconds()
print("total run_emr_job time was {} second and {} iterations".format(delta, mut_idx))
path = '/Users/coulter/Desktop/life_notes/2016_q1/scvl/'
# todo, change this to use print(datetime.datetime.now().date())
save_sch = False
if save_sch:
tag = '2016-09-06a_'
sch.gen_csv(path + tag + "simple.csv")
sch.write_audit_file(path + tag + "audit_2016_spr.csv")
sch_py_obj = path + tag + 'python_file_obj.pickle'
with open(sch_py_obj,'wb') as sch_file:
pickle.dump(sch, sch_file)
except (Exception, KeyboardInterrupt) as e:
print(sch.get_audit_text())
print('Initial traceback was:\n{}'.format(traceback.format_exc()))
raise (e)
return sch