Home > matpower4.0 > have_fcn.m

have_fcn

PURPOSE ^

HAVE_FCN Test for optional functionality.

SYNOPSIS ^

function TorF = have_fcn(tag)

DESCRIPTION ^

HAVE_FCN  Test for optional functionality.
   TORF = HAVE_FCN(TAG) returns 1 if the optional functionality is
   available, 0 otherwise.

   Possible values for input TAG and their meanings:
       bpmpd       - BP, BPMPD interior point solver
       constr      - CONSTR, solver from Optimization Toolbox 1.x/2.x
       cplex       - CPLEX, IBM ILOG CPLEX Optimizer
       fmincon     - FMINCON, solver from Optimization Toolbox 2.x +
       ipopt       - IPOPT, NLP solver (https://projects.coin-or.org/Ipopt/)
       linprog     - LINPROG, LP solver from Optimization Toolbox 2.x +
       lp          - LP, LP solver from Optimization Toolbox 1.x/2.x
       minopf      - MINOPF, MINOPF, MINOS-based OPF solver
       mosek       - MOSEK, LP/QP solver (http://www.mosek.com/)
       quadprog    - QUADPROG, QP solver from Optimization Toolbox 2.x +
       quadprog_ls - QUADPROG with large-scale interior point convex solver
                       from Optimization Toolbox 6.x +
       qp          - QP, QP solver from Optimization Toolbox 1.x/2.x
       pdipmopf    - PDIPMOPF, primal-dual interior point method OPF solver
       scpdipmopf  - SCPDIPMOPF, step-controlled PDIPM OPF solver
       smartmarket - RUNMARKET and friends, for running an auction
       tralmopf    - TRALMOPF, trust region based augmented Langrangian
                     OPF solver
       anon_fcns   - anonymous functions, MATLAB version >= 7
       octave      - code is running under Octave, not MATLAB

   Examples:
       if have_fcn('minopf')
           results = runopf(mpc, mpoption('OPF_ALG', 500));
       end

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function TorF = have_fcn(tag)
0002 %HAVE_FCN  Test for optional functionality.
0003 %   TORF = HAVE_FCN(TAG) returns 1 if the optional functionality is
0004 %   available, 0 otherwise.
0005 %
0006 %   Possible values for input TAG and their meanings:
0007 %       bpmpd       - BP, BPMPD interior point solver
0008 %       constr      - CONSTR, solver from Optimization Toolbox 1.x/2.x
0009 %       cplex       - CPLEX, IBM ILOG CPLEX Optimizer
0010 %       fmincon     - FMINCON, solver from Optimization Toolbox 2.x +
0011 %       ipopt       - IPOPT, NLP solver (https://projects.coin-or.org/Ipopt/)
0012 %       linprog     - LINPROG, LP solver from Optimization Toolbox 2.x +
0013 %       lp          - LP, LP solver from Optimization Toolbox 1.x/2.x
0014 %       minopf      - MINOPF, MINOPF, MINOS-based OPF solver
0015 %       mosek       - MOSEK, LP/QP solver (http://www.mosek.com/)
0016 %       quadprog    - QUADPROG, QP solver from Optimization Toolbox 2.x +
0017 %       quadprog_ls - QUADPROG with large-scale interior point convex solver
0018 %                       from Optimization Toolbox 6.x +
0019 %       qp          - QP, QP solver from Optimization Toolbox 1.x/2.x
0020 %       pdipmopf    - PDIPMOPF, primal-dual interior point method OPF solver
0021 %       scpdipmopf  - SCPDIPMOPF, step-controlled PDIPM OPF solver
0022 %       smartmarket - RUNMARKET and friends, for running an auction
0023 %       tralmopf    - TRALMOPF, trust region based augmented Langrangian
0024 %                     OPF solver
0025 %       anon_fcns   - anonymous functions, MATLAB version >= 7
0026 %       octave      - code is running under Octave, not MATLAB
0027 %
0028 %   Examples:
0029 %       if have_fcn('minopf')
0030 %           results = runopf(mpc, mpoption('OPF_ALG', 500));
0031 %       end
0032 
0033 %   MATPOWER
0034 %   $Id: have_fcn.m,v 1.20 2011/01/18 15:23:36 cvs Exp $
0035 %   by Ray Zimmerman, PSERC Cornell
0036 %   Copyright (c) 2004-2011 by Power System Engineering Research Center (PSERC)
0037 %
0038 %   This file is part of MATPOWER.
0039 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0040 %
0041 %   MATPOWER is free software: you can redistribute it and/or modify
0042 %   it under the terms of the GNU General Public License as published
0043 %   by the Free Software Foundation, either version 3 of the License,
0044 %   or (at your option) any later version.
0045 %
0046 %   MATPOWER is distributed in the hope that it will be useful,
0047 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0048 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0049 %   GNU General Public License for more details.
0050 %
0051 %   You should have received a copy of the GNU General Public License
0052 %   along with MATPOWER. If not, see <http://www.gnu.org/licenses/>.
0053 %
0054 %   Additional permission under GNU GPL version 3 section 7
0055 %
0056 %   If you modify MATPOWER, or any covered work, to interface with
0057 %   other modules (such as MATLAB code and MEX-files) available in a
0058 %   MATLAB(R) or comparable environment containing parts covered
0059 %   under other licensing terms, the licensors of MATPOWER grant
0060 %   you additional permission to convey the resulting work.
0061 
0062 switch tag
0063     case 'bpmpd'
0064         TorF = exist('bp', 'file') == 3;
0065     case 'constr'
0066         TorF = exist('constr', 'file') == 2 && exist('foptions', 'file');
0067     case 'cplex'
0068         TorF = 0;
0069         if exist('cplexqp', 'file')
0070             %% it's installed, but we need to check for MEX for this arch
0071             p = which('cplexqp');   %% get the path
0072             len = length(p) - length('cplexqp.p');
0073             w = what(p(1:len));             %% look for mex files on the path
0074             for k = 1:length(w.mex)
0075                 if regexp(w.mex{k}, 'cplexlink[^\.]*');
0076                     TorF = 1;
0077                     break;
0078                 end
0079             end
0080         end
0081     case 'fmincon'
0082         TorF = exist('fmincon', 'file') == 2;
0083     case 'ipopt'
0084         TorF = exist('ipopt', 'file') == 3;
0085     case 'linprog'
0086         TorF = exist('linprog', 'file') == 2;
0087     case 'lp'
0088         TorF = exist('lp', 'file') == 2;
0089     case 'minopf'
0090         TorF = exist('minopf', 'file') == 3;
0091     case 'mosek'
0092         TorF = exist('mosekopt', 'file') == 3;
0093     case 'quadprog'
0094         TorF = exist('quadprog', 'file') == 2;
0095     case 'quadprog_ls'
0096         v = ver('optim');
0097         if str2num(v.Version) >= 6
0098             TorF = 1;
0099         else
0100             TorF = 0;
0101         end
0102     case 'qp'
0103         TorF = exist('qp', 'file') == 2;
0104     case 'smartmarket'
0105         TorF = exist('runmarket', 'file') == 2;
0106     case 'octave'
0107         TorF = exist('OCTAVE_VERSION', 'builtin') == 5;
0108     case 'anon_fcns'
0109         if have_fcn('octave')
0110             TorF = 1;
0111         else
0112             v = ver('Matlab');
0113             if str2double(v.Version(1)) < 7    %% anonymous functions not available
0114                 TorF = 0;
0115             else
0116                 TorF = 1;
0117             end
0118         end
0119     case {'pdipmopf', 'scpdipmopf', 'tralmopf'}
0120         if have_fcn('octave')
0121             TorF = 0;
0122         else
0123             v = ver('Matlab');
0124             %% requires >= MATLAB 6.5 (R13) (released 20-Jun-2002)
0125             %% older versions do not have mxCreateDoubleScalar() function
0126             %% (they have mxCreateScalarDouble() instead)
0127             if datenum(v.Date) >= 731387
0128                 switch tag
0129                     case 'pdipmopf'
0130                         TorF = exist('pdipmopf', 'file') == 3;
0131                     case 'scpdipmopf'
0132                         TorF = exist('scpdipmopf', 'file') == 3;
0133                     case 'tralmopf'
0134                         %% requires >= MATLAB 7.3 (R2006b) (released 03-Aug-2006)
0135                         %% older versions do not include the needed form of chol()
0136                         if datenum(v.Date) >= 732892
0137                             TorF = exist('tralmopf', 'file') == 3;
0138                         else
0139                             TorF = 0;
0140                         end
0141                 end
0142             else
0143                 TorF = 0;
0144             end
0145         end
0146     otherwise
0147         error('have_fcn: unknown functionality %s', tag);
0148 end

Generated on Mon 26-Jan-2015 14:56:45 by m2html © 2005