getMILPParams Returns a MOSEK parameter structure used when solving mixed-integer linear programming problems params structure with one or more of the following fields maxTime maximal running time in minutes (opt, default 600) relGap maximal relative gap between integer and relaxed solution in order to be considered optimal (0.0-1.0) (opt, default 0.2) printReport true if the results of the optimization should be displayed on the screen (opt, default false) mosekParams a parameter structure to be used with MOSEK Usage: mosekParams=getMILPParams(params) Rasmus Agren, 2013-07-16
0001 function mosekParams=getMILPParams(params) 0002 % getMILPParams 0003 % Returns a MOSEK parameter structure used when solving mixed-integer 0004 % linear programming problems 0005 % 0006 % params structure with one or more of the following fields 0007 % maxTime maximal running time in minutes (opt, default 600) 0008 % relGap maximal relative gap between integer and relaxed 0009 % solution in order to be considered optimal (0.0-1.0) 0010 % (opt, default 0.2) 0011 % printReport true if the results of the optimization should be 0012 % displayed on the screen (opt, default false) 0013 % 0014 % mosekParams a parameter structure to be used with MOSEK 0015 % 0016 % Usage: mosekParams=getMILPParams(params) 0017 % 0018 % Rasmus Agren, 2013-07-16 0019 % 0020 0021 if nargin<1 0022 params=[]; 0023 end 0024 0025 mosekParams=params; 0026 mosekParams.MSK_DPAR_MIO_TOL_ABS_RELAX_INT=10^-9; 0027 mosekParams.MSK_DPAR_MIO_TOL_REL_GAP=0.05; 0028 mosekParams.MSK_DPAR_MIO_TOL_REL_RELAX_INT=10^-9; 0029 mosekParams.MSK_DPAR_MIO_TOL_X=10^-9; 0030 mosekParams.MSK_DPAR_MIO_TOL_FEAS=10^-9; 0031 mosekParams.MSK_DPAR_BASIS_TOL_S=10^-9; 0032 mosekParams.MSK_DPAR_BASIS_TOL_X=10^-9; 0033 0034 %Get the mosek version. This is a bit problematic since the Mosek function 0035 %for getting the version came in version 7. 0036 if any(strfind(evalc('mosekopt info'),'MOSEK Version 7')) 0037 mosekParams.MSK_DPAR_PRESOLVE_TOL_ABS_LINDEP=10^-9; 0038 mosekParams.MSK_IPAR_PRESOLVE_USE=1; 0039 else 0040 mosekParams.MSK_DPAR_PRESOLVE_TOL_LIN_DEP=10^-9; 0041 %Turn off the presolve. This is because Mosek sometimes returns non-feasible 0042 %solutions because of problems with the presolver. Should check if version 0043 %is <6.0.0.147 0044 mosekParams.MSK_IPAR_PRESOLVE_USE=0; 0045 end 0046 0047 %Use a starting integer solution if supplied. This has no effect if no such 0048 %solution is supplied 0049 %mosekParams.MSK_IPAR_MIO_CONSTRUCT_SOL=1; 0050 0051 %10 hours as default upper time limit 0052 mosekParams.MSK_DPAR_OPTIMIZER_MAX_TIME=10*60*60; 0053 0054 if isfield(params,'maxTime') 0055 mosekParams.MSK_DPAR_OPTIMIZER_MAX_TIME=params.maxTime*60; 0056 mosekParams=rmfield(mosekParams,'maxTime'); 0057 end 0058 if isfield(params,'relGap') 0059 mosekParams.MSK_DPAR_MIO_TOL_REL_GAP=params.relGap; 0060 mosekParams=rmfield(mosekParams,'relGap'); 0061 end 0062 if isfield(params,'printReport') 0063 mosekParams=rmfield(mosekParams,'printReport'); 0064 end 0065 end