Path: blob/devel/ElmerGUI/netgen/libsrc/opti/opti.hpp
3206 views
#ifndef FILE_OPTI1#define FILE_OPTI23/**************************************************************************/4/* File: opti.hpp */5/* Author: Joachim Schoeberl */6/* Date: 01. Jun. 95 */7/**************************************************************************/891011namespace netgen12{1314/**15Function to be minimized.16*/17class MinFunction18{19public:20///21virtual double Func (const Vector & x) const;22///23virtual void Grad (const Vector & x, Vector & g) const;24/// function and gradient25virtual double FuncGrad (const Vector & x, Vector & g) const;26/// directional derivative27virtual double FuncDeriv (const Vector & x, const Vector & dir, double & deriv) const;28/// if |g| < gradaccuray, then stop bfgs29virtual double GradStopping (const Vector & /* x */) const { return 0; }3031///32virtual void ApproximateHesse (const Vector & /* x */,33DenseMatrix & /* hesse */) const;34};353637class OptiParameters38{39public:40int maxit_linsearch;41int maxit_bfgs;42double typf;43double typx;4445OptiParameters ()46{47maxit_linsearch = 100;48maxit_bfgs = 100;49typf = 1;50typx = 1;51}52};535455/** Implementation of BFGS method.56Efficient method for non-linear minimiztion problems.57@param x initial value and solution58@param fun function to be minimized59*/60extern double BFGS (Vector & x, const MinFunction & fun,61const OptiParameters & par,62double eps = 1e-8);6364/** Steepest descent method.65Simple method for non-linear minimization problems.66@param x initial value and solution67@param fun function to be minimized68*/69void SteepestDescent (Vector & x, const MinFunction & fun,70const OptiParameters & par);717273extern void lines (74Vector & x, // i: Ausgangspunkt der Liniensuche75Vector & xneu, // o: Loesung der Liniensuche bei Erfolg76Vector & p, // i: Suchrichtung77double & f, // i: Funktionswert an der Stelle x78// o: Funktionswert an der Stelle xneu, falls ifail = 079Vector & g, // i: Gradient an der Stelle x80// o: Gradient an der Stelle xneu, falls ifail = 08182const MinFunction & fun, // function to minmize83const OptiParameters & par, // parameters84double & alphahat, // i: Startwert f�r alpha_hat85// o: Loesung falls ifail = 086double fmin, // i: untere Schranke f�r f87double mu1, // i: Parameter mu_1 aus Alg.2.188double sigma, // i: Parameter sigma aus Alg.2.189double xi1, // i: Parameter xi_1 aus Alg.2.190double xi2, // i: Parameter xi_1 aus Alg.2.191double tau, // i: Parameter tau aus Alg.2.192double tau1, // i: Parameter tau_1 aus Alg.2.193double tau2, // i: Parameter tau_2 aus Alg.2.194int & ifail); // o: 0 bei erfolgreicher Liniensuche95// -1 bei Abbruch wegen Unterschreiten von fmin96// 1 bei Abbruch, aus sonstigen Gr�nden979899100101/**102Solver for linear programming problem.103104\begin{verbatim}105min c^t x106A x <= b107\end{verbatim}108*/109extern void LinearOptimize (const DenseMatrix & a, const Vector & b,110const Vector & c, Vector & x);111112113#ifdef NONE114115/**116Simple projection iteration.117118find $u = argmin_{v >= 0} 0.5 u A u - f u$119*/120extern void ApproxProject (const BaseMatrix & a, Vector & u,121const Vector & f,122double tau, int its);123124125/**126CG Algorithm for quadratic programming problem.127See: Dostal ...128129d ... diag(A) ^{-1}130*/131extern void ApproxProjectCG (const BaseMatrix & a, Vector & x,132const Vector & b, const class DiagMatrix & d,133double gamma, int & steps, int & changes);134135#endif136137138}139140#endif141142143144