-
Couldn't load subscription status.
- Fork 271
Description
Dear support team,
I hope you are doing well. I have seen an interesting question regarding the power term in the optimization models, and I am willing to know how SCIP deals with that, specifically, how it linearizes the model internally. The terms in the model would be something like
model = Model()
x = model.addVar(name="x", vtype="C", lb = -100, ub = 100)
y = model.addVar(name="y", vtype="C", lb = -100, ub = 100)
s = model.addVar(name="s", vtype="C", lb = -100, ub = 100)
model.setObjective(s, "maximize")
model.addCons( (5**y) == 5*x, "c0")
model.addCons( (2**y) + (8**y) == 130, "c1")
model.addCons( s == (y/x), "c2")
model.redirectOutput()
model.printVersion()
model.setPresolve(SCIP_PARAMSETTING.OFF)
model.setSeparating(SCIP_PARAMSETTING.OFF)
model.setHeuristics(SCIP_PARAMSETTING.OFF)
model.optimize()
By solving this, SCIP throws an error:
TypeError Traceback (most recent call last)
[/tmp/ipython-input-1872219861.py](https://localhost:8080/#) in <cell line: 0>()
10 model.setObjective(s, "maximize")
11
---> 12 model.addCons( (5**y) == 5*x, "c0")
13 model.addCons( (2**y) + (8**y) == 130, "c1")
14 model.addCons( s == (y/x), "c2")
TypeError: unsupported operand type(s) for ** or pow(): 'int' and 'pyscipopt.scip.Variable'
- Is there any specific way to add power terms, also containing the variable(s) in the power, in SCIP?
Also, I have often used GAMS/SCIP to solve the problem. It surprisingly solves the problem optimally, and the output is:
presolving:
(round 1, fast) 0 del vars, 0 del conss, 0 add conss, 13 chg bounds, 0 chg sides, 0 chg coeffs, 0 upgd conss, 0 impls, 0 clqs
(0.0s) symmetry computation started: requiring (bin +, int +, cont +), (fixed: bin -, int -, cont -)
(0.0s) no symmetry present (symcode time: 0.00)
presolving (2 rounds: 2 fast, 1 medium, 1 exhaustive):
0 deleted vars, 0 deleted constraints, 0 added constraints, 13 tightened bounds, 0 added holes, 0 changed sides, 0 changed coefficients
0 implications, 0 cliques
presolved problem has 3 variables (0 bin, 0 int, 0 impl, 3 cont) and 3 constraints
3 constraints of type <nonlinear>
Presolving Time: 0.00
time | node | left |LP iter|LP it/n|mem/heur|mdpt |vars |cons |rows |cuts |sepa|confs|strbr| dualbound | primalbound | gap | compl.
0.0s| 1 | 0 | 6 | - | 694k | 0 | 11 | 3 | 16 | 0 | 0 | 0 | 0 | 7.028440e+00 | -- | Inf | unknown
L 0.0s| 1 | 0 | 6 | - | subnlp| 0 | 11 | 3 | 16 | 0 | 0 | 0 | 0 | 7.028440e+00 | 6.577991e+00 | 6.85%| unknown
0.0s| 1 | 0 | 7 | - | 703k | 0 | 11 | 3 | 17 | 1 | 1 | 0 | 0 | 7.028440e+00 | 6.577991e+00 | 6.85%| unknown
0.0s| 1 | 0 | 7 | - | 703k | 0 | 11 | 3 | 17 | 1 | 1 | 0 | 0 | 7.028440e+00 | 6.577991e+00 | 6.85%| unknown
0.0s| 1 | 0 | 8 | - | 703k | 0 | 11 | 3 | 18 | 2 | 2 | 0 | 0 | 7.028440e+00 | 6.577991e+00 | 6.85%| unknown
SCIP Status : solving was interrupted [gap limit reached]
Solving Time (sec) : 0.00
Solving Nodes : 1
Primal Bound : +6.57799101062506e+00 (1 solutions)
Dual Bound : +6.57800059142918e+00
Gap : 0.00 %
------------------------------------------
object.L = 6.578
VARIABLE x.L = 0.353
VARIABLE y.L = 2.322
- How does GAMS really translate the problem in a way that SCIP can deal with that?
Best regards
Abbas