Home > matpower5.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 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.

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

   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 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.
0065 %
0066 %       http://docs.mosek.com/7.0/toolbox/Parameters.html
0067 %
0068 %   See also MOSEKOPT, MPOPTION.
0069 
0070 %   MATPOWER
0071 %   $Id: mosek_options.m 2242 2014-01-03 17:49:15Z ray $
0072 %   by Ray Zimmerman, PSERC Cornell
0073 %   Copyright (c) 2010-2013 by Power System Engineering Research Center (PSERC)
0074 %
0075 %   This file is part of MATPOWER.
0076 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0077 %
0078 %   MATPOWER is free software: you can redistribute it and/or modify
0079 %   it under the terms of the GNU General Public License as published
0080 %   by the Free Software Foundation, either version 3 of the License,
0081 %   or (at your option) any later version.
0082 %
0083 %   MATPOWER is distributed in the hope that it will be useful,
0084 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0085 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0086 %   GNU General Public License for more details.
0087 %
0088 %   You should have received a copy of the GNU General Public License
0089 %   along with MATPOWER. If not, see <http://www.gnu.org/licenses/>.
0090 %
0091 %   Additional permission under GNU GPL version 3 section 7
0092 %
0093 %   If you modify MATPOWER, or any covered work, to interface with
0094 %   other modules (such as MATLAB code and MEX-files) available in a
0095 %   MATLAB(R) or comparable environment containing parts covered
0096 %   under other licensing terms, the licensors of MATPOWER grant
0097 %   you additional permission to convey the resulting work.
0098 
0099 %%-----  initialization and arg handling  -----
0100 %% defaults
0101 verbose = 2;
0102 gaptol  = 0;
0103 fname   = '';
0104 
0105 %% get symbolic constant names
0106 [r, res] = mosekopt('symbcon echo(0)');
0107 sc = res.symbcon;
0108 
0109 %% second argument
0110 if nargin > 1 && ~isempty(mpopt)
0111     if ischar(mpopt)        %% 2nd arg is FNAME (string)
0112         fname = mpopt;
0113         have_mpopt = 0;
0114     else                    %% 2nd arg is MPOPT (MATPOWER options struct)
0115         have_mpopt = 1;
0116         verbose = mpopt.verbose;
0117         if isfield(mpopt.mosek, 'opt_fname') && ~isempty(mpopt.mosek.opt_fname)
0118             fname = mpopt.mosek.opt_fname;
0119         elseif mpopt.mosek.opt
0120             fname = sprintf('mosek_user_options_%d', mpopt.mosek.opt);
0121         end
0122     end
0123 else
0124     have_mpopt = 0;
0125 end
0126 
0127 %%-----  set default options for MOSEK  -----
0128 %% solution algorithm
0129 if have_mpopt
0130     alg = mpopt.mosek.lp_alg;
0131     switch alg
0132         case {  sc.MSK_OPTIMIZER_FREE,                  %% 0
0133                 sc.MSK_OPTIMIZER_INTPNT,                %% 1
0134                 sc.MSK_OPTIMIZER_PRIMAL_SIMPLEX,        %% 4
0135                 sc.MSK_OPTIMIZER_DUAL_SIMPLEX,          %% 5
0136                 sc.MSK_OPTIMIZER_PRIMAL_DUAL_SIMPLEX,   %% 6
0137                 sc.MSK_OPTIMIZER_FREE_SIMPLEX,          %% 7
0138                 sc.MSK_OPTIMIZER_CONCURRENT }           %% 10
0139             opt.MSK_IPAR_OPTIMIZER = alg;
0140         otherwise
0141             opt.MSK_IPAR_OPTIMIZER = sc.MSK_OPTIMIZER_FREE;
0142     end
0143     %% (make default opf.violation correspond to default MSK_DPAR_INTPNT_TOL_PFEAS)
0144     opt.MSK_DPAR_INTPNT_TOL_PFEAS = mpopt.opf.violation/500;
0145     if mpopt.mosek.max_it
0146         opt.MSK_IPAR_INTPNT_MAX_ITERATIONS = mpopt.mosek.max_it;
0147     end
0148     if mpopt.mosek.gap_tol
0149         opt.MSK_DPAR_INTPNT_TOL_REL_GAP = mpopt.mosek.gap_tol;
0150     end
0151     if mpopt.mosek.max_time
0152         opt.MSK_DPAR_OPTIMIZER_MAX_TIME = mpopt.mosek.max_time;
0153     end
0154     if mpopt.mosek.num_threads
0155         opt.MSK_IPAR_INTPNT_NUM_THREADS = mpopt.mosek.num_threads;
0156     end
0157 else
0158     opt.MSK_IPAR_OPTIMIZER = sc.MSK_OPTIMIZER_FREE;
0159 end
0160 % opt.MSK_DPAR_INTPNT_TOL_PFEAS = 1e-8;       %% primal feasibility tol
0161 % opt.MSK_DPAR_INTPNT_TOL_DFEAS = 1e-8;       %% dual feasibility tol
0162 % opt.MSK_DPAR_INTPNT_TOL_MU_RED = 1e-16;     %% relative complementarity gap tol
0163 % opt.MSK_DPAR_INTPNT_TOL_REL_GAP = 1e-8;     %% relative gap termination tol
0164 % opt.MSK_IPAR_INTPNT_MAX_ITERATIONS = 400;   %% max iterations for int point
0165 % opt.MSK_IPAR_SIM_MAX_ITERATIONS = 10000000; %% max iterations for simplex
0166 % opt.MSK_DPAR_OPTIMIZER_MAX_TIME = -1;       %% max time allowed (< 0 --> Inf)
0167 % opt.MSK_IPAR_INTPNT_NUM_THREADS = 1;        %% number of threads
0168 % opt.MSK_IPAR_PRESOLVE_USE = sc.MSK_PRESOLVE_MODE_OFF;
0169 
0170 % if verbose == 0
0171 %     opt.MSK_IPAR_LOG = 0;
0172 % end
0173 
0174 %%-----  call user function to modify defaults  -----
0175 if ~isempty(fname)
0176     if have_mpopt
0177         opt = feval(fname, opt, mpopt);
0178     else
0179         opt = feval(fname, opt);
0180     end
0181 end
0182 
0183 %%-----  apply overrides  -----
0184 if have_mpopt && isfield(mpopt.mosek, 'opts') && ~isempty(mpopt.mosek.opts)
0185     opt = nested_struct_copy(opt, mpopt.mosek.opts);
0186 end
0187 if nargin > 0 && ~isempty(overrides)
0188     opt = nested_struct_copy(opt, overrides);
0189 end

Generated on Mon 26-Jan-2015 15:21:31 by m2html © 2005