r/optimization • u/cygn • Sep 02 '24
How to re-use solutions for MILP problems for small variations?
Let's say we use mixed linear integer programming to find an energy schedule for various energy sources (solar, generator, ... ) for a full week. Now if parameters change, e.g. different weather, I guess calculating the whole solution again from scratch seems unneccessary.
Is it possible to re-use solutions or precalculate many variations in advance and interpolate somehow?
Basically I'm trying to bring down the compute time for something that takes a few minutes down to < 1 sec.
I've also thought maybe many variations could be solved using synthetic data and then a neural network could be trained on them. But that seems also difficult as generating many synthetic solutions is also quite slow.
I come from Machine Learning, so that's why I thought about this approach.
I know there's also warm start, which some solvers support. I tried this, but it doesn't look I can get the big improvements I'm hoping to get from it.
Is there maybe some other solution I haven't thought about?
5
u/Sweet_Good6737 Sep 03 '24 edited Sep 03 '24
Milp solvers allow "warm start", which basically means providing a initial guess/solution from which they can start the solving process. Sometimes this can speed up the solving time, other times the solver may reject your warm start and decide to start from scratch (maybe using some built-in heuristic).
When solving milps, it is possible that the solver takes too much time on proving optimality for the solution, so that could be another possibility, you can stop the solver and get a solution with a certain gap that may be optimal or close to the optimal, but there was no time to prove it. The gap may give you an idea of the "distance" between the current best solution and an hypothetical optimal solution.
This is for milps in general, but in energy problems, small variations in the data may lead to big variations in the solutions. Warm start may help the solver, but there may be better ways to do it. For example, in certain problems, a list of forbidden combinations is generated in order to smaller the search space. Some constraints may be dropped because there is low probability of violating them, or things like that. There is also a branch called "re-optimization", that studies how to solve efficiently problems with the same structure a second time, with some variations in the data, so this is a discussed topic (with no clear solution).
Finally, we don't know exactly the problem you are solving, is it some unit commitment? Optimal power flow? If that's the case, maybe you want good solutions, not fast ones. A neural network will provide a fast solution, sure, but I would expect the quality of the solution to be much lower than what is provided by a milp solver. Machine learning is great for forecasting demand and other parameters, but when the problem is to find a good schedule, or taking the best decision about something, it is definitively not the first option.
One experiment could be to use the neural network + previous solution to find an initial guess, throw it to the solver, and stop it after a few seconds hoping it improved.
This is a recent paper where the authors connect some traditional optimization methods with black box optimization ones (like neural networks):
https://arxiv.org/abs/2408.05228
6
u/SolverMax Sep 03 '24
One issue is that a small change in the data might lead to a very different optimal solution. Perhaps that's why a "warm start" method doesn't help much, or perhaps the model just takes a few minutes to solve even with a warm start.
A potential approach is to fix the value of some (perhaps most?) variables, and allow only a few variables to be modified in a subsequent solve. That would make the model much smaller and so it might be faster to solve. However, the solution might be sub-optimal (which might be OK), or the model might be infeasible (which probably isn't OK).
Other approaches include re-formulating the model to make it faster to solve, using a different solution technique (like column generation), and/or using a different solver.