scipopt / PySCIPOpt

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

How to speed up the solution process. #850

Closed fengshaoA closed 3 months ago

fengshaoA commented 3 months ago

Recently, when using SCIP to solve optimization problems of slightly larger scale, the solving speed is relatively slow. I am unsure if this is due to my lack of mastery of a parameter design technique in SCIP’s solving process. Therefore, I would like to ask if there are any effective parameter settings that can accelerate the solving speed during SCIP’s solution process.

leoneifler commented 3 months ago

Of course it is possible to tune the parameters for better performance for your specific application. But giving any advice here without more information is impossible. Could you elaborate on what types of problem you are trying to solve?

fengshaoA commented 3 months ago

Of course it is possible to tune the parameters for better performance for your specific application. But giving any advice here without more information is impossible. Could you elaborate on what types of problem you are trying to solve?

Alright, I am currently working on a public transit vehicle scheduling problem, which is a mixed-integer programming model. I am hoping to find a feasible solution rather than the global optimal solution.

fengshaoA commented 3 months ago

Of course it is possible to tune the parameters for better performance for your specific application. But giving any advice here without more information is impossible. Could you elaborate on what types of problem you are trying to solve?

Alright, I am currently working on a public transit vehicle scheduling problem, which is a mixed-integer programming model. I am hoping to find a feasible solution rather than the global optimal solution.

Or rather, for general mixed-integer programming problems, are there several key parameters that, by adjusting them, can speed up the problem-solving process?

leoneifler commented 3 months ago

If you are mostly interested in finding feasible solutions, then I would suggest setting the heuristics to aggressive using setHeuristics(AGGRESSIVE) (I think that is the correct syntax but please double check). If you don't care about optimality at all, then you might also experiment with disabling cutting planes, for example. In general, there is no one-fits-all solution for parameter tuning. It all depends on the type of problem and specific problem structure that you have.

Joao-Dionisio commented 3 months ago

Hey @fengshaoA! You can also try looking at setEmphasis (the corresponding SCIP documentation).

You can try doing

from pyscipopt import Model, SCIP_PARAMEMPHASIS

model = Model()
model.setEmphasis(SCIP_PARAMEMPHASIS.PHASEFEAS)

I believe this tells SCIP to focus on finding feasible solutions rather than proving optimality.

EDIT: If you really just want one feasible solution, then there is SCIP_PARAMEMPHASIS.FEASIBILITY.

fengshaoA commented 3 months ago

I tried the two methods mentioned above, and setEmphasis() worked best. Without adding this parameter, the time taken was over 3000 seconds. After adding it, the time spent ranged from 575 to 870 seconds. Using SCIP_PARAMEMPHASIS.PHASEFEAS took approximately 870 seconds, and SCIP_PARAMEMPHASIS.FEASIBILITY took about 570 seconds. Thank you!

leoneifler commented 3 months ago

Another, slightly more involved thing you can try is to look at the SCIP logfiles. If you repeatedly solve similar problems and you see that some SCIP components take a long time (such as specific heuristics or cutting planes) but never find anything, then disabling those can save a lot of effort in future solves.

fengshaoA commented 3 months ago

Another, slightly more involved thing you can try is to look at the SCIP logfiles. If you repeatedly solve similar problems and you see that some SCIP components take a long time (such as specific heuristics or cutting planes) but never find anything, then disabling those can save a lot of effort in future solves.

Thank you! In fact, I often encounter this during the solving process, but I’m not sure what causes it. Following your advice, I should focus on analyzing the log files to determine the slowest parts and then optimize them.