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