Skip to content

Commit 474bab4

Browse files
committed
Modify eflag output of mi/qps_highs() to reflect model_status_string returned by HiGHS.
1 parent 8eeb6ab commit 474bab4

5 files changed

Lines changed: 117 additions & 18 deletions

File tree

CHANGES.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,27 @@ Change history for MP-Opt-Model
55
since version 5.0
66
-----------------
77

8+
#### 4/30/26
9+
- Modify `eflag` output of `qps_highs()` and `miqps_highs()` to reflect
10+
the `model_status_string` returned by the HiGHS solver.
11+
812
#### 4/20/26
9-
- Move `mp.opt_model.is_mixed_integer()` logic into new
10-
`are_all_continuous()` method of `mp.sm_variable`, and make the former
11-
a simple wrapper.
12-
- Fix bug with parameter caching in `mp.sm_variable`, where calling
13-
`params()` without requesting the variable type would not cache it,
14-
so subsequent requests for the variable time incorrectly returned an
15-
empty string. Now the variable type is assembled and cached any time
16-
there is a non-continuous variable present.
13+
- Move `mp.opt_model.is_mixed_integer()` logic into new
14+
`are_all_continuous()` method of `mp.sm_variable`, and make the former
15+
a simple wrapper.
16+
- Fix bug with parameter caching in `mp.sm_variable`, where calling
17+
`params()` without requesting the variable type would not cache it,
18+
so subsequent requests for the variable time incorrectly returned an
19+
empty string. Now the variable type is assembled and cached any time
20+
there is a non-continuous variable present.
1721

1822
#### 12/11/25
19-
- Add `clear_cached_params()` method to `mp.set_manager_opt_model` and
20-
`mp.opt_model`, to clear aggregated parameters cached by the `params()`
21-
method.
23+
- Add `clear_cached_params()` method to `mp.set_manager_opt_model` and
24+
`mp.opt_model`, to clear aggregated parameters cached by the `params()`
25+
method.
2226

2327
#### 12/10/25
24-
- Add support for the Gurobi's new PDHG LP solver in `qps_gurobi()`.
28+
- Add support for the Gurobi's new PDHG LP solver in `qps_gurobi()`.
2529

2630
#### 11/14/25
2731
- Add support for the new HiPO interior point LP solver in HiGHS, including

docs/src/MP-Opt-Model-manual/MP-Opt-Model-manual.tex

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@
245245
%\title{\hl{--- DRAFT ---}\\\hl{\em do not distribute}\\~\\{\huge \bfseries \mpomname{} User's Manual } \\ ~ \\ \LARGE Version \mpomver{}\\
246246
\title{{\huge \bfseries \mpomname{} User's Manual } \\ ~ \\ \LARGE Version \mpomver{}}
247247
\author{Ray~D.~Zimmerman}
248-
\date{July 12, 2025} % comment this line to display the current date
248+
%\date{July 12, 2025} % comment this line to display the current date
249249
%\date{May 8, 2020\thanks{Second revision. First revision was April 29, 2020}} % comment this line to display the current date
250250

251251
%%% BEGIN DOCUMENT
@@ -256,7 +256,7 @@
256256
\vfill
257257
\begin{center}
258258
{\scriptsize
259-
\copyright~2020--2025~\PSERC{}\\
259+
\copyright~2020--2026~\PSERC{}\\
260260
All Rights Reserved}
261261
\end{center}
262262

@@ -6738,6 +6738,7 @@ \subsubsection*{New Features}
67386738
\item New \code{fix\_integer} option for \code{miqps\_master()} and \code{mp.opt\_model.solve()}. Set to true to fix any integer variables to their initial values, as specified in \code{x0} or \code{opt.x0}.
67396739
\item Add \code{relax\_integer} option to \code{miqps\_master()} and move the implementation from \code{mp.opt\_model.solve()}.
67406740
\item Add \code{clear\_cached\_params()} method to \code{mp.set\_manager\_opt\_model} and \code{mp.opt\_model}, to clear aggregated parameters cached by the \code{params()} method.
6741+
\item Support for \highs{} solution status in \code{eflag} output of \code{miqps\_highs()} and \code{qps\_highs()}.
67416742
\item Support for the new HiPO interior point LP solver in the \highs{} optimizer.
67426743
\item Support for the new PDHG LP solver in \gurobi{}.
67436744
\item New methods:

lib/miqps_highs.m

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,54 @@
291291
%% extract results
292292
x = soln.col_value;
293293
f = info.objective_function_value;
294-
eflag = info.valid && soln.value_valid;
294+
if info.valid && soln.value_valid && strcmp(info.model_status_string, 'Optimal')
295+
eflag = 1;
296+
else
297+
switch info.model_status_string
298+
case 'Not Set'
299+
eflag = 0;
300+
case 'Load error'
301+
eflag = -1;
302+
case 'Model error'
303+
eflag = -2;
304+
case 'Presolve error'
305+
eflag = -3;
306+
case 'Solve error'
307+
eflag = -4;
308+
case 'Postsolve error'
309+
eflag = -5;
310+
case 'Empty'
311+
eflag = -6;
312+
case 'Memory limit reached'
313+
eflag = -7;
314+
case 'Optimal'
315+
eflag = 1;
316+
case 'Infeasible'
317+
eflag = -9;
318+
case 'Primal infeasible or unbounded'
319+
eflag = -10;
320+
case 'Unbounded'
321+
eflag = -11;
322+
case 'Bound on objective reached'
323+
eflag = -12;
324+
case 'Target for objective reached'
325+
eflag = -13;
326+
case 'Time limit reached'
327+
eflag = -14;
328+
case 'Iteration limit reached'
329+
eflag = -15;
330+
case 'Solution limit reached'
331+
eflag = -16;
332+
case 'Interrupted by user'
333+
eflag = -17;
334+
case 'Interrupted by HiGHS'
335+
eflag = -18;
336+
case 'Unknown'
337+
eflag = -19;
338+
otherwise
339+
eflag = -100;
340+
end
341+
end
295342
output = info;
296343

297344
%% separate duals into binding lower & upper bounds

lib/mpomver.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
% See also mpver.
1717

1818
% MP-Opt-Model
19-
% Copyright (c) 2010-2025, Power Systems Engineering Research Center (PSERC)
19+
% Copyright (c) 2010-2026, Power Systems Engineering Research Center (PSERC)
2020
% by Ray Zimmerman, PSERC Cornell
2121
%
2222
% This file is part of MP-Opt-Model.
@@ -26,7 +26,7 @@
2626
v = struct( 'Name', 'MP-Opt-Model', ...
2727
'Version', '5.1-dev', ...
2828
'Release', '', ...
29-
'Date', '20-Apr-2026' );
29+
'Date', '30-Apr-2026' );
3030
if nargout > 0
3131
if nargin > 0
3232
rv = v;

lib/qps_highs.m

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,54 @@
233233
%% extract results
234234
x = soln.col_value;
235235
f = info.objective_function_value;
236-
eflag = info.valid && soln.value_valid;
236+
if info.valid && soln.value_valid && strcmp(info.model_status_string, 'Optimal')
237+
eflag = 1;
238+
else
239+
switch info.model_status_string
240+
case 'Not Set'
241+
eflag = 0;
242+
case 'Load error'
243+
eflag = -1;
244+
case 'Model error'
245+
eflag = -2;
246+
case 'Presolve error'
247+
eflag = -3;
248+
case 'Solve error'
249+
eflag = -4;
250+
case 'Postsolve error'
251+
eflag = -5;
252+
case 'Empty'
253+
eflag = -6;
254+
case 'Memory limit reached'
255+
eflag = -7;
256+
case 'Optimal'
257+
eflag = 1;
258+
case 'Infeasible'
259+
eflag = -9;
260+
case 'Primal infeasible or unbounded'
261+
eflag = -10;
262+
case 'Unbounded'
263+
eflag = -11;
264+
case 'Bound on objective reached'
265+
eflag = -12;
266+
case 'Target for objective reached'
267+
eflag = -13;
268+
case 'Time limit reached'
269+
eflag = -14;
270+
case 'Iteration limit reached'
271+
eflag = -15;
272+
case 'Solution limit reached'
273+
eflag = -16;
274+
case 'Interrupted by user'
275+
eflag = -17;
276+
case 'Interrupted by HiGHS'
277+
eflag = -18;
278+
case 'Unknown'
279+
eflag = -19;
280+
otherwise
281+
eflag = -100;
282+
end
283+
end
237284
output = info;
238285

239286
%% separate duals into binding lower & upper bounds

0 commit comments

Comments
 (0)