Re: Nonlinear CG

"Ben FrantzDale" <[email protected]> Tue, 16 Jan 2007 18:53:49 -0500
Newsgroups gmane.comp.lib.mtl.devel
Message-ID <[email protected]>
--===============1567559369==
Content-Type: multipart/alternative; 
	boundary="----=_Part_91359_22147565.1168991629415"

------=_Part_91359_22147565.1168991629415
Content-Type: text/plain; charset=WINDOWS-1252; format=flowed
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

It appears that the two primary ways to make CG nonlinear is to change how
the line search is performed and how beta is determined. I'm invissioning a
nonlinear_cg() function that takes those options as function objects. That
is, you might call it like
  nonlinear_cg(f, x, b, P, iter,
                      Secant(), FletcherReeves());

(See below for function objects for the two popular ways to compute beta.)


Some methods require only f', others require both f and f', others require
f' and f''. Any thoughts as to do that generically? One possibility would b=
e
for the operator() of f to take two, three, or four arguments. That is,
  f(x, d) -> d =3D f(x)
  f(x, d, g) -> d =3D f(x), g =3D f'(x)
  f(x, d, g, H) -> d =3D f(x), g =3D f'(x), H =3D f''(x).

Other options include making derivative(f)(x, g) return g, but that seems a
bit too clever for its own good.

Thoughts?

=97Ben


template <typename Vector>
struct FletcherReeves {
  double operator()(Vector const& r,
            Vector const& r_next) const
  {
    return (itl::dot_conj(r_next, r_next)
        /
        itl::dot_conj(r, r));
  }
};

template <typename Vector>
struct PolakRibiere {
  double operator()(Vector const& r,
            Vector const& r_next) const
  {
    Vector r_dif(itl::size(r));
    itl::add(r_next, itl::scaled(r, -1.0), r_diff);

    double const beata =3D (itl::dot_conj(r_next, r_diff)
              /
              itl::dot_conj(r, r));
    return std::max(0.0, beta);
  }
};

------=_Part_91359_22147565.1168991629415
Content-Type: text/html; charset=WINDOWS-1252
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

It appears that the two primary ways to make CG nonlinear is to change how =
the line search is performed and how beta is determined. I&#39;m invissioni=
ng a nonlinear_cg() function that takes those options as function objects. =
That is, you might call it like
<br>&nbsp; nonlinear_cg(f, x, b, P, iter,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp; Secant(), FletcherReeves());<br><br>(See below for fu=
nction objects for the two popular ways to compute beta.)<br><br><br>Some m=
ethods require only f&#39;, others require both f and f&#39;, others requir=
e f&#39; and f&#39;&#39;. Any thoughts as to do that generically? One possi=
bility would be for the operator() of f to take two, three, or four argumen=
ts. That is,
<br>&nbsp; f(x, d) -&gt; d =3D f(x)<br>&nbsp; f(x, d, g) -&gt; d =3D f(x), =
g =3D f&#39;(x)<br>&nbsp; f(x, d, g, H) -&gt; d =3D f(x), g =3D f&#39;(x), =
H =3D f&#39;&#39;(x).<br><br>Other options include making derivative(f)(x, =
g) return g, but that seems a bit too clever for its own good.
<br><br>Thoughts?<br><br>=97Ben<br><br><br>template &lt;typename Vector&gt;=
<br>struct FletcherReeves {<br>&nbsp; double operator()(Vector const&amp; r=
,<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Vector const&=
amp; r_next) const<br>&nbsp; {<br>&nbsp;&nbsp;&nbsp; return (itl::dot_conj(=
r_next, r_next)
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /<br>&nbsp;&nbsp;&nbsp; &nbsp;&nb=
sp;&nbsp; itl::dot_conj(r, r));<br>&nbsp; }<br>};<br><br>template &lt;typen=
ame Vector&gt;<br>struct PolakRibiere {<br>&nbsp; double operator()(Vector =
const&amp; r,<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; V=
ector const&amp; r_next) const<br>&nbsp; {
<br>&nbsp;&nbsp;&nbsp; Vector r_dif(itl::size(r));<br>&nbsp;&nbsp;&nbsp; it=
l::add(r_next, itl::scaled(r, -1.0), r_diff);<br><br>&nbsp;&nbsp;&nbsp; dou=
ble const beata =3D (itl::dot_conj(r_next, r_diff)<br>&nbsp;&nbsp;&nbsp; &n=
bsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; /<br>&nbsp;&nbsp;&nbsp; &nbsp;&n=
bsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; itl::dot_conj(r, r));<br>&nbsp;&nbsp;&=
nbsp; return std::max(
0.0, beta);<br>&nbsp; }<br>};<br><br><br><br>

------=_Part_91359_22147565.1168991629415--

--===============1567559369==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
This list is archived at http://www.osl.iu.edu/MailArchives/mtl-devel/
--===============1567559369==--