From 9f8c7d1df1fb4d937ff647d92e3f74aabb6c85ba Mon Sep 17 00:00:00 2001
From: firefly-cpp
Date: Sun, 30 Jan 2022 17:29:04 +0100
Subject: [PATCH 1/5] Generate CHANGELOG
---
CHANGELOG.md | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)
create mode 100644 CHANGELOG.md
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..815f85f
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,56 @@
+# Changelog
+
+## [0.2.3](https://github.com/firefly-cpp/uARMSolver/tree/0.2.3) (2022-01-22)
+
+[Full Changelog](https://github.com/firefly-cpp/uARMSolver/compare/0.2.2...0.2.3)
+
+**Closed issues:**
+
+- Project logo [\#10](https://github.com/firefly-cpp/uARMSolver/issues/10)
+- Include the man page [\#8](https://github.com/firefly-cpp/uARMSolver/issues/8)
+
+**Merged pull requests:**
+
+- logo update [\#11](https://github.com/firefly-cpp/uARMSolver/pull/11) ([rhododendrom](https://github.com/rhododendrom))
+
+## [0.2.2](https://github.com/firefly-cpp/uARMSolver/tree/0.2.2) (2021-11-17)
+
+[Full Changelog](https://github.com/firefly-cpp/uARMSolver/compare/0.2.1...0.2.2)
+
+**Merged pull requests:**
+
+- Add man page; improve CLI ergonomics; simplify config docs [\#9](https://github.com/firefly-cpp/uARMSolver/pull/9) ([musicinmybrain](https://github.com/musicinmybrain))
+
+## [0.2.1](https://github.com/firefly-cpp/uARMSolver/tree/0.2.1) (2021-02-14)
+
+[Full Changelog](https://github.com/firefly-cpp/uARMSolver/compare/0.2...0.2.1)
+
+**Merged pull requests:**
+
+- Update WINDOWS\_INSTALLATION.md [\#7](https://github.com/firefly-cpp/uARMSolver/pull/7) ([DamijanNov](https://github.com/DamijanNov))
+- Update WINDOWS\_INSTALLATION.md [\#6](https://github.com/firefly-cpp/uARMSolver/pull/6) ([DamijanNov](https://github.com/DamijanNov))
+- Added WINDOWS\_INSTALLATION.md with instructions for Windows users [\#5](https://github.com/firefly-cpp/uARMSolver/pull/5) ([DamijanNov](https://github.com/DamijanNov))
+
+## [0.2](https://github.com/firefly-cpp/uARMSolver/tree/0.2) (2020-11-03)
+
+[Full Changelog](https://github.com/firefly-cpp/uARMSolver/compare/0.1...0.2)
+
+**Merged pull requests:**
+
+- Feature/makefile cflags [\#4](https://github.com/firefly-cpp/uARMSolver/pull/4) ([sanjayankur31](https://github.com/sanjayankur31))
+
+## [0.1](https://github.com/firefly-cpp/uARMSolver/tree/0.1) (2020-10-22)
+
+[Full Changelog](https://github.com/firefly-cpp/uARMSolver/compare/uARMSolver-0.1...0.1)
+
+## [uARMSolver-0.1](https://github.com/firefly-cpp/uARMSolver/tree/uARMSolver-0.1) (2020-10-22)
+
+[Full Changelog](https://github.com/firefly-cpp/uARMSolver/compare/ca56676b5cfde67824ed9badf3d97e17bf0e9298...uARMSolver-0.1)
+
+**Merged pull requests:**
+
+- Added cmake build to project. [\#3](https://github.com/firefly-cpp/uARMSolver/pull/3) ([kb2623](https://github.com/kb2623))
+
+
+
+\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
From 49901655def96d20b65838821e15f33ac20832f4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Carlos=20Aznar=C3=A1n=20Laos?=
Date: Thu, 3 Feb 2022 10:50:41 -0500
Subject: [PATCH 2/5] Add instructions for install from AUR, and a badge
---
README.md | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/README.md b/README.md
index 41ba93a..2294b4d 100644
--- a/README.md
+++ b/README.md
@@ -5,6 +5,8 @@
+[](https://aur.archlinux.org/packages/uarmsolver)
+
## Description
The framework is written fully in C++ and runs on all platforms. It allows users to preprocess their data in a transaction database, to make discretization of data, to search for association rules and to guide a presentation/visualization of the best rules found using external tools. As opposed to the existing software packages or frameworks, this also supports numerical and real-valued types of attributes besides the categorical ones. Mining the association rules is defined as an optimization and solved using the nature-inspired algorithms that can be incorporated easily. Because the algorithms normally discover a huge amount of association rules, the framework enables a modular inclusion of so-called visual guiders for extracting the knowledge hidden in data, and visualize these using external tools.
@@ -25,6 +27,11 @@ To install uARMSolver on RHEL, CentOS, Scientific Linux enable EPEL 8 and use:
```sh
$ dnf install uARMSolver
```
+To install uARMSolver on [Arch-based distributions](https://wiki.archlinux.org/title/Arch-based_distributions#Active), please use an [AUR helper](https://wiki.archlinux.org/title/AUR_helpers):
+
+```sh
+$ yay -Syyu uarmsolver
+```
To install uARMSolver on Windows, please follow to the [following instructions](WINDOWS_INSTALLATION.md).
From cebee9f560ca48becf17382cf236c23fb891f534 Mon Sep 17 00:00:00 2001
From: Iztok Fister Jr
Date: Sat, 5 Feb 2022 20:18:03 +0100
Subject: [PATCH 3/5] Add Fedora badge
---
README.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/README.md b/README.md
index 2294b4d..b0f88cf 100644
--- a/README.md
+++ b/README.md
@@ -6,6 +6,7 @@
[](https://aur.archlinux.org/packages/uarmsolver)
+[](https://src.fedoraproject.org/rpms/uARMSolver)
## Description
From 4c84592c1c914c592ed93d97db057b4f8e30d8ce Mon Sep 17 00:00:00 2001
From: firefly-cpp
Date: Thu, 10 Mar 2022 16:27:24 +0100
Subject: [PATCH 4/5] Add references for datasets
---
datasets/README.md | 6 ++++++
1 file changed, 6 insertions(+)
create mode 100644 datasets/README.md
diff --git a/datasets/README.md b/datasets/README.md
new file mode 100644
index 0000000..389ab2e
--- /dev/null
+++ b/datasets/README.md
@@ -0,0 +1,6 @@
+# References
+
+- The Abalone dataset is downloaded from https://archive.ics.uci.edu/ml/index.php.
+
+- flights and planets datasets are downloaded from: https://github.com/mwaskom/seaborn-data
+
From 0f1933778af8e4633b95168eda330d8cfd694a9f Mon Sep 17 00:00:00 2001
From: firefly-cpp
Date: Tue, 15 Mar 2022 12:41:37 +0100
Subject: [PATCH 5/5] Add data squashing technique
---
bin/arm.set | 11 ++
makefile | 6 +-
sources/DESolver.cpp | 6 +-
sources/Problem.cpp | 3 +
sources/Setup.cpp | 101 ++++++++++++
sources/Setup.h | 25 +++
sources/Squash.cpp | 350 +++++++++++++++++++++++++++++++++++++++++
sources/Squash.h | 50 ++++++
sources/uARMSolver.cpp | 19 ++-
9 files changed, 563 insertions(+), 8 deletions(-)
create mode 100644 sources/Squash.cpp
create mode 100644 sources/Squash.h
diff --git a/bin/arm.set b/bin/arm.set
index 26ed6e7..d8fa017 100644
--- a/bin/arm.set
+++ b/bin/arm.set
@@ -18,6 +18,17 @@ Period = 1
%Intervals = 5
}
+% Squashing algorithm selection = {NONE, CAUCHY, EUCLID, ...}
+%Squash = EUCLID
+%CAUCHY_PARAM
+%{
+%THRESHOLD = 0.99
+%}
+%EUCLID_PARAM
+%{
+%THRESHOLD = 0.9
+%}
+
% Algoritem selection = {NONE, DE, PSO, ...}
Algorithm = DE
% DE parameters
diff --git a/makefile b/makefile
index 535f4c6..a972cc6 100644
--- a/makefile
+++ b/makefile
@@ -5,11 +5,11 @@ ifeq ($(DEBUG), 1)
CXXFLAGS := $(CXXFLAGS) -O0 -g3 -Wall -fmessage-length=0
endif
-SRCS = ./sources/Archive.cpp ./sources/Attribute.cpp ./sources/DESolver.cpp ./sources/Evaluate.cpp ./sources/Feature.cpp ./sources/Problem.cpp ./sources/Rule.cpp ./sources/Setup.cpp ./sources/uARMSolver.cpp
+SRCS = ./sources/Archive.cpp ./sources/Attribute.cpp ./sources/DESolver.cpp ./sources/Evaluate.cpp ./sources/Feature.cpp ./sources/Problem.cpp ./sources/Rule.cpp ./sources/Setup.cpp ./sources/Squash.cpp ./sources/uARMSolver.cpp
-DEPS = ./Archive.d ./Attribute.d ./DESolver.d ./Evaluate.d ./Feature.d ./Problem.d ./Rule.d ./Setup.d ./uARMSolver.d
+DEPS = ./Archive.d ./Attribute.d ./DESolver.d ./Evaluate.d ./Feature.d ./Problem.d ./Rule.d ./Setup.d ./Squash.d ./uARMSolver.d
-OBJS = ./Archive.o ./Attribute.o ./DESolver.o ./Evaluate.o ./Feature.o ./Problem.o ./Rule.o ./Setup.o ./uARMSolver.o
+OBJS = ./Archive.o ./Attribute.o ./DESolver.o ./Evaluate.o ./Feature.o ./Problem.o ./Rule.o ./Setup.o ./Squash.o ./uARMSolver.o
all: bin/uARMSolver
diff --git a/sources/DESolver.cpp b/sources/DESolver.cpp
index 7cb64e4..1a9ce8f 100644
--- a/sources/DESolver.cpp
+++ b/sources/DESolver.cpp
@@ -23,13 +23,13 @@ DESolver::DESolver(int dim,int popSize, Problem problem) :
{
prob = problem;
nDim = eval.encode(D, prob);
-
+cout << "DESolver: dim= " << nDim << ", nPop= " << nPop << endl;
for(int i=0;i row;
for(int j=0;j tokens;
token_line(line, tokens, ',');
if (auto_parsing) {
diff --git a/sources/Setup.cpp b/sources/Setup.cpp
index e7e513f..bd40755 100644
--- a/sources/Setup.cpp
+++ b/sources/Setup.cpp
@@ -43,6 +43,9 @@ bool Setup::read()
} else if (tokens[0].compare("Visualisation") == 0) {// visualizationblock
block = 3;
visual = vis_to_int(tokens[2]);
+ } else if (tokens[0].compare("Squash") == 0) {// squashing
+ block = 4;
+ squash = sq_to_int(tokens[2]);
} else if (tokens[0][0] == '%') { // comment line - ignore
continue;
} else if (tokens[0][0] == '{') { // start of block
@@ -60,6 +63,9 @@ bool Setup::read()
case 3: // parsing visualization block
parse_vis_blk(tokens);
break;
+ case 4: // parsing squashing block
+ parse_sq_blk(tokens);
+ break;
}
}
@@ -102,6 +108,8 @@ void Setup::parse_prob_blk(vectortokens)
{
if(tokens[0].compare("Tdbase_name") == 0) {
tdbase_name = tokens[2];
+ } else if(tokens[0].compare("SqDbase_name") == 0) {
+ sq_dbase_name = tokens[2];
} else if(tokens[0].compare("Rule_name") == 0) {
rule_name = tokens[2];
} else if(tokens[0].compare("Out_name") == 0) {
@@ -231,6 +239,72 @@ int Setup::vis_to_int(string vis)
return n_vis;
}
+/**
+ * Parse the kind of squashing algorithm for solving ARM.
+ *
+ * @param the vector of parsed tokens.
+ * @return no return code.
+ */
+void Setup::parse_sq_blk(vectortokens)
+{
+ switch(squash) {
+ case SQUASH_CAUCHY:
+ parse_sq_cauchy(tokens);
+ break;
+ case SQUASH_EUCLID:
+ parse_sq_euclid(tokens);
+ break;
+ }
+}
+
+/**
+ * Parse the parameter setting of the Cauchy squashing algorithm for solving ARM.
+ *
+ * @param the vector of parsed tokens.
+ * @return no return code.
+ */
+void Setup::parse_sq_cauchy(vectortokens)
+{
+ if (tokens[0].compare("CAUCHY_PARAM") == 0) {
+ cout << "CAUCHY_PARAM started..." << endl;
+ } else if (tokens[0].compare("THRESHOLD") == 0) {
+ sq_param.sq.Thresh = stof(tokens[2]);
+ }
+}
+
+/**
+ * Parse the parameter setting of the Euclidian squashing algorithm for solving ARM.
+ *
+ * @param the vector of parsed tokens.
+ * @return no return code.
+ */
+void Setup::parse_sq_euclid(vectortokens)
+{
+ if (tokens[0].compare("EUCLID_PARAM") == 0) {
+ cout << "EUCLID_PARAM started..." << endl;
+ } else if (tokens[0].compare("THRESHOLD") == 0) {
+ sq_param.sq.Thresh = stof(tokens[2]);
+ }
+}
+
+/**
+ * Map the squashing method from string.
+ *
+ * @param the string.
+ * @return integer return code identifying the visualization method.
+ */
+int Setup::sq_to_int(string sq)
+{
+ int n_sq = SQUASH_NONE;
+
+ if(sq.compare("CAUCHY") == 0) {
+ n_sq = SQUASH_CAUCHY;
+ } else if(sq.compare("EUCLID") == 0) {
+ n_sq = SQUASH_EUCLID;
+ }
+ return n_sq;
+}
+
/**
* Print out all three parameter parts determining a behavior of the solver.
*
@@ -242,6 +316,7 @@ void Setup::print_param()
print_prob_blk();
print_alg_blk();
print_vis_blk();
+ print_sq_blk();
}
/**
@@ -255,6 +330,7 @@ void Setup::print_prob_blk()
cout << "Problem block setup: " << endl;
cout << "---------------------" << endl;
cout << "Tdbase_name= " << tdbase_name << endl;
+ cout << "SqDbase_name= " << sq_dbase_name << endl;
cout << "Rule_name= " << rule_name << endl;
cout << "Out_name= " << out_name << endl;
cout << "Period= " << period << endl;
@@ -318,6 +394,31 @@ void Setup::print_vis_blk()
cout << "---------------------" << endl;
}
+/**
+ * Print out the parameter setting of the squashing method.
+ *
+ * @param no input parameters.
+ * @return no return code.
+ */
+void Setup::print_sq_blk()
+{
+ cout << "Squashing block setup: " << endl;
+ cout << "---------------------" << endl;
+
+ switch(squash) {
+ case SQUASH_CAUCHY:
+ cout << "Method= CAUCHY" << endl;
+ cout << "Threshold= " << sq_param.sq.Thresh << endl;
+ break;
+ case SQUASH_EUCLID:
+ cout << "Method= EUCLID" << endl;
+ break;
+ default:
+ cout << "Method= NONE" << endl;
+ }
+ cout << "---------------------" << endl;
+}
+
/**
* Print out the tokens parsed from the input line.
*
diff --git a/sources/Setup.h b/sources/Setup.h
index f835a99..8440726 100644
--- a/sources/Setup.h
+++ b/sources/Setup.h
@@ -19,6 +19,10 @@
#define VISUAL_FLOW 1
#define VISUAL_METRO 2
+#define SQUASH_NONE 0
+#define SQUASH_CAUCHY 1
+#define SQUASH_EUCLID 2
+
using namespace std;
// algorithm's setups
@@ -34,6 +38,11 @@ using namespace std;
int N;
};
+ // squashing setups
+ struct sq_param {
+ double Thresh;
+ };
+
/**
* Definition of setup parameter input file
*
@@ -61,25 +70,34 @@ class Setup {
void parse_vis_blk(vectortokens);
void parse_vis_flow(vectortokens);
int vis_to_int(string vis);
+ void parse_sq_blk(vectortokens);
+ void parse_sq_cauchy(vectortokens);
+ void parse_sq_euclid(vectortokens);
+ int sq_to_int(string sq);
void print_tokens(vectortokens);
void print_prob_blk();
void print_alg_blk();
void print_vis_blk();
+ void print_sq_blk();
void print_param();
// getters
int get_solver() { return solver; }
int get_period() { return period; }
+ int get_squash() { return squash; }
int get_Np() { return Np; }
int get_FEs() { return FEs; }
int get_RUNs() { return RUNs; }
string get_tdbase_name() { return tdbase_name; }
+ string get_sq_dbase_name() { return sq_dbase_name; }
string get_rule_name() { return rule_name; }
string get_out_name() { return out_name; }
+
// setters
void set_solver(int val) { solver = val; }
void set_period(int val) { period = val; }
+ void set_squash(int val) { squash = val; }
void set_Np(int val) { Np = val; }
void set_FEs(int val) { FEs = val; }
void set_RUNs(int val) { RUNs = val; }
@@ -91,12 +109,14 @@ class Setup {
int period; ///< number of transaction databases & archives
int solver; ///< algorithm for solving ARM
int visual; ///< visualization method
+ int squash; ///< squashing method
int Np; ///< population size
int FEs; ///< number of fitness function evaluations
int RUNs; ///< number of independent runs
string arm_set_name; ///< ARM setup file name
string tdbase_name; ///< transaction database
+ string sq_dbase_name; ///< squashed database
string rule_name; ///< rule database
string out_name; ///< output file name
@@ -108,6 +128,11 @@ class Setup {
union {
flow_param flow;
} vis_param; ///< visualization parameters
+
+ union {
+ sq_param sq;
+ } sq_param; ///< squashing parameters
+
};
#endif /* SETUP_H_ */
diff --git a/sources/Squash.cpp b/sources/Squash.cpp
new file mode 100644
index 0000000..bb1e705
--- /dev/null
+++ b/sources/Squash.cpp
@@ -0,0 +1,350 @@
+/*
+ * Squash.cpp
+ *
+ * Created on: Mar 10, 2022
+ * Author: iztok
+ */
+
+#include "Squash.h"
+
+Squash::Squash() {
+ // TODO Auto-generated constructor stub
+
+}
+
+Squash::~Squash() {
+ // TODO Auto-generated destructor stub
+}
+
+/**
+ * Make squashing database.
+ *
+ * @param setup, problem classes.
+ * @return the size of database.
+ */
+int Squash::make_sq_dbase(Setup setup, Problem prob)
+{
+ uint pos = 0;
+ uint k = 0;
+ cout << "make_sq_dbase started..." << endl;
+ init_squashed(prob.dbase.size());
+ while(pos < prob.dbase.size()) {
+ sq_set.clear();
+ // avoid all squashed rows
+ while(pos < prob.dbase.size() && is_squashed(pos))
+ pos++;
+ int sq_set_name = pos;
+ if(pos+1 < prob.dbase.size()) {
+ sq_set.push_back(prob.dbase[pos]);
+ set_squashed(pos);
+ for(uint i=pos+1;i= setup.sq_param.sq.Thresh) {
+ sq_set.push_back(prob.dbase[i]);
+ set_squashed(i);
+ k++;
+ }
+ }
+ }
+ }
+ if(sq_set.size() > 0) {
+ vector sq_vec;
+ make_sq_vector(sq_set_name, sq_vec, prob.feat.size());
+ sq_dbase.push_back(sq_vec);
+ sq_vec.clear();
+ }
+ pos++;
+ }
+ sq_set.clear();
+ return sq_dbase.size();
+}
+
+/**
+ * Reset the visited transaction.
+ *
+ * @param the number of transactions.
+ * @return no return code.
+ */
+void Squash::init_squashed(int n)
+{
+ for(int i=0;i vec_1, vector vec_2)
+{
+ uint n_attr = vec_1.size();
+ double inner = 0.0, a = 0.0, b = 0.0;
+ for(uint i=0;i vec_1, vector vec_2, vector feat)
+{
+ uint n_attr = vec_1.size();
+ double dist = 0.0, weight = 0.0;
+ for(uint i=0;i &sq_vec, int n_attr)
+{
+ for(int i=0;i similar_set;
+ vector similar_count;
+ // for all similar transactions
+ for(uint j=0;j set_str, string str)
+{
+ int pos = -1;
+ uint i = 0;
+ while(pos < 0 && i count)
+{
+ int max_i = 0;
+ for(uint i=1;i count[max_i])
+ max_i = i;
+ }
+ return max_i;
+}
+
+/**
+ * Print out the statistics obtained by the squashing method.
+ *
+ * @param the problem class.
+ * @return no return code.
+ */
+void Squash::stat(Problem prob)
+{
+ cout << "Squshing statistics:" << endl;
+ cout << "Original dbase: " << prob.dbase.size() << endl;
+ cout << "Squashed dbase: " << sq_dbase.size() << endl;
+ cout << "Squashing rate: " << (1.0-(double) sq_dbase.size()/(double) prob.dbase.size())*100.0 << " %" << endl;
+}
+
+/**
+ * Print vector attributes.
+ *
+ * @param no input parameters.
+ * @return no return code.
+ */
+void Squash::print_vec(vector vec)
+{
+ cout << "{";
+ for (uint i = 0; i < vec.size(); i++) {
+ cout << "(" << vec[i].type << "," << vec[i].present << ",";
+ if (vec[i].type == ATTR_CATEGORICAL)
+ cout << vec[i].s_val;
+ else if (vec[i].type == ATTR_NUMERICAL)
+ cout << vec[i].i_val;
+ else
+ cout << vec[i].f_val;
+ cout << ")";
+ }
+ cout << "}" << endl;
+}
+
+/**
+ * Print bool vector (for debugging purposes).
+ *
+ * @param no input parameters.
+ * @return no return code.
+ */
+void Squash::print_vec(vector vec)
+{
+ cout << "(";
+ for (uint i = 0; i < vec.size(); i++) {
+ cout << vec[i] << ",";
+ }
+ cout << ")" << endl;
+}
+
+/**
+ * Print int vector (for debugging purposes).
+ *
+ * @param no input parameters.
+ * @return no return code.
+ */
+void Squash::print_vec(vector vec)
+{
+ cout << "(";
+ for (uint i = 0; i < vec.size(); i++) {
+ cout << vec[i] << ",";
+ }
+ cout << ")" << endl;
+}
+
+/**
+ * Print int vector (for debugging purposes).
+ *
+ * @param no input parameters.
+ * @return no return code.
+ */
+void Squash::print_vec(vector vec)
+{
+ cout << "(";
+ for (uint i = 0; i < vec.size(); i++) {
+ cout << vec[i] << ",";
+ }
+ cout << ")" << endl;
+}
+
+/**
+ * Print attributes.
+ *
+ * @param no input parameters.
+ * @return no return code.
+ */
+void Squash::print()
+{
+ cout << "Squashed matrix:" << endl;
+ for (uint i = 0; i < sq_dbase.size(); i++) {
+ cout << "[" << i+1 << "] (";
+ for (uint j = 0; j < sq_dbase[i].size(); j++) {
+ if(sq_dbase[i][j].type == ATTR_CATEGORICAL)
+ cout << sq_dbase[i][j].s_val << ",";
+ else if(sq_dbase[i][j].type == ATTR_NUMERICAL)
+ cout << sq_dbase[i][j].i_val << ",";
+ else
+ cout << sq_dbase[i][j].f_val << ",";
+ }
+ cout << ")" << endl;
+ }
+}
+
+/**
+ * Write attributes into output file.
+ *
+ * @param no input parameters.
+ * @return no return code.
+ */
+void Squash::write(Setup setup)
+{
+ ofstream out(setup.get_sq_dbase_name());
+
+ if (out.is_open()) {
+ for (uint i = 0; i < sq_dbase.size(); i++) {
+ for (uint j = 0; j < sq_dbase[i].size(); j++) {
+ if (sq_dbase[i][j].type == ATTR_CATEGORICAL)
+ out << sq_dbase[i][j].s_val << ",";
+ else if (sq_dbase[i][j].type == ATTR_NUMERICAL)
+ out << sq_dbase[i][j].i_val << ",";
+ else
+ out << sq_dbase[i][j].f_val << ",";
+ }
+ out << endl;
+ }
+ }
+ out.close();
+}
diff --git a/sources/Squash.h b/sources/Squash.h
new file mode 100644
index 0000000..9b1689c
--- /dev/null
+++ b/sources/Squash.h
@@ -0,0 +1,50 @@
+/*
+ * Squash.h
+ *
+ * Created on: Mar 10, 2022
+ * Author: iztok
+ */
+
+#ifndef SOURCE_SQUASH_H_
+#define SOURCE_SQUASH_H_
+
+#include "Setup.h"
+#include "Problem.h"
+
+
+/**
+ * Squashing the transaction database class
+ *
+ *
+ */
+
+class Squash {
+public:
+ Squash();
+ virtual ~Squash();
+
+ int make_sq_dbase(Setup setup, Problem prob);
+ void init_squashed(int n);
+ bool is_squashed(int pos) { return sq_squashed[pos]; }
+ void set_squashed(int pos) { sq_squashed[pos] = true; }
+ void reset_squashed(int pos) { sq_squashed[pos] = false; }
+ double sq_similarity(vector vec_1, vector vec_2);
+ double sq_distance(vector vec_1, vector vec_2, vector feat);
+ void make_sq_vector(int sq_set_name, vector &sq_vec, int n_attr);
+ int in_similar_set(vector set_str, string str);
+ int find_max_count(vector count);
+ void stat(Problem prob);
+ void write(Setup setup);
+ void print_vec(vector vec);
+ void print_vec(vector vec);
+ void print_vec(vector vec);
+ void print_vec(vector vec);
+ void print();
+
+public:
+ vector< vector > sq_dbase; ///< squashing transaction database represented as a collection of attributes
+ vector< vector > sq_set; ///< squashing set database represented as a collection of attributes
+ vector< bool > sq_squashed; ///< indicate if the transaction is already squashed
+};
+
+#endif /* SOURCE_SQUASH_H_ */
diff --git a/sources/uARMSolver.cpp b/sources/uARMSolver.cpp
index 8e4176d..7671fe7 100644
--- a/sources/uARMSolver.cpp
+++ b/sources/uARMSolver.cpp
@@ -24,6 +24,7 @@
#include "Setup.h"
#include "Archive.h"
#include "Problem.h"
+#include "Squash.h"
#define N_DIM 10
#define N_POP 100
@@ -99,9 +100,20 @@ int main(int argc, char* argv[])
str.append(f_name);
}
- printf("Reading file= %d, f_name= %s...\n", i + 1, str.c_str());
+ printf("Reading transaction database= %d, f_name= %s...\n", i + 1, str.c_str());
// read transaction database(s)
prob[i].init_tdbase(setup, str);
+
+ // squashing database if needed
+ if(setup.get_squash() > 0) {
+ Squash sq;
+ sq.make_sq_dbase(setup, prob[i]);
+ sq.write(setup);
+ sq.stat(prob[i]);
+ prob[i].dbase.clear();
+ prob[i].dbase = sq.sq_dbase;
+ sq.sq_dbase.clear();
+ }
}
Archive rules[setup.get_period()];
@@ -168,17 +180,20 @@ void solve(Setup setup, Problem problem, Archive &rules)
clock_t start_t, end_t; // time measuring in miliseconds
start_t = clock();
-
+ cout << "Solver strated..." << endl;
switch(setup.get_solver()) {
case SOLVER_DE: {
int n_dim = problem.get_dimension();
int n_np = setup.get_Np();
int n_run = setup.get_RUNs();
+ cout << "n_dim= " << n_dim << ", n_np= " << n_np << endl;
DESolver solver(n_dim, n_np, problem);
+ cout << "Setup..." << endl;
solver.Setup(setup.alg_param.de.strategy, setup.alg_param.de.scale, setup.alg_param.de.xover);
for(int i=0;i