Matrix-friendly python API, transponse of Mvar
AnsweredHello everyone!
I’m trying to model a Reconfiguration electrical distribution system problem using Gurobi matrix-friendly python API technique. Particularly, I have a problem when I define an objective function and I have some transpose of Mvar(). My main question is how to get a transpose of the Mvar ? I attached more details and a test that I did below.
Thanks in advance for your help.
Orlando M. Valarezo
Description of the problem: I’m trying to model a Reconfiguration electrical distribution system problem using Gurobi matrix-friendly python API technique. Particularly, I have a problem when I implement the following equation:
Objective function:
Firstly, to test ..I’m trying to implement this expression in python:
As you can see, p(i,t) is an MVar and B is a matrix parameter. My main question is how to get a transponse of the Mvar p(i,t). I tried the following code, EV_cost represents the previous equation:
Results:
Maybe, I think is the problem with the transpose because I did the following Example Transpose Matrix-variable (v_pEV). Then I got the shape of the transpose of V-PEV and the results are () like you see below:
-
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?. -
Have you tried ignoring the transpose? The API tries to intuit how the matrix multiplication should be performed. E.g., I suspect the following would work:
sum(v_pEV[i][:, t] @ B[i] @ v_pEV[i][:, t] for i in range(Nb) for t in range(Nt))
If not, could you please post a minimal working example that includes the definitions of \(\texttt{v_pEV}\) and \(\texttt{B}\)?
0 -
Hi Eli!
Thanks so much for your kind reply. I followed your recommendation and ignored the transpose, effectively I didn't get errors!
So I will continue with the implementation and when I get the final results I'll post an update.
Many thanks!
Orlando M. Valarezo
0
Post is closed for comments.
Comments
3 comments