CPLEX_OPTIONS Sets options for CPLEX. OPT = CPLEX_OPTIONS OPT = CPLEX_OPTIONS(OVERRIDES) OPT = CPLEX_OPTIONS(OVERRIDES, FNAME) OPT = CPLEX_OPTIONS(OVERRIDES, MPOPT) Sets the values for the options struct normally passed to CPLEXOPTIMSET. Inputs are all optional, second argument must be either a string (FNAME) or a vector (MPOPT): OVERRIDES - struct containing values to override the defaults FNAME - name of user-supplied function called after default options are set to modify them. Calling syntax is: MODIFIED_OPT = FNAME(DEFAULT_OPT); MPOPT - MATPOWER options vector, uses the following entries: OPF_VIOLATION (16) - used to set opt.simplex.tolerances.feasibility VERBOSE (31) - used to set opt.barrier.display, opt.conflict.display, opt.mip.display, opt.sifting.display, opt.simplex.display, opt.tune.display CPLEX_LPMETHOD (95) - used to set opt.lpmethod CPLEX_QPMETHOD (96) - used to set opt.qpmethod CPLEX_OPT (97) - user option file, if MPOPT(97) is non-zero it is appended to 'cplex_user_options_' to form the name of a user-supplied function used as FNAME described above, except with calling syntax: MODIFIED_OPT = FNAME(DEFAULT_OPT, MPOPT); Output is an options struct to pass to CPLEXOPTIMSET. Example: If MPOPT(97) = 3, then after setting the default CPLEX options, CPLEX_OPTIONS will execute the following user-defined function to allow option overrides: opt = cplex_user_options_3(opt, mpopt); The contents of cplex_user_options_3.m, could be something like: function opt = cplex_user_options_3(opt, mpopt) opt.threads = 2; opt.simplex.refactor = 1; opt.timelimit = 10000; For details on the available options, see the "Parameters Reference Manual" section of the CPLEX documentation at: http://publib.boulder.ibm.com/infocenter/cosinfoc/v12r2/ See also CPLEXLP, CPLEXQP, MPOPTION.
0001 function opt = cplex_options(overrides, mpopt) 0002 %CPLEX_OPTIONS Sets options for CPLEX. 0003 % 0004 % OPT = CPLEX_OPTIONS 0005 % OPT = CPLEX_OPTIONS(OVERRIDES) 0006 % OPT = CPLEX_OPTIONS(OVERRIDES, FNAME) 0007 % OPT = CPLEX_OPTIONS(OVERRIDES, MPOPT) 0008 % 0009 % Sets the values for the options struct normally passed to 0010 % CPLEXOPTIMSET. 0011 % 0012 % Inputs are all optional, second argument must be either a string 0013 % (FNAME) or a vector (MPOPT): 0014 % 0015 % OVERRIDES - struct containing values to override the defaults 0016 % FNAME - name of user-supplied function called after default 0017 % options are set to modify them. Calling syntax is: 0018 % MODIFIED_OPT = FNAME(DEFAULT_OPT); 0019 % MPOPT - MATPOWER options vector, uses the following entries: 0020 % OPF_VIOLATION (16) - used to set opt.simplex.tolerances.feasibility 0021 % VERBOSE (31) - used to set opt.barrier.display, 0022 % opt.conflict.display, opt.mip.display, opt.sifting.display, 0023 % opt.simplex.display, opt.tune.display 0024 % CPLEX_LPMETHOD (95) - used to set opt.lpmethod 0025 % CPLEX_QPMETHOD (96) - used to set opt.qpmethod 0026 % CPLEX_OPT (97) - user option file, if MPOPT(97) is non-zero 0027 % it is appended to 'cplex_user_options_' to form the name of a 0028 % user-supplied function used as FNAME described above, except 0029 % with calling syntax: 0030 % MODIFIED_OPT = FNAME(DEFAULT_OPT, MPOPT); 0031 % 0032 % Output is an options struct to pass to CPLEXOPTIMSET. 0033 % 0034 % Example: 0035 % 0036 % If MPOPT(97) = 3, then after setting the default CPLEX options, 0037 % CPLEX_OPTIONS will execute the following user-defined function 0038 % to allow option overrides: 0039 % 0040 % opt = cplex_user_options_3(opt, mpopt); 0041 % 0042 % The contents of cplex_user_options_3.m, could be something like: 0043 % 0044 % function opt = cplex_user_options_3(opt, mpopt) 0045 % opt.threads = 2; 0046 % opt.simplex.refactor = 1; 0047 % opt.timelimit = 10000; 0048 % 0049 % For details on the available options, see the "Parameters Reference 0050 % Manual" section of the CPLEX documentation at: 0051 % 0052 % http://publib.boulder.ibm.com/infocenter/cosinfoc/v12r2/ 0053 % 0054 % See also CPLEXLP, CPLEXQP, MPOPTION. 0055 0056 % MATPOWER 0057 % $Id: cplex_options.m,v 1.6 2011/09/16 15:28:27 cvs Exp $ 0058 % by Ray Zimmerman, PSERC Cornell 0059 % Copyright (c) 2010 by Power System Engineering Research Center (PSERC) 0060 % 0061 % This file is part of MATPOWER. 0062 % See http://www.pserc.cornell.edu/matpower/ for more info. 0063 % 0064 % MATPOWER is free software: you can redistribute it and/or modify 0065 % it under the terms of the GNU General Public License as published 0066 % by the Free Software Foundation, either version 3 of the License, 0067 % or (at your option) any later version. 0068 % 0069 % MATPOWER is distributed in the hope that it will be useful, 0070 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0071 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0072 % GNU General Public License for more details. 0073 % 0074 % You should have received a copy of the GNU General Public License 0075 % along with MATPOWER. If not, see <http://www.gnu.org/licenses/>. 0076 % 0077 % Additional permission under GNU GPL version 3 section 7 0078 % 0079 % If you modify MATPOWER, or any covered work, to interface with 0080 % other modules (such as MATLAB code and MEX-files) available in a 0081 % MATLAB(R) or comparable environment containing parts covered 0082 % under other licensing terms, the licensors of MATPOWER grant 0083 % you additional permission to convey the resulting work. 0084 0085 %%----- initialization and arg handling ----- 0086 %% defaults 0087 verbose = 1; 0088 feastol = 1e-6; 0089 fname = ''; 0090 0091 %% second argument 0092 if nargin > 1 && ~isempty(mpopt) 0093 if ischar(mpopt) %% 2nd arg is FNAME (string) 0094 fname = mpopt; 0095 have_mpopt = 0; 0096 else %% 2nd arg is MPOPT (MATPOWER options vector) 0097 have_mpopt = 1; 0098 %% (make default OPF_VIOLATION correspond to default CPLEX feastol) 0099 feastol = mpopt(16)/5; %% OPF_VIOLATION 0100 verbose = mpopt(31); %% VERBOSE 0101 lpmethod = mpopt(95); %% CPLEX_LPMETHOD 0102 qpmethod = mpopt(96); %% CPLEX_QPMETHOD 0103 if mpopt(97) %% CPLEX_OPT 0104 fname = sprintf('cplex_user_options_%d', mpopt(97)); 0105 end 0106 end 0107 else 0108 have_mpopt = 0; 0109 end 0110 0111 %%----- set default options for CPLEX ----- 0112 opt = cplexoptimset('cplex'); 0113 opt.simplex.tolerances.feasibility = feastol; 0114 0115 %% printing 0116 vrb = max([0 verbose-1]); 0117 opt.barrier.display = vrb; 0118 opt.conflict.display = vrb; 0119 opt.mip.display = vrb; 0120 opt.sifting.display = vrb; 0121 opt.simplex.display = vrb; 0122 opt.tune.display = vrb; 0123 0124 %% solution algorithm 0125 if have_mpopt 0126 opt.lpmethod = lpmethod; %% CPLEX_LPMETHOD 0127 opt.qpmethod = qpmethod; %% CPLEX_QPMETHOD 0128 % else 0129 % opt.lpmethod = 2; 0130 % opt.qpmethod = 2; 0131 end 0132 0133 %%----- call user function to modify defaults ----- 0134 if ~isempty(fname) 0135 if have_mpopt 0136 opt = feval(fname, opt, mpopt); 0137 else 0138 opt = feval(fname, opt); 0139 end 0140 end 0141 0142 %%----- apply overrides ----- 0143 if nargin > 0 && ~isempty(overrides) 0144 names = fieldnames(overrides); 0145 for k = 1:length(names) 0146 if isstruct(overrides.(names{k})) 0147 names2 = fieldnames(overrides.(names{k})); 0148 for k2 = 1:length(names2) 0149 if isstruct(overrides.(names{k}).(names2{k2})) 0150 names3 = fieldnames(overrides.(names{k}).(names2{k2})); 0151 for k3 = 1:length(names3) 0152 opt.(names{k}).(names2{k2}).(names3{k3}) = overrides.(names{k}).(names2{k2}).(names3{k3}); 0153 end 0154 else 0155 opt.(names{k}).(names2{k2}) = overrides.(names{k}).(names2{k2}); 0156 end 0157 end 0158 else 0159 opt.(names{k}) = overrides.(names{k}); 0160 end 0161 end 0162 end 0163 0164 0165 %-------------------------- Default Options Struct -------------------------- 0166 % as returned by ... 0167 % >> opt = cplexoptimset('cplex') 0168 % 0169 % opt = 0170 % advance: 1 0171 % barrier: [1x1 struct] 0172 % algorithm: 0 0173 % colnonzeros: 0 0174 % convergetol: 1.0000e-08 0175 % crossover: 0 0176 % display: 1 0177 % limits: [1x1 struct] 0178 % corrections: -1 0179 % growth: 1.0000e+12 0180 % iteration: 9.2234e+18 0181 % objrange: 1.0000e+20 0182 % ordering: 0 0183 % qcpconvergetol: 1.0000e-07 0184 % startalg: 1 0185 % clocktype: 2 0186 % conflict: [1x1 struct] 0187 % display: 1 0188 % diagnostics: 'off' 0189 % emphasis: [1x1 struct] 0190 % memory: 0 0191 % mip: 0 0192 % numerical: 0 0193 % exportmodel: '' 0194 % feasopt: [1x1 struct] 0195 % mode: 0 0196 % tolerance: 1.0000e-06 0197 % lpmethod: 0 0198 % mip: [1x1 struct] 0199 % cuts: [1x1 struct] 0200 % cliques: 0 0201 % covers: 0 0202 % disjunctive: 0 0203 % flowcovers: 0 0204 % gomory: 0 0205 % gubcovers: 0 0206 % implied: 0 0207 % mcfcut: 0 0208 % mircut: 0 0209 % pathcut: 0 0210 % zerohalfcut: 0 0211 % display: 2 0212 % interval: 0 0213 % limits: [1x1 struct] 0214 % aggforcut: 3 0215 % auxrootthreads: 0 0216 % cutpasses: 0 0217 % cutsfactor: 4 0218 % eachcutlimit: 2.1000e+09 0219 % gomorycand: 200 0220 % gomorypass: 0 0221 % nodes: 9.2234e+18 0222 % polishtime: 0 0223 % populate: 20 0224 % probetime: 1.0000e+75 0225 % repairtries: 0 0226 % solutions: 9.2234e+18 0227 % strongcand: 10 0228 % strongit: 0 0229 % submipnodelim: 500 0230 % treememory: 1.0000e+75 0231 % ordertype: 0 0232 % polishafter: [1x1 struct] 0233 % absmipgap: 0 0234 % mipgap: 0 0235 % nodes: 9.2234e+18 0236 % solutions: 9.2234e+18 0237 % time: 1.0000e+75 0238 % pool: [1x1 struct] 0239 % absgap: 1.0000e+75 0240 % capacity: 2.1000e+09 0241 % intensity: 0 0242 % relgap: 1.0000e+75 0243 % replace: 0 0244 % strategy: [1x1 struct] 0245 % backtrack: 0.9999 0246 % bbinterval: 7 0247 % branch: 0 0248 % dive: 0 0249 % file: 1 0250 % fpheur: 0 0251 % heuristicfreq: 0 0252 % kappastats: 0 0253 % lbheur: 0 0254 % miqcpstrat: 0 0255 % nodeselect: 1 0256 % order: 1 0257 % presolvenode: 0 0258 % probe: 0 0259 % rinsheur: 0 0260 % search: 0 0261 % startalgorithm: 0 0262 % subalgorithm: 0 0263 % variableselect: 0 0264 % tolerances: [1x1 struct] 0265 % absmipgap: 1.0000e-06 0266 % integrality: 1.0000e-05 0267 % lowercutoff: -1.0000e+75 0268 % mipgap: 1.0000e-04 0269 % objdifference: 0 0270 % relobjdifference: 0 0271 % uppercutoff: 1.0000e+75 0272 % output: [1x1 struct] 0273 % clonelog: 1 0274 % intsolfileprefix: '' 0275 % mpslong: 1 0276 % writelevel: 0 0277 % parallel: 0 0278 % preprocessing: [1x1 struct] 0279 % aggregator: -1 0280 % boundstrength: -1 0281 % coeffreduce: -1 0282 % dependency: -1 0283 % dual: 0 0284 % fill: 10 0285 % linear: 1 0286 % numpass: -1 0287 % presolve: 1 0288 % qpmakepsd: 1 0289 % reduce: 3 0290 % relax: -1 0291 % repeatpresolve: -1 0292 % symmetry: -1 0293 % qpmethod: 0 0294 % read: [1x1 struct] 0295 % apiencoding: '' 0296 % constraints: 30000 0297 % datacheck: 0 0298 % fileencoding: 'ISO-8859-1' 0299 % nonzeros: 250000 0300 % qpnonzeros: 5000 0301 % scale: 0 0302 % variables: 60000 0303 % sifting: [1x1 struct] 0304 % algorithm: 0 0305 % display: 1 0306 % iterations: 9.2234e+18 0307 % simplex: [1x1 struct] 0308 % crash: 1 0309 % dgradient: 0 0310 % display: 1 0311 % limits: [1x1 struct] 0312 % iterations: 9.2234e+18 0313 % lowerobj: -1.0000e+75 0314 % perturbation: 0 0315 % singularity: 10 0316 % upperobj: 1.0000e+75 0317 % perturbation: [1x1 struct] 0318 % indicator: 0 0319 % constant: 1.0000e-06 0320 % pgradient: 0 0321 % pricing: 0 0322 % refactor: 0 0323 % tolerances: [1x1 struct] 0324 % feasibility: 1.0000e-06 0325 % markowitz: 0.0100 0326 % optimality: 1.0000e-06 0327 % solutiontarget: 0 0328 % threads: 0 0329 % timelimit: 1.0000e+75 0330 % tune: [1x1 struct] 0331 % display: 1 0332 % measure: 1 0333 % repeat: 1 0334 % timelimit: 10000 0335 % workdir: '.' 0336 % workmem: 128