Matrix assembly as equality constraint
回答済みHi all,
I would like to define a matrix equality constraint (i.e. matrix assembly) in python.
The equality constraint defines the assembly of a matrix. The constraint is defined as in the code below, but this doesn't work. Can anyone suggest a correction?
Thank you very much for your attention and help!
x = mod.addVars(N, vtype=gp.GRB.CONTINUOUS, lb=0., ub=1., name="x")
A = mod.addMVar(shape=(n,n), vtype=gp.GRB.CONTINUOUS, lb=0, ub=gp.GRB.INFINITY, name="A")
AMat = mod.addConstrs( ( A == sum( xMax * np.ones((n,n)) * x[i] for i in range(N) ) ), name='A matrix')
0
-
正式なコメント
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 try Gurobot, our chatbot interface offering instant, expert-level support. -
the error that i get is: Variable is not a 1D MVar object
0 -
Hi Nicolo,
Currently, the Python Matrix API is not compatible with advanced matrix equations and operation such as a matrix assembly. I think it is best to model your equality constraints via the normal Var objects, i.e., define matrix \(A\) via the addVars method. You would then have to construct your constraints row by row.
Best regards,
Jaromił0
投稿コメントは受け付けていません。
コメント
3件のコメント