fix #2656
This commit is contained in:
@@ -94,7 +94,7 @@
|
||||
"PARSER.add_argument(\n",
|
||||
" '--solver', default='sat', help='Method used to solve: sat, mip.')\n",
|
||||
"PARSER.add_argument(\n",
|
||||
" '--output_proto',\n",
|
||||
" '--output_proto_file',\n",
|
||||
" default='',\n",
|
||||
" help='Output file to write the cp_model proto to.')\n",
|
||||
"\n",
|
||||
@@ -174,7 +174,7 @@
|
||||
" return states, transitions\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def solve_cutting_stock_with_arc_flow_and_sat(output_proto):\n",
|
||||
"def solve_cutting_stock_with_arc_flow_and_sat(output_proto_file):\n",
|
||||
" \"\"\"Solve the cutting stock with arc-flow and the CP-SAT solver.\"\"\"\n",
|
||||
" items = regroup_and_count(DESIRED_LENGTHS)\n",
|
||||
" print('Items:', items)\n",
|
||||
@@ -241,8 +241,8 @@
|
||||
" for i in range(len(objective_vars))))\n",
|
||||
"\n",
|
||||
" # Output model proto to file.\n",
|
||||
" if output_proto:\n",
|
||||
" output_file = open(output_proto, 'w')\n",
|
||||
" if output_proto_file:\n",
|
||||
" output_file = open(output_proto_file, 'w')\n",
|
||||
" output_file.write(str(model.Proto()))\n",
|
||||
" output_file.close()\n",
|
||||
"\n",
|
||||
@@ -333,7 +333,7 @@
|
||||
"\n",
|
||||
"\"\"\"Main function\"\"\"\n",
|
||||
"if args.solver == 'sat':\n",
|
||||
" solve_cutting_stock_with_arc_flow_and_sat(args.output_proto)\n",
|
||||
" solve_cutting_stock_with_arc_flow_and_sat(args.output_proto_file)\n",
|
||||
"else: # 'mip'\n",
|
||||
" solve_cutting_stock_with_arc_flow_and_mip()\n",
|
||||
"\n"
|
||||
|
||||
@@ -101,7 +101,7 @@
|
||||
"PARSER.add_argument(\n",
|
||||
" '--instance', default=1, type=int, help='Instance number (1..3).')\n",
|
||||
"PARSER.add_argument(\n",
|
||||
" '--output_proto',\n",
|
||||
" '--output_proto_file',\n",
|
||||
" default=\"\",\n",
|
||||
" help='Output file to write the cp_model'\n",
|
||||
" 'proto to.')\n",
|
||||
|
||||
@@ -101,7 +101,7 @@
|
||||
"\n",
|
||||
"FLAGS = flags.FLAGS\n",
|
||||
"\n",
|
||||
"flags.DEFINE_string('output_proto', '',\n",
|
||||
"flags.DEFINE_string('output_proto_file', '',\n",
|
||||
" 'Output file to write the cp_model proto to.')\n",
|
||||
"flags.DEFINE_string('params', 'num_search_workers:8,log_search_progress:true',\n",
|
||||
" 'Sat solver parameters.')\n",
|
||||
@@ -2001,9 +2001,9 @@
|
||||
" model.Minimize(\n",
|
||||
" cp_model.LinearExpr.ScalProd(delay_literals, delay_weights))\n",
|
||||
"\n",
|
||||
" if not minimize_drivers and FLAGS.output_proto:\n",
|
||||
" print('Writing proto to %s' % FLAGS.output_proto)\n",
|
||||
" with open(FLAGS.output_proto, 'w') as text_file:\n",
|
||||
" if not minimize_drivers and FLAGS.output_proto_file:\n",
|
||||
" print('Writing proto to %s' % FLAGS.output_proto_file)\n",
|
||||
" with open(FLAGS.output_proto_file, 'w') as text_file:\n",
|
||||
" text_file.write(str(model))\n",
|
||||
"\n",
|
||||
" # Solve model.\n",
|
||||
|
||||
@@ -92,7 +92,7 @@
|
||||
"FLAGS = flags.FLAGS\n",
|
||||
"\n",
|
||||
"flags.DEFINE_string('input', '', 'Input file to parse and solve.')\n",
|
||||
"flags.DEFINE_string('output_proto', '',\n",
|
||||
"flags.DEFINE_string('output_proto_file', '',\n",
|
||||
" 'Output file to write the cp_model proto to.')\n",
|
||||
"flags.DEFINE_string('params', '', 'Sat solver parameters.')\n",
|
||||
"flags.DEFINE_bool('use_interval_makespan', True,\n",
|
||||
@@ -375,7 +375,7 @@
|
||||
"\n",
|
||||
"rcpsp_parser = pywraprcpsp.RcpspParser()\n",
|
||||
"rcpsp_parser.ParseFile(FLAGS.input)\n",
|
||||
"SolveRcpsp(rcpsp_parser.Problem(), FLAGS.output_proto, FLAGS.params)\n",
|
||||
"SolveRcpsp(rcpsp_parser.Problem(), FLAGS.output_proto_file, FLAGS.params)\n",
|
||||
"\n"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@
|
||||
"\n",
|
||||
"FLAGS = flags.FLAGS\n",
|
||||
"\n",
|
||||
"flags.DEFINE_string('output_proto', '',\n",
|
||||
"flags.DEFINE_string('output_proto_file', '',\n",
|
||||
" 'Output file to write the cp_model proto to.')\n",
|
||||
"flags.DEFINE_string('params', 'max_time_in_seconds:10.0',\n",
|
||||
" 'Sat solver parameters.')\n",
|
||||
@@ -252,7 +252,7 @@
|
||||
" return cost_variables, cost_coefficients\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def solve_shift_scheduling(params, output_proto):\n",
|
||||
"def solve_shift_scheduling(params, output_proto_file):\n",
|
||||
" \"\"\"Solves the shift scheduling problem.\"\"\"\n",
|
||||
" # Data\n",
|
||||
" num_employees = 8\n",
|
||||
@@ -437,9 +437,9 @@
|
||||
" sum(obj_int_vars[i] * obj_int_coeffs[i]\n",
|
||||
" for i in range(len(obj_int_vars))))\n",
|
||||
"\n",
|
||||
" if output_proto:\n",
|
||||
" print('Writing proto to %s' % output_proto)\n",
|
||||
" with open(output_proto, 'w') as text_file:\n",
|
||||
" if output_proto_file:\n",
|
||||
" print('Writing proto to %s' % output_proto_file)\n",
|
||||
" with open(output_proto_file, 'w') as text_file:\n",
|
||||
" text_file.write(str(model))\n",
|
||||
"\n",
|
||||
" # Solve the model.\n",
|
||||
@@ -486,7 +486,7 @@
|
||||
" print(' - wall time : %f s' % solver.WallTime())\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"solve_shift_scheduling(FLAGS.params, FLAGS.output_proto)\n",
|
||||
"solve_shift_scheduling(FLAGS.params, FLAGS.output_proto_file)\n",
|
||||
"\n"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@
|
||||
"# Command line arguments.\n",
|
||||
"PARSER = argparse.ArgumentParser()\n",
|
||||
"PARSER.add_argument(\n",
|
||||
" '--output_proto',\n",
|
||||
" '--output_proto_file',\n",
|
||||
" default='',\n",
|
||||
" help='Output file to write the cp_model'\n",
|
||||
" 'proto to.')\n",
|
||||
@@ -121,7 +121,7 @@
|
||||
"\"\"\"Solves a complex single machine jobshop scheduling problem.\"\"\"\n",
|
||||
"\n",
|
||||
"parameters = args.params\n",
|
||||
"output_proto = args.output_proto\n",
|
||||
"output_proto_file = args.output_proto_file\n",
|
||||
"\n",
|
||||
"#----------------------------------------------------------------------------\n",
|
||||
"# Data.\n",
|
||||
@@ -319,9 +319,9 @@
|
||||
"\n",
|
||||
"#----------------------------------------------------------------------------\n",
|
||||
"# Write problem to file.\n",
|
||||
"if output_proto:\n",
|
||||
" print('Writing proto to %s' % output_proto)\n",
|
||||
" with open(output_proto, 'w') as text_file:\n",
|
||||
"if output_proto_file:\n",
|
||||
" print('Writing proto to %s' % output_proto_file)\n",
|
||||
" with open(output_proto_file, 'w') as text_file:\n",
|
||||
" text_file.write(str(model))\n",
|
||||
"\n",
|
||||
"#----------------------------------------------------------------------------\n",
|
||||
|
||||
Reference in New Issue
Block a user