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://www.ibm.com/support/knowledgecenter/SSSA5P 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://www.ibm.com/support/knowledgecenter/SSSA5P 0068 % 0069 % See also CPLEXLP, CPLEXQP, MPOPTION. 0070 0071 % MATPOWER 0072 % Copyright (c) 2010-2016, Power Systems Engineering Research Center (PSERC) 0073 % by Ray Zimmerman, PSERC Cornell 0074 % 0075 % This file is part of MATPOWER. 0076 % Covered by the 3-clause BSD License (see LICENSE file for details). 0077 % See https://matpower.org for more info. 0078 0079 %%----- initialization and arg handling ----- 0080 %% defaults 0081 verbose = 1; 0082 feastol = 1e-6; 0083 fname = ''; 0084 0085 %% second argument 0086 if nargin > 1 && ~isempty(mpopt) 0087 if ischar(mpopt) %% 2nd arg is FNAME (string) 0088 fname = mpopt; 0089 have_mpopt = 0; 0090 else %% 2nd arg is MPOPT (MATPOWER options struct) 0091 have_mpopt = 1; 0092 %% (make default opf.violation correspond to default CPLEX feastol) 0093 feastol = mpopt.opf.violation/5; 0094 verbose = mpopt.verbose; 0095 if isfield(mpopt.cplex, 'opt_fname') && ~isempty(mpopt.cplex.opt_fname) 0096 fname = mpopt.cplex.opt_fname; 0097 elseif mpopt.cplex.opt 0098 fname = sprintf('cplex_user_options_%d', mpopt.cplex.opt); 0099 end 0100 end 0101 else 0102 have_mpopt = 0; 0103 end 0104 0105 %%----- set default options for CPLEX ----- 0106 if have_fcn('matlab', 'vnum') >= 8.006 && have_fcn('cplex', 'vnum') <= 12.006003 0107 s = warning('QUERY', 'MATLAB:lang:badlyScopedReturnValue'); 0108 warning('OFF', 'MATLAB:lang:badlyScopedReturnValue'); 0109 opt = cplexoptimset('cplex'); 0110 warning(s.state, 'MATLAB:lang:badlyScopedReturnValue'); 0111 else 0112 opt = cplexoptimset('cplex'); 0113 end 0114 opt.simplex.tolerances.feasibility = feastol; 0115 opt.output.clonelog = -1; 0116 0117 %% printing 0118 vrb = max([0 verbose-1]); 0119 opt.barrier.display = vrb; 0120 opt.conflict.display = vrb; 0121 opt.mip.display = vrb; 0122 opt.sifting.display = vrb; 0123 opt.simplex.display = vrb; 0124 opt.tune.display = vrb; 0125 if verbose > 2 0126 opt.Display = 'iter'; 0127 elseif verbose > 1 0128 opt.Display = 'on'; 0129 elseif verbose > 0 0130 opt.Display = 'off'; 0131 end 0132 0133 %% solution algorithm 0134 if have_mpopt 0135 opt.lpmethod = mpopt.cplex.lpmethod; 0136 opt.qpmethod = mpopt.cplex.qpmethod; 0137 end 0138 0139 %%----- call user function to modify defaults ----- 0140 if ~isempty(fname) 0141 if have_mpopt 0142 opt = feval(fname, opt, mpopt); 0143 else 0144 opt = feval(fname, opt); 0145 end 0146 end 0147 0148 %%----- apply overrides ----- 0149 if have_mpopt && isfield(mpopt.cplex, 'opts') && ~isempty(mpopt.cplex.opts) 0150 opt = nested_struct_copy(opt, mpopt.cplex.opts); 0151 end 0152 if nargin > 0 && ~isempty(overrides) 0153 opt = nested_struct_copy(opt, overrides); 0154 end 0155 0156 0157 %-------------------------- Default Options Struct -------------------------- 0158 % as returned by ... 0159 % >> opt = cplexoptimset('cplex') 0160 % 0161 % opt = 0162 % advance: 1 0163 % barrier: [1x1 struct] 0164 % algorithm: 0 0165 % colnonzeros: 0 0166 % convergetol: 1.0000e-08 0167 % crossover: 0 0168 % display: 1 0169 % limits: [1x1 struct] 0170 % corrections: -1 0171 % growth: 1.0000e+12 0172 % iteration: 9.2234e+18 0173 % objrange: 1.0000e+20 0174 % ordering: 0 0175 % qcpconvergetol: 1.0000e-07 0176 % startalg: 1 0177 % clocktype: 2 0178 % conflict: [1x1 struct] 0179 % display: 1 0180 % diagnostics: 'off' 0181 % emphasis: [1x1 struct] 0182 % memory: 0 0183 % mip: 0 0184 % numerical: 0 0185 % exportmodel: '' 0186 % feasopt: [1x1 struct] 0187 % mode: 0 0188 % tolerance: 1.0000e-06 0189 % lpmethod: 0 0190 % mip: [1x1 struct] 0191 % cuts: [1x1 struct] 0192 % cliques: 0 0193 % covers: 0 0194 % disjunctive: 0 0195 % flowcovers: 0 0196 % gomory: 0 0197 % gubcovers: 0 0198 % implied: 0 0199 % mcfcut: 0 0200 % mircut: 0 0201 % pathcut: 0 0202 % zerohalfcut: 0 0203 % display: 2 0204 % interval: 0 0205 % limits: [1x1 struct] 0206 % aggforcut: 3 0207 % auxrootthreads: 0 0208 % cutpasses: 0 0209 % cutsfactor: 4 0210 % eachcutlimit: 2.1000e+09 0211 % gomorycand: 200 0212 % gomorypass: 0 0213 % nodes: 9.2234e+18 0214 % polishtime: 0 0215 % populate: 20 0216 % probetime: 1.0000e+75 0217 % repairtries: 0 0218 % solutions: 9.2234e+18 0219 % strongcand: 10 0220 % strongit: 0 0221 % submipnodelim: 500 0222 % treememory: 1.0000e+75 0223 % ordertype: 0 0224 % polishafter: [1x1 struct] 0225 % absmipgap: 0 0226 % mipgap: 0 0227 % nodes: 9.2234e+18 0228 % solutions: 9.2234e+18 0229 % time: 1.0000e+75 0230 % pool: [1x1 struct] 0231 % absgap: 1.0000e+75 0232 % capacity: 2.1000e+09 0233 % intensity: 0 0234 % relgap: 1.0000e+75 0235 % replace: 0 0236 % strategy: [1x1 struct] 0237 % backtrack: 0.9999 0238 % bbinterval: 7 0239 % branch: 0 0240 % dive: 0 0241 % file: 1 0242 % fpheur: 0 0243 % heuristicfreq: 0 0244 % kappastats: 0 0245 % lbheur: 0 0246 % miqcpstrat: 0 0247 % nodeselect: 1 0248 % order: 1 0249 % presolvenode: 0 0250 % probe: 0 0251 % rinsheur: 0 0252 % search: 0 0253 % startalgorithm: 0 0254 % subalgorithm: 0 0255 % variableselect: 0 0256 % tolerances: [1x1 struct] 0257 % absmipgap: 1.0000e-06 0258 % integrality: 1.0000e-05 0259 % lowercutoff: -1.0000e+75 0260 % mipgap: 1.0000e-04 0261 % objdifference: 0 0262 % relobjdifference: 0 0263 % uppercutoff: 1.0000e+75 0264 % output: [1x1 struct] 0265 % clonelog: 1 0266 % intsolfileprefix: '' 0267 % mpslong: 1 0268 % writelevel: 0 0269 % parallel: 0 0270 % preprocessing: [1x1 struct] 0271 % aggregator: -1 0272 % boundstrength: -1 0273 % coeffreduce: -1 0274 % dependency: -1 0275 % dual: 0 0276 % fill: 10 0277 % linear: 1 0278 % numpass: -1 0279 % presolve: 1 0280 % qpmakepsd: 1 0281 % reduce: 3 0282 % relax: -1 0283 % repeatpresolve: -1 0284 % symmetry: -1 0285 % qpmethod: 0 0286 % read: [1x1 struct] 0287 % apiencoding: '' 0288 % constraints: 30000 0289 % datacheck: 0 0290 % fileencoding: 'ISO-8859-1' 0291 % nonzeros: 250000 0292 % qpnonzeros: 5000 0293 % scale: 0 0294 % variables: 60000 0295 % sifting: [1x1 struct] 0296 % algorithm: 0 0297 % display: 1 0298 % iterations: 9.2234e+18 0299 % simplex: [1x1 struct] 0300 % crash: 1 0301 % dgradient: 0 0302 % display: 1 0303 % limits: [1x1 struct] 0304 % iterations: 9.2234e+18 0305 % lowerobj: -1.0000e+75 0306 % perturbation: 0 0307 % singularity: 10 0308 % upperobj: 1.0000e+75 0309 % perturbation: [1x1 struct] 0310 % indicator: 0 0311 % constant: 1.0000e-06 0312 % pgradient: 0 0313 % pricing: 0 0314 % refactor: 0 0315 % tolerances: [1x1 struct] 0316 % feasibility: 1.0000e-06 0317 % markowitz: 0.0100 0318 % optimality: 1.0000e-06 0319 % solutiontarget: 0 0320 % threads: 0 0321 % timelimit: 1.0000e+75 0322 % tune: [1x1 struct] 0323 % display: 1 0324 % measure: 1 0325 % repeat: 1 0326 % timelimit: 10000 0327 % workdir: '.' 0328 % workmem: 128