TypeError: unsupported operand type(s) for *: 'float' and 'tupledict'
回答済みHi,
I am trying to code this constraints but get an error.
Below are one fo my constraints.

Below is my code:
ramda = m.addMVar((2, 6, 6, 6), name='ramda')
for j in range(6):
m.addConstr(ramda[:, j, 0:j, :].sum() + ramda[:, j, j + 1:, :].sum() - v[j] <= 0)
and ramda is a 4-d matrix.
Thank you for reading my post and helping me out!
0
-
正式なコメント
This post is more than two 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 try Gurobot, our chatbot interface offering instant, expert-level support. -
Hi Tao,
The error message is not being produced by the code you have pasted. The culprit should be a line containing the * symbol, as per the error message.
The following code, for example, runs without problem:
m = gp.Model()
ramda = m.addMVar((2, 6, 6, 6), name='ramda')
v = [1]*6
for j in range(1,5):
m.addConstr(ramda[:, j, 0:j, :].sum() + ramda[:, j, j + 1:, :].sum() - v[j] <= 0)Note you will need to handle j = 0 and j = 5 separately since
ramda[:, j, 0:0, :].sum()
and
ramda[:, 5, 6:, :].sum()
will raise an error (the MVar slice contains no variables).
- Riley
0
投稿コメントは受け付けていません。
コメント
2件のコメント