How to relax all variables of a model to be continuous #2234
-
|
Is there a straightforward way to take a model object and relax all of its variables to be continuous? For comparison, mip has a |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 8 replies
-
|
Yes, set the option solve_relaxation = true |
Beta Was this translation helpful? Give feedback.
-
|
Hi @jajhall . Does |
Beta Was this translation helpful? Give feedback.
-
|
The following works, but don't ask me why! I'm not a Python programmer. Previously the values of That your reasonable approach doesn't work, and my approach - which, to me, looks equivalent to yours - does work, is a real indication of what a terrible language Python is! Although the call to model = highspy.Highs()
model.readModel("2club200v15p5scn.mps")
print("# of integer vars (before relaxation) = ", sum(v != highspy.HighsVarType.kContinuous for v in model.getLp().integrality_))
lp = model.getLp()
integrality = lp.integrality_
for i in range(lp.num_col_):
integrality[i] = highspy.HighsVarType.kContinuous
lp.integrality_ = integrality
status = model.passModel(lp)
print(" model.passModel(lp) returns ", status)
print("# of integer vars (after relaxation) = ", sum(v != highspy.HighsVarType.kContinuous for v in model.getLp().integrality_)) |
Beta Was this translation helpful? Give feedback.
Yes, set the option
solve_relaxation = true