Skip to content

Commit

Permalink
Fix compact modeling examples
Browse files Browse the repository at this point in the history
  • Loading branch information
tobre1 committed Jun 17, 2024
1 parent 42e1460 commit ddc96a2
Show file tree
Hide file tree
Showing 12 changed files with 68 additions and 189 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,13 @@ CPMFindPackage(

CPMFindPackage(
NAME ViennaLS
GIT_TAG viennacore
VERSION 4.0.0
GIT_REPOSITORY "https://github.com/ViennaTools/ViennaLS"
EXCLUDE_FROM_ALL ${VIENNAPS_BUILD_PYTHON})

CPMFindPackage(
NAME ViennaCS
GIT_TAG main
VERSION 1.0.0
GIT_REPOSITORY "https://github.com/ViennaTools/ViennaCS"
EXCLUDE_FROM_ALL ${VIENNAPS_BUILD_PYTHON})

Expand Down
9 changes: 5 additions & 4 deletions examples/KDTreeBenchmark/KDTreeBenchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
#include <omp.h>
#endif

#include <compact/psKDTree.hpp>
#include <vcKDTree.hpp>
#include <vcSmartPointer.hpp>

inline double getTime() {
#ifdef _OPENMP
Expand Down Expand Up @@ -41,7 +42,7 @@ std::vector<std::vector<T>> generatePoints(unsigned N, unsigned D) {
return data;
}

namespace ps = viennaps;
using namespace viennacore;

int main(int argc, char *argv[]) {
using NumericType = double;
Expand Down Expand Up @@ -81,10 +82,10 @@ int main(int argc, char *argv[]) {

{
std::cout << "Growing Tree...\n";
ps::SmartPointer<ps::KDTree<NumericType>> tree = nullptr;
SmartPointer<KDTree<NumericType>> tree = nullptr;
auto startTime = getTime();
for (unsigned i = 0; i < repetitions; ++i) {
tree = ps::SmartPointer<ps::KDTree<NumericType>>::New(points);
tree = SmartPointer<KDTree<NumericType>>::New(points);
tree->build();
}
auto endTime = getTime();
Expand Down
21 changes: 11 additions & 10 deletions examples/interpolationDemo/interpolationDemo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <compact/psDataScaler.hpp>

namespace fs = std::filesystem;
namespace ps = viennaps;

template <typename DataSource, typename Estimator, typename SizeType>
void doEstimation(DataSource &dataSource, Estimator &estimator,
Expand Down Expand Up @@ -58,7 +59,7 @@ int main(int argc, char *argv[]) {
int numSamples = 40;

{
psCSVDataSource<NumericType> dataSource(
ps::CSVDataSource<NumericType> dataSource(
(dataPath / "griddata.csv").string());

// Quick demo of the positional and named parameters feature
Expand Down Expand Up @@ -96,13 +97,13 @@ int main(int argc, char *argv[]) {

// End of parameter demo

psRectilinearGridInterpolation<NumericType> estimator;
ps::RectilinearGridInterpolation<NumericType> estimator;
estimator.setDataDimensions(InputDim, OutputDim);

auto data = dataSource.getData();
estimator.setData(data);

psCSVDataSource<NumericType> writer("grid_output.csv");
ps::CSVDataSource<NumericType> writer("grid_output.csv");
writer.setHeader(
"x, y, z, data\nData generated by rectilinear interpolation "
"on rectilinear grid");
Expand All @@ -114,36 +115,36 @@ int main(int argc, char *argv[]) {
int OutputDim = 1;

{
psCSVDataSource<NumericType> dataSource(
ps::CSVDataSource<NumericType> dataSource(
(dataPath / "scatterdata.csv").string());

int numberOfNeighbors = 5;
NumericType distanceExponent = 2.;

psNearestNeighborsInterpolation<NumericType> estimator;
ps::NearestNeighborsInterpolation<NumericType> estimator;
estimator.setDistanceExponent(distanceExponent);
estimator.setNumberOfNeighbors(numberOfNeighbors);
estimator.setDataDimensions(InputDim, OutputDim);

auto data = dataSource.getData();
estimator.setData(data);

psCSVDataSource<NumericType> writer("nn_std_output.csv");
ps::CSVDataSource<NumericType> writer("nn_std_output.csv");
writer.setHeader("x, y, z, data\nData generated by nearest neighbors "
"interpolation using standard deviation scaling");

doEstimation(writer, estimator, numSamples, InputDim);
}

{
psCSVDataSource<NumericType> dataSource(
ps::CSVDataSource<NumericType> dataSource(
(dataPath / "scatterdata.csv").string());

int numberOfNeighbors = 5;
NumericType distanceExponent = 1. / 5.;

psNearestNeighborsInterpolation<NumericType,
psMedianDistanceScaler<NumericType>>
ps::NearestNeighborsInterpolation<NumericType,
ps::MedianDistanceScaler<NumericType>>
estimator;
estimator.setDistanceExponent(distanceExponent);
estimator.setNumberOfNeighbors(numberOfNeighbors);
Expand All @@ -152,7 +153,7 @@ int main(int argc, char *argv[]) {
auto data = dataSource.getData();
estimator.setData(data);

psCSVDataSource<NumericType> writer("nn_median_output.csv");
ps::CSVDataSource<NumericType> writer("nn_median_output.csv");
writer.setHeader("x, y, z, data\nData generated by nearest neighbors "
"interpolation using median distance scaling.");

Expand Down
10 changes: 0 additions & 10 deletions examples/volumeModel/CMakeLists.txt

This file was deleted.

13 changes: 0 additions & 13 deletions examples/volumeModel/config.txt

This file was deleted.

36 changes: 0 additions & 36 deletions examples/volumeModel/parameters.hpp

This file was deleted.

42 changes: 0 additions & 42 deletions examples/volumeModel/volumeModel.cpp

This file was deleted.

38 changes: 0 additions & 38 deletions examples/volumeModel/volumeModel.py

This file was deleted.

20 changes: 13 additions & 7 deletions include/viennaps/compact/psDataScaler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
#include <numeric>
#include <vector>

namespace viennaps {

using namespace viennacore;

// Base class for data scalers
template <typename NumericType> class psDataScaler {
template <typename NumericType> class DataScaler {
protected:
using ItemType = std::vector<NumericType>;
using ItemVectorType = std::vector<ItemType>;
Expand All @@ -21,8 +25,8 @@ template <typename NumericType> class psDataScaler {

// Class that calculates scaling factors based on standard deviation
template <typename NumericType>
class psStandardScaler : public psDataScaler<NumericType> {
using Parent = psDataScaler<NumericType>;
class StandardScaler : public DataScaler<NumericType> {
using Parent = DataScaler<NumericType>;

using typename Parent::ItemType;
using typename Parent::ItemVectorType;
Expand All @@ -32,7 +36,7 @@ class psStandardScaler : public psDataScaler<NumericType> {
const ItemVectorType &data;

public:
psStandardScaler(const ItemVectorType &passedData) : data(passedData) {}
StandardScaler(const ItemVectorType &passedData) : data(passedData) {}

void apply() override {
if (data.empty())
Expand Down Expand Up @@ -75,8 +79,8 @@ class psStandardScaler : public psDataScaler<NumericType> {

// Class that calculates scaling factors based on median distances
template <typename NumericType>
class psMedianDistanceScaler : public psDataScaler<NumericType> {
using Parent = psDataScaler<NumericType>;
class MedianDistanceScaler : public DataScaler<NumericType> {
using Parent = DataScaler<NumericType>;

using typename Parent::ItemType;
using typename Parent::ItemVectorType;
Expand All @@ -86,7 +90,7 @@ class psMedianDistanceScaler : public psDataScaler<NumericType> {
const ItemVectorType &data;

public:
psMedianDistanceScaler(const ItemVectorType &passedData) : data(passedData) {}
MedianDistanceScaler(const ItemVectorType &passedData) : data(passedData) {}

void apply() override {
if (data.empty())
Expand Down Expand Up @@ -122,3 +126,5 @@ class psMedianDistanceScaler : public psDataScaler<NumericType> {
}
}
};

} // namespace viennaps
Loading

0 comments on commit ddc96a2

Please sign in to comment.