@@ -15,14 +15,14 @@ function t_om_solve_miqps(quiet)
15
15
16
16
algs = {' DEFAULT' , ' CPLEX' , ' MOSEK' , ' GUROBI' , ' GLPK' , ' OT' };
17
17
names = {' DEFAULT' , ' CPLEX' , ' MOSEK' , ' Gurobi' , ' glpk' , ' intlin/lin/quadprog' };
18
- check = {@have_miqp_solver , ' cplex' , ' mosek' , ' gurobi' , ' glpk' , ' intlinprog' };
18
+ check = {@have_milp_solver , ' cplex' , ' mosek' , ' gurobi' , ' glpk' , ' intlinprog' };
19
19
does_qp = [0 1 1 1 0 0 ];
20
20
if have_feature(' gurobi' ) || have_feature(' cplex' ) || have_feature(' mosek' )
21
21
does_qp(1 ) = 1 ;
22
22
end
23
23
24
- n = 17 ;
25
- nmiqp = 10 ;
24
+ n = 33 ;
25
+ nmiqp = 20 ;
26
26
nmiqp_soln = 30 ;
27
27
diff_tool = ' bbdiff' ;
28
28
show_diff_on_fail = false ;
@@ -87,6 +87,8 @@ function t_om_solve_miqps(quiet)
87
87
end
88
88
opt.mosek_opt = mosek_options([], mpopt );
89
89
end
90
+ opt_r = opt ;
91
+ opt_r.relax_integer = 1 ;
90
92
91
93
% opt.verbose = 3;
92
94
t = sprintf(' %s - 2-d ILP : ' , names{k });
@@ -105,6 +107,11 @@ function t_om_solve_miqps(quiet)
105
107
t_is(x , [4 ; 2 ], 12 , [t ' x' ]);
106
108
t_is(f , - 14 , 12 , [t ' f' ]);
107
109
t_ok(~om .has_parsed_soln(), [t ' has_parsed_soln() is false' ]);
110
+ t = sprintf(' %s - 2-d ILP (integer relaxed) : ' , names{k });
111
+ [x , f , s , out , lam ] = om .solve(opt_r );
112
+ t_is(s , 1 , 12 , [t ' success' ]);
113
+ t_is(x , [2.441860465 ; 3.255813953 ], 8 , [t ' x' ]);
114
+ t_is(f , - 14.651162791 , 8 , [t ' f' ]);
108
115
109
116
t = sprintf(' %s - 6-d ILP : ' , names{k });
110
117
%% from https://doi.org/10.1109/TASE.2020.2998048
@@ -125,10 +132,19 @@ function t_om_solve_miqps(quiet)
125
132
norm(x - [0 ; 0 ; 3 ; 1 ; 0 ; 2 ], Inf ) < 1e- 12 || ...
126
133
norm(x - [0 ; 0 ; 3 ; 0 ; 2 ; 1 ], Inf ) < 1e- 12 , [t ' x' ]);
127
134
t_is(f , 16 , 12 , [t ' f' ]);
135
+ t = sprintf(' %s - 6-d ILP (integer relaxed) : ' , names{k });
136
+ [x , f , s , out , lam ] = om .solve(opt_r );
137
+ t_is(s , 1 , 12 , [t ' success' ]);
138
+ t_ok(norm(x - [0 ; 0 ; 2.7 ; 0 ; 0 ; 2.5 ], Inf ) < 1e- 12 || ...
139
+ norm(x - [0 ; 0 ; 3.0 ; 0 ; 0 ; 2.2 ], Inf ) < 1e- 12 , [t ' x' ]);
140
+ t_is(f , 15.6 , 12 , [t ' f' ]);
128
141
129
142
if does_qp(k )
130
143
t = sprintf(' %s - 4-d MIQP : ' , names{k });
131
144
%% from cplexmiqpex.m, CPLEX_Studio_Academic124/cplex/examples/src/matlab/cplexmiqpex.m
145
+ %% Note: This is a lame example; the integer relaxed problem already
146
+ %% has an integer feasible solution, so this is actually just
147
+ %% a simple QP. -RDZ 10/29/24
132
148
H = sparse([ 33 6 0 0 ;
133
149
6 22 11.5 0 ;
134
150
0 11.5 11 0 ;
@@ -157,6 +173,15 @@ function t_om_solve_miqps(quiet)
157
173
t_is(lam .mu_u , [0 ; 272 ; 0 ], 6 , [t ' lam.mu_u' ]);
158
174
t_is(lam .lower , [0 ; 0 ; 349.5 ; 4350 ], 5 , [t ' lam.lower' ]);
159
175
t_is(lam .upper , [0 ; 0 ; 0 ; 0 ], 7 , [t ' lam.upper' ]);
176
+ t = sprintf(' %s - 4-d MIQP (integer relaxed) : ' , names{k });
177
+ [x , f , s , out , lam ] = om .solve(opt_r );
178
+ t_is(s , 1 , 12 , [t ' success' ]);
179
+ t_is(x , [7 ; 7 ; 0 ; 2 ], 7 , [t ' x' ]);
180
+ t_is(f , 1618.5 , 4 , [t ' f' ]);
181
+ t_is(lam .mu_l , [466 ; 0 ; 0 ], 6 , [t ' lam.mu_l' ]);
182
+ t_is(lam .mu_u , [0 ; 272 ; 0 ], 6 , [t ' lam.mu_u' ]);
183
+ t_is(lam .lower , [0 ; 0 ; 349.5 ; 4350 ], 5 , [t ' lam.lower' ]);
184
+ t_is(lam .upper , [0 ; 0 ; 0 ; 0 ], 7 , [t ' lam.upper' ]);
160
185
161
186
t = sprintf(' %s - 6-d IQP : ' , names{k });
162
187
%% from Bragin, et. al. https://doi.org/10.1007/s10957-014-0561-3
@@ -176,14 +201,19 @@ function t_om_solve_miqps(quiet)
176
201
norm(x - [17 ; 0 ; 16 ; 0 ; 17 ; 0 ], Inf ) < 1e-7 || ...
177
202
norm(x - [17 ; 0 ; 17 ; 0 ; 16 ; 0 ], Inf ) < 1e-7 , [t ' x' ]);
178
203
t_is(f , 417 , 6 , [t ' f' ]);
204
+ t = sprintf(' %s - 6-d IQP (integer relaxed) : ' , names{k });
205
+ [x , f , s , out , lam ] = om .solve(opt_r );
206
+ t_is(s , 1 , 12 , [t ' success' ]);
207
+ t_is(x , [50 ;0;50;0;50;0]/3 , 8 , [t ' x' ]);
208
+ t_is(f , 1250 / 3 , 6 , [t ' f' ]);
179
209
else
180
210
t_skip(nmiqp , sprintf(' %s does not handle MIQP problems' , names{k }));
181
211
end
182
212
% opt.verbose = 0;
183
213
end
184
214
end
185
215
186
- if have_miqp_solver ()
216
+ if have_milp_solver ()
187
217
t = ' om.soln.' ;
188
218
c = [-2 ; - 3 ];
189
219
A = sparse([195 273 ; 4 40 ]);
@@ -276,7 +306,7 @@ function t_om_solve_miqps(quiet)
276
306
277
307
t_end ;
278
308
279
- function TorF = have_miqp_solver ()
309
+ function TorF = have_milp_solver ()
280
310
TorF = have_feature(' cplex' ) || have_feature(' glpk' ) || ...
281
311
have_feature(' gurobi' ) || have_feature(' intlinprog' ) || ...
282
312
have_feature(' mosek' );
0 commit comments