Variables C in .lp file?
回答済みGood Morning,
I'm using gurobi to minimize a problem. I use "model.addVars(n,n)" to create my variables:
x = model.addVars(m, n, i, j)
Then, I use model.addVar to populate some of these vars (not all of them):
x[i, j, v, p] = self.model.addVar(lb=0, ub=1, obj=m[i, j],
vtype=GRB.BINARY,
name= 'name')
This code is into a "for" function, and "m" is a matrix that contais some values.
However, after solve the model, in ".lp" file, a lot of other variables appear in objective function and constraints, like this:
In objective
0 C0 + 0 C1 + 0 C2 + 0 C3
In constraint:
r10: C1074 + C1734 + C3474 + C7074 + C7734 + C8934 + C9714 + C10014
+ C10074 + C11874 + C20454 + C20574 + C20754 + C20994 + x_1_17_10_4
But this variable 'C' was not created.
Anyone knows what that means? Moreover, how can I remove these variables?
-
正式なコメント
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,
Model.addVars() adds new variables to the model, just like Model.addVar(). Because you don't supply a name to these variables, the default names \( \texttt{C0} \), \( \texttt{C1} \) , etc. are used. The \( \texttt{C} \) stands for "continuous."
If you want to only add the \( \texttt{x} \) variables to the model, you could define \( \texttt{x} \) as a dictionary with \( \texttt{ x = {}} \), then add the variables you want with individual calls to Model.addVar().
Also, note that you don't have to explicitly declare \( [0,1] \) bounds when adding binary variables to the model.
Thanks,
Eli
0
投稿コメントは受け付けていません。
コメント
2件のコメント