Memory Error occurs during setting objective function
ユーザーの入力を待っています。Hello!
I am currently working on a flow optimization problem on Jupyter notebook.
The code worked on smaller scale problem, but when trying it on the full scale dataset, MemoryError occurs.
It first happened in adding the constraints, but after dividing each row into separate blocks, I was able to add all constraints successfully.
However, now the MemoryError occurs when setting the objective function. The error message is as follows.
--------------------------------------------------------------------------- MemoryError Traceback (most recent call last) <ipython-input-68-3a5806b77431> in <module> ----> 1 obj = gp.quicksum(k*routes_dict[(s, r)] * gp.quicksum(X[(s,r,p)] for p in parts) for s in s_nodes for r in r_nodes) \ 2 + gp.quicksum(unit_value_dict[p] * gp.quicksum(Excess_stock[(n, p)] for n in nodes) for p in parts) \ 3 + gp.quicksum(unit_value_dict[p] * gp.quicksum(Deficit_stock[(n, p)] for n in nodes) for p in parts) 4 5 model.setObjective(obj, GRB.MINIMIZE) src\gurobipy\linexpr.pxi in gurobipy.LinExpr.__add__() src\gurobipy\linexpr.pxi in gurobipy.LinExpr.__init__() MemoryError:
As for the code, please refer to the following link for the relevant code.
If you need additional information, please do not hesitate to let me know.
Thank you.
Best,
Jinwoo
-
正式なコメント
This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum. Or why not try our AI Gurobot?. -
Hi Jinwoo,
What are the dimensions of the sets \(\texttt{parts, nodes, s_nodes, r_nodes}\)?
You could try reducing the number of \(\texttt{for}\)-loops by using
obj = LinExpr(0)
for p in parts:
for n in nodes:
obj.add(Excess_stock[(n,p)], unit_value_dict[p])
obj.add(Deficit_stock[(n, p)], unit_value_dict[p])
for s in s_nodes:
for r in r_nodes:
obj.add(k*routes_dict[(s, r)], X[(s,r,p)])You could also consider using the addTerms method.
Best regards,
Jaromił0
投稿コメントは受け付けていません。
コメント
2件のコメント