Skip to content
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

example for LP warm start? #617

Closed
kehlert opened this issue Nov 28, 2021 · 7 comments
Closed

example for LP warm start? #617

kehlert opened this issue Nov 28, 2021 · 7 comments

Comments

@kehlert
Copy link

kehlert commented Nov 28, 2021

Hi, I'm having trouble finding documentation on how to properly do a warm-start with the HiGHs solver. Looks like it's called "hot start" in the code, but it's not clear exactly how it should be used, especially when changing the right-hand side of the constraints. I assumed that the MIP solver would be using it, but I didn't see any references to a warm/hot start in the MIP code.

Is there an example anywhere? Is it as simple as calling get/setHotStart?

edit: after experimenting, looks like the Highs object (C++ interface) automatically uses warm/hot starts.

@jajhall
Copy link
Member

jajhall commented Nov 30, 2021

There are various warm/hot start facilities in HiGHS, and I'm sorry that the documentation is lagging behind development. As you suggest, HiGHS will automatically use warm/hot starts if it can, so all that a user has to do is call run() after changing a model (using HiGHS methods).

I've realised from your question that this simplicity is obscured by the existence of get/setHotStart and (un)freezeBasis. The latter methods are sophisticated levels of hot start that were written for the HiGHS MIP solver - which uses its own instances of the HiGHS class.

If you're just changing the RHS of constraints, (using changeRowsBounds) after a default solve (ie not using the interior point solver) then HiGHS will recognise that the modified problem can be solved using the optimal solution (basis and basis matrix factorization, if you're familiar with these issues) of the original problem. The same is true if you change variable costs or bounds.

The more you change an LP, the more has to be done to take advantage of its optimal solution when re-solving, but HiGHS will do all it can invisibly. There are some situations where it is better to use an optimal basis saved from solving another LP, and this can be done with get/setBasis.

Until we've got extensive documentation - we're a very small team and the current priority is MIP solver performance - I'll see that there are a few more comments in examples like call_highs_from_cpp.cpp.

Thanks for your patience and I hope that, otherwise, HiGHS is proving to be satisfactory!

@jajhall
Copy link
Member

jajhall commented Nov 30, 2021

Comments added to Highs.h, indicating (un)freezeBasis and get/setHotStart as advanced methods: for HiGHS MIP solver

@SanPen
Copy link

SanPen commented Oct 9, 2022

Hi, I am interested in using hot-start, however after reading the comments above I am not sure how yet.

Let's suppose I have the following code:

Highs highs;

// 1. pass a model
highs.passModel(MY_MODEL1);

// 2. execute
HighsStatus return_status = highs.run(); 

// 3. collect the results and do some operation ...

// 4. pass a modified version of the model 1
highs.passModel(MY_MODEL1_MODIFIED); 

// 5. execute
return_status = highs.run(); 

// 6. collect the results and do some operation ...

Before the step 5, I'd expect some sort of initial solution passing.

Does the second run get automatically hot started?

How can I hot start a model with an already feasible solution that I have? (independently of previous runs)

thanks,
Santiago

@jajhall
Copy link
Member

jajhall commented Oct 9, 2022

If you've only got a feasible point, then set it up as a HighsSolution instance solution and pass it before 5. using

highs.passSolution(solution)

and HiGHS will do its best to form a basis for the LP solver.

@aphi
Copy link

aphi commented Aug 16, 2023

Is this possible via highspy at this stage? To pass a single starting feasible solution for a model to the solver.

Looking in the highs_bindings.cpp I don't see passSolution exposed there. There are some starts references but I guess they refer to indices of relevant coefficients in a matrix.

@jajhall
Copy link
Member

jajhall commented Aug 16, 2023

I've added 'highs_passSolution' to 'highs_bindings.cpp', but it's still in the 'latest' branch, and releases are generated using 'master'.

For Linux (and Mac?), if you can install HiGHS 'latest' from source using the documentation on https://ergo-code.github.io/HiGHS/dev/interfaces/cpp/, ensuring that LD_LIBRARY_PATH includes CMAKE_INSTALL_PREFIX/lib, then you can install highspy locally as follows

In ~/HiGHS/highspy, run

pip install ../.

@aphi
Copy link

aphi commented Aug 16, 2023

Thank you @jajhall

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants