-
Notifications
You must be signed in to change notification settings - Fork 526
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use initial solution for MIP (and LP?) with APPSI HiGHS interface #3450
Comments
I think I've done enough research here that I might be able to do implement this feature on my own into the repository if nobody else wants to grab this issue. What would be nice to know beforehand is if I misunderstood the documentation and if there's actually a way to pass initial solutions to the HiGHS-APPSI interface, so I don't stress myself out doing some unnecessary changes :) - I'd also be very thankful if someone else does the changes. |
Hi @FGlazov - this isn't an answer to your request, but I wanted you to be aware. We are actually working on adding a new interface to HiGHS (and other solvers) using our future functionality, so I wouldn't recommend taking time to make changes to the APPSI code. |
I also think that this is a very needed feature, actually the only blocker for me right now to fully adapt Pyomo as a HiGHS user. I would be happy to contribute in implementation and testing of this feature as well. |
@sk-surya In my case, I used the CBC solver and fed it with an initial solution. The APPSI CBC Solver is a bit buggy in my experience (it doesn't interrupt correctly when the solver times out), I used the command line CBC solver variant that you can get via Specifically in my use case I still use HiGHS to do the rolling horizon heuristic, as it's quick enough even without initial solution, and then feed the result from HiGHS into CBC. Quite hacky and requires two full model passes to two diffrent solver backends, but it's OK for my use case since it barely makes a dent in my 6-hour time budget and gives me better solutions. |
@FGlazov, Interesting. In my case, I'm doing multiple MIP resolves (~500) to get sensitivities. Each resolve is very cheap to do (~ms). I guess I could build the model in pyomo, generate LP file, read it in Highspy and do the resolving there. But would need to figure out mapping the pyomo block components and modify the corresponding value in the loaded model. It would be great to just hack and get it working in APPSI HIGHS for the interim before the new interface. I can contribute, if @mrmundt or someone could provide some initial directions. |
Hi, everyone! Wow, this got a lot of traffic. We have the new interfaces high on our priority list, but we only have so much time. (Unfortunately, all of us only work on Pyomo part time.) If someone wants to work on getting this integrated into APPSI, we are a-okay with that and welcome PRs. I recommend reviewing the Contribution Guide. I will also work on getting some of our design discussions published somewhere accessible for you all to look over (we have a large set of running notes but they're internal to the team). |
Summary
I wish to use initial solutions to the MIP and LP HiGHS solver using the APPSI HighsPy interface.
Rationale
It is not uncommon to be able to create decent initial solutions to a MIP problem, for example, by using a heuristic. The MIP solver can then use the initial solution to speed up the solving process - potentially giving you an optimal or better solution, if you're time constrained in solving the MIP model.
Being able to pass solutions to a MIP solver also allows for better naive implementations of various LP/MIP solving techniques, such as a Bender's Decomposition or a Rolling Horizon Heuristic.
This can also be helpful for LP problems, I'm not sure if a similar thing can be done for the QP solver.
Description
The current solve functions found in APPSI Highspy interface look like this:
I expect there to be a call to
self._solver_model.setSolution
filled with the values I've passed to my Pyomo model in order to pass an initial solution for an LP/MIP problem. However, I was not able to find this call anywhere in the methods I've listed above, nor in any of the methods called insidesolve
and_solve
.Why I think solver_model.setSolution is the correct function to use here:
I am also open to other suggestions on how to pass initial solutions to HiGHs. For example, the CLI also supports passing a solution file: https://ergo-code.github.io/HiGHS/dev/executable/ - So an alternative could be to build an old-school CLI-based Pyomo solver, that passes the initial solution using the
--read_solution_file
option. But I think this is a rather crappy alternative, because this sort of implementation does not provide the benefits APPSI does (i.e. a persistent solver).Additional information
I'm interested in this topic because I want to implement a Rolling Horizon Heursitic using HiGHS and Pyomo. My code looks like this:
Where
__fix_variables_for_date
fixes past variables to their current values, and future ones to zero. Essentially, many calls tomodel.example_var_set.fix(0.0)
(for future variables) andmy_var.fix(my_var.value)
(for past variables).In any case, this heuristic is able to find a decent initial solution rather quickly (<10 minutes). What I want to do is to feed this initial solution back into my master problem, which runs for about 6 hours in total. The solution I find using this heuristic is about as good as the solution by cold starting my master problem and letting it compute for 2 hours. So if I'm able to pass the initial solution from the heuristic into my master problem, I'd get a little under 2 hours of more headroom to find a better solution to my master problem.
The thing is: The master problem solve does not benefit from the rolling horizon heuristic I did above it in my python snippet. Indeed, the solution logs for my master problem solve, with the rolling horizon heuristc activated, look like this for a simplified dev-model I ran for 200 seconds:
Whereas the solution logs for the last iteration of the rolling horizon heuristic look like this:
What I expect to happen is that the master problem solve starts off with the initial solution provided by the last iteration of the rolling horizon heuristic, and thus start with a primal bound of 49876.730482 - the dual bound should get reset and recomputed, since the underlying MIP has less constraints.
The text was updated successfully, but these errors were encountered: