Skip to content

Commit accc9c1

Browse files
committed
Fix writing solution in Mosek
1 parent 4b7785a commit accc9c1

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

include/pyoptinterface/mosek_model.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
B(MSK_makeemptytask); \
1919
B(MSK_deletetask); \
2020
B(MSK_writedata); \
21-
B(MSK_writesolutionfile); \
21+
B(MSK_writesolution); \
2222
B(MSK_appendvars); \
2323
B(MSK_getnumvar); \
2424
B(MSK_putvartype); \

lib/mosek_model.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,23 @@ void MOSEKModel::close()
184184
void MOSEKModel::write(const std::string &filename)
185185
{
186186
bool is_solution = false;
187-
if (filename.ends_with(".sol") || filename.ends_with(".bas") || filename.ends_with(".int"))
187+
if (filename.ends_with(".sol") || filename.ends_with(".bas") || filename.ends_with(".int") ||
188+
filename.ends_with(".jsol"))
188189
{
189190
is_solution = true;
190191
}
191192
MSKrescodee error;
192193
if (is_solution)
193194
{
194-
error = mosek::MSK_writesolutionfile(m_model.get(), filename.c_str());
195+
if (m_soltype)
196+
{
197+
error = mosek::MSK_writesolution(m_model.get(), m_soltype.value(), filename.c_str());
198+
}
199+
else
200+
{
201+
throw std::runtime_error(
202+
"Solution type is unavailable. Please optimize before writing solution.");
203+
}
195204
}
196205
else
197206
{

0 commit comments

Comments
 (0)