Home > matpower4.0 > mosek_options.m

mosek_options

PURPOSE ^

MOSEK_OPTIONS Sets options for MOSEK.

SYNOPSIS ^

function opt = mosek_options(overrides, mpopt)

DESCRIPTION ^

MOSEK_OPTIONS  Sets options for MOSEK.

   OPT = MOSEK_OPTIONS
   OPT = MOSEK_OPTIONS(OVERRIDES)
   OPT = MOSEK_OPTIONS(OVERRIDES, FNAME)
   OPT = MOSEK_OPTIONS(OVERRIDES, MPOPT)

   Sets the values for the param struct normally passed to MOSEKOPT.

   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.MSK_DPAR_INTPNT_TOL_PFEAS
           VERBOSE (31)        - not currently used here
           MOSEK_MAX_IT (112)  - used to set opt.MSK_IPAR_INTPNT_MAX_ITERATIONS
           MOSEK_GAP_TOL (113) - used to set opt.MSK_DPAR_INTPNT_TOL_REL_GAP
           MOSEK_MAX_TIME (114) - used to set opt.MSK_DPAR_OPTIMIZER_MAX_TIME
           MOSEK_NUM_THREADS (115) - used to set opt.MSK_IPAR_INTPNT_NUM_THREADS
           MOSEK_OPT (116)     - user option file, if MPOPT(116) is non-zero
               non-zero it is appended to 'mosek_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 a param struct to pass to MOSEKOPT.

   Example:

   If MPOPT(116) = 3, then after setting the default MOSEK options,
   MOSEK_OPTIONS will execute the following user-defined function
   to allow option overrides:

       opt = mosek_user_options_3(opt, mpopt);

   The contents of mosek_user_options_3.m, could be something like:

       function opt = mosek_user_options_3(opt, mpopt)
       opt.MSK_DPAR_INTPNT_TOL_DFEAS   = 1e-9;
       opt.MSK_IPAR_SIM_MAX_ITERATIONS = 5000000;

   See the Parameters reference in Appendix E of "The MOSEK
   optimization toolbox for MATLAB manaul" for
   details on the available options.

       http://www.mosek.com/documentation/

   See also MOSEKOPT, MPOPTION.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function opt = mosek_options(overrides, mpopt)
0002 %MOSEK_OPTIONS  Sets options for MOSEK.
0003 %
0004 %   OPT = MOSEK_OPTIONS
0005 %   OPT = MOSEK_OPTIONS(OVERRIDES)
0006 %   OPT = MOSEK_OPTIONS(OVERRIDES, FNAME)
0007 %   OPT = MOSEK_OPTIONS(OVERRIDES, MPOPT)
0008 %
0009 %   Sets the values for the param struct normally passed to MOSEKOPT.
0010 %
0011 %   Inputs are all optional, second argument must be either a string
0012 %   (FNAME) or a vector (MPOPT):
0013 %
0014 %       OVERRIDES - struct containing values to override the defaults
0015 %       FNAME - name of user-supplied function called after default
0016 %           options are set to modify them. Calling syntax is:
0017 %               MODIFIED_OPT = FNAME(DEFAULT_OPT);
0018 %       MPOPT - MATPOWER options vector, uses the following entries:
0019 %           OPF_VIOLATION (16)  - used to set opt.MSK_DPAR_INTPNT_TOL_PFEAS
0020 %           VERBOSE (31)        - not currently used here
0021 %           MOSEK_MAX_IT (112)  - used to set opt.MSK_IPAR_INTPNT_MAX_ITERATIONS
0022 %           MOSEK_GAP_TOL (113) - used to set opt.MSK_DPAR_INTPNT_TOL_REL_GAP
0023 %           MOSEK_MAX_TIME (114) - used to set opt.MSK_DPAR_OPTIMIZER_MAX_TIME
0024 %           MOSEK_NUM_THREADS (115) - used to set opt.MSK_IPAR_INTPNT_NUM_THREADS
0025 %           MOSEK_OPT (116)     - user option file, if MPOPT(116) is non-zero
0026 %               non-zero it is appended to 'mosek_user_options_' to form
0027 %               the name of a user-supplied function used as FNAME
0028 %               described above, except with calling syntax:
0029 %                   MODIFIED_OPT = FNAME(DEFAULT_OPT, MPOPT);
0030 %
0031 %   Output is a param struct to pass to MOSEKOPT.
0032 %
0033 %   Example:
0034 %
0035 %   If MPOPT(116) = 3, then after setting the default MOSEK options,
0036 %   MOSEK_OPTIONS will execute the following user-defined function
0037 %   to allow option overrides:
0038 %
0039 %       opt = mosek_user_options_3(opt, mpopt);
0040 %
0041 %   The contents of mosek_user_options_3.m, could be something like:
0042 %
0043 %       function opt = mosek_user_options_3(opt, mpopt)
0044 %       opt.MSK_DPAR_INTPNT_TOL_DFEAS   = 1e-9;
0045 %       opt.MSK_IPAR_SIM_MAX_ITERATIONS = 5000000;
0046 %
0047 %   See the Parameters reference in Appendix E of "The MOSEK
0048 %   optimization toolbox for MATLAB manaul" for
0049 %   details on the available options.
0050 %
0051 %       http://www.mosek.com/documentation/
0052 %
0053 %   See also MOSEKOPT, MPOPTION.
0054 
0055 %   MATPOWER
0056 %   $Id: mosek_options.m,v 1.1 2010/11/24 22:31:32 cvs Exp $
0057 %   by Ray Zimmerman, PSERC Cornell
0058 %   Copyright (c) 2010 by Power System Engineering Research Center (PSERC)
0059 %
0060 %   This file is part of MATPOWER.
0061 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0062 %
0063 %   MATPOWER is free software: you can redistribute it and/or modify
0064 %   it under the terms of the GNU General Public License as published
0065 %   by the Free Software Foundation, either version 3 of the License,
0066 %   or (at your option) any later version.
0067 %
0068 %   MATPOWER is distributed in the hope that it will be useful,
0069 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0070 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0071 %   GNU General Public License for more details.
0072 %
0073 %   You should have received a copy of the GNU General Public License
0074 %   along with MATPOWER. If not, see <http://www.gnu.org/licenses/>.
0075 %
0076 %   Additional permission under GNU GPL version 3 section 7
0077 %
0078 %   If you modify MATPOWER, or any covered work, to interface with
0079 %   other modules (such as MATLAB code and MEX-files) available in a
0080 %   MATLAB(R) or comparable environment containing parts covered
0081 %   under other licensing terms, the licensors of MATPOWER grant
0082 %   you additional permission to convey the resulting work.
0083 
0084 %%-----  initialization and arg handling  -----
0085 %% defaults
0086 verbose = 2;
0087 gaptol  = 0;
0088 fname   = '';
0089 
0090 %% get symbolic constant names
0091 [r, res] = mosekopt('symbcon echo(0)');
0092 sc = res.symbcon;
0093 
0094 %% second argument
0095 if nargin > 1 && ~isempty(mpopt)
0096     if ischar(mpopt)        %% 2nd arg is FNAME (string)
0097         fname = mpopt;
0098         have_mpopt = 0;
0099     else                    %% 2nd arg is MPOPT (MATPOWER options vector)
0100         have_mpopt = 1;
0101         %% (make default OPF_VIOLATION correspond to default MOSEK intpnt_tol_pfeas)
0102         verbose = mpopt(31);    %% VERBOSE
0103         if mpopt(116)           %% MOSEK_OPT
0104             fname = sprintf('mosek_user_options_%d', mpopt(116));
0105         end
0106     end
0107 else
0108     have_mpopt = 0;
0109 end
0110 
0111 %%-----  set default options for MOSEK  -----
0112 %% solution algorithm
0113 if have_mpopt
0114     alg = mpopt(111);   %% MOSEK_LP_ALG
0115     switch alg
0116         case {  sc.MSK_OPTIMIZER_FREE,                  %% 0
0117                 sc.MSK_OPTIMIZER_INTPNT,                %% 1
0118                 sc.MSK_OPTIMIZER_PRIMAL_SIMPLEX,        %% 4
0119                 sc.MSK_OPTIMIZER_DUAL_SIMPLEX,          %% 5
0120                 sc.MSK_OPTIMIZER_PRIMAL_DUAL_SIMPLEX,   %% 6
0121                 sc.MSK_OPTIMIZER_FREE_SIMPLEX,          %% 7
0122                 sc.MSK_OPTIMIZER_CONCURRENT }           %% 10
0123             opt.MSK_IPAR_OPTIMIZER = alg;
0124         otherwise
0125             opt.MSK_IPAR_OPTIMIZER = sc.MSK_OPTIMIZER_FREE;
0126     end
0127     %% (make default OPF_VIOLATION correspond to default MSK_DPAR_INTPNT_TOL_PFEAS)
0128     opt.MSK_DPAR_INTPNT_TOL_PFEAS = mpopt(16)/500;  %% OPF_VIOLATION
0129     if mpopt(112)       %% MOSEK_MAX_IT
0130         opt.MSK_IPAR_INTPNT_MAX_ITERATIONS = mpopt(112);
0131     end
0132     if mpopt(113)       %% MOSEK_GAP_TOL
0133         opt.MSK_DPAR_INTPNT_TOL_REL_GAP = mpopt(113);
0134     end
0135     if mpopt(114)       %% MOSEK_MAX_TIME
0136         opt.MSK_DPAR_OPTIMIZER_MAX_TIME = mpopt(114);
0137     end
0138     if mpopt(115)       %% MOSEK_NUM_THREADS
0139         opt.MSK_IPAR_INTPNT_NUM_THREADS = mpopt(115);
0140     end
0141 else
0142     opt.MSK_IPAR_OPTIMIZER = sc.MSK_OPTIMIZER_FREE;
0143 end
0144 % opt.MSK_DPAR_INTPNT_TOL_PFEAS = 1e-8;       %% primal feasibility tol
0145 % opt.MSK_DPAR_INTPNT_TOL_DFEAS = 1e-8;       %% dual feasibility tol
0146 % opt.MSK_DPAR_INTPNT_TOL_MU_RED = 1e-16;     %% relative complementarity gap tol
0147 % opt.MSK_DPAR_INTPNT_TOL_REL_GAP = 1e-8;     %% relative gap termination tol
0148 % opt.MSK_IPAR_INTPNT_MAX_ITERATIONS = 400;   %% max iterations for int point
0149 % opt.MSK_IPAR_SIM_MAX_ITERATIONS = 10000000; %% max iterations for simplex
0150 % opt.MSK_DPAR_OPTIMIZER_MAX_TIME = -1;       %% max time allowed (< 0 --> Inf)
0151 % opt.MSK_IPAR_INTPNT_NUM_THREADS = 1;        %% number of threads
0152 % opt.MSK_IPAR_PRESOLVE_USE = sc.MSK_PRESOLVE_MODE_OFF;
0153 
0154 % if verbose == 0
0155 %     opt.MSK_IPAR_LOG = 0;
0156 % end
0157 
0158 %%-----  call user function to modify defaults  -----
0159 if ~isempty(fname)
0160     if have_mpopt
0161         opt = feval(fname, opt, mpopt);
0162     else
0163         opt = feval(fname, opt);
0164     end
0165 end
0166 
0167 %%-----  apply overrides  -----
0168 if nargin > 0 && ~isempty(overrides)
0169     names = fieldnames(overrides);
0170     for k = 1:length(names)
0171         opt.(names{k}) = overrides.(names{k});
0172     end
0173 end

Generated on Mon 26-Jan-2015 14:56:45 by m2html © 2005