function code = opf_slvr(alg)
%OPF_SLVR    Which OPF solver is used by alg.
%   code = opf_slvr(alg) returns a solver code given an algorithm code.
%   The codes are:
%       0 - 'constr' from Optimization Toolbox 1.x or 2.x
%       1 - 'LPconstr', dense LP-based solver
%       2 - 'LPconstr', sparse LP-based solver with relaxed constraints
%       3 - 'LPconstr', sparse LP-based solver with full set of constraints
%       4 - 'fmincon', from Optimization Toolbox 2.x and later
%       5 - 'minopf', MINOS-based solver

%   MATPOWER
%   $Id: opf_slvr.m,v 1.5 2004/09/01 16:17:53 ray Exp $
%   by Ray Zimmerman, PSERC Cornell
%   Copyright (c) 1996-2004 by Power System Engineering Research Center (PSERC)
%   See http://www.pserc.cornell.edu/matpower/ for more info.

if alg < 500
    code = rem(alg, 100) / 20;
    if code ~= 0 & code ~= 1 & code ~= 2 & code ~= 3
        error(['opf_slvr: unknown OPF algorithm (', num2str(alg) , ')']);
    end
elseif alg == 520
    code = 4;
elseif alg == 500
    code = 5;
else
    error(['opf_slvr: unknown OPF algorithm (', num2str(alg) , ')']);
end

return;
