Skip to content

Commit

Permalink
Moved SGPP::pde::RegularizationConfiguration to datadriven
Browse files Browse the repository at this point in the history
git-svn-id: https://ipvs.informatik.uni-stuttgart.de/SGpp/repos/trunk@5521 4eea3252-f0fb-4393-894d-40516dce545b
  • Loading branch information
Sekuraz committed Feb 8, 2016
1 parent 60b74d2 commit 43dfa25
Show file tree
Hide file tree
Showing 24 changed files with 487 additions and 491 deletions.
3 changes: 2 additions & 1 deletion datadriven/build/jsgpp/datadriven.i
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// sgpp.sparsegrids.org

%{
#include <sgpp/pde/application/RegularizationConfiguration.hpp>
#include <sgpp/solver/TypesSolver.hpp>
%}

Expand Down Expand Up @@ -45,6 +44,8 @@
%include "datadriven/src/sgpp/datadriven/operation/hash/simple/OperationDensityMarginalizeKDE.hpp"
%include "datadriven/src/sgpp/datadriven/operation/hash/simple/OperationDensityConditionalKDE.hpp"

%include "datadriven/src/sgpp/datadriven/application/RegularizationConfiguration.hpp"

//- namespace datadriven ------------------------------------------
namespace datadriven {
/*%nodefaultdtor SGPP::datadriven::OperationTest;
Expand Down
3 changes: 2 additions & 1 deletion datadriven/build/pysgpp/datadriven.i
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// sgpp.sparsegrids.org

%{
#include <sgpp/pde/application/RegularizationConfiguration.hpp>
#include <sgpp/solver/TypesSolver.hpp>
%}

Expand Down Expand Up @@ -46,6 +45,8 @@
%include "datadriven/src/sgpp/datadriven/operation/hash/simple/OperationDensityMarginalizeKDE.hpp"
%include "datadriven/src/sgpp/datadriven/operation/hash/simple/OperationDensityConditionalKDE.hpp"

%include "datadriven/src/sgpp/datadriven/application/RegularizationConfiguration.hpp"

//- namespace datadriven ------------------------------------------
namespace datadriven {
/*%nodefaultdtor SGPP::datadriven::OperationTest;
Expand Down
6 changes: 3 additions & 3 deletions datadriven/examples/learnerSGDETest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <sgpp/datadriven/tools/ARFFTools.hpp>
#include <sgpp/datadriven/application/LearnerSGDE.hpp>
#include <sgpp/base/grid/Grid.hpp>
#include <sgpp/pde/application/RegularizationConfiguration.hpp>
#include <sgpp/datadriven/application/RegularizationConfiguration.hpp>
#include <sgpp/datadriven/application/LearnerSGDE.hpp>
#include <sgpp/datadriven/application/GaussianKDE.hpp>
#include <sgpp/globaldef.hpp>
Expand Down Expand Up @@ -44,8 +44,8 @@ int main(int argc, char** argv) {

// configure regularization
cout << "# create regularization config" << endl;
SGPP::pde::RegularizationConfiguration regularizationConfig;
regularizationConfig.regType_ = SGPP::pde::RegularizationType::Laplace;
SGPP::datadriven::RegularizationConfiguration regularizationConfig;
regularizationConfig.regType_ = SGPP::datadriven::RegularizationType::Laplace;

// configure learner
cout << "# create learner config" << endl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ int main(int argc, char** argv) {
solverConfig.threshold_ = -1.0;
solverConfig.type_ = SGPP::solver::SLESolverType::CG;

SGPP::pde::RegularizationConfiguration regularizationConfig;
regularizationConfig.regType_ = SGPP::pde::RegularizationType::Laplace;
SGPP::datadriven::RegularizationConfiguration regularizationConfig;
regularizationConfig.regType_ = SGPP::datadriven::RegularizationType::Laplace;

bool verbose = true;

Expand Down
4 changes: 2 additions & 2 deletions datadriven/examples/piecewiseSmoothingRegressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ int main(int argc, char** argv) {
solverConfig.threshold_ = -1.0;
solverConfig.type_ = SGPP::solver::SLESolverType::CG;

SGPP::pde::RegularizationConfiguration regularizationConfig;
regularizationConfig.regType_ = SGPP::pde::RegularizationType::Laplace;
SGPP::datadriven::RegularizationConfiguration regularizationConfig;
regularizationConfig.regType_ = SGPP::datadriven::RegularizationType::Laplace;

// SGPP::float_t lambda = 0.1;
SGPP::float_t lambda = 0.0005;
Expand Down
8 changes: 4 additions & 4 deletions datadriven/src/sgpp/datadriven/application/Learner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
namespace SGPP {
namespace datadriven {

Learner::Learner(SGPP::pde::RegularizationType& regularization,
Learner::Learner(SGPP::datadriven::RegularizationType& regularization,
const bool isRegression, const bool verbose)
: LearnerBase(isRegression, verbose), CMode_(regularization), C_(NULL) {
}

Learner::Learner(const std::string tGridFilename,
const std::string tAlphaFilename, SGPP::pde::RegularizationType& regularization,
const std::string tAlphaFilename, SGPP::datadriven::RegularizationType& regularization,
const bool isRegression, const bool verbose)
: LearnerBase(tGridFilename, tAlphaFilename, isRegression, verbose),
CMode_(regularization), C_(NULL) {
Expand All @@ -42,9 +42,9 @@ SGPP::datadriven::DMSystemMatrixBase* Learner::createDMSystem(
if (C_ != NULL)
delete C_;

if (this->CMode_ == pde::RegularizationType::Laplace) {
if (this->CMode_ == datadriven::RegularizationType::Laplace) {
C_ = SGPP::op_factory::createOperationLaplace(*this->grid_);
} else if (this->CMode_ == pde::RegularizationType::Identity) {
} else if (this->CMode_ == datadriven::RegularizationType::Identity) {
C_ = SGPP::op_factory::createOperationIdentity(*this->grid_);
} else {
// should not happen
Expand Down
8 changes: 4 additions & 4 deletions datadriven/src/sgpp/datadriven/application/Learner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#define LEARNER_HPP

#include <sgpp/datadriven/application/LearnerBase.hpp>
#include <sgpp/pde/application/RegularizationConfiguration.hpp>
#include <sgpp/datadriven/application/RegularizationConfiguration.hpp>
#include <sgpp/globaldef.hpp>


Expand All @@ -22,7 +22,7 @@ namespace datadriven {
class Learner : public LearnerBase {
protected:
/// regularization mode
SGPP::pde::RegularizationType CMode_;
SGPP::datadriven::RegularizationType CMode_;
/// regularization operator
SGPP::base::OperationMatrix* C_;

Expand All @@ -38,7 +38,7 @@ class Learner : public LearnerBase {
* @param isRegression flag for regression
* @param isVerbose flag for verbose output
*/
Learner(SGPP::pde::RegularizationType& regularization, const bool isRegression,
Learner(SGPP::datadriven::RegularizationType& regularization, const bool isRegression,
const bool isVerbose = true);

/**
Expand All @@ -51,7 +51,7 @@ class Learner : public LearnerBase {
* @param isVerbose set to true in order to allow console output
*/
Learner(const std::string tGridFilename, const std::string tAlphaFilename,
SGPP::pde::RegularizationType& regularization,
SGPP::datadriven::RegularizationType& regularization,
const bool isRegression, const bool isVerbose = true);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace SGPP {

namespace datadriven {

LearnerDensityBased::LearnerDensityBased(SGPP::pde::RegularizationType&
LearnerDensityBased::LearnerDensityBased(SGPP::datadriven::RegularizationType&
regularization, const bool isRegression,
const bool isVerbose) :
LearnerBase(isRegression, isVerbose), CMode_(regularization) {
Expand Down Expand Up @@ -257,9 +257,9 @@ LearnerTiming LearnerDensityBased::train(SGPP::base::DataMatrix& trainDataset,
}

for (size_t ii = 0; ii < class_indeces.size(); ii++) {
if (this->CMode_ == SGPP::pde::RegularizationType::Laplace) {
if (this->CMode_ == SGPP::datadriven::RegularizationType::Laplace) {
CVec_.push_back(SGPP::op_factory::createOperationLaplace(*this->gridVec_[ii]));
} else if (this->CMode_ == SGPP::pde::RegularizationType::Identity) {
} else if (this->CMode_ == SGPP::datadriven::RegularizationType::Identity) {
CVec_.push_back(SGPP::op_factory::createOperationIdentity(*this->gridVec_[ii]));
} else {
throw base::application_exception("LearnerDensityBased::train: Unknown regularization operator");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <sgpp/datadriven/application/Learner.hpp>
#include <sgpp/base/grid/type/LinearGrid.hpp>
#include <sgpp/base/grid/type/ModLinearGrid.hpp>
#include <sgpp/pde/application/RegularizationConfiguration.hpp>
#include <sgpp/datadriven/application/RegularizationConfiguration.hpp>

#include <sgpp/globaldef.hpp>
#include <sgpp/base/grid/type/LinearBoundaryGrid.hpp>
Expand All @@ -28,7 +28,7 @@ class LearnerDensityBased: public SGPP::datadriven::LearnerBase {
//Stores the coefficients for every class
std::vector<SGPP::base::DataVector> alphaVec_;
/// regularization mode
SGPP::pde::RegularizationType CMode_;
SGPP::datadriven::RegularizationType CMode_;
//with prior
bool withPrior;
//number of classes
Expand All @@ -40,7 +40,7 @@ class LearnerDensityBased: public SGPP::datadriven::LearnerBase {
// vector of regterms
std::vector<SGPP::base::OperationMatrix*> CVec_;
public:
LearnerDensityBased(SGPP::pde::RegularizationType&, const bool isRegression,
LearnerDensityBased(SGPP::datadriven::RegularizationType&, const bool isRegression,
const bool isVerbose = true);
virtual ~LearnerDensityBased();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace SGPP {
namespace datadriven {

LearnerDensityBasedReg::LearnerDensityBasedReg(
SGPP::pde::RegularizationType& regularization,
SGPP::datadriven::RegularizationType& regularization,
float_t border) :
LearnerBase(true), CMode_(regularization), C_(NULL), maxValue_(0.), minValue_(
0.), border_(border) {
Expand Down Expand Up @@ -165,9 +165,9 @@ LearnerTiming LearnerDensityBasedReg::train(SGPP::base::DataMatrix&
if (C_ != NULL)
delete C_;

if (this->CMode_ == SGPP::pde::RegularizationType::Laplace) {
if (this->CMode_ == SGPP::datadriven::RegularizationType::Laplace) {
C_ = SGPP::op_factory::createOperationLaplace(*grid_);
} else if (this->CMode_ == SGPP::pde::RegularizationType::Identity) {
} else if (this->CMode_ == SGPP::datadriven::RegularizationType::Identity) {
C_ = SGPP::op_factory::createOperationIdentity(*grid_);
} else {
// should not happen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <sgpp/datadriven/application/LearnerBase.hpp>
#include <sgpp/datadriven/application/Learner.hpp>
#include <sgpp/pde/application/RegularizationConfiguration.hpp>
#include <sgpp/datadriven/application/RegularizationConfiguration.hpp>

#include <string>

Expand All @@ -33,7 +33,7 @@ class LearnerDensityBasedReg: public LearnerBase {
* @param border offset for the normalization of the class data
*/
LearnerDensityBasedReg(
SGPP::pde::RegularizationType& regularization,
SGPP::datadriven::RegularizationType& regularization,
float_t border = 0.);

/**
Expand Down Expand Up @@ -83,7 +83,7 @@ class LearnerDensityBasedReg: public LearnerBase {

protected:
/// regularization mode
SGPP::pde::RegularizationType CMode_;
SGPP::datadriven::RegularizationType CMode_;
/// regularization operator
SGPP::base::OperationMatrix* C_;
/// maximum value (used for de-normalization)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ LearnerPiecewiseConstantSmoothedRegression::LearnerPiecewiseConstantSmoothedRegr
SGPP::base::RegularGridConfiguration& gridConfig,
SGPP::base::AdpativityConfiguration& adaptivityConfig,
SGPP::solver::SLESolverConfiguration& solverConfig,
SGPP::pde::RegularizationConfiguration& regularizationConfig, bool verbose) :
SGPP::datadriven::RegularizationConfiguration& regularizationConfig, bool verbose) :
gridConfig(gridConfig), adaptivityConfig(adaptivityConfig),
solverConfig(solverConfig), regularizationConfig(
regularizationConfig), verbose(verbose) {
Expand Down Expand Up @@ -127,10 +127,10 @@ LearnerPiecewiseConstantSmoothedRegression::computeRegularizationMatrix(
SGPP::base::Grid& grid) {
OperationMatrix* C = NULL;

if (regularizationConfig.regType_ == SGPP::pde::RegularizationType::Identity) {
if (regularizationConfig.regType_ == SGPP::datadriven::RegularizationType::Identity) {
C = SGPP::op_factory::createOperationIdentity(grid);
} else if (regularizationConfig.regType_ ==
SGPP::pde::RegularizationType::Laplace) {
SGPP::datadriven::RegularizationType::Laplace) {
C = SGPP::op_factory::createOperationLaplace(grid);
} else {
throw application_exception("LearnerDensityRegression::train : unknown regularization type");
Expand Down
Loading

0 comments on commit 43dfa25

Please sign in to comment.