diff --git a/examples/notebook/examples/arc_flow_cutting_stock_sat.ipynb b/examples/notebook/examples/arc_flow_cutting_stock_sat.ipynb index 7d18e5e8fe..4dd9f75844 100644 --- a/examples/notebook/examples/arc_flow_cutting_stock_sat.ipynb +++ b/examples/notebook/examples/arc_flow_cutting_stock_sat.ipynb @@ -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" diff --git a/examples/notebook/examples/bus_driver_scheduling_flow_sat.ipynb b/examples/notebook/examples/bus_driver_scheduling_flow_sat.ipynb index 9ee69e22cd..497b3cc5fd 100644 --- a/examples/notebook/examples/bus_driver_scheduling_flow_sat.ipynb +++ b/examples/notebook/examples/bus_driver_scheduling_flow_sat.ipynb @@ -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", diff --git a/examples/notebook/examples/bus_driver_scheduling_sat.ipynb b/examples/notebook/examples/bus_driver_scheduling_sat.ipynb index 6bca47c4d8..75b1329372 100644 --- a/examples/notebook/examples/bus_driver_scheduling_sat.ipynb +++ b/examples/notebook/examples/bus_driver_scheduling_sat.ipynb @@ -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", diff --git a/examples/notebook/examples/rcpsp_sat.ipynb b/examples/notebook/examples/rcpsp_sat.ipynb index a21f24327f..26e8eda2aa 100644 --- a/examples/notebook/examples/rcpsp_sat.ipynb +++ b/examples/notebook/examples/rcpsp_sat.ipynb @@ -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" ] } diff --git a/examples/notebook/examples/shift_scheduling_sat.ipynb b/examples/notebook/examples/shift_scheduling_sat.ipynb index 253faecf4a..4273ccfe70 100644 --- a/examples/notebook/examples/shift_scheduling_sat.ipynb +++ b/examples/notebook/examples/shift_scheduling_sat.ipynb @@ -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" ] } diff --git a/examples/notebook/examples/single_machine_scheduling_with_setup_release_due_dates_sat.ipynb b/examples/notebook/examples/single_machine_scheduling_with_setup_release_due_dates_sat.ipynb index bca0a93897..aec0e0d8ee 100644 --- a/examples/notebook/examples/single_machine_scheduling_with_setup_release_due_dates_sat.ipynb +++ b/examples/notebook/examples/single_machine_scheduling_with_setup_release_due_dates_sat.ipynb @@ -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", diff --git a/examples/python/arc_flow_cutting_stock_sat.py b/examples/python/arc_flow_cutting_stock_sat.py index 83dbfc8dc4..c22a2c385f 100644 --- a/examples/python/arc_flow_cutting_stock_sat.py +++ b/examples/python/arc_flow_cutting_stock_sat.py @@ -25,7 +25,7 @@ PARSER = argparse.ArgumentParser() PARSER.add_argument( '--solver', default='sat', help='Method used to solve: sat, mip.') PARSER.add_argument( - '--output_proto', + '--output_proto_file', default='', help='Output file to write the cp_model proto to.') @@ -105,7 +105,7 @@ def create_state_graph(items, max_capacity): return states, transitions -def solve_cutting_stock_with_arc_flow_and_sat(output_proto): +def solve_cutting_stock_with_arc_flow_and_sat(output_proto_file): """Solve the cutting stock with arc-flow and the CP-SAT solver.""" items = regroup_and_count(DESIRED_LENGTHS) print('Items:', items) @@ -172,8 +172,8 @@ def solve_cutting_stock_with_arc_flow_and_sat(output_proto): for i in range(len(objective_vars)))) # Output model proto to file. - if output_proto: - output_file = open(output_proto, 'w') + if output_proto_file: + output_file = open(output_proto_file, 'w') output_file.write(str(model.Proto())) output_file.close() @@ -265,7 +265,7 @@ def solve_cutting_stock_with_arc_flow_and_mip(): def main(args): """Main function""" if args.solver == 'sat': - solve_cutting_stock_with_arc_flow_and_sat(args.output_proto) + solve_cutting_stock_with_arc_flow_and_sat(args.output_proto_file) else: # 'mip' solve_cutting_stock_with_arc_flow_and_mip() diff --git a/examples/python/bus_driver_scheduling_flow_sat.py b/examples/python/bus_driver_scheduling_flow_sat.py index c012d93b56..e44cb53863 100644 --- a/examples/python/bus_driver_scheduling_flow_sat.py +++ b/examples/python/bus_driver_scheduling_flow_sat.py @@ -32,7 +32,7 @@ PARSER = argparse.ArgumentParser() PARSER.add_argument( '--instance', default=1, type=int, help='Instance number (1..3).') PARSER.add_argument( - '--output_proto', + '--output_proto_file', default="", help='Output file to write the cp_model' 'proto to.') diff --git a/examples/python/bus_driver_scheduling_sat.py b/examples/python/bus_driver_scheduling_sat.py index 76766016c7..15ba3bb4dd 100644 --- a/examples/python/bus_driver_scheduling_sat.py +++ b/examples/python/bus_driver_scheduling_sat.py @@ -33,7 +33,7 @@ from ortools.sat.python import cp_model FLAGS = flags.FLAGS -flags.DEFINE_string('output_proto', '', +flags.DEFINE_string('output_proto_file', '', 'Output file to write the cp_model proto to.') flags.DEFINE_string('params', 'num_search_workers:8,log_search_progress:true', 'Sat solver parameters.') @@ -1933,9 +1933,9 @@ def bus_driver_scheduling(minimize_drivers, max_num_drivers): model.Minimize( cp_model.LinearExpr.ScalProd(delay_literals, delay_weights)) - if not minimize_drivers and FLAGS.output_proto: - print('Writing proto to %s' % FLAGS.output_proto) - with open(FLAGS.output_proto, 'w') as text_file: + if not minimize_drivers and FLAGS.output_proto_file: + print('Writing proto to %s' % FLAGS.output_proto_file) + with open(FLAGS.output_proto_file, 'w') as text_file: text_file.write(str(model)) # Solve model. diff --git a/examples/python/rcpsp_sat.py b/examples/python/rcpsp_sat.py index 57e9855a23..7fa688b84e 100644 --- a/examples/python/rcpsp_sat.py +++ b/examples/python/rcpsp_sat.py @@ -24,7 +24,7 @@ from ortools.sat.python import cp_model FLAGS = flags.FLAGS flags.DEFINE_string('input', '', 'Input file to parse and solve.') -flags.DEFINE_string('output_proto', '', +flags.DEFINE_string('output_proto_file', '', 'Output file to write the cp_model proto to.') flags.DEFINE_string('params', '', 'Sat solver parameters.') flags.DEFINE_bool('use_interval_makespan', True, @@ -316,7 +316,7 @@ def SolveRcpsp(problem, proto_file, params): def main(_): rcpsp_parser = pywraprcpsp.RcpspParser() rcpsp_parser.ParseFile(FLAGS.input) - SolveRcpsp(rcpsp_parser.Problem(), FLAGS.output_proto, FLAGS.params) + SolveRcpsp(rcpsp_parser.Problem(), FLAGS.output_proto_file, FLAGS.params) if __name__ == '__main__': diff --git a/examples/python/shift_scheduling_sat.py b/examples/python/shift_scheduling_sat.py index 6ba8f16cde..8b75eb05b5 100644 --- a/examples/python/shift_scheduling_sat.py +++ b/examples/python/shift_scheduling_sat.py @@ -21,7 +21,7 @@ from google.protobuf import text_format FLAGS = flags.FLAGS -flags.DEFINE_string('output_proto', '', +flags.DEFINE_string('output_proto_file', '', 'Output file to write the cp_model proto to.') flags.DEFINE_string('params', 'max_time_in_seconds:10.0', 'Sat solver parameters.') @@ -184,7 +184,7 @@ def add_soft_sum_constraint(model, works, hard_min, soft_min, min_cost, return cost_variables, cost_coefficients -def solve_shift_scheduling(params, output_proto): +def solve_shift_scheduling(params, output_proto_file): """Solves the shift scheduling problem.""" # Data num_employees = 8 @@ -369,9 +369,9 @@ def solve_shift_scheduling(params, output_proto): sum(obj_int_vars[i] * obj_int_coeffs[i] for i in range(len(obj_int_vars)))) - if output_proto: - print('Writing proto to %s' % output_proto) - with open(output_proto, 'w') as text_file: + if output_proto_file: + print('Writing proto to %s' % output_proto_file) + with open(output_proto_file, 'w') as text_file: text_file.write(str(model)) # Solve the model. @@ -419,7 +419,7 @@ def solve_shift_scheduling(params, output_proto): def main(_): - solve_shift_scheduling(FLAGS.params, FLAGS.output_proto) + solve_shift_scheduling(FLAGS.params, FLAGS.output_proto_file) if __name__ == '__main__': diff --git a/examples/python/single_machine_scheduling_with_setup_release_due_dates_sat.py b/examples/python/single_machine_scheduling_with_setup_release_due_dates_sat.py index 75e5d2d17b..06fb252368 100644 --- a/examples/python/single_machine_scheduling_with_setup_release_due_dates_sat.py +++ b/examples/python/single_machine_scheduling_with_setup_release_due_dates_sat.py @@ -21,7 +21,7 @@ from ortools.sat.python import cp_model # Command line arguments. PARSER = argparse.ArgumentParser() PARSER.add_argument( - '--output_proto', + '--output_proto_file', default='', help='Output file to write the cp_model' 'proto to.') @@ -53,7 +53,7 @@ def main(args): """Solves a complex single machine jobshop scheduling problem.""" parameters = args.params - output_proto = args.output_proto + output_proto_file = args.output_proto_file #---------------------------------------------------------------------------- # Data. @@ -251,9 +251,9 @@ def main(args): #---------------------------------------------------------------------------- # Write problem to file. - if output_proto: - print('Writing proto to %s' % output_proto) - with open(output_proto, 'w') as text_file: + if output_proto_file: + print('Writing proto to %s' % output_proto_file) + with open(output_proto_file, 'w') as text_file: text_file.write(str(model)) #----------------------------------------------------------------------------