How to call Highs.writeLocalModel in C++ #2045
Replies: 1 comment 1 reply
-
Sorry, That said, does it not work if you set If you've gone as far as passing your model to HiGHS, just call |
Beta Was this translation helpful? Give feedback.
-
Hi, I'm stuck trying to get Highs.writeLocalModel to work. Has anyone got this working in C++, and have a code snippet to share?
The definition is:
HighsStatus Highs::writeLocalModel(HighsModel& model, const std::string& filename)
... so you need to pass it a reference to a model object.
The problem is that if I pass it a HighsModel object that has not yet been passed to Highs using Highs.passModel, it throws an exception. After a lot of debugging, it seems the problem is that HighsModel.lp_.a_matrix.num_col_ and num_row_ are not yet initialized, leading to an index out of bounds exception.
These two values are initialized when the model is passed to Highs, so it would work if I could pass Highs.model_ to writeLocalModel. However, the only way to access this model_ object in my code is to call the Highs.getModel(), but this returns a const reference to the model, whereas the writeLocalModel takes a non-const reference, so trying this results in a compilation error.
Anyone know how to do this?
Beta Was this translation helpful? Give feedback.
All reactions