Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion 04_TransportProblem.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,11 @@
"# cost .. z =e= sum((i,j), c(i,j)*x(i,j)) ;\n",
"# Model transport /all/ ;\n",
"# Solve transport using lp minimizing z ;\n",
"#\n",
"# itertools.product() returns the Cartesian product of two or more iterables\n\n",
"import itertools\n",
"def objective_rule(model):\n",
" return sum(model.c[i,j]*model.x[i,j] for i in model.i for j in model.j)\n",
" return sum(model.c[i,j]*model.x[i,j] for i, j in itertools.product(model.i, model.j))\n",
"\n",
"model.objective = Objective(rule=objective_rule, sense=minimize, doc='Define objective function')"
]
Expand Down