Skip to content

Commit

Permalink
refactor param passing#49 (#50)
Browse files Browse the repository at this point in the history
Former-commit-id: bd18e5d
  • Loading branch information
tuidan authored Aug 25, 2021
1 parent 7be4f80 commit bc9c43e
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 33 deletions.
3 changes: 2 additions & 1 deletion include/Algorithm/Birch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <Algorithm/OfflineClustering/KMeans.hpp>
#include <Sinks/DataSink.hpp>
#include <Algorithm/DataStructure/CFTree.hpp>
#include <Utils/BenchmarkUtils.hpp>
namespace SESAME {

class BirchParameter : public AlgorithmParameters {
Expand All @@ -27,7 +28,7 @@ class Birch : public Algorithm {
NodePtr root;
vector<NodePtr> leafNodes;
CFTreePtr cfTree;
Birch();
Birch(param_t &cmd_params);

~Birch();

Expand Down
4 changes: 3 additions & 1 deletion include/Algorithm/CluStream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include <Algorithm/OfflineClustering/KMeans.hpp>
#include <Algorithm/WindowModel/LandmarkWindow.hpp>
#include <Algorithm/DataStructure/Snapshot.hpp>
#include <Utils/BenchmarkUtils.hpp>

namespace SESAME {

class CluStreamParameter : public AlgorithmParameters {
Expand All @@ -42,7 +44,7 @@ class CluStream : public Algorithm {
int pointsForgot;
int pointsMerged;
clock_t startTime;
CluStream();
CluStream(param_t &cmd_params);
~CluStream();

void Initilize() override;
Expand Down
4 changes: 3 additions & 1 deletion include/Algorithm/StreamKM.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include <iostream>
#include <Algorithm/OfflineClustering/KMeans.hpp>
#include <Sinks/DataSink.hpp>
#include <Utils/BenchmarkUtils.hpp>

namespace SESAME {

class StreamKMParameter : public AlgorithmParameters {
Expand All @@ -30,7 +32,7 @@ class StreamKM : public Algorithm {
vector <PointPtr> inputs;//buffered inputs.
vector <PointPtr> streamingCoreset;//intermediate results.
KMeans km;//used for offline processing.
StreamKM();
StreamKM(param_t &cmd_params);

~StreamKM();

Expand Down
27 changes: 3 additions & 24 deletions src/Algorithm/AlgorithmFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,15 @@

SESAME::AlgorithmPtr SESAME::AlgorithmFactory::create(param_t &cmd_params) {
if (cmd_params.algoName == "StreamKMeans") {
shared_ptr<StreamKM> streamkm = std::make_shared<StreamKM>();
streamkm->StreamKMParam.pointNumber = cmd_params.pointNumber;
streamkm->StreamKMParam.clusterNumber = cmd_params.clusterNumber;
streamkm->StreamKMParam.windowSize = cmd_params.coresetSize;
streamkm->StreamKMParam.seed = cmd_params.seed;
streamkm->StreamKMParam.dimension = cmd_params.dimension;
shared_ptr<StreamKM> streamkm = std::make_shared<StreamKM>(cmd_params);;
return (SESAME::AlgorithmPtr) streamkm;
}
if (cmd_params.algoName == "CluStream") {
shared_ptr<CluStream> cluStream = std::make_shared<CluStream>();
cluStream->CluStreamParam.pointNumber = cmd_params.pointNumber;
cluStream->CluStreamParam.clusterNumber = cmd_params.onlineClusterNumber;
cluStream->CluStreamParam.dimension = cmd_params.dimension;
cluStream->CluStreamParam.lastArrivingNum = cmd_params.lastArrivingNum;
cluStream->CluStreamParam.timeWindow = cmd_params.timeWindow;
cluStream->CluStreamParam.timeInterval = cmd_params.timeInterval;
cluStream->CluStreamParam.offlineClusterNumber = cmd_params.clusterNumber;
cluStream->CluStreamParam.radiusFactor = cmd_params.radiusFactor;
cluStream->CluStreamParam.initBuffer = cmd_params.initBuffer;
cluStream->CluStreamParam.offlineTimeWindow = cmd_params.offlineTimeWindow;

shared_ptr<CluStream> cluStream = std::make_shared<CluStream>(cmd_params);
return (SESAME::AlgorithmPtr) cluStream;
}
if (cmd_params.algoName == "Birch") {
shared_ptr<Birch> birch = std::make_shared<Birch>();
birch->BirchParam.pointNumber = cmd_params.pointNumber;
birch->BirchParam.dimension = cmd_params.dimension;
birch->BirchParam.maxInternalNodes = cmd_params.maxInternalNodes;
birch->BirchParam.maxLeafNodes = cmd_params.maxLeafNodes;
birch->BirchParam.thresholdDistance = cmd_params.thresholdDistance;
shared_ptr<Birch> birch = std::make_shared<Birch>(cmd_params);
return (SESAME::AlgorithmPtr) birch;
}
throw std::invalid_argument("Unsupported");
Expand Down
8 changes: 6 additions & 2 deletions src/Algorithm/Birch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@ void SESAME::Birch::runOfflineClustering(DataSinkPtr sinkPtr) {
// this->kmeans->produceResult(oldGroups, sinkPtr);
}

SESAME::Birch::Birch() {

SESAME::Birch::Birch(param_t &cmd_params) {
this->BirchParam.pointNumber = cmd_params.pointNumber;
this->BirchParam.dimension = cmd_params.dimension;
this->BirchParam.maxInternalNodes = cmd_params.maxInternalNodes;
this->BirchParam.maxLeafNodes = cmd_params.maxLeafNodes;
this->BirchParam.thresholdDistance = cmd_params.thresholdDistance;
}
SESAME::Birch::~Birch() {

Expand Down
13 changes: 11 additions & 2 deletions src/Algorithm/CluStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,17 @@
* initialData:input intial data
*@Return: void
*/
SESAME::CluStream::CluStream() {

SESAME::CluStream::CluStream(param_t &cmd_params) {
this->CluStreamParam.pointNumber = cmd_params.pointNumber;
this->CluStreamParam.clusterNumber = cmd_params.onlineClusterNumber;
this->CluStreamParam.dimension = cmd_params.dimension;
this->CluStreamParam.lastArrivingNum = cmd_params.lastArrivingNum;
this->CluStreamParam.timeWindow = cmd_params.timeWindow;
this->CluStreamParam.timeInterval = cmd_params.timeInterval;
this->CluStreamParam.offlineClusterNumber = cmd_params.clusterNumber;
this->CluStreamParam.radiusFactor = cmd_params.radiusFactor;
this->CluStreamParam.initBuffer = cmd_params.initBuffer;
this->CluStreamParam.offlineTimeWindow = cmd_params.offlineTimeWindow;
}
SESAME::CluStream::~CluStream() {

Expand Down
8 changes: 6 additions & 2 deletions src/Algorithm/StreamKM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,12 @@ void SESAME::StreamKM::runOfflineClustering(DataSinkPtr sinkPtr) {
// cout << endl;
//}

SESAME::StreamKM::StreamKM() {

SESAME::StreamKM::StreamKM(param_t &cmd_params) {
this->StreamKMParam.pointNumber = cmd_params.pointNumber;
this->StreamKMParam.clusterNumber = cmd_params.clusterNumber;
this->StreamKMParam.windowSize = cmd_params.coresetSize;
this->StreamKMParam.seed = cmd_params.seed;
this->StreamKMParam.dimension = cmd_params.dimension;
}
SESAME::StreamKM::~StreamKM() {

Expand Down

0 comments on commit bc9c43e

Please sign in to comment.