notebook: regenerate them
This commit is contained in:
@@ -98,6 +98,8 @@
|
||||
" y = solver.IntVar(0.0, solver.infinity(), \"y\")\n",
|
||||
" z = solver.IntVar(0.0, solver.infinity(), \"z\")\n",
|
||||
"\n",
|
||||
" print(\"Number of variables =\", solver.NumVariables())\n",
|
||||
"\n",
|
||||
" # 2*x + 7*y + 3*z <= 50\n",
|
||||
" constraint0 = solver.Constraint(-solver.infinity(), 50)\n",
|
||||
" constraint0.SetCoefficient(x, 2)\n",
|
||||
@@ -116,6 +118,8 @@
|
||||
" constraint2.SetCoefficient(y, 2)\n",
|
||||
" constraint2.SetCoefficient(z, -6)\n",
|
||||
"\n",
|
||||
" print(\"Number of constraints =\", solver.NumConstraints())\n",
|
||||
"\n",
|
||||
" # Maximize 2*x + 2*y + 3*z\n",
|
||||
" objective = solver.Objective()\n",
|
||||
" objective.SetCoefficient(x, 2)\n",
|
||||
@@ -123,14 +127,23 @@
|
||||
" objective.SetCoefficient(z, 3)\n",
|
||||
" objective.SetMaximization()\n",
|
||||
"\n",
|
||||
" # Solve the problem and print the solution.\n",
|
||||
" solver.Solve()\n",
|
||||
" # Print the objective value of the solution.\n",
|
||||
" print(\"Maximum objective function value = %d\" % solver.Objective().Value())\n",
|
||||
" print()\n",
|
||||
" # Print the value of each variable in the solution.\n",
|
||||
" for variable in [x, y, z]:\n",
|
||||
" print(\"%s = %d\" % (variable.name(), variable.solution_value()))\n",
|
||||
" # Solve the problem.\n",
|
||||
" print(f\"Solving with {solver.SolverVersion()}\")\n",
|
||||
" status = solver.Solve()\n",
|
||||
"\n",
|
||||
" # Print the solution.\n",
|
||||
" if status == pywraplp.Solver.OPTIMAL:\n",
|
||||
" print(\"Solution:\")\n",
|
||||
" print(f\"Objective value = {solver.Objective().Value()}\")\n",
|
||||
" # Print the value of each variable in the solution.\n",
|
||||
" for variable in [x, y, z]:\n",
|
||||
" print(f\"{variable.name()} = {variable.solution_value()}\")\n",
|
||||
" else:\n",
|
||||
" print(\"The problem does not have an optimal solution.\")\n",
|
||||
"\n",
|
||||
" print(\"\\nAdvanced usage:\")\n",
|
||||
" print(f\"Problem solved in {solver.wall_time():d} milliseconds\")\n",
|
||||
" print(f\"Problem solved in {solver.iterations():d} iterations\")\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"IntegerProgrammingExample()\n",
|
||||
|
||||
Reference in New Issue
Block a user