Home > matpower4.1 > 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_LP_ALG (111)  - used to set opt.MSK_IPAR_OPTIMIZER
           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
               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_LP_ALG (111)  - used to set opt.MSK_IPAR_OPTIMIZER
0022 %           MOSEK_MAX_IT (112)  - used to set opt.MSK_IPAR_INTPNT_MAX_ITERATIONS
0023 %           MOSEK_GAP_TOL (113) - used to set opt.MSK_DPAR_INTPNT_TOL_REL_GAP
0024 %           MOSEK_MAX_TIME (114) - used to set opt.MSK_DPAR_OPTIMIZER_MAX_TIME
0025 %           MOSEK_NUM_THREADS (115) - used to set opt.MSK_IPAR_INTPNT_NUM_THREADS
0026 %           MOSEK_OPT (116)     - user option file, if MPOPT(116) is non-zero
0027 %               it is appended to 'mosek_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 a param struct to pass to MOSEKOPT.
0033 %
0034 %   Example:
0035 %
0036 %   If MPOPT(116) = 3, then after setting the default MOSEK options,
0037 %   MOSEK_OPTIONS will execute the following user-defined function
0038 %   to allow option overrides:
0039 %
0040 %       opt = mosek_user_options_3(opt, mpopt);
0041 %
0042 %   The contents of mosek_user_options_3.m, could be something like:
0043 %
0044 %       function opt = mosek_user_options_3(opt, mpopt)
0045 %       opt.MSK_DPAR_INTPNT_TOL_DFEAS   = 1e-9;
0046 %       opt.MSK_IPAR_SIM_MAX_ITERATIONS = 5000000;
0047 %
0048 %   See the Parameters reference in Appendix E of "The MOSEK
0049 %   optimization toolbox for MATLAB manaul" for
0050 %   details on the available options.
0051 %
0052 %       http://www.mosek.com/documentation/
0053 %
0054 %   See also MOSEKOPT, MPOPTION.
0055 
0056 %   MATPOWER
0057 %   $Id: mosek_options.m,v 1.2 2011/06/29 20:33:14 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 = 2;
0088 gaptol  = 0;
0089 fname   = '';
0090 
0091 %% get symbolic constant names
0092 [r, res] = mosekopt('symbcon echo(0)');
0093 sc = res.symbcon;
0094 
0095 %% second argument
0096 if nargin > 1 && ~isempty(mpopt)
0097     if ischar(mpopt)        %% 2nd arg is FNAME (string)
0098         fname = mpopt;
0099         have_mpopt = 0;
0100     else                    %% 2nd arg is MPOPT (MATPOWER options vector)
0101         have_mpopt = 1;
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 15:00:13 by m2html © 2005