Commit d29ed54f authored by Lasse Hinrichsen's avatar Lasse Hinrichsen
Browse files

Use functional interface in bisection

parent 2241fdf4
......@@ -5,6 +5,7 @@
#include <iomanip>
#include <dune/solvers/common/interval.hh>
#include <dune/tnnmg/localsolvers/functionproperties.hh>
/** \brief Minimize a scalar convex functional by bisection
**/
......@@ -52,9 +53,9 @@ class Bisection
count = 0;
// try if projected initial guess is sufficient
Dune::Solvers::Interval<double> dom = J.domain();
Dune::Solvers::Interval<double> dom = Dune::TNNMG::domain(J);
x = dom.projectIn(x);
Dune::Solvers::Interval<double> DJ = J.subDifferential(x);
Dune::Solvers::Interval<double> DJ = Dune::TNNMG::subDifferential(J, x);
++count;
if (DJ.containsZero(safety_))
{
......@@ -70,7 +71,7 @@ class Bisection
I[1] = x;
I[0] = dom.projectFromBelow(I[1] - DJ[0]);
DJ = J.subDifferential(I[0]);
DJ = Dune::TNNMG::subDifferential(J, I[0]);
++count;
while (DJ[0] > safety_)
{
......@@ -80,7 +81,7 @@ class Bisection
I[0] = dom[0];
break;
}
DJ = J.subDifferential(I[0]);
DJ = Dune::TNNMG::subDifferential(J, I[0]);
++count;
}
}
......@@ -89,7 +90,7 @@ class Bisection
I[0] = x;
I[1] = dom.projectFromAbove(I[0] - DJ[1]);
DJ = J.subDifferential(I[1]);
DJ = Dune::TNNMG::subDifferential(J, I[1]);
++count;
while (DJ[1] < -safety_)
{
......@@ -99,7 +100,7 @@ class Bisection
I[1] = dom[1];
break;
}
DJ = J.subDifferential(I[1]);
DJ = Dune::TNNMG::subDifferential(J, I[1]);
++count;
}
}
......@@ -145,13 +146,13 @@ class Bisection
++n;
// evaluate subdifferential
DJ = J.subDifferential(x);
DJ = Dune::TNNMG::subDifferential(J, x);
++count;
if (verbosity>0)
{
Dune::Solvers::Interval<double> DJ0 = J.subDifferential(I[0]);
Dune::Solvers::Interval<double> DJ1 = J.subDifferential(I[1]);
Dune::Solvers::Interval<double> DJ0 = Dune::TNNMG::subDifferential(J, I[0]);
Dune::Solvers::Interval<double> DJ1 = Dune::TNNMG::subDifferential(J, I[1]);
const std::streamsize p = std::cout.precision();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment