How to add a matrix variable to a matrix/array?
Awaiting user inputI have defined an array and a matrix variable in the concrete model. Then I add the constraint below. However, "Incompatible dimension" is casted. What's wrong with my code?
y_i = [[3, 2, 1, 1, 2],
[3, 2, 1, 1, 2],
[3, 2, 1, 1, 2]]
## y_ii's dimension: B * 1, i = 1, ..., N
y_ii = locals()
for i in range(N):
y_ii['y_'+str(i+1)+str(i+1)] = m.addMVar(len(B),
name = 'y_{}{}'.format(i+1, i+1))
for i in range(N):
### (1c)
m.addConstr(y_ii['y_'+str(i+1)+str(i+1)] == y_i[i])
0
-
Official comment
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 Jacob,
Please post a minimal working example reproducing this issue. In particular, in your code snippet the values of \(N\) and \(B\) are missing.
Best regards,
Jaromił0
Post is closed for comments.
Comments
2 comments