def run_rtn(case, options): if case['model'] == 'rtn1': steel_rtn = PlantRtnBuilder(case) opt_math_model = OptModelBuilder(steel_rtn, options) elif case['model'] == 'rtn2': steel_rtn = PlantRtn2Builder(case) opt_math_model = OptModelBuilderRTN2(steel_rtn, options) else: opt_math_model = None # log.info('task %d resource %d binary %d total %d constraint %d T %d' # % (opt_math_model.num_tasks, opt_math_model.num_resources, # opt_math_model.num_x, (opt_math_model.num_y+opt_math_model.num_x), # opt_math_model.num_con, opt_math_model.num_t)) result = solve_cplex(opt_math_model) # result = solve_schedule_bb.SteelBranchBound(steel_rtn, opt_math_model).solve_bb() if result['status'] in [101, 102, 107]: # print json.dumps(result, indent=2) log.info('%-40s obj %.1f group %d CPU %d rel_gap %.4f relax_obj %.1f status %d' % (case['doc'], result['obj'], case['group_num'], result['cpu_time'], result['rel_gap'], result['best_relaxed_obj'], result['status'])) xx = result['xx'].toarray() np.savetxt('%sxx_%s.txt' % (DIR_TEMP, case['doc']), xx) yy = result['yy'].toarray() np.savetxt('%syy_%s.txt' % (DIR_TEMP, case['doc']), yy) else: log.error('%s No solution after %d s status %d' % (case['doc'], result['cpu_time'], result['status']))
def run_rtn(case, options, work_dir): if case['model'] == 'rtn1': steel_rtn = PlantRtnBuilder(case) opt_math_model = OptModelBuilder(steel_rtn, options) elif case['model'] == 'rtn2': steel_rtn = PlantRtn2Builder(case) opt_math_model = OptModelBuilderRTN2(steel_rtn, options) else: opt_math_model = None result = solve_cplex(opt_math_model) if result['status'] in [101, 102, 107]: log.info('%-40s obj %.1f group %d CPU %d rel_gap %.4f relax_obj %.1f status %d' % (case['doc'], result['obj'], case['group_num'], result['cpu_time'], result['rel_gap'], result['best_relaxed_obj'], result['status'])) xx = result['xx'].toarray() yy = result['yy'].toarray() steel_util.dump_schedule(case, xx.reshape(-1).tolist(), yy.reshape(-1).tolist(), work_dir) else: log.error('%s No solution after %d s status %d' % (case['doc'], result['cpu_time'], result['status']))