Home > matpower7.0 > lib > t > t_mpoption.m

t_mpoption

PURPOSE ^

T_MPOPTION Tests for MPOPTION.

SYNOPSIS ^

function t_mpoption(quiet)

DESCRIPTION ^

T_MPOPTION  Tests for MPOPTION.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function t_mpoption(quiet)
0002 %T_MPOPTION  Tests for MPOPTION.
0003 
0004 %   MATPOWER
0005 %   Copyright (c) 2013-2017, Power Systems Engineering Research Center (PSERC)
0006 %   by Ray Zimmerman, PSERC Cornell
0007 %
0008 %   This file is part of MATPOWER.
0009 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0010 %   See https://matpower.org for more info.
0011 
0012 if nargin < 1
0013     quiet = 0;
0014 end
0015 
0016 v = 20;
0017 
0018 t_begin(152, quiet);
0019 
0020 %% default options struct
0021 t = 'mpoption() : ';
0022 mpopt = mpoption();
0023 t_ok(isstruct(mpopt), [t 'isstruct mpopt']);
0024 t_ok(isfield(mpopt, 'v'), [t ' isfield mpopt.v']);
0025 t_is(mpopt.v, v, 12, [t '         mpopt.v == ' sprintf('%d', v)]);
0026 
0027 t_ok(isfield(mpopt, 'model'), [t ' isfield mpopt.model']);
0028 t_ok(strcmp(mpopt.model, 'AC'), [t '         mpopt.model = ''AC''']);
0029 
0030 t_ok(isfield(mpopt, 'pf'), [t ' isfield mpopt.pf']);
0031 t_ok(isstruct(mpopt.pf), [t 'isstruct mpopt.pf']);
0032 t_ok(isfield(mpopt.pf, 'alg'), [t ' isfield mpopt.pf.alg']);
0033 t_ok(strcmp(mpopt.pf.alg, 'NR'), [t '         mpopt.pf.alg = ''NR''']);
0034 t_ok(isfield(mpopt.pf, 'tol'), [t ' isfield mpopt.pf.tol']);
0035 t_is(mpopt.pf.tol, 1e-8, 12, [t '         mpopt.pf.tol == 1e-8']);
0036 t_ok(isfield(mpopt.pf, 'nr'), [t ' isfield mpopt.pf.nr']);
0037 t_ok(isstruct(mpopt.pf.nr), [t 'isstruct mpopt.pf.nr']);
0038 t_ok(isfield(mpopt.pf.nr, 'max_it'), [t ' isfield mpopt.pf.nr.max_it']);
0039 t_is(mpopt.pf.nr.max_it, 10, 12, [t '         mpopt.pf.nr.max_it == 10']);
0040 t_ok(isfield(mpopt.pf, 'fd'), [t ' isfield mpopt.pf.fd']);
0041 t_ok(isstruct(mpopt.pf.fd), [t 'isstruct mpopt.pf.fd']);
0042 t_ok(isfield(mpopt.pf.fd, 'max_it'), [t ' isfield mpopt.pf.fd.max_it']);
0043 t_is(mpopt.pf.fd.max_it, 30, 12, [t '         mpopt.pf.fd.max_it == 30']);
0044 t_ok(isfield(mpopt.pf, 'gs'), [t ' isfield mpopt.pf.gs']);
0045 t_ok(isstruct(mpopt.pf.gs), [t 'isstruct mpopt.pf.gs']);
0046 t_ok(isfield(mpopt.pf.gs, 'max_it'), [t ' isfield mpopt.pf.gs.max_it']);
0047 t_is(mpopt.pf.gs.max_it, 1000, 12, [t '         mpopt.pf.gs.max_it == 1000']);
0048 t_ok(isfield(mpopt.pf, 'enforce_q_lims'), [t ' isfield mpopt.pf.enforce_q_lims']);
0049 t_is(mpopt.pf.enforce_q_lims, 0, 12, [t '         mpopt.pf.enforce_q_lims == 0']);
0050 
0051 t_ok(isfield(mpopt, 'opf'), [t ' isfield mpopt.opf']);
0052 t_ok(isstruct(mpopt.opf), [t 'isstruct mpopt.opf']);
0053 t_ok(isfield(mpopt.opf, 'ac'), [t ' isfield mpopt.opf.ac']);
0054 t_ok(isstruct(mpopt.opf.ac), [t 'isstruct mpopt.opf.ac']);
0055 t_ok(isfield(mpopt.opf.ac, 'solver'), [t ' isfield mpopt.opf.ac.solver']);
0056 t_ok(strcmp(mpopt.opf.ac.solver, 'DEFAULT'), [t '         mpopt.opf.ac.solver = ''DEFAULT''']);
0057 t_ok(isfield(mpopt.opf, 'dc'), [t ' isfield mpopt.opf.dc']);
0058 t_ok(isstruct(mpopt.opf.dc), [t 'isstruct mpopt.opf.dc']);
0059 t_ok(isfield(mpopt.opf.dc, 'solver'), [t ' isfield mpopt.opf.dc.solver']);
0060 t_ok(strcmp(mpopt.opf.dc.solver, 'DEFAULT'), [t '         mpopt.opf.dc.solver = ''DEFAULT''']);
0061 t_ok(isfield(mpopt.opf, 'violation'), [t ' isfield mpopt.opf.violation']);
0062 t_is(mpopt.opf.violation, 5e-6, 12, [t '         mpopt.opf.violation == 5e-6']);
0063 t_ok(isfield(mpopt.opf, 'flow_lim'), [t ' isfield mpopt.opf.flow_lim']);
0064 t_ok(strcmp(upper(mpopt.opf.flow_lim), 'S'), [t '         mpopt.opf.flow_lim = ''S''']);
0065 t_ok(isfield(mpopt.opf, 'ignore_angle_lim'), [t ' isfield mpopt.opf.ignore_angle_lim']);
0066 t_is(mpopt.opf.ignore_angle_lim, 0, 12, [t '         mpopt.opf.ignore_angle_lim == 0']);
0067 t_ok(isfield(mpopt.opf, 'return_raw_der'), [t ' isfield mpopt.opf.return_raw_der']);
0068 t_is(mpopt.opf.return_raw_der, 0, 12, [t '         mpopt.opf.return_raw_der == 0']);
0069 
0070 t_ok(isfield(mpopt, 'out'), [t ' isfield mpopt.out']);
0071 t_ok(isstruct(mpopt.out), [t 'isstruct mpopt.out']);
0072 t_ok(isfield(mpopt.out, 'all'), [t ' isfield mpopt.out.all']);
0073 t_is(mpopt.out.all, -1, 12, [t '         mpopt.out.all == -1']);
0074 t_ok(isfield(mpopt.out, 'sys_sum'), [t ' isfield mpopt.out.sys_sum']);
0075 t_is(mpopt.out.sys_sum, 1, 12, [t '         mpopt.out.sys_sum == 1']);
0076 t_ok(isfield(mpopt.out, 'area_sum'), [t ' isfield mpopt.out.area_sum']);
0077 t_is(mpopt.out.area_sum, 0, 12, [t '         mpopt.out.area_sum == 0']);
0078 t_ok(isfield(mpopt.out, 'bus'), [t ' isfield mpopt.out.bus']);
0079 t_is(mpopt.out.bus, 1, 12, [t '         mpopt.out.bus == 1']);
0080 t_ok(isfield(mpopt.out, 'branch'), [t ' isfield mpopt.out.branch']);
0081 t_is(mpopt.out.branch, 1, 12, [t '         mpopt.out.branch == 1']);
0082 t_ok(isfield(mpopt.out, 'gen'), [t ' isfield mpopt.out.gen']);
0083 t_is(mpopt.out.gen, 0, 12, [t '         mpopt.out.gen == 0']);
0084 t_ok(isfield(mpopt.out, 'lim'), [t ' isfield mpopt.out.lim']);
0085 t_ok(isstruct(mpopt.out.lim), [t 'isstruct mpopt.out.lim']);
0086 t_ok(isfield(mpopt.out.lim, 'all'), [t ' isfield mpopt.out.lim.all']);
0087 t_is(mpopt.out.lim.all, -1, 12, [t '         mpopt.out.lim.all == -1']);
0088 t_ok(isfield(mpopt.out.lim, 'v'), [t ' isfield mpopt.out.lim.v']);
0089 t_is(mpopt.out.lim.v, 1, 12, [t '         mpopt.out.lim.v == 1']);
0090 t_ok(isfield(mpopt.out.lim, 'line'), [t ' isfield mpopt.out.lim.line']);
0091 t_is(mpopt.out.lim.line, 1, 12, [t '         mpopt.out.lim.line == 1']);
0092 t_ok(isfield(mpopt.out.lim, 'pg'), [t ' isfield mpopt.out.lim.pg']);
0093 t_is(mpopt.out.lim.pg, 1, 12, [t '         mpopt.out.lim.pg == 1']);
0094 t_ok(isfield(mpopt.out.lim, 'qg'), [t ' isfield mpopt.out.lim.qg']);
0095 t_is(mpopt.out.lim.qg, 1, 12, [t '         mpopt.out.lim.qg == 1']);
0096 t_ok(isfield(mpopt.out, 'force'), [t ' isfield mpopt.out.force']);
0097 t_is(mpopt.out.force, 0, 12, [t '         mpopt.out.force == 0']);
0098 
0099 t_ok(isfield(mpopt, 'verbose'), [t ' isfield mpopt.verbose']);
0100 t_is(mpopt.verbose, 1, 12, [t '         mpopt.verbose == 1']);
0101 
0102 t_ok(isfield(mpopt, 'exp'), [t ' isfield mpopt.exp']);
0103 t_ok(isstruct(mpopt.exp), [t '         isstruct(mpopt.exp)']);
0104 t_ok(isfield(mpopt.exp, 'sys_wide_zip_loads'), [t ' isfield mpopt.exp.sys_wide_zip_loads']);
0105 t_ok(isstruct(mpopt.exp.sys_wide_zip_loads), [t '         isstruct(mpopt.exp.sys_wide_zip_loads)']);
0106 t_ok(isfield(mpopt.exp.sys_wide_zip_loads, 'pw'), [t ' isfield mpopt.exp.sys_wide_zip_loads.pw']);
0107 t_ok(isempty(mpopt.exp.sys_wide_zip_loads.pw), [t '         isempty(mpopt.exp.sys_wide_zip_loads.pw)']);
0108 t_ok(isfield(mpopt.exp.sys_wide_zip_loads, 'qw'), [t ' isfield mpopt.exp.sys_wide_zip_loads.qw']);
0109 t_ok(isempty(mpopt.exp.sys_wide_zip_loads.pw), [t '         isempty(mpopt.exp.sys_wide_zip_loads.pw)']);
0110 
0111 mpopt0 = mpopt;
0112 
0113 t = 'mpoption(mpoption(), []) == mpoption_old()';
0114 mpopt_v = mpoption_old;
0115 t_is(mpoption(mpopt0, []), mpopt_v, 12, t);
0116 
0117 t = 'mpoption(ov) : ';
0118 ov = struct('verbose', 3, 'model', 'DC', 'opf', struct('dc', struct('solver', 'MIPS')));
0119 mpopt = mpoption(ov);
0120 t_is(mpopt.verbose, 3, 12, [t 'mpopt.verbose']);
0121 t_ok(strcmp(upper(mpopt.model), 'DC'), [t 'mpopt.model']);
0122 t_ok(strcmp(mpopt.opf.dc.solver, 'MIPS'), [t 'mpopt.opf.dc.solver']);
0123 mpopt.verbose = 1;
0124 mpopt.model = 'AC';
0125 mpopt.opf.dc.solver = 'DEFAULT';
0126 %% The following line appears to work around a bizarre bug in MATLAB 7.0.4 (Mac)
0127 %% that caused the next test, and subsequent 'everything else' tests, to fail
0128 %% mysteriously (but not if a debugger breakpoint was set).
0129 isequal(mpopt, mpopt0);
0130 t_ok(isequal(mpopt, mpopt0), [t 'everything else']);
0131 
0132 t = 'mpoption(''t_mpoption_ov'') : ';
0133 mpopt = mpoption('t_mpoption_ov');
0134 t_is(mpopt.verbose, 2, 12, [t 'mpopt.verbose']);
0135 t_ok(strcmp(upper(mpopt.model), 'DC'), [t 'mpopt.model']);
0136 t_ok(strcmp(mpopt.opf.dc.solver, 'CPLEX'), [t 'mpopt.opf.dc.solver']);
0137 mpopt.verbose = 1;
0138 mpopt.model = 'AC';
0139 mpopt.opf.dc.solver = 'DEFAULT';
0140 t_ok(isequal(mpopt, mpopt0), [t 'everything else']);
0141 
0142 t = 'mpoption(<new-style pairs>) : ';
0143 mpopt = mpoption('verbose', 3, 'opf.dc.solver', 'MIPS', 'model', 'DC');
0144 t_is(mpopt.verbose, 3, 12, [t 'mpopt.verbose']);
0145 t_ok(strcmp(upper(mpopt.model), 'DC'), [t 'mpopt.model']);
0146 t_ok(strcmp(mpopt.opf.dc.solver, 'MIPS'), [t 'mpopt.opf.dc.solver']);
0147 mpopt.verbose = 1;
0148 mpopt.model = 'AC';
0149 mpopt.opf.dc.solver = 'DEFAULT';
0150 t_ok(isequal(mpopt, mpopt0), [t 'everything else']);
0151 
0152 t = 'mpoption(<old-style pairs>) : ';
0153 mpopt = mpoption('VERBOSE', 0, 'PF_DC', 1, 'OPF_ALG_DC', 250);
0154 t_is(mpopt.verbose, 0, 12, [t 'mpopt.verbose']);
0155 t_ok(strcmp(upper(mpopt.model), 'DC'), [t 'mpopt.model']);
0156 t_ok(strcmp(mpopt.opf.dc.solver, 'MIPS'), [t 'mpopt.opf.dc.solver']);
0157 t_is(mpopt.mips.step_control, 1, 12, [t 'mpopt.mips.step_control']);
0158 mpopt.verbose = 1;
0159 mpopt.model = 'AC';
0160 mpopt.opf.dc.solver = 'DEFAULT';
0161 mpopt.mips.step_control = 0;
0162 mpopt = delete_missing_optional_fields(mpopt, mpopt0);
0163 t_ok(isequal(mpopt, mpopt0), [t 'everything else']);
0164 
0165 t = 'mpoption(default_mpopt_v) : ';
0166 mpopt = mpoption(mpopt_v);
0167 mpopt = delete_missing_optional_fields(mpopt, mpopt0);
0168 t_ok(isequal(mpopt, mpopt0), t);
0169 
0170 t = 'mpoption(mpopt_v) : ';
0171 mpopt_v1 = mpoption_old('VERBOSE', 0, 'PF_DC', 1, 'OPF_ALG_DC', 250);
0172 mpopt = mpoption(mpopt_v1);
0173 t_is(mpopt.verbose, 0, 12, [t 'mpopt.verbose']);
0174 t_ok(strcmp(upper(mpopt.model), 'DC'), [t 'mpopt.model']);
0175 t_ok(strcmp(mpopt.opf.dc.solver, 'MIPS'), [t 'mpopt.opf.dc.solver']);
0176 t_is(mpopt.mips.step_control, 1, 12, [t 'mpopt.mips.step_control']);
0177 mpopt.verbose = 1;
0178 mpopt.model = 'AC';
0179 mpopt.opf.dc.solver = 'DEFAULT';
0180 mpopt.mips.step_control = 0;
0181 mpopt = delete_missing_optional_fields(mpopt, mpopt0);
0182 t_ok(isequal(mpopt, mpopt0), [t 'everything else']);
0183 
0184 t = 'mpoption(mpopt_v, ov) : ';
0185 ov = struct('verbose', 3, 'model', 'AC', 'opf', struct('ac', struct('solver', 'MIPS')));
0186 mpopt = mpoption(mpopt_v1(1:116), ov);      %% use only first 116 elements, i.e MATPOWER 4.0 vector
0187 t_is(mpopt.verbose, 3, 12, [t 'mpopt.verbose']);
0188 t_ok(strcmp(upper(mpopt.model), 'AC'), [t 'mpopt.model']);
0189 t_ok(strcmp(mpopt.opf.dc.solver, 'MIPS'), [t 'mpopt.opf.dc.solver']);
0190 t_is(mpopt.mips.step_control, 1, 12, [t 'mpopt.mips.step_control']);
0191 t_ok(strcmp(mpopt.opf.ac.solver, 'MIPS'), [t 'mpopt.opf.ac.solver']);
0192 mpopt.verbose = 1;
0193 mpopt.opf.dc.solver = 'DEFAULT';
0194 mpopt.mips.step_control = 0;
0195 mpopt.opf.ac.solver = 'DEFAULT';
0196 mpopt = delete_missing_optional_fields(mpopt, mpopt0);
0197 t_ok(isequal(mpopt, mpopt0), [t 'everything else']);
0198 
0199 t = 'mpoption(mpopt_v, ''t_mpoption_ov'') : ';
0200 mpopt = mpoption(mpopt_v1(1:93), 't_mpoption_ov');      %% use only first 93 elements, i.e MATPOWER 3.2 vector
0201 t_is(mpopt.verbose, 2, 12, [t 'mpopt.verbose']);
0202 t_ok(strcmp(upper(mpopt.model), 'DC'), [t 'mpopt.model']);
0203 t_ok(strcmp(mpopt.opf.dc.solver, 'CPLEX'), [t 'mpopt.opf.dc.solver']);
0204 t_is(mpopt.mips.step_control, 1, 12, [t 'mpopt.mips.step_control']);
0205 mpopt.verbose = 1;
0206 mpopt.model = 'AC';
0207 mpopt.opf.dc.solver = 'DEFAULT';
0208 mpopt.mips.step_control = 0;
0209 mpopt = delete_missing_optional_fields(mpopt, mpopt0);
0210 t_ok(isequal(mpopt, mpopt0), [t 'everything else']);
0211 
0212 t = 'mpoption(mpopt_v, <new-style pairs>) : ';
0213 mpopt = mpoption(mpopt_v1, 'verbose', 3, 'model', 'AC', 'opf.ac.solver', 'MIPS');
0214 t_is(mpopt.verbose, 3, 12, [t 'mpopt.verbose']);
0215 t_ok(strcmp(upper(mpopt.model), 'AC'), [t 'mpopt.model']);
0216 t_ok(strcmp(mpopt.opf.dc.solver, 'MIPS'), [t 'mpopt.opf.dc.solver']);
0217 t_is(mpopt.mips.step_control, 1, 12, [t 'mpopt.mips.step_control']);
0218 t_ok(strcmp(mpopt.opf.ac.solver, 'MIPS'), [t 'mpopt.opf.ac.solver']);
0219 mpopt.verbose = 1;
0220 mpopt.opf.dc.solver = 'DEFAULT';
0221 mpopt.mips.step_control = 0;
0222 mpopt.opf.ac.solver = 'DEFAULT';
0223 mpopt = delete_missing_optional_fields(mpopt, mpopt0);
0224 t_ok(isequal(mpopt, mpopt0), [t 'everything else']);
0225 
0226 t = 'mpoption(mpopt_v, <old-style pairs>) : ';
0227 mpopt = mpoption(mpopt_v1, 'VERBOSE', 3, 'PF_DC', 0, 'OPF_ALG', 520);
0228 t_is(mpopt.verbose, 3, 12, [t 'mpopt.verbose']);
0229 t_ok(strcmp(upper(mpopt.model), 'AC'), [t 'mpopt.model']);
0230 t_ok(strcmp(mpopt.opf.dc.solver, 'MIPS'), [t 'mpopt.opf.dc.solver']);
0231 t_is(mpopt.mips.step_control, 1, 12, [t 'mpopt.mips.step_control']);
0232 t_ok(strcmp(mpopt.opf.ac.solver, 'FMINCON'), [t 'mpopt.opf.ac.solver']);
0233 mpopt.verbose = 1;
0234 mpopt.opf.dc.solver = 'DEFAULT';
0235 mpopt.mips.step_control = 0;
0236 mpopt.opf.ac.solver = 'DEFAULT';
0237 mpopt = delete_missing_optional_fields(mpopt, mpopt0);
0238 t_ok(isequal(mpopt, mpopt0), [t 'everything else']);
0239 
0240 t = 'mpoption(mpopt) : ';
0241 mpopt1 = mpoption('verbose', 0, 'model', 'DC', 'out.gen', 1, 'opf.dc.solver', 'GUROBI');
0242 mpopt = mpoption(mpopt1);
0243 t_ok(isequal(mpopt, mpopt1), [t 'unchanged']);
0244 
0245 t = 'mpoption(mpopt, ov) : ';
0246 ov = struct('verbose', 3, 'model', 'AC', 'opf', struct('ac', struct('solver', 'KNITRO')));
0247 mpopt = mpoption(mpopt1, ov);
0248 t_is(mpopt.verbose, 3, 12, [t 'mpopt.verbose']);
0249 t_ok(strcmp(upper(mpopt.model), 'AC'), [t 'mpopt.model']);
0250 t_ok(strcmp(mpopt.opf.dc.solver, 'GUROBI'), [t 'mpopt.opf.dc.solver']);
0251 t_is(mpopt.out.gen, 1, 12, [t 'mpopt.out.gen']);
0252 t_ok(strcmp(mpopt.opf.ac.solver, 'KNITRO'), [t 'mpopt.opf.ac.solver']);
0253 mpopt.verbose = 1;
0254 mpopt.opf.dc.solver = 'DEFAULT';
0255 mpopt.out.gen = 0;
0256 mpopt.opf.ac.solver = 'DEFAULT';
0257 t_ok(isequal(mpopt, mpopt0), [t 'everything else']);
0258 
0259 t = 'mpoption(mpopt, ''t_mpoption_ov'') : ';
0260 mpopt = mpoption(mpopt1, 't_mpoption_ov');
0261 t_is(mpopt.verbose, 2, 12, [t 'mpopt.verbose']);
0262 t_ok(strcmp(upper(mpopt.model), 'DC'), [t 'mpopt.model']);
0263 t_ok(strcmp(mpopt.opf.dc.solver, 'CPLEX'), [t 'mpopt.opf.dc.solver']);
0264 t_is(mpopt.out.gen, 1, 12, [t 'mpopt.out.gen']);
0265 mpopt.verbose = 1;
0266 mpopt.model = 'AC';
0267 mpopt.opf.dc.solver = 'DEFAULT';
0268 mpopt.out.gen = 0;
0269 t_ok(isequal(mpopt, mpopt0), [t 'everything else']);
0270 
0271 t = 'mpoption(mpopt, <new-style pairs>) : ';
0272 mpopt = mpoption(mpopt1, 'verbose', 3, 'model', 'AC', 'opf.ac.solver', 'KNITRO');
0273 t_is(mpopt.verbose, 3, 12, [t 'mpopt.verbose']);
0274 t_ok(strcmp(upper(mpopt.model), 'AC'), [t 'mpopt.model']);
0275 t_ok(strcmp(mpopt.opf.dc.solver, 'GUROBI'), [t 'mpopt.opf.dc.solver']);
0276 t_is(mpopt.out.gen, 1, 12, [t 'mpopt.out.gen']);
0277 t_ok(strcmp(mpopt.opf.ac.solver, 'KNITRO'), [t 'mpopt.opf.ac.solver']);
0278 mpopt.verbose = 1;
0279 mpopt.opf.dc.solver = 'DEFAULT';
0280 mpopt.out.gen = 0;
0281 mpopt.opf.ac.solver = 'DEFAULT';
0282 t_ok(isequal(mpopt, mpopt0), [t 'everything else']);
0283 
0284 t = 'mpoption(mpopt, <old-style pairs>) : ';
0285 mpopt = mpoption(mpopt1, 'VERBOSE', 3, 'PF_DC', 0, 'OPF_ALG', 580);
0286 t_is(mpopt.verbose, 3, 12, [t 'mpopt.verbose']);
0287 t_ok(strcmp(upper(mpopt.model), 'AC'), [t 'mpopt.model']);
0288 t_ok(strcmp(mpopt.opf.dc.solver, 'GUROBI'), [t 'mpopt.opf.dc.solver']);
0289 t_is(mpopt.out.gen, 1, 12, [t 'mpopt.out.gen']);
0290 t_ok(strcmp(mpopt.opf.ac.solver, 'IPOPT'), [t 'mpopt.opf.ac.solver']);
0291 mpopt.verbose = 1;
0292 mpopt.opf.dc.solver = 'DEFAULT';
0293 mpopt.out.gen = 0;
0294 mpopt.opf.ac.solver = 'DEFAULT';
0295 t_ok(isequal(mpopt, mpopt0), [t 'everything else']);
0296 
0297 t_end;
0298 
0299 
0300 function opt = delete_missing_optional_fields(opt, unless)
0301 %% deletes the fields from opt, unless they are found in unless
0302 %% (which is empty by default)
0303 %pkgs = {'cplex', 'sdp_pf', 'sopf', 'yalmip'};
0304 pkgs = {...
0305     'cplex', 'fmincon', 'gurobi', 'ipopt', 'knitro', 'minopf', ...
0306     'mosek', 'sopf', 'pdipm', 'tralm', ...
0307 };
0308 if nargin < 2
0309     unless = struct;
0310 end
0311 for k = 1:length(pkgs)
0312     if ~isfield(unless, pkgs{k}) && isfield(opt, pkgs{k})
0313         opt = rmfield(opt, pkgs{k});
0314     end
0315 end

Generated on Mon 24-Jun-2019 15:58:45 by m2html © 2005