Skip to content

Highs::passModel() takes the model by value #2078

Answered by jajhall
cvanaret asked this question in Q&A
Discussion options

You must be logged in to vote

I didn't write this, but I believe that one reason is so that we can use std::move thus

h.passModel(std::move(lpmodel));

It also allows us to do things like this

HighsStatus Highs::passModel(HighsLp lp) {
HighsModel model;
model.lp_ = std::move(lp);
return passModel(std::move(model));
}

when only a HighsLp instance is passed, and this couldn't be done if a const reference were passed. Maybe we could overload with additional methods

Highs::passModel(const &HighsModel model)

Highs::passModel(const &HighsLp lp)

Note that HiGHS operates on its own internal model instance, rather than the model that is passed to it, since it needs to be able to modify the user's model.

Replies: 2 comments

Comment options

jajhall
Dec 6, 2024
Maintainer Sponsor

You must be logged in to vote
0 replies
Answer selected by cvanaret
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #2077 on December 06, 2024 14:13.