scipopt / PySCIPOpt

Python interface for the SCIP Optimization Suite
https://scipopt.github.io/PySCIPOpt
MIT License
786 stars 252 forks source link

The model is not solved on linux #721

Closed trufak closed 1 year ago

trufak commented 1 year ago

Hello!

The model is solved on windows, but does not work on linux (ubuntu 22.04). Tell me is this an error with the model or something else?

Script:

M = 10**10
hours = range(24)
p_potr = [110836,110169,110543,111490,113073,115773,120200,123508,126095,
               126164,125927,124981,124471,124900,124607,124512,123885,124048,
               124463,124833,123409,119947,115714,112672]
p_zz1_min=1
p_zz1_max=50
p_zz2_min=200
p_zz2_max=300
p_zz3_min=700
p_zz3_max=800
e_ges_sut = 22000
p_ges_min = [0,0,0,0,0,0,0,680,680,680,680,680,680,680,680,680,680,0,0,0,0,0,0,0]
p_ges_max = [1198,1198,1198,1198,1198,1198,1198,1198,1198,
             1198,1198,1198,1198,1198,1198,1198,1198,1198,
             1198,1198,1198,1198,1198,1198]
p_up_limit = 300
p_down_limit = 300
middle_p_tec = (sum(p_potr) - e_ges_sut)/24

from pyscipopt import Model, quicksum

from constants import *
model = Model("model")

p_ges = [model.addVar("p_ges_%d" % h, lb = p_ges_min[h], ub = p_ges_max[h]) for h in hours]
problem = model.addVar("problem")
zz1 = [model.addVar("zz1_%d" % h, vtype='B') for h in hours]
zz2 = [model.addVar("zz2_%d" % h, vtype='B') for h in hours]
zz3 = [model.addVar("zz3_%d" % h, vtype='B') for h in hours]
model.setObjective(problem)  
model.addCons(quicksum([(p_potr[h] - p_ges[h] - middle_p_tec)**2 for h in hours]) <= problem)
model.addCons(quicksum(p_ges) == e_ges_sut)
for h in hours[1:]:
   model.addCons(p_ges[h] - p_ges[h-1] <= p_up_limit)
for h in hours[:-1]:
   model.addCons(p_ges[h] - p_ges[h+1] <= p_down_limit)
for h in hours:
    model.addCons(p_ges[h] <=  p_zz1_min + zz1[h] * M + zz2[h] * M + zz3[h] * M)
    model.addCons(p_ges[h] >=  p_zz1_max * zz1[h])
    model.addCons(p_ges[h] <=  p_zz2_min + zz2[h] * M + zz3[h] * M)
    model.addCons(p_ges[h] >=  p_zz2_max * zz2[h])
    model.addCons(p_ges[h] <=  p_zz3_min + zz3[h] * M)
    model.addCons(p_ges[h] >=  p_zz3_max * zz3[h])

model.optimize()
sol = model.getBestSol()

for h in hours:
    print(str(round(sol[p_ges[h]])) + "    " +  str(round(sol[zz1[h]])) + "    " +  str(round(sol[zz2[h]])) + "    " +  str(round(sol[zz3[h]])))
print(sum([sol[p_ges[h]] for h in hours]))

Result on windows:

presolving: (round 1, fast) 0 del vars, 25 del conss, 0 add conss, 4 chg bounds, 39 chg sides, 158 chg coeffs, 0 upgd conss, 0 impls, 12 clqs (round 2, fast) 25 del vars, 51 del conss, 0 add conss, 5 chg bounds, 42 chg sides, 160 chg coeffs, 0 upgd conss, 0 impls, 0 clqs (round 3, fast) 26 del vars, 52 del conss, 0 add conss, 5 chg bounds, 42 chg sides, 160 chg coeffs, 0 upgd conss, 0 impls, 0 clqs (round 4, exhaustive) 26 del vars, 75 del conss, 0 add conss, 5 chg bounds, 42 chg sides, 160 chg coeffs, 0 upgd conss, 0 impls, 0 clqs (round 5, exhaustive) 26 del vars, 75 del conss, 0 add conss, 5 chg bounds, 42 chg sides, 160 chg coeffs, 58 upgd conss, 0 impls, 0 clqs (round 6, exhaustive) 26 del vars, 75 del conss, 0 add conss, 5 chg bounds, 42 chg sides, 160 chg coeffs, 70 upgd conss, 58 impls, 0 clqs (0.0s) probing cycle finished: starting next cycle (0.0s) symmetry computation started: requiring (bin +, int -, cont -), (fixed: bin -, int +, cont +) (0.0s) no symmetry present presolving (7 rounds: 7 fast, 4 medium, 4 exhaustive): 26 deleted vars, 75 deleted constraints, 0 added constraints, 5 tightened bounds, 0 added holes, 42 changed sides, 160 changed coefficients 165 implications, 0 cliques presolved problem has 71 variables (46 bin, 0 int, 0 impl, 25 cont) and 117 constraints 70 constraints of type 46 constraints of type 1 constraints of type 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. t 0.0s| 1 | 0 | 337 | - | trysol| 0 | 96 | 117 | 189 | 0 | 0 | 0 | 0 | 6.576222e+08 | 7.338650e+08 | 11.59%| unknown 0.0s| 1 | 0 | 457 | - | 1841k | 0 | 96 | 117 | 189 | 0 | 0 | 0 | 0 | 6.880001e+08 | 7.338650e+08 | 6.67%| unknown 0.0s| 1 | 0 | 457 | - | 1843k | 0 | 96 | 117 | 189 | 0 | 0 | 0 | 0 | 6.880001e+08 | 7.338650e+08 | 6.67%| unknown 0.0s| 1 | 0 | 484 | - | 1950k | 0 | 96 | 117 | 214 | 25 | 1 | 0 | 0 | 6.891035e+08 | 7.338650e+08 | 6.50%| unknown 0.0s| 1 | 0 | 487 | - | 1983k | 0 | 96 | 117 | 217 | 28 | 2 | 0 | 0 | 6.891035e+08 | 7.338650e+08 | 6.50%| unknown 0.0s| 1 | 0 | 490 | - | 2014k | 0 | 96 | 117 | 219 | 30 | 3 | 0 | 0 | 6.891035e+08 | 7.338650e+08 | 6.50%| unknown 0.0s| 1 | 0 | 492 | - | 2089k | 0 | 96 | 117 | 221 | 32 | 4 | 0 | 0 | 6.891035e+08 | 7.338650e+08 | 6.50%| unknown 0.0s| 1 | 0 | 497 | - | 2113k | 0 | 96 | 117 | 222 | 33 | 5 | 0 | 0 | 6.891035e+08 | 7.338650e+08 | 6.50%| unknown 0.0s| 1 | 0 | 498 | - | 2140k | 0 | 96 | 117 | 223 | 34 | 6 | 0 | 0 | 6.891035e+08 | 7.338650e+08 | 6.50%| unknown L 0.0s| 1 | 0 | 636 | - | rens| 0 | 96 | 117 | 223 | 34 | 8 | 0 | 0 | 6.891035e+08 | 6.892001e+08 | 0.01%| unknown 1.0s| 1 | 0 | 636 | - | 2197k | 0 | 96 | 117 | 223 | 34 | 8 | 0 | 0 | 6.891035e+08 | 6.892001e+08 | 0.01%| unknown 1.0s| 1 | 0 | 636 | - | 2199k | 0 | 96 | 117 | 182 | 34 | 8 | 0 | 0 | 6.891035e+08 | 6.892001e+08 | 0.01%| unknown 1.0s| 1 | 0 | 639 | - | 2217k | 0 | 96 | 117 | 152 | 35 | 9 | 0 | 0 | 6.891198e+08 | 6.892001e+08 | 0.01%| unknown 1.0s| 1 | 0 | 639 | - | 2219k | 0 | 96 | 117 | 152 | 35 | 9 | 0 | 0 | 6.891198e+08 | 6.892001e+08 | 0.01%| unknown 1.0s| 1 | 0 | 641 | - | 2219k | 0 | 96 | 117 | 153 | 36 | 10 | 0 | 0 | 6.891489e+08 | 6.892001e+08 | 0.01%| unknown time | node | left |LP iter|LP it/n|mem/heur|mdpt |vars |cons |rows |cuts |sepa|confs|strbr| dualbound | primalbound | gap | compl. 1.0s| 1 | 0 | 641 | - | 2221k | 0 | 96 | 117 | 153 | 36 | 10 | 0 | 0 | 6.891489e+08 | 6.892001e+08 | 0.01%| unknown 1.0s| 1 | 0 | 641 | - | 2221k | 0 | 96 | 33 | 153 | 36 | 10 | 0 | 0 | 6.891489e+08 | 6.892001e+08 | 0.01%| unknown 1.0s| 1 | 0 | 650 | - | 2249k | 0 | 96 | 33 | 160 | 43 | 11 | 0 | 0 | 6.891681e+08 | 6.892001e+08 | 0.00%| unknown 1.0s| 1 | 0 | 650 | - | 2251k | 0 | 96 | 33 | 132 | 43 | 11 | 0 | 0 | 6.891681e+08 | 6.892001e+08 | 0.00%| unknown 1.0s| 1 | 0 | 653 | - | 2251k | 0 | 96 | 33 | 92 | 44 | 12 | 0 | 0 | 6.891795e+08 | 6.892001e+08 | 0.00%| unknown 1.0s| 1 | 0 | 653 | - | 2251k | 0 | 96 | 33 | 92 | 44 | 12 | 0 | 0 | 6.891795e+08 | 6.892001e+08 | 0.00%| unknown (run 1, node 1) restarting after 41 global fixings of integer variables

(restart) converted 11 cuts from the global cut pool into linear constraints

presolving: (round 1, fast) 66 del vars, 0 del conss, 0 add conss, 0 chg bounds, 8 chg sides, 11 chg coeffs, 0 upgd conss, 165 impls, 0 clqs (round 2, exhaustive) 66 del vars, 0 del conss, 0 add conss, 0 chg bounds, 8 chg sides, 11 chg coeffs, 4 upgd conss, 165 impls, 0 clqs presolving (3 rounds: 3 fast, 2 medium, 2 exhaustive): 66 deleted vars, 0 deleted constraints, 0 added constraints, 0 tightened bounds, 0 added holes, 8 changed sides, 11 changed coefficients 167 implications, 1 cliques presolved problem has 30 variables (5 bin, 0 int, 0 impl, 25 cont) and 44 constraints 10 constraints of type 32 constraints of type 1 constraints of type 1 constraints of type 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. 1.0s| 1 | 0 | 765 | - | 2383k | 0 | 55 | 44 | 116 | 0 | 0 | 0 | 0 | 6.891795e+08 | 6.892001e+08 | 0.00%| unknown 1.0s| 1 | 0 | 779 | - | 2401k | 0 | 55 | 44 | 126 | 10 | 1 | 0 | 0 | 6.891795e+08 | 6.892001e+08 | 0.00%| unknown 1.0s| 1 | 0 | 790 | - | 2419k | 0 | 55 | 44 | 135 | 19 | 2 | 0 | 0 | 6.891795e+08 | 6.892001e+08 | 0.00%| unknown r 1.0s| 1 | 0 | 790 | - |randroun| 0 | 55 | 44 | 135 | 19 | 2 | 0 | 0 | 6.891795e+08 | 6.892001e+08 | 0.00%| unknown 1.0s| 1 | 0 | 803 | - | 2422k | 0 | 55 | 44 | 138 | 22 | 3 | 0 | 0 | 6.891795e+08 | 6.892001e+08 | 0.00%| unknown 1.0s| 1 | 0 | 854 | - | 2422k | 0 | 55 | 44 | 142 | 26 | 4 | 0 | 0 | 6.891795e+08 | 6.892001e+08 | 0.00%| unknown 1.0s| 1 | 0 | 857 | - | 2422k | 0 | 55 | 44 | 144 | 28 | 5 | 0 | 0 | 6.892001e+08 | 6.892001e+08 | 0.00%| unknown 1.0s| 1 | 0 | 857 | - | 2422k | 0 | 55 | 44 | 144 | 28 | 5 | 0 | 0 | 6.892001e+08 | 6.892001e+08 | 0.00%| unknown

SCIP Status : problem is solved [optimal solution found] Solving Time (sec) : 1.00 Solving Nodes : 1 (total of 2 nodes in 2 runs) Primal Bound : +6.89200059772410e+08 (4 solutions) Dual Bound : +6.89200059772410e+08 Gap : 0.00 % 0 0 0 0 0 0 0 0 0 0 0 0 200 1 0 0 500 1 1 0 800 1 1 1 1100 1 1 1 1198 1 1 1 1198 1 1 1 1198 1 1 1 1198 1 1 1 1198 1 1 1 1198 1 1 1 1198 1 1 1 1198 1 1 1 1198 1 1 1 1198 1 1 1 1198 1 1 1 1198 1 0 1 1198 0 0 1 1198 0 0 1 1176 0 0 1 876 0 0 1 576 1 1 0 22000.0

Result on Linux:

presolving: (round 1, fast) 0 del vars, 25 del conss, 0 add conss, 4 chg bounds, 39 chg sides, 158 chg coeffs, 0 upgd conss, 0 impls, 12 clqs (round 2, fast) 25 del vars, 51 del conss, 0 add conss, 5 chg bounds, 42 chg sides, 160 chg coeffs, 0 upgd conss, 0 impls, 0 clqs (round 3, fast) 26 del vars, 52 del conss, 0 add conss, 5 chg bounds, 42 chg sides, 160 chg coeffs, 0 upgd conss, 0 impls, 0 clqs (round 4, exhaustive) 26 del vars, 75 del conss, 0 add conss, 5 chg bounds, 42 chg sides, 160 chg coeffs, 0 upgd conss, 0 impls, 0 clqs (round 5, exhaustive) 26 del vars, 75 del conss, 0 add conss, 5 chg bounds, 42 chg sides, 160 chg coeffs, 58 upgd conss, 0 impls, 0 clqs (round 6, exhaustive) 26 del vars, 75 del conss, 0 add conss, 5 chg bounds, 42 chg sides, 160 chg coeffs, 70 upgd conss, 58 impls, 0 clqs (0.0s) probing cycle finished: starting next cycle (0.0s) symmetry computation started: requiring (bin +, int -, cont -), (fixed: bin -, int +, cont +) (0.0s) no symmetry present presolving (7 rounds: 7 fast, 4 medium, 4 exhaustive): 26 deleted vars, 75 deleted constraints, 0 added constraints, 5 tightened bounds, 0 added holes, 42 changed sides, 160 changed coefficients 165 implications, 0 cliques presolved problem has 71 variables (46 bin, 0 int, 0 impl, 25 cont) and 117 constraints 70 constraints of type 46 constraints of type 1 constraints of type Presolving Time: 0.03

time | node | left |LP iter|LP it/n|mem/heur|mdpt |vars |cons |rows |cuts |sepa|confs|strbr| dualbound | primalbound | gap | compl. t 0.1s| 1 | 0 | 337 | - | trysol| 0 | 96 | 117 | 189 | 0 | 0 | 0 | 0 | 6.576222e+08 | 7.338650e+08 | 11.59%| unknown 0.1s| 1 | 0 | 457 | - | 1880k | 0 | 96 | 117 | 189 | 0 | 0 | 0 | 0 | 6.880001e+08 | 7.338650e+08 | 6.67%| unknown 0.1s| 1 | 0 | 457 | - | 1883k | 0 | 96 | 117 | 189 | 0 | 0 | 0 | 0 | 6.880001e+08 | 7.338650e+08 | 6.67%| unknown 0.1s| 1 | 0 | 484 | - | 1990k | 0 | 96 | 117 | 214 | 25 | 1 | 0 | 0 | 6.891035e+08 | 7.338650e+08 | 6.50%| unknown 0.1s| 1 | 0 | 487 | - | 2023k | 0 | 96 | 117 | 217 | 28 | 2 | 0 | 0 | 6.891035e+08 | 7.338650e+08 | 6.50%| unknown 0.1s| 1 | 0 | 490 | - | 2053k | 0 | 96 | 117 | 219 | 30 | 3 | 0 | 0 | 6.891035e+08 | 7.338650e+08 | 6.50%| unknown 0.1s| 1 | 0 | 492 | - | 2129k | 0 | 96 | 117 | 221 | 32 | 4 | 0 | 0 | 6.891035e+08 | 7.338650e+08 | 6.50%| unknown 0.1s| 1 | 0 | 497 | - | 2153k | 0 | 96 | 117 | 222 | 33 | 5 | 0 | 0 | 6.891035e+08 | 7.338650e+08 | 6.50%| unknown 0.1s| 1 | 0 | 498 | - | 2180k | 0 | 96 | 117 | 223 | 34 | 6 | 0 | 0 | 6.891035e+08 | 7.338650e+08 | 6.50%| unknown

Scip operation is terminated without an error message!

Joao-Dionisio commented 1 year ago

Hello, @trufak! I can run with no issues on Ubuntu 22.04...

image

This is the expected output, right? How did you install pyscipopt on Ubuntu?

trufak commented 1 year ago

I installed pyscipopt using conda. How did you install? Yes, this is the expected result. Thank you, you gave me hope! I tried reinstalling using conda, but I keep getting this error: "Invalid instruction (the memory stack is flushed to disk)"

Joao-Dionisio commented 1 year ago

I also installed using conda, @trufak...

Searching that error in google, I arrive at this issue that mentions that it's probably a problem with the drivers. Are your drivers up to date?

But in any case, it doesn't seem to be a problem with SCIP, at least it doesn't seem like it :/

trufak commented 1 year ago

I tried it on another Linux computer, everything is fine! Thank you!