Skip to content
Snippets Groups Projects
Commit b195c86a authored by Sander, Oliver's avatar Sander, Oliver
Browse files

Collect some statistics about trust-region runs

Automatic testing of the RiemannianTrustRegionSolver class requires
to know what it did on the previous run.  This patch adds
some infrastructure to collect this information.
parent 18b28b45
No related branches found
No related tags found
1 merge request!25Harmonicmap integration test
...@@ -351,7 +351,8 @@ void RiemannianTrustRegionSolver<Basis,TargetSpace>::solve() ...@@ -351,7 +351,8 @@ void RiemannianTrustRegionSolver<Basis,TargetSpace>::solve()
localMapper, localMapper,
0); 0);
#endif #endif
for (int i=0; i<maxTrustRegionSteps_; i++) { auto& i = statistics_.finalIteration;
for (i=0; i<maxTrustRegionSteps_; i++) {
/* std::cout << "current iterate:\n"; /* std::cout << "current iterate:\n";
for (size_t j=0; j<x_.size(); j++) for (size_t j=0; j<x_.size(); j++)
...@@ -643,4 +644,6 @@ void RiemannianTrustRegionSolver<Basis,TargetSpace>::solve() ...@@ -643,4 +644,6 @@ void RiemannianTrustRegionSolver<Basis,TargetSpace>::solve()
// ////////////////////////////////////////////// // //////////////////////////////////////////////
if (instrumented_) if (instrumented_)
fclose(fp); fclose(fp);
statistics_.finalEnergy = oldEnergy;
} }
...@@ -92,6 +92,16 @@ class RiemannianTrustRegionSolver ...@@ -92,6 +92,16 @@ class RiemannianTrustRegionSolver
typedef typename MapperFactory<typename Basis::GridView,Basis>::LocalMapper LocalMapper; typedef typename MapperFactory<typename Basis::GridView,Basis>::LocalMapper LocalMapper;
#endif #endif
/** \brief Records information about the last run of the RiemannianTrustRegionSolver
*
* This is used primarily for unit testing.
*/
struct Statistics
{
std::size_t finalIteration;
field_type finalEnergy;
};
public: public:
...@@ -144,6 +154,8 @@ public: ...@@ -144,6 +154,8 @@ public:
SolutionType getSol() const {return x_;} SolutionType getSol() const {return x_;}
const Statistics& getStatistics() const {return statistics_;}
protected: protected:
#if HAVE_MPI #if HAVE_MPI
...@@ -163,7 +175,7 @@ protected: ...@@ -163,7 +175,7 @@ protected:
Dune::FieldVector<double,blocksize> scaling_; Dune::FieldVector<double,blocksize> scaling_;
/** \brief Maximum number of trust-region steps */ /** \brief Maximum number of trust-region steps */
int maxTrustRegionSteps_; std::size_t maxTrustRegionSteps_;
/** \brief Maximum number of multigrid iterations */ /** \brief Maximum number of multigrid iterations */
int innerIterations_; int innerIterations_;
...@@ -195,6 +207,8 @@ protected: ...@@ -195,6 +207,8 @@ protected:
/** \brief If set to true we log convergence speed and other stuff */ /** \brief If set to true we log convergence speed and other stuff */
bool instrumented_; bool instrumented_;
/** \brief Store information about solver runs for unit testing */
Statistics statistics_;
}; };
#include "riemanniantrsolver.cc" #include "riemanniantrsolver.cc"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment