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

Generated on Mon 26-Jan-2015 15:00:13 by m2html © 2005