Home > matpower5.1 > clp_options.m

clp_options

PURPOSE ^

CLP_OPTIONS Sets options for CLP.

SYNOPSIS ^

function opt = clp_options(overrides, mpopt)

DESCRIPTION ^

CLP_OPTIONS  Sets options for CLP.

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

   Sets the values for the options struct normally passed to CLP.

   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:
           verbose        - used to set opt.msglev
           clp.opts       - struct containing values to use as OVERRIDES
           clp.opt_fname  - name of user-supplied function used as FNAME,
               except with calling syntax:
                   MODIFIED_OPT = FNAME(DEFAULT_OPT, MPOPT);

   Output is an options struct to pass to CLP.

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

   Example:

   If clp.opt_fname = 'clp_user_options_3', then after setting the
   default CLP options, CLP_OPTIONS will execute the following
   user-defined function to allow option overrides:

       opt = clp_user_options_3(opt, mpopt);

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

       function opt = clp_user_options_3(opt, mpopt)
       opt.algorithm   = 1;
       opt.numThreads  = 2;

   See the documentation for the CLP Options by typing 'help clp'.

   See also CLP, MPOPTION.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function opt = clp_options(overrides, mpopt)
0002 %CLP_OPTIONS  Sets options for CLP.
0003 %
0004 %   OPT = CLP_OPTIONS
0005 %   OPT = CLP_OPTIONS(OVERRIDES)
0006 %   OPT = CLP_OPTIONS(OVERRIDES, FNAME)
0007 %   OPT = CLP_OPTIONS(OVERRIDES, MPOPT)
0008 %
0009 %   Sets the values for the options struct normally passed to CLP.
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 %           verbose        - used to set opt.msglev
0020 %           clp.opts       - struct containing values to use as OVERRIDES
0021 %           clp.opt_fname  - name of user-supplied function used as FNAME,
0022 %               except with calling syntax:
0023 %                   MODIFIED_OPT = FNAME(DEFAULT_OPT, MPOPT);
0024 %
0025 %   Output is an options struct to pass to CLP.
0026 %
0027 %   There are multiple ways of providing values to override the default
0028 %   options. Their precedence and order of application are as follows:
0029 %
0030 %   With inputs OVERRIDES and FNAME
0031 %       1. FNAME is called
0032 %       2. OVERRIDES are applied
0033 %   With inputs OVERRIDES and MPOPT
0034 %       1. FNAME (from clp.opt_fname) is called
0035 %       2. clp.opts (if not empty) are applied
0036 %       3. OVERRIDES are applied
0037 %
0038 %   Example:
0039 %
0040 %   If clp.opt_fname = 'clp_user_options_3', then after setting the
0041 %   default CLP options, CLP_OPTIONS will execute the following
0042 %   user-defined function to allow option overrides:
0043 %
0044 %       opt = clp_user_options_3(opt, mpopt);
0045 %
0046 %   The contents of clp_user_options_3.m, could be something like:
0047 %
0048 %       function opt = clp_user_options_3(opt, mpopt)
0049 %       opt.algorithm   = 1;
0050 %       opt.numThreads  = 2;
0051 %
0052 %   See the documentation for the CLP Options by typing 'help clp'.
0053 %
0054 %   See also CLP, MPOPTION.
0055 
0056 %   MATPOWER
0057 %   Copyright (c) 2010-2015 by Power System Engineering Research Center (PSERC)
0058 %   by Ray Zimmerman, PSERC Cornell
0059 %
0060 %   $Id: clp_options.m 2644 2015-03-11 19:34:22Z ray $
0061 %
0062 %   This file is part of MATPOWER.
0063 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0064 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0065 
0066 %%-----  initialization and arg handling  -----
0067 %% defaults
0068 verbose = 2;
0069 fname   = '';
0070 
0071 %% second argument
0072 if nargin > 1 && ~isempty(mpopt)
0073     if ischar(mpopt)        %% 2nd arg is FNAME (string)
0074         fname = mpopt;
0075         have_mpopt = 0;
0076     else                    %% 2nd arg is MPOPT (MATPOWER options struct)
0077         have_mpopt = 1;
0078         verbose = mpopt.verbose;
0079         if isfield(mpopt.clp, 'opt_fname') && ~isempty(mpopt.clp.opt_fname)
0080             fname = mpopt.clp.opt_fname;
0081         end
0082     end
0083 else
0084     have_mpopt = 0;
0085 end
0086 
0087 %%-----  set default options for CLP  -----
0088 %% printing
0089 if have_fcn('opti_clp')
0090     opt.display = verbose;
0091 else
0092     opt.verbose = verbose;
0093 end
0094 
0095 %%-----  call user function to modify defaults  -----
0096 if ~isempty(fname)
0097     if have_mpopt
0098         opt = feval(fname, opt, mpopt);
0099     else
0100         opt = feval(fname, opt);
0101     end
0102 end
0103 
0104 %%-----  apply overrides  -----
0105 if have_mpopt && isfield(mpopt.clp, 'opts') && ~isempty(mpopt.clp.opts)
0106     opt = nested_struct_copy(opt, mpopt.clp.opts);
0107 end
0108 if nargin > 0 && ~isempty(overrides)
0109     opt = nested_struct_copy(opt, overrides);
0110 end

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