1#ifndef HOMOTOPY_BASE_HH
2#define HOMOTOPY_BASE_HH
9#include "dune/grid/config.h"
15#include <boost/timer/timer.hpp>
24class InteriorPointSqrtModel;
32 InteriorPointParameters(
double mu_,
double desiredAccuracy_,
double desiredContraction_,
int maxSteps_,
double muFinal_,
double relDist,
double accfinal_,
33 double reductionStart_,
double reductionFactorBest_,
double redWorst_=1-1e-4)
164 bool stepSuccessful();
166 void computeCorrector();
167 void computeGapParameter();
243 normPlain(normPlain_)
245 if(!normPlain) normPlain = &norm;
268 std::unique_ptr<AbstractFunctionSpaceElement> iterate;
276 boost::timer::cpu_timer overalltime;
289template<
class Equation>
290double bisection(
double a,
double b, Equation
const& f,
double accuracy,
int& iterations)
298 if(f(u) > 0) b=u;
else a=u;
300 while(b-a >= accuracy && (a+b)/2 != a && (a+b)/2 != b && iterations<50);
301 if(iterations > 48) std::cout <<
"Warning: bisection algorithm performed > 48 iterations" << std::endl;
316 normPlain(normPlain_),
317 finalsolver(finalsolver_)
319 if(!normPlain_) normPlain=&norm;
371 std::unique_ptr<AbstractFunctionSpaceElement> iterate, tangent;
381 boost::timer::cpu_timer overalltime;
Interfaces for function space oriented algorithms.
Abstract Vector for function space algorithms.
Class that models the functionality of a (possibly inexact) linear solver.
Creates a functional from a homotopy of functionals by inserting a parameter.
Base class for algorithms. Provides a unified interface and some simple wrapper routines,...
Base class for homotopy methods. Here, the main algorithm is programmed.
virtual double lengthOfPath()=0
estimate of length of homopoty path
std::unique_ptr< AbstractFunctionSpaceElement > trialIterate
AbstractParameterFunctional * functional
virtual void finalizeCorrector()=0
what should be done after corrector
InteriorPointParameters & p
virtual int convergenceTest()
convergence test. returns true if method converged and solution is found.
virtual void finalizeHomotopy()
to be performed, if convergence of path has occured
void solve(AbstractParameterFunctional *f, AbstractFunctionSpaceElement &x)
virtual void terminationMessage(int errorFlag)
output of a termination message
virtual void finalize()
Optional overload by derived class.
virtual void updateModelOfHomotopy(int step)=0
update of path parameters, e.g. eta and omega
virtual void recoverIterate()=0
make old iterate to current iterate (on failed corrector)
NewtonsMethod & corrector
virtual double muOnSuccess(int step)=0
New mu if corrector was successful.
virtual void computePredictor(int step)
Default: classical predictor.
HomotopyBase(NewtonsMethod &n_, InteriorPointParameters &p_)
virtual void updateIterate()=0
make trial iterate to current iterate (on successful corrector)
virtual double muOnFailure()=0
New mu if corrector failed.
virtual void logQuantities()
virtual void initialize()
Optional overload by derived class.
virtual double muFinal()=0
mu for successful termination
virtual void initializeCorrector()=0
what should be done before corrector
LoggedQuantity< double > muTrial
LoggedQuantity< double > mu
LoggedQuantity< double > sigma
virtual ~InteriorPointParameters()
LoggedQuantity< double > j
LoggedQuantity< double > jp
virtual void doForAll(LQAction::ToDo td)
To be overloaded by derived class.
double reductionFactorBest
void reset()
Reset all quantities in this class.
double reductionFactorWorst
LoggedQuantity< double > deltaMu
InteriorPointParameters(double mu_, double desiredAccuracy_, double desiredContraction_, int maxSteps_, double muFinal_, double relDist, double accfinal_, double reductionStart_, double reductionFactorBest_, double redWorst_=1-1e-4)
double desiredContraction
double firstStepFailureFactor
InteriorPointParametersSqrt()
LoggedQuantity< int > newtonSum
LoggedQuantity< double > omega
virtual void doForAll(LQAction::ToDo td)
To be overloaded by derived class.
virtual ~InteriorPointParametersSqrt()
LoggedQuantity< double > jpl
LoggedQuantity< double > curvature
LoggedQuantity< double > slope
LoggedQuantity< double > accuracyCorrector
LoggedQuantity< double > eta
LoggedQuantity< double > timemeasured
Very simple implementation of homotopy method: fixed stepsize.
virtual double muFinal()
mu for successful termination
virtual void finalizeCorrector()
what should be done after corrector
virtual void initializeCorrector()
what should be done before corrector
InteriorPointSimple(NewtonsMethod &n_, InteriorPointParameters &p_)
virtual double lengthOfPath()
estimate of length of homopoty path
virtual void updateModelOfHomotopy(int step)
update of path parameters, e.g. eta and omega
virtual double muOnFailure()
New mu if corrector failed.
virtual double muOnSuccess(int step)
New mu if corrector was successful.
virtual void updateIterate()
make trial iterate to current iterate (on successful corrector)
virtual void recoverIterate()
make old iterate to current iterate (on failed corrector)
virtual void updateIterate()
make trial iterate to current iterate (on successful corrector)
virtual void finalize()
Optional overload by derived class.
virtual void updateModelOfHomotopy(int step)
update of path parameters, e.g. eta and omega
virtual void finalizeHomotopy()
to be performed, if convergence of path has occured
virtual void initialize()
Optional overload by derived class.
virtual double muFinal()
mu for successful termination
virtual double muOnSuccess(int step)
New mu if corrector was successful.
virtual void recoverIterate()
make old iterate to current iterate (on failed corrector)
virtual double muOnFailure()
New mu if corrector failed.
InteriorPointSlopeEstimate(NewtonsMethod &n_, AbstractNorm const &norm_, InteriorPointParameters &p_, AbstractNewtonDirection &solver_, AbstractNorm const *normPlain_=0, NewtonsMethod *finalsolver_=0)
virtual void initializeCorrector()
what should be done before corrector
virtual void finalizeCorrector()
what should be done after corrector
virtual void logQuantities()
virtual double lengthOfPath()
estimate of length of homopoty path
virtual void computePredictor(int step)
Default: classical predictor.
InteriorPointMethod with a sqrt-model of the path: eta ~ mu^{-1/2}, omega ~mu^{-1/2}.
InteriorPointSqrtModel(NewtonsMethod &n_, AbstractNorm const &norm_, InteriorPointParameters &p_, AbstractNewtonDirection &solver_, AbstractNorm const *normPlain_=0)
virtual void logQuantities()
virtual void recoverIterate()
make old iterate to current iterate (on failed corrector)
virtual void initialize()
Optional overload by derived class.
virtual void initializeCorrector()
what should be done before corrector
virtual double lengthOfPath()
estimate of length of homopoty path
virtual double muFinal()
mu for successful termination
virtual void finalizeCorrector()
what should be done after corrector
virtual void updateIterate()
make trial iterate to current iterate (on successful corrector)
virtual double muOnSuccess(int step)
New mu if corrector was successful.
virtual double muOnFailure()
New mu if corrector failed.
virtual void updateModelOfHomotopy(int step)
update of path parameters, e.g. eta and omega
Base class for algorithmic parameters.
virtual void reset()
Reset all quantities in this class.
virtual void doForAll(LQAction::ToDo td)
To be overloaded by derived class.
void doAction(LQAction::ToDo td, std::string const &name_="noName")
bool isValid()
Returns true, iff there is a valid current value.
Base class for Newton's method. Defines the main algorithm, potentially using damping.
Some model functions for various purposes.
double bisection(double a, double b, Equation const &f, double accuracy, int &iterations)
Performs bisection algorithm to find a zero of a.