Commit f1726817 authored by David Bommes's avatar David Bommes

changed Name NSolverGmmInterface -> NProblemGmmInterface

git-svn-id: http://www.openflipper.org/svnrepo/CoMISo/trunk@62 1355f012-dd97-4b2f-ae87-10fa9f823a57
parent 13f8bcec
......@@ -16,7 +16,7 @@
#include <ACG/Utils/StopWatch.hh>
#include <gmm/gmm.h>
#include "NSolverGmmInterface.hh"
#include "NProblemGmmInterface.hh"
//== FORWARDDECLARATIONS ======================================================
......@@ -56,14 +56,14 @@ public:
/// Destructor
~NPDerivativeChecker() {}
bool check_all(NSolverGmmInterface* _np, double _dx, double _eps)
bool check_all(NProblemGmmInterface* _np, double _dx, double _eps)
{
conf_.dx = _dx;
conf_.eps = _eps;
return check_all(_np);
}
bool check_all(NSolverGmmInterface* _np)
bool check_all(NProblemGmmInterface* _np)
{
bool d1_ok = check_d1(_np);
bool d2_ok = check_d2(_np);
......@@ -71,7 +71,7 @@ public:
return ( d1_ok && d2_ok);
}
bool check_d1(NSolverGmmInterface* _np)
bool check_d1(NProblemGmmInterface* _np)
{
int n_ok = 0;
int n_errors = 0;
......@@ -113,14 +113,14 @@ public:
return (n_errors == 0);
}
bool check_d2(NSolverGmmInterface* _np)
bool check_d2(NProblemGmmInterface* _np)
{
int n_ok = 0;
int n_errors = 0;
int n = _np->n_unknowns();
std::vector<double> x(n);
NSolverGmmInterface::SMatrixNS H(n,n);
NProblemGmmInterface::SMatrixNS H(n,n);
for(int i=0; i<conf_.n_iters; ++i)
{
......
......@@ -12,7 +12,7 @@
//== INCLUDES =================================================================
#include <gmm/gmm.h>
#include "NSolverGmmInterface.hh"
#include "NProblemGmmInterface.hh"
#include "LinearConstraintHandlerElimination.hh"
#include "LinearConstraintHandlerPenalty.hh"
//#include "LinearConstraintHandlerLagrange.hh"
......@@ -36,7 +36,7 @@ problem into an unconstrained one.
// ConstraintHandler working with Elimination approach
class NPLinearConstraintsElimination : public NSolverGmmInterface, public LinearConstraintHandlerElimination
class NPLinearConstraintsElimination : public NProblemGmmInterface, public LinearConstraintHandlerElimination
{
public:
......@@ -44,7 +44,7 @@ public:
typedef gmm::array1D_reference<double*> VectorPT;
/// Default constructor having a pointer to the main problem
NPLinearConstraintsElimination( NSolverGmmInterface* _np) : base_(_np), cache_initialized_(false)
NPLinearConstraintsElimination( NProblemGmmInterface* _np) : base_(_np), cache_initialized_(false)
{
if( !base_) std::cerr << "Warning: initialized NPLinearConstraints with zero pointer...\n";
this->initialize_identity(base_->n_unknowns());
......@@ -149,7 +149,7 @@ protected:
}
private:
NSolverGmmInterface* base_;
NProblemGmmInterface* base_;
bool cache_initialized_;
......@@ -163,7 +163,7 @@ private:
// ConstraintHandler working with Penalty
class NPLinearConstraintsPenalty : public NSolverGmmInterface, public LinearConstraintHandlerPenalty
class NPLinearConstraintsPenalty : public NProblemGmmInterface, public LinearConstraintHandlerPenalty
{
public:
......@@ -171,7 +171,7 @@ public:
typedef gmm::array1D_reference<double*> VectorPT;
/// Default constructor having a pointer to the main problem
NPLinearConstraintsPenalty( NSolverGmmInterface* _np) : base_(_np)
NPLinearConstraintsPenalty( NProblemGmmInterface* _np) : base_(_np)
{ if( !base_) std::cerr << "Warning: initialized NPLinearConstraints with zero pointer...\n"; }
/// Destructor
......@@ -216,7 +216,7 @@ public:
}
private:
NSolverGmmInterface* base_;
NProblemGmmInterface* base_;
};
......
......@@ -16,7 +16,7 @@
#include <ACG/Utils/StopWatch.hh>
#include <gmm/gmm.h>
#include "NSolverGmmInterface.hh"
#include "NProblemGmmInterface.hh"
//== FORWARDDECLARATIONS ======================================================
......@@ -28,18 +28,18 @@ namespace ACG {
/** \class NSolverGmmInterface NSolverGmmInterface.hh <ACG/.../NSolverGmmInterface.hh>
/** \class NProblemGmmInterface NProblemGmmInterface.hh <ACG/.../NProblemGmmInterface.hh>
Brief Description.
A more elaborate description follows.
*/
class NPTiming : public NSolverGmmInterface
class NPTiming : public NProblemGmmInterface
{
public:
/// Default constructor
NPTiming(NSolverGmmInterface* _base) : base_(_base) {start_timing();}
NPTiming(NProblemGmmInterface* _base) : base_(_base) {start_timing();}
/// Destructor
~NPTiming() {}
......@@ -125,7 +125,7 @@ protected:
}
private:
NSolverGmmInterface* base_;
NProblemGmmInterface* base_;
StopWatch swg_;
StopWatch sw_;
......
//=============================================================================
//
// CLASS BaseTaoGmmInterface
// CLASS NProblemGmmInterface
//
//=============================================================================
#ifndef ACG_NSOLVERGMMINTERFACE_HH
#define ACG_NSOLVERGMMINTERFACE_HH
#ifndef ACG_NPROBLEMGMMINTERFACE_HH
#define ACG_NPROBLEMGMMINTERFACE_HH
//== INCLUDES =================================================================
......@@ -23,13 +23,13 @@ namespace ACG {
/** \class NSolverGmmInterface NSolverGmmInterface.hh <ACG/.../NSolverGmmInterface.hh>
/** \class NProblemGmmInterface NProblemGmmInterface.hh <ACG/.../NPRoblemGmmInterface.hh>
Brief Description.
A more elaborate description follows.
*/
class NSolverGmmInterface
class NProblemGmmInterface
{
public:
......@@ -37,10 +37,10 @@ public:
typedef gmm::row_matrix< gmm::wsvector<double> > SMatrixNS;
/// Default constructor
NSolverGmmInterface() {}
NProblemGmmInterface() {}
/// Destructor
~NSolverGmmInterface() {}
~NProblemGmmInterface() {}
virtual int n_unknowns ( ) = 0;
virtual void initial_x ( double* _x ) = 0;
......@@ -54,6 +54,6 @@ public:
//=============================================================================
} // namespace ACG
//=============================================================================
#endif // ACG_NSOLVERGMMINTERFACE_HH defined
#endif // ACG_NROBLEMGMMINTERFACE_HH defined
//=============================================================================
......@@ -19,13 +19,13 @@ namespace ACG {
// solve
int
NewtonSolver::
solve(NSolverGmmInterface* _problem)
solve(NProblemGmmInterface* _problem)
{
// get problem size
int n = _problem->n_unknowns();
// hesse matrix
NSolverGmmInterface::SMatrixNS H;
NProblemGmmInterface::SMatrixNS H;
// gradient
std::vector<double> x(n), x_new(n), dx(n), g(n);
......
......@@ -12,7 +12,7 @@
//== INCLUDES =================================================================
#include <gmm/gmm.h>
#include "NSolverGmmInterface.hh"
#include "NProblemGmmInterface.hh"
//== FORWARDDECLARATIONS ======================================================
......@@ -41,10 +41,10 @@ public:
~NewtonSolver() {}
// solve
int solve(NSolverGmmInterface* _problem);
int solve(NProblemGmmInterface* _problem);
// solve specifying parameters
int solve(NSolverGmmInterface* _problem, int _max_iter, double _eps)
int solve(NProblemGmmInterface* _problem, int _max_iter, double _eps)
{
max_iter_ = _max_iter;
convergence_eps_ = _eps;
......
......@@ -28,7 +28,7 @@ bool TAOSolver::initialized_ = false;
int
TAOSolver::
solve( NSolverGmmInterface* _base)
solve( NProblemGmmInterface* _base)
{
// // initialize (only once)
// initialize();
......@@ -141,7 +141,7 @@ int
TAOSolver::
objective( TAO_APPLICATION _app, Vec _x, double* _result, void* _base)
{
NSolverGmmInterface* base = (NSolverGmmInterface*) _base;
NProblemGmmInterface* base = (NProblemGmmInterface*) _base;
PetscScalar *x;
......@@ -165,7 +165,7 @@ int
TAOSolver::
gradient(TAO_APPLICATION _app, Vec _x, Vec _g, void* _base)
{
NSolverGmmInterface* base = (NSolverGmmInterface*) _base;
NProblemGmmInterface* base = (NProblemGmmInterface*) _base;
PetscScalar *x, *g;
int info;
......@@ -192,7 +192,7 @@ int
TAOSolver::
hessian(TAO_APPLICATION _app, Vec _x, Mat* _H, Mat* _H_pre, MatStructure* _H_struct, void* _base)
{
NSolverGmmInterface* base = (NSolverGmmInterface*) _base;
NProblemGmmInterface* base = (NProblemGmmInterface*) _base;
PetscScalar *x;
......@@ -203,12 +203,12 @@ hessian(TAO_APPLICATION _app, Vec _x, Mat* _H, Mat* _H_pre, MatStructure* _H_str
info = MatZeroEntries(*_H); CHKERRQ(info);
// iterate over non-zero elements
NSolverGmmInterface::SMatrixNS H;
NProblemGmmInterface::SMatrixNS H;
base->eval_hessian( x, H);
for (unsigned int i = 0; i < gmm::mat_nrows(H); ++i)
{
typedef gmm::linalg_traits<NSolverGmmInterface::SMatrixNS>::const_sub_row_type
typedef gmm::linalg_traits<NProblemGmmInterface::SMatrixNS>::const_sub_row_type
CRow;
CRow row = gmm::mat_const_row(H, i);
......
......@@ -18,7 +18,7 @@
#include <tao.h>
#include <gmm/gmm.h>
#include "NSolverGmmInterface.hh"
#include "NProblemGmmInterface.hh"
//== FORWARDDECLARATIONS ======================================================
......@@ -47,7 +47,7 @@ public:
~TAOSolver() {}
// solve problem
static int solve( NSolverGmmInterface* _base);
static int solve( NProblemGmmInterface* _base);
private:
......
//=============================================================================
//
// CLASS BaseTaoGmmInterface
//
//=============================================================================
#ifndef ACG_TESTINTERFACE_HH
#define ACG_TESTINTERFACE_HH
//== INCLUDES =================================================================
#include "NProblemGmmInterface.hh"
#include <gmm/gmm.h>
//== FORWARDDECLARATIONS ======================================================
//== NAMESPACES ===============================================================
namespace ACG {
//== CLASS DEFINITION =========================================================
/** \class BaseTaoGmmInterface BaseTaoGmmInterface.hh <ACG/.../BaseTaoGmmInterface.hh>
Brief Description.
A more elaborate description follows.
*/
class TestInterface : public NProblemGmmInterface
{
public:
/// Default constructor
TestInterface() {}
/// Destructor
~TestInterface() {}
// minimize (x-2.4)^2
virtual int n_unknowns ( )
{
return 1;
}
virtual void initial_x ( double* _x )
{
_x[0] = 100;
}
virtual double eval_f ( const double* _x )
{
return (_x[0]-2.4)*(_x[0]-2.4);
}
virtual void eval_gradient( const double* _x, double* _g)
{
_g[0] = 2.0*(_x[0]-2.4);
}
virtual void eval_hessian( const double* _x, SMatrixNS& _H)
{
gmm::resize(_H,1,1);
_H(0,0) = 2.0;
}
virtual void store_result ( const double* _x )
{
std::cerr << "result: " << _x[0] << std::endl;
}
};
//=============================================================================
} // namespace ACG
//=============================================================================
#endif // ACG_TESTINTERFACE_HH defined
//=============================================================================
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