Commit 0768e2a0 authored by steffen.schotthoefer's avatar steffen.schotthoefer
Browse files

Newton framework in progress

parent 8d9ecf12
#ifndef ENTROPYFUNCTIONAL_H
#define ENTROPYFUNCTIONAL_H
class EntropyFunctionalBase
{
public:
EntropyFunctionalBase() {}
static EntropyFunctionalBase* CreateEntropyFunctional();
/*! \brief: Computes the value of the specific entropy functional. */
double virtual ComputeEntropy( double x ) = 0;
/*! \brief: Computes the sensitivity value of the specific entropy functional. */
double virtual ComputeEntropySens( double x ) = 0;
/*! \brief: Computes the value of the Legendre dual of the specific entropy functional. */
double virtual ComputeLegendreDual( double x ) = 0;
/*! \brief: Computes the sensitivity value ofthe Legendre dual of the specific entropy functional. */
double virtual ComputeLegendreDualSens( double x ) = 0;
protected:
};
class QuadraticEntropy : EntropyFunctionalBase
{
public:
QuadraticEntropy() {}
/*! \brief: Computes the value of the specific entropy functional. */
double ComputeEntropy( double x ) override { return 0.5 * x * x; }
/*! \brief: Computes the sensitivity value of the specific entropy functional. */
double virtual ComputeEntropySens( double x ) override { return x; }
/*! \brief: Computes the value of the Legendre dual of the specific entropy functional. */
double virtual ComputeLegendreDual( double x ) override { return 0.5 * x * x; }
/*! \brief: Computes the sensitivity value ofthe Legendre dual of the specific entropy functional. */
double virtual ComputeLegendreDualSens( double x ) override { return x; }
protected:
};
#endif // ENTROPYFUNCTIONAL_H
#ifndef MOMENTBASIS_H
#define MOMENTBASIS_H
class MomentBasis
{
public:
MomentBasis() {}
static double p_0( double v ) { return 1; }
static double p_1( double v ) { return v; }
static double p_2( double v ) { return 0.5 * v * v; }
};
#endif // MOMENTBASIS_H
#ifndef NEWTONOPTIMIZER_H
#define NEWTONOPTIMIZER_H
#include "entropyfunctional.h"
#include "settings/config.h"
#include <vector>
class NewtonOptimizer
{
public:
NewtonOptimizer( Config* settings );
/*! \brief: Solves the optimization problem for given moments*/
Solve( std::vector<std::vector<double>> moments );
/*! \brief Get pointer to solution vector for each cell */
std::vector<std::vector<double>>* GetSolution(){ return &_lambda };
protected:
Config* _settings; /*! \brief: Settings file */
EntropyFunctionalBase _entropyFunctional; /*! \brief: entropy functional */
std::vector<std::vector<double>> _lambda; /*! \brief: Solution of the optimization problem */
int _nCells; /*! \brief: Number of cells, i.e. outer length of vectorvector _lambda */
int _nMomentEq; /*! \brief: Number of moment equations, i.e. length of vector _lambda per cell */
};
#endif // NEWTONOPTIMIZER_H
#ifndef NEWTONOPTIMIZER_H
#define NEWTONOPTIMIZER_H
#include <vector>
#include "settings/config.h"
class NewtonOptimizer
{
public:
NewtonOptimizer();
/*! \brief: Solves the optimization problem for given moments*/
Solve(std::vector<std::vector<double>> moments);
/*! \brief Get pointer to solution vector for each cell */
std::vector<std::vector<double>> * GetSolution(){return &_lambda};
protected:
std::vector<std::vector<double>> _lambda; /*! \brief: Solution of the optimization problem */
};
#endif // NEWTONOPTIMIZER_H
#include "entropyfunctional.h"
EntropyFunctionalBase::CreateEntropyFunctional() {
return new QuadraticEntropy();
// switch( name ) TODO: Implement other entropy functionals.
}
#include "momentbasis.h"
MomentBasisBase::MomentBasisBase() {}
#include "newtonoptimizer.h"
NewtonOptimizer::NewtonOptimizer( Config* settings ) {
_settings = settings;
_entropyFunctional = EntropyFunctionalBase::CreateEntropyFunctional();
_nCells = 0; // Dummy value
_nMomentEq = 0; // Dummy value
}
NewtonOptimizer::Solve( std::vector<std::vector<double>> moments ) {
double objFunc = 0.0;
double objFuncSens = 0.0;
return 0;
}
#include "newtonoptimizer.h"
NewtonOptimizer::NewtonOptimizer()
{
}
Supports Markdown
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