Python API: Shape of single entry of MVaR variable differs
回答済みHello,
I am collaborating in a project in Python and an issue regarding matrix manipulation came up. Assume an 1D matrix variable:
x = m.addMVar(100 , vtype = gp.GRB.CONTINUOUS, lb = -gp.GRB.INFINITY)
In my machine (Windows, Python 3.7.6, gurobipy 9.5.0, numpy 1.21.4, scipy 1.6.0), an element of this variable returns shape: x[0].shape = (1,), i.e., still a vector.
In another machine(MAC-OS, gurobipy = 9.5.0, numpy = 1.21.2 and python = 3.7.6) the same operation returns a scalar.
Is there a difference based on the OS?
-
正式なコメント
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?. -
In Gurobi 9.1, selecting a single element from an MVar object returns an MVar of shape \( \texttt{(1,)} \). This behavior was changed in Gurobi 9.5, where selecting a single element from an MVar object returns a Var object. You can read more about this in the detailed release notes for version 9.5.
I suspect the Python environment on your Windows machine still has Gurobi version 9.1 installed. Can you please check which Gurobi version is installed using the following?
import gurobipy as gp
print(gp.gurobi.version())1 -
Yes, you are correct. The Windows machine still has the 9.1 version, I mistakenly thought it was up to date.
0
投稿コメントは受け付けていません。
コメント
3件のコメント