[GurobiPy] setting GRB.Param.Threads to 1 changes result
回答済みHello,
I want to solve a MILP (maximize) with Gurobi using only one thread.
I'm changing the number of threads like this:
m.setParam(GRB.Param.Threads, <my_number_of_threads>)
When running Gurobi without a thread limit, I get an ObjVal of 528.8578
I get the same value when using lp_solve.
When running Gurobi with a thread limit of 1, I get an ObjVal of 530.1279
I'm confused, because the result shouldn't change.
I checked my code for errors which could cause this, but I haven't found any yet.
Is there anything I might have forgotten to consider, when changing the number of threads?
I paste the .lp file down below, so I would be very grateful if someone could try to solve it with no thread limit and one thread and see if the result changes.
Thank you.
Edit: I'm using Gurobi 9.1.2 and Python 2.7.18 on Linux.
\ Model stationary_nondeterministic_schedulers
\ LP format - for model browsing. Use MPS format to capture full model detail.
Maximize
r_4 - 18.76874999999998 active_0_0 - 18.76874999999998 active_0_1
- 18.76874999999998 active_0_2 - 18.76874999999998 active_0_3
- 18.76874999999998 active_1_0 - 18.76874999999998 active_1_1
- 18.76874999999998 active_1_2 - 18.76874999999998 active_1_3
- 18.76874999999998 active_2_0 - 18.76874999999998 active_2_1
- 18.76874999999998 active_2_2 - 18.76874999999998 active_2_3
- 18.76874999999998 active_3_0 - 18.76874999999998 active_3_1
- 18.76874999999998 active_3_2 - 18.76874999999998 active_3_3
Subject To
R0: x_0_3 + x_0_0 + x_0_1 + x_0_2 = 1
R1: 2002 x_0_0 + 0.9001 r_0 - 0.8991 r_1 <= 2002
R2: 2002 x_0_1 + 0.25075 r_0 - 0.24975 r_5 <= 2002
R3: 2002 x_0_2 + 0.5005 r_0 - 0.4995 r_3 <= 2001
R4: 2002 x_0_3 + 0.5005 r_0 - 0.4995 r_3 <= 2001
R5: x_1_3 + x_1_2 + x_1_1 + x_1_0 = 1
R6: 2002 x_1_0 + 0.001 r_1 <= 2002
R7: 2002 x_1_1 + 0.25075 r_1 - 0.24975 r_6 <= 2002
R8: 2002 x_1_2 - 0.4995 r_0 + r_1 - 0.4995 r_3 <= 2003
R9: 2002 x_1_3 - 0.4995 r_0 + r_1 - 0.4995 r_3 <= 2001
R10: x_2_1 + x_2_2 + x_2_3 + x_2_0 = 1
R11: 2002 x_2_0 + 0.001 r_2 <= 2002
R12: 2002 x_2_1 + 0.25075 r_2 - 0.24975 r_7 <= 2002
R13: 2002 x_2_2 - 0.4995 r_0 + r_2 - 0.4995 r_3 <= 2001
R14: 2002 x_2_3 - 0.4995 r_0 + r_2 - 0.4995 r_3 <= 2002
R15: x_3_0 + x_3_3 + x_3_2 + x_3_1 = 1
R16: 2002 x_3_0 - 0.8991 r_2 + 0.9001 r_3 <= 2002
R17: 2002 x_3_1 + 0.75025 r_3 - 0.74925 r_8 <= 2002
R18: 2002 x_3_2 - 0.4995 r_0 + 0.5005 r_3 <= 2001
R19: 2002 x_3_3 - 0.4995 r_0 + 0.5005 r_3 <= 2003
R20: x_4_0 + x_4_1 + x_4_2 + x_4_3 = 1
R21: 2002 x_4_0 + r_4 - 0.4995 r_9 - 0.4995 r_10 <= 2002
R22: 2002 x_4_1 + r_4 - 0.4995 r_9 - 0.4995 r_10 <= 2002
R23: 2002 x_4_2 + r_4 - 0.4995 r_9 - 0.4995 r_10 <= 2002
R24: 2002 x_4_3 + r_4 - 0.4995 r_9 - 0.4995 r_10 <= 2002
R25: x_5_1 + x_5_0 + x_5_3 + x_5_2 = 1
R26: 2002 x_5_0 - 0.0999 r_0 - 0.8991 r_1 + r_5 <= 2002
R27: 2002 x_5_1 - 0.74925 r_0 + 0.75025 r_5 <= 2002
R28: 2002 x_5_2 - 0.4995 r_0 - 0.4995 r_3 + r_5 <= 2001
R29: 2002 x_5_3 - 0.4995 r_0 - 0.4995 r_3 + r_5 <= 2001
R30: x_6_2 + x_6_3 + x_6_0 + x_6_1 = 1
R31: 2002 x_6_0 - 0.999 r_1 + r_6 <= 2002
R32: 2002 x_6_1 - 0.74925 r_1 + 0.75025 r_6 <= 2002
R33: 2002 x_6_2 - 0.4995 r_0 - 0.4995 r_3 + r_6 <= 2003
R34: 2002 x_6_3 - 0.4995 r_0 - 0.4995 r_3 + r_6 <= 2001
R35: x_7_3 + x_7_2 + x_7_1 + x_7_0 = 1
R36: 2002 x_7_0 - 0.999 r_2 + r_7 <= 2002
R37: 2002 x_7_1 - 0.74925 r_2 + 0.75025 r_7 <= 2002
R38: 2002 x_7_2 - 0.4995 r_0 - 0.4995 r_3 + r_7 <= 2001
R39: 2002 x_7_3 - 0.4995 r_0 - 0.4995 r_3 + r_7 <= 2002
R40: x_8_0 + x_8_1 + x_8_2 + x_8_3 = 1
R41: 2002 x_8_0 - 0.8991 r_2 - 0.0999 r_3 + r_8 <= 2002
R42: 2002 x_8_1 - 0.24975 r_3 + 0.25075 r_8 <= 2002
R43: 2002 x_8_2 - 0.4995 r_0 - 0.4995 r_3 + r_8 <= 2001
R44: 2002 x_8_3 - 0.4995 r_0 - 0.4995 r_3 + r_8 <= 2003
R45: x_9_1 + x_9_0 + x_9_3 + x_9_2 = 1
R46: 2002 x_9_0 - 0.0999 r_0 - 0.8991 r_1 + r_9 <= 2002
R47: 2002 x_9_1 - 0.74925 r_0 - 0.24975 r_5 + r_9 <= 2002
R48: 2002 x_9_2 - 0.4995 r_0 - 0.4995 r_3 + r_9 <= 2001
R49: 2002 x_9_3 - 0.4995 r_0 - 0.4995 r_3 + r_9 <= 2001
R50: x_10_3 + x_10_0 + x_10_1 + x_10_2 = 1
R51: 2002 x_10_0 - 0.8991 r_2 - 0.0999 r_3 + r_10 <= 2002
R52: 2002 x_10_1 - 0.24975 r_3 - 0.74925 r_8 + r_10 <= 2002
R53: 2002 x_10_2 - 0.4995 r_0 - 0.4995 r_3 + r_10 <= 2001
R54: 2002 x_10_3 - 0.4995 r_0 - 0.4995 r_3 + r_10 <= 2003
R55: - x_0_0 + active_0_0 >= 0
R56: - x_1_0 + active_0_0 >= 0
R57: - x_2_0 + active_0_0 >= 0
R58: - x_3_0 + active_0_0 >= 0
R59: - x_0_1 + active_0_1 >= 0
R60: - x_1_1 + active_0_1 >= 0
R61: - x_2_1 + active_0_1 >= 0
R62: - x_3_1 + active_0_1 >= 0
R63: - x_0_2 + active_0_2 >= 0
R64: - x_1_2 + active_0_2 >= 0
R65: - x_2_2 + active_0_2 >= 0
R66: - x_3_2 + active_0_2 >= 0
R67: - x_0_3 + active_0_3 >= 0
R68: - x_1_3 + active_0_3 >= 0
R69: - x_2_3 + active_0_3 >= 0
R70: - x_3_3 + active_0_3 >= 0
R71: - x_8_0 + active_1_0 >= 0
R72: - x_5_0 + active_1_0 >= 0
R73: - x_6_0 + active_1_0 >= 0
R74: - x_7_0 + active_1_0 >= 0
R75: - x_8_1 + active_1_1 >= 0
R76: - x_5_1 + active_1_1 >= 0
R77: - x_6_1 + active_1_1 >= 0
R78: - x_7_1 + active_1_1 >= 0
R79: - x_8_2 + active_1_2 >= 0
R80: - x_5_2 + active_1_2 >= 0
R81: - x_6_2 + active_1_2 >= 0
R82: - x_7_2 + active_1_2 >= 0
R83: - x_8_3 + active_1_3 >= 0
R84: - x_5_3 + active_1_3 >= 0
R85: - x_6_3 + active_1_3 >= 0
R86: - x_7_3 + active_1_3 >= 0
R87: - x_4_0 + active_2_0 >= 0
R88: - x_4_1 + active_2_1 >= 0
R89: - x_4_2 + active_2_2 >= 0
R90: - x_4_3 + active_2_3 >= 0
R91: - x_9_0 + active_3_0 >= 0
R92: - x_10_0 + active_3_0 >= 0
R93: - x_9_1 + active_3_1 >= 0
R94: - x_10_1 + active_3_1 >= 0
R95: - x_9_2 + active_3_2 >= 0
R96: - x_10_2 + active_3_2 >= 0
R97: - x_9_3 + active_3_3 >= 0
R98: - x_10_3 + active_3_3 >= 0
Bounds
-1001 <= r_0 <= 1001
-1001 <= r_1 <= 1001
-1001 <= r_2 <= 1001
-1001 <= r_3 <= 1001
-1001 <= r_4 <= 1001
-1001 <= r_5 <= 1001
-1001 <= r_6 <= 1001
-1001 <= r_7 <= 1001
-1001 <= r_8 <= 1001
-1001 <= r_9 <= 1001
-1001 <= r_10 <= 1001
Binaries
x_7_3 x_1_3 x_9_1 x_3_0 x_8_0 x_2_1 x_6_2 x_5_1 x_0_3 x_10_3 x_7_2 x_4_0
x_1_2 x_9_0 x_3_3 x_8_1 x_6_3 x_5_0 x_2_2 x_10_0 x_4_1 x_1_1 x_3_2 x_0_0
x_8_2 x_7_1 x_9_3 x_6_0 x_2_3 x_10_1 x_4_2 x_1_0 x_5_3 x_0_1 x_8_3 x_7_0
x_9_2 x_6_1 x_3_1 x_2_0 x_4_3 x_5_2 x_0_2 x_10_2 active_0_0 active_0_1
active_0_2 active_0_3 active_1_0 active_1_1 active_1_2 active_1_3
active_2_0 active_2_1 active_2_2 active_2_3 active_3_0 active_3_1
active_3_2 active_3_3
End
-
正式なコメント
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,
I was able to reproduce the behavior for a specific Seed.
The 528.8578 solution point has very good solution quality, which can be checked with the printQuality function. The bound and integer violations are 0 and the constraint violations are in the e-13 range.
The 530.1279 solution point has worse solution quality. The integer violations are in the e-6 range and the constraint violation is worse than for the 528.8578 solution point. However, the 530.1279 solution point is optimal and feasible within the set tolerances FeasibilityTol and IntFeasTol.
Gurobi tries to find feasible solutions with as high solution quality as possible but if it comes across a solution which is feasible within tolerances only, it accepts this solution. This behavior is not unusual and can be observed for all numerical algorithms which work with tolerances.
You can tackle this behavior by tightening the tolerances FeasibilityTol and IntFeasTol.
Best regards,
Jaromił0 -
Hi,
Thank you for the great insight and explanation.
I'll consider these options.Thank you and best regards.
0
投稿コメントは受け付けていません。
コメント
3件のコメント