Home > matpower7.1 > mp-opt-model > lib > have_feature_ipopt.m

have_feature_ipopt

PURPOSE ^

HAVE_FEATURE_IPOPT Detect availability/version info for IPOPT

SYNOPSIS ^

function [TorF, vstr, rdate] = have_feature_ipopt()

DESCRIPTION ^

HAVE_FEATURE_IPOPT  Detect availability/version info for IPOPT

   Feature detection function implementing 'ipopt' tag for HAVE_FEATURE
   to detect availability/version of IPOPT, a nonlinear programming
   solver from COIN-OR (https://github.com/coin-or/Ipopt).

   See also HAVE_FEATURE, NLPS_MASTER, QPS_MASTER, IPOPT.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function [TorF, vstr, rdate] = have_feature_ipopt()
0002 %HAVE_FEATURE_IPOPT  Detect availability/version info for IPOPT
0003 %
0004 %   Feature detection function implementing 'ipopt' tag for HAVE_FEATURE
0005 %   to detect availability/version of IPOPT, a nonlinear programming
0006 %   solver from COIN-OR (https://github.com/coin-or/Ipopt).
0007 %
0008 %   See also HAVE_FEATURE, NLPS_MASTER, QPS_MASTER, IPOPT.
0009 
0010 %   MP-Opt-Model
0011 %   Copyright (c) 2004-2020, Power Systems Engineering Research Center (PSERC)
0012 %   by Ray Zimmerman, PSERC Cornell
0013 %
0014 %   This file is part of MP-Opt-Model.
0015 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0016 %   See https://github.com/MATPOWER/mp-opt-model for more info.
0017 
0018 TorF = exist('ipopt', 'file') == 3;
0019 vstr = '';
0020 rdate = '';
0021 if TorF
0022     if have_feature('evalc')
0023         str = evalc('qps_ipopt([],[1; 1],[1 1],[2],[2],[1; 1],[1; 1],[1; 1],struct(''verbose'', 2))');
0024         pat = 'Ipopt version ([^\s,]+)';
0025         [s,e,tE,m,t] = regexp(str, pat);
0026         if ~isempty(t)
0027             vstr = t{1}{1};
0028             if vstr2num(vstr) >= 3.011 && ~exist('ipopt_auxdata', 'file')
0029                 TorF = 0;
0030                 warning('Improper installation of IPOPT. Version %s detected, but IPOPT_AUXDATA.M is missing.', vstr);
0031             end
0032         end
0033     else
0034         try
0035             x = feval('qps_ipopt', [],[1; 1],[1 1],[2],[2],[1; 1],[1; 1],[1; 1],struct('verbose', 0));
0036             if ~isequal(x, [1;1])
0037                 TorF = 0;
0038             end
0039         catch
0040             TorF = 0;
0041         end
0042     end
0043 end
0044 
0045 function num = vstr2num(vstr)
0046 % Converts version string to numerical value suitable for < or > comparisons
0047 % E.g. '3.11.4' -->  3.011004
0048 pat = '\.?(\d+)';
0049 [s,e,tE,m,t] = regexp(vstr, pat);
0050 b = 1;
0051 num = 0;
0052 for k = 1:length(t)
0053     num = num + b * str2num(t{k}{1});
0054     b = b / 1000;
0055 end

Generated on Fri 09-Oct-2020 11:21:31 by m2html © 2005