Home > matpower5.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 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.MSK_DPAR_INTPNT_TOL_PFEAS
           verbose         - not currently used here
           mosek.lp_alg    - used to set opt.MSK_IPAR_OPTIMIZER
           mosek.max_it    - used to set opt.MSK_IPAR_INTPNT_MAX_ITERATIONS
           mosek.gap_tol   - used to set opt.MSK_DPAR_INTPNT_TOL_REL_GAP
           mosek.max_time  - used to set opt.MSK_DPAR_OPTIMIZER_MAX_TIME
           mosek.num_threads - used to set opt.MSK_IPAR_INTPNT_NUM_THREADS
           mosek.opts      - struct containing values to use as OVERRIDES
           mosek.opt_fname - name of user-supplied function used as FNAME,
               except with calling syntax:
                   MODIFIED_OPT = FNAME(DEFAULT_OPT, MPOPT);
           mosek.opt       - numbered user option function, if and only if
               mosek.opt_fname is empty and mosek.opt is non-zero, the value
               of mosek.opt_fname is generated by appending mosek.opt to
               'mosek_user_options_' (for backward compatibility with old
               MATPOWER option MOSEK_OPT).

   Output is a param struct to pass to MOSEKOPT.

   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 mosek.opt_fname or mosek.opt) is called
       2. mosek.opts (if not empty) are applied
       3. OVERRIDES are applied

   Example:

   If mosek.opt = 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 "The MOSEK optimization toolbox
   for MATLAB manaul" for details on the available options. You may also
   want to use the symbolic constants defined by MOSEK_SYMBCON.

       http://docs.mosek.com/7.1/toolbox/Parameters.html

   See also MOSEK_SYMBCON, 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 struct (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 struct, uses the following fields:
0019 %           opf.violation   - used to set opt.MSK_DPAR_INTPNT_TOL_PFEAS
0020 %           verbose         - not currently used here
0021 %           mosek.lp_alg    - used to set opt.MSK_IPAR_OPTIMIZER
0022 %           mosek.max_it    - used to set opt.MSK_IPAR_INTPNT_MAX_ITERATIONS
0023 %           mosek.gap_tol   - used to set opt.MSK_DPAR_INTPNT_TOL_REL_GAP
0024 %           mosek.max_time  - used to set opt.MSK_DPAR_OPTIMIZER_MAX_TIME
0025 %           mosek.num_threads - used to set opt.MSK_IPAR_INTPNT_NUM_THREADS
0026 %           mosek.opts      - struct containing values to use as OVERRIDES
0027 %           mosek.opt_fname - name of user-supplied function used as FNAME,
0028 %               except with calling syntax:
0029 %                   MODIFIED_OPT = FNAME(DEFAULT_OPT, MPOPT);
0030 %           mosek.opt       - numbered user option function, if and only if
0031 %               mosek.opt_fname is empty and mosek.opt is non-zero, the value
0032 %               of mosek.opt_fname is generated by appending mosek.opt to
0033 %               'mosek_user_options_' (for backward compatibility with old
0034 %               MATPOWER option MOSEK_OPT).
0035 %
0036 %   Output is a param struct to pass to MOSEKOPT.
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 mosek.opt_fname or mosek.opt) is called
0046 %       2. mosek.opts (if not empty) are applied
0047 %       3. OVERRIDES are applied
0048 %
0049 %   Example:
0050 %
0051 %   If mosek.opt = 3, then after setting the default MOSEK options,
0052 %   MOSEK_OPTIONS will execute the following user-defined function
0053 %   to allow option overrides:
0054 %
0055 %       opt = mosek_user_options_3(opt, mpopt);
0056 %
0057 %   The contents of mosek_user_options_3.m, could be something like:
0058 %
0059 %       function opt = mosek_user_options_3(opt, mpopt)
0060 %       opt.MSK_DPAR_INTPNT_TOL_DFEAS   = 1e-9;
0061 %       opt.MSK_IPAR_SIM_MAX_ITERATIONS = 5000000;
0062 %
0063 %   See the Parameters reference in "The MOSEK optimization toolbox
0064 %   for MATLAB manaul" for details on the available options. You may also
0065 %   want to use the symbolic constants defined by MOSEK_SYMBCON.
0066 %
0067 %       http://docs.mosek.com/7.1/toolbox/Parameters.html
0068 %
0069 %   See also MOSEK_SYMBCON, MOSEKOPT, MPOPTION.
0070 
0071 %   MATPOWER
0072 %   Copyright (c) 2010-2015 by Power System Engineering Research Center (PSERC)
0073 %   by Ray Zimmerman, PSERC Cornell
0074 %
0075 %   $Id: mosek_options.m 2644 2015-03-11 19:34:22Z ray $
0076 %
0077 %   This file is part of MATPOWER.
0078 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0079 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0080 
0081 %%-----  initialization and arg handling  -----
0082 %% defaults
0083 verbose = 2;
0084 gaptol  = 0;
0085 fname   = '';
0086 
0087 %% get symbolic constant names
0088 sc = mosek_symbcon;
0089 
0090 %% second argument
0091 if nargin > 1 && ~isempty(mpopt)
0092     if ischar(mpopt)        %% 2nd arg is FNAME (string)
0093         fname = mpopt;
0094         have_mpopt = 0;
0095     else                    %% 2nd arg is MPOPT (MATPOWER options struct)
0096         have_mpopt = 1;
0097         verbose = mpopt.verbose;
0098         if isfield(mpopt.mosek, 'opt_fname') && ~isempty(mpopt.mosek.opt_fname)
0099             fname = mpopt.mosek.opt_fname;
0100         elseif mpopt.mosek.opt
0101             fname = sprintf('mosek_user_options_%d', mpopt.mosek.opt);
0102         end
0103     end
0104 else
0105     have_mpopt = 0;
0106 end
0107 
0108 %%-----  set default options for MOSEK  -----
0109 %% solution algorithm
0110 if have_mpopt
0111     alg = mpopt.mosek.lp_alg;
0112     switch alg                                          %% v6.x v7.x
0113         case {  sc.MSK_OPTIMIZER_FREE,                  %%  0    0
0114                 sc.MSK_OPTIMIZER_INTPNT,                %%  1    1
0115                 sc.MSK_OPTIMIZER_PRIMAL_SIMPLEX,        %%  4    3
0116                 sc.MSK_OPTIMIZER_DUAL_SIMPLEX,          %%  5    4
0117                 sc.MSK_OPTIMIZER_PRIMAL_DUAL_SIMPLEX,   %%  6    5
0118                 sc.MSK_OPTIMIZER_FREE_SIMPLEX,          %%  7    6
0119 %                 sc.MSK_OPTIMIZER_NETWORK_PRIMAL_SIMPLEX,%%  -    7 (non-existent for MOSEK v6)
0120                 sc.MSK_OPTIMIZER_CONCURRENT }           %% 10   10
0121             opt.MSK_IPAR_OPTIMIZER = alg;
0122         otherwise
0123             if have_fcn('mosek', 'vnum') >= 7 && ...
0124                     alg == sc.MSK_OPTIMIZER_NETWORK_PRIMAL_SIMPLEX
0125                 opt.MSK_IPAR_OPTIMIZER = alg;
0126             else
0127                 opt.MSK_IPAR_OPTIMIZER = sc.MSK_OPTIMIZER_FREE;
0128             end
0129     end
0130 
0131     %% (make default opf.violation correspond to default MSK_DPAR_INTPNT_TOL_PFEAS)
0132     opt.MSK_DPAR_INTPNT_TOL_PFEAS = mpopt.opf.violation/500;
0133     if mpopt.mosek.max_it
0134         opt.MSK_IPAR_INTPNT_MAX_ITERATIONS = mpopt.mosek.max_it;
0135     end
0136     if mpopt.mosek.gap_tol
0137         opt.MSK_DPAR_INTPNT_TOL_REL_GAP = mpopt.mosek.gap_tol;
0138     end
0139     if mpopt.mosek.max_time
0140         opt.MSK_DPAR_OPTIMIZER_MAX_TIME = mpopt.mosek.max_time;
0141     end
0142     if mpopt.mosek.num_threads
0143         if have_fcn('mosek', 'vnum') < 7
0144             opt.MSK_IPAR_INTPNT_NUM_THREADS = mpopt.mosek.num_threads;
0145         else
0146             opt.MSK_IPAR_NUM_THREADS = mpopt.mosek.num_threads;
0147         end
0148     end
0149 else
0150     opt.MSK_IPAR_OPTIMIZER = sc.MSK_OPTIMIZER_FREE;
0151 end
0152 % opt.MSK_DPAR_INTPNT_TOL_PFEAS = 1e-8;       %% primal feasibility tol
0153 % opt.MSK_DPAR_INTPNT_TOL_DFEAS = 1e-8;       %% dual feasibility tol
0154 % opt.MSK_DPAR_INTPNT_TOL_MU_RED = 1e-16;     %% relative complementarity gap tol
0155 % opt.MSK_DPAR_INTPNT_TOL_REL_GAP = 1e-8;     %% relative gap termination tol
0156 % opt.MSK_IPAR_INTPNT_MAX_ITERATIONS = 400;   %% max iterations for int point
0157 % opt.MSK_IPAR_SIM_MAX_ITERATIONS = 10000000; %% max iterations for simplex
0158 % opt.MSK_DPAR_OPTIMIZER_MAX_TIME = -1;       %% max time allowed (< 0 --> Inf)
0159 % opt.MSK_IPAR_INTPNT_NUM_THREADS = 1;        %% number of threads
0160 % opt.MSK_IPAR_PRESOLVE_USE = sc.MSK_PRESOLVE_MODE_OFF;
0161 
0162 % if verbose == 0
0163 %     opt.MSK_IPAR_LOG = 0;
0164 % end
0165 
0166 %%-----  call user function to modify defaults  -----
0167 if ~isempty(fname)
0168     if have_mpopt
0169         opt = feval(fname, opt, mpopt);
0170     else
0171         opt = feval(fname, opt);
0172     end
0173 end
0174 
0175 %%-----  apply overrides  -----
0176 if have_mpopt && isfield(mpopt.mosek, 'opts') && ~isempty(mpopt.mosek.opts)
0177     opt = nested_struct_copy(opt, mpopt.mosek.opts);
0178 end
0179 if nargin > 0 && ~isempty(overrides)
0180     opt = nested_struct_copy(opt, overrides);
0181 end

Generated on Fri 20-Mar-2015 18:23:34 by m2html © 2005