Home > matpower5.0 > glpk_options.m

glpk_options

PURPOSE ^

GLPK_OPTIONS Sets options for GLPK.

SYNOPSIS ^

function opt = glpk_options(overrides, mpopt)

DESCRIPTION ^

GLPK_OPTIONS  Sets options for GLPK.

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

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

   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
           glpk.opts      - struct containing values to use as OVERRIDES
           glpk.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 GLPK.

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

   Example:

   If glpk.opt_fname = 'glpk_user_options_3', then after setting the
   default GLPK options, GLPK_OPTIONS will execute the following
   user-defined function to allow option overrides:

       opt = glpk_user_options_3(opt, mpopt);

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

       function opt = glpk_user_options_3(opt, mpopt)
       opt.lpsolver = 1;
       opt.dual     = 2;

   See the documentation for the PARAM argument at

       http://www.gnu.org/software/octave/doc/interpreter/Linear-Programming.html

   or by typing 'help glpk'.


   See also GLPK, MPOPTION.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function opt = glpk_options(overrides, mpopt)
0002 %GLPK_OPTIONS  Sets options for GLPK.
0003 %
0004 %   OPT = GLPK_OPTIONS
0005 %   OPT = GLPK_OPTIONS(OVERRIDES)
0006 %   OPT = GLPK_OPTIONS(OVERRIDES, FNAME)
0007 %   OPT = GLPK_OPTIONS(OVERRIDES, MPOPT)
0008 %
0009 %   Sets the values for the options struct normally passed to
0010 %   GLPK.
0011 %
0012 %   Inputs are all optional, second argument must be either a string
0013 %   (FNAME) or a struct (MPOPT):
0014 %
0015 %       OVERRIDES - struct containing values to override the defaults
0016 %       FNAME - name of user-supplied function called after default
0017 %           options are set to modify them. Calling syntax is:
0018 %                   MODIFIED_OPT = FNAME(DEFAULT_OPT);
0019 %       MPOPT - MATPOWER options struct, uses the following fields:
0020 %           verbose        - used to set opt.msglev
0021 %           glpk.opts      - struct containing values to use as OVERRIDES
0022 %           glpk.opt_fname - name of user-supplied function used as FNAME,
0023 %               except with calling syntax:
0024 %                   MODIFIED_OPT = FNAME(DEFAULT_OPT, MPOPT);
0025 %
0026 %   Output is an options struct to pass to GLPK.
0027 %
0028 %   There are multiple ways of providing values to override the default
0029 %   options. Their precedence and order of application are as follows:
0030 %
0031 %   With inputs OVERRIDES and FNAME
0032 %       1. FNAME is called
0033 %       2. OVERRIDES are applied
0034 %   With inputs OVERRIDES and MPOPT
0035 %       1. FNAME (from glpk.opt_fname) is called
0036 %       2. glpk.opts (if not empty) are applied
0037 %       3. OVERRIDES are applied
0038 %
0039 %   Example:
0040 %
0041 %   If glpk.opt_fname = 'glpk_user_options_3', then after setting the
0042 %   default GLPK options, GLPK_OPTIONS will execute the following
0043 %   user-defined function to allow option overrides:
0044 %
0045 %       opt = glpk_user_options_3(opt, mpopt);
0046 %
0047 %   The contents of glpk_user_options_3.m, could be something like:
0048 %
0049 %       function opt = glpk_user_options_3(opt, mpopt)
0050 %       opt.lpsolver = 1;
0051 %       opt.dual     = 2;
0052 %
0053 %   See the documentation for the PARAM argument at
0054 %
0055 %       http://www.gnu.org/software/octave/doc/interpreter/Linear-Programming.html
0056 %
0057 %   or by typing 'help glpk'.
0058 %
0059 %
0060 %   See also GLPK, MPOPTION.
0061 
0062 %   MATPOWER
0063 %   $Id: glpk_options.m 2339 2014-06-27 18:47:49Z ray $
0064 %   by Ray Zimmerman, PSERC Cornell
0065 %   Copyright (c) 2010-2013 by Power System Engineering Research Center (PSERC)
0066 %
0067 %   This file is part of MATPOWER.
0068 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0069 %
0070 %   MATPOWER is free software: you can redistribute it and/or modify
0071 %   it under the terms of the GNU General Public License as published
0072 %   by the Free Software Foundation, either version 3 of the License,
0073 %   or (at your option) any later version.
0074 %
0075 %   MATPOWER is distributed in the hope that it will be useful,
0076 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0077 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0078 %   GNU General Public License for more details.
0079 %
0080 %   You should have received a copy of the GNU General Public License
0081 %   along with MATPOWER. If not, see <http://www.gnu.org/licenses/>.
0082 %
0083 %   Additional permission under GNU GPL version 3 section 7
0084 %
0085 %   If you modify MATPOWER, or any covered work, to interface with
0086 %   other modules (such as MATLAB code and MEX-files) available in a
0087 %   MATLAB(R) or comparable environment containing parts covered
0088 %   under other licensing terms, the licensors of MATPOWER grant
0089 %   you additional permission to convey the resulting work.
0090 
0091 %%-----  initialization and arg handling  -----
0092 %% defaults
0093 verbose = 2;
0094 fname   = '';
0095 
0096 %% second argument
0097 if nargin > 1 && ~isempty(mpopt)
0098     if ischar(mpopt)        %% 2nd arg is FNAME (string)
0099         fname = mpopt;
0100         have_mpopt = 0;
0101     else                    %% 2nd arg is MPOPT (MATPOWER options struct)
0102         have_mpopt = 1;
0103         verbose = mpopt.verbose;
0104         if isfield(mpopt.glpk, 'opt_fname') && ~isempty(mpopt.glpk.opt_fname)
0105             fname = mpopt.glpk.opt_fname;
0106         end
0107     end
0108 else
0109     have_mpopt = 0;
0110 end
0111 
0112 %%-----  set default options for GLPK  -----
0113 %% printing
0114 opt.msglev = verbose;
0115 
0116 %%-----  call user function to modify defaults  -----
0117 if ~isempty(fname)
0118     if have_mpopt
0119         opt = feval(fname, opt, mpopt);
0120     else
0121         opt = feval(fname, opt);
0122     end
0123 end
0124 
0125 %%-----  apply overrides  -----
0126 if have_mpopt && isfield(mpopt.glpk, 'opts') && ~isempty(mpopt.glpk.opts)
0127     opt = nested_struct_copy(opt, mpopt.glpk.opts);
0128 end
0129 if nargin > 0 && ~isempty(overrides)
0130     opt = nested_struct_copy(opt, overrides);
0131 end

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