# P System–Based Clustering Methods Using NoSQL Databases

^{1}

^{2}

^{*}

## Abstract

**:**

## 1. Introduction

`pymongo`and

`redis`packages enable the user to access MongoDB and Redis database methods directly—can be a basis of any desired user-defined algorithms aiming to take advantage of the potential of these systems.

## 2. Materials and Methods

#### 2.1. Clustering Algorithms

#### 2.2. Membrane Systems

- V is a finite alphabet of objects;
- $T\u2291V$ is the output alphabet;
- $C\u2291V-T$ is catalyst;
- $\mu $ is a membrane structure, containing the n membranes;
- ${w}_{i}\phantom{\rule{4pt}{0ex}}(1\phantom{\rule{0.166667em}{0ex}}\u2a7d\phantom{\rule{0.166667em}{0ex}}i\phantom{\rule{0.166667em}{0ex}}\u2a7d\phantom{\rule{0.166667em}{0ex}}n)$ are strings representing multisets over V associated with regions $1,2,\dots ,n$ of $\mu $;
- ${R}_{i}\phantom{\rule{4pt}{0ex}}(1\phantom{\rule{0.166667em}{0ex}}\u2a7d\phantom{\rule{0.166667em}{0ex}}i\phantom{\rule{0.166667em}{0ex}}\u2a7d\phantom{\rule{0.166667em}{0ex}}n)$ is a finite set of evolution rules associated with region i for all i;
- ${p}_{i}$ is a partial order relation over ${R}_{i}$

- $V=\{a,b,d,e,f\}$, $T=\left\{e\right\}$, $C=0$;
- $\mu ={{[}_{1}{{[}_{2}{{[}_{3}]}_{3}]}_{2}]}_{1}$;
- ${w}_{1}=\lambda $, ${R}_{1}=\{e\to {e}_{out}\}$, ${p}_{1}=0$;
- ${w}_{2}=\lambda $, ${R}_{2}=\{b\to d,d\to de,{r}_{1}:ff\to f,{r}_{2}:f\to \delta \}$, ${p}_{2}=\{{r}_{1}>{r}_{2}\}$;
- ${w}_{3}=af$, ${R}_{3}=\{a\to ab,a\phantom{\rule{3.33333pt}{0ex}}\to b\delta ,f\to ff\}$, ${p}_{3}=0$;

#### 2.3. Membrane Clustering

#### 2.4. NoSQL

#### 2.5. The Used Algorithm

**Definition**

**1.**

- O is a finite, non-empty alphabet of objects;
- μ describes the (graph) structure, containing the p nested cells;
- ${w}_{i}\phantom{\rule{4pt}{0ex}}(1\phantom{\rule{0.166667em}{0ex}}\u2a7d\phantom{\rule{0.166667em}{0ex}}i\phantom{\rule{0.166667em}{0ex}}\u2a7d\phantom{\rule{0.166667em}{0ex}}p)$ is a finite multiset of objects over O, contained by cell i of μ in the initial state of the calculation;
- ${R}_{i}\phantom{\rule{4pt}{0ex}}(1\phantom{\rule{0.166667em}{0ex}}\u2a7d\phantom{\rule{0.166667em}{0ex}}i\phantom{\rule{0.166667em}{0ex}}\u2a7d\phantom{\rule{0.166667em}{0ex}}p)$ is a finite set of evolutionary rules contained by cell i of μ;
- $R\u2019$ is finite set of communicational rules between the cells of μ; and finally
- ${i}_{0}\in \{0,\phantom{\rule{0.166667em}{0ex}}1,\phantom{\rule{0.166667em}{0ex}}\cdots ,\phantom{\rule{0.166667em}{0ex}}p\}$ specifies the cell accommodating the output of the computation (if ${i}_{0}=0$, the region outside the outer cell contains the output).

`random`python module. The value of w is calculated as follows:

BEGIN Initialize cells and best positions WHILE step < tmax DO FOR each cell DO FOR each object DO CALL update_best_position() END END FOR each cell DO IF best in cell < global best THEN Update global best END END Increase step END RETURN global best positions END FUNCTION update_best_position() BEGIN Calculate w using Equation~(2) Evolve object using Equation~(1) Calculate partition matrix using Equation~(4) Calculate FCM using Equation~(3) IF FCM for given object < best so far THEN Update best position for object END END

## 3. Results

#### 3.1. Experiments

`pymongo`and the

`redis`packages for directly accessing the MongoDB and Redis databases. The data points used by the P system in the experiments are structured in the following way. In MongoDB, a collection, which is a JSON document, corresponds to a collection of points. In this document, each line corresponds to a point, where the dimensions of the point are listed with their values.

{“d1”: 5.68, “d2”: 0.35, “d3”: 3.12, …} {“d1”: −0.83, “d2”: 3.67, “d3”: 1.12, …} {“d1”: −6.48, “d2”: −7.1, “d3”: 4.89, …} …

collection1:point1 5.68 0.35 3.12 … collection1:point2 −0.83 3.67 1.12 … collection1:point3 −6.48 −7.1 4.89 … …

`make_blobs`function of the

`sklearn`[46] python module. We loaded the data by generating JSON files, then importing them into MongoDB. In the case of Redis, we connected to the database through python and loaded the data by calling the

`lpush`Redis operation. To query the databases we used the

`find`MongoDB operation and the

`lrange`Redis operation. During the calculation, each point was stored in

`numpy`arrays.

`RSS`of the

`memory_info`function of the

`Process`in the

`psutil`python module. RSS is the “Resident Set Size”, the non-swapped physical memory a process has used. The measurements were made on Intel(R) Core(TM) i5-1035G1 CPU with 8 GB RAM.

#### 3.2. Evaluation

## 4. Discussion and Conclusions

#### 4.1. Conclusions

#### 4.2. Future Work

## Author Contributions

## Funding

## Institutional Review Board Statement

## Informed Consent Statement

## Data Availability Statement

## Conflicts of Interest

## Abbreviations

SA | Simulated Annealing |

GA | Genetic Algorithm |

ABC | Artificial Bee Colony |

DE | Differential Evolution |

PSO | Particle Swarm Optimization |

RFO | Red Fox Optimization |

PBO | Polar Bear Optimization |

ChOA | Chimp Optimization Algorithm |

CUDA | Compute Unified Device Architecture |

MAQIS | Membrane Algorithm with Quantum-Inspired Subalgorithms |

FPGA | Field Programmable Gate Arrays |

PDP | Programmed Data Processor |

MeCoSim | Membrane Computing Simulator |

SNP | Spiking Neural P Systems |

SNMC | Spiking Neural Membrane Computing |

SAT problem | Boolean Satisfiability Problem |

KMCA | Kernel-based Membrane Clustering Algorithm |

PSO-CP | Particle Swarm Optimization Cell-like P system |

FCM | Fuzzy C-Means |

RSS | Resident Set Size |

UCI | University of California, Irvine |

## References

- Păun, G. Computing with Membranes. J. Comput. Syst. Sci.
**2000**, 61, 108–143. [Google Scholar] [CrossRef] [Green Version] - Li, Y.; Manoharan, S. A performance comparison of SQL and NoSQL databases. In Proceedings of the 2013 IEEE Pacific Rim Conference on Communications, Computers and Signal Processing (PACRIM), Vancouver, BC, Canada, 27–29 August 2013; pp. 15–19. [Google Scholar]
- MacQueen, J. Some methods for classification and analysis of multivariate observations. In Proceedings of the 5th Berkeley Symposium on Mathematical Statistics and Probability, Oakland, CA, USA, 1 January 1967; Volume 1, pp. 281–297. [Google Scholar]
- Hamerly, G.; Elkan, C. Learning the k in k-means. In Advances in Neural Information Processing Systems; MIT Press: Cambridge, MA, USA; London, UK, 2004; pp. 281–288. [Google Scholar]
- Xu, R.; Wunsch, D. Survey of clustering algorithms. IEEE Trans. Neural Netw.
**2005**, 16, 645–678. [Google Scholar] [CrossRef] [PubMed] [Green Version] - van der Merwe, D.W.; Engelbrecht, A.P. Data clustering using particle swarm optimization. In Proceedings of the 2003 Congress on Evolutionary Computation (CEC ’03), Canberra, ACT, Australia, 8–12 December 2003; Volume 1, pp. 215–220. [Google Scholar] [CrossRef]
- Karaboga, D.; Ozturk, C. A novel clustering approach: Artificial bee colony (ABC) algorithm. Appl. Soft Comput.
**2010**, 11, 652–657. [Google Scholar] [CrossRef] - Das, S.; Abraham, A.; Konar, A. Automatic clustering using an improved differential evolution algorithm. IEEE Trans. Syst. Man Cybern. Part A Syst. Hum.
**2007**, 38, 218–237. [Google Scholar] [CrossRef] - Połap, D. Polar bear optimization algorithm: Meta-heuristic with fast population movement and dynamic birth and death mechanism. Symmetry
**2017**, 9, 203. [Google Scholar] [CrossRef] [Green Version] - Połap, D.; Woźniak, M. Red fox optimization algorithm. Expert Syst. Appl.
**2021**, 166, 114107. [Google Scholar] [CrossRef] - Khishe, M.; Mosavi, M.R. Chimp optimization algorithm. Expert Syst. Appl.
**2020**, 149, 113338. [Google Scholar] [CrossRef] - Păun, G. Membrane Computing—An Introduction; Springer: Berlin/Heidelberg, Germany, 2002. [Google Scholar]
- Păun, G.; Rozenberg, G. A guide to membrane computing. Theor. Comput. Sci.
**2002**, 287, 73–100. [Google Scholar] [CrossRef] [Green Version] - Csuhaj-Varjú, E. Communicating P Systems: Bio-inspired Computational Models for Complex Systems. In Proceedings of the CEUR Workshop Proceedings, Oravská Lesná, Slovakia, 18–22 September 2020; pp. 3–8. [Google Scholar]
- Díaz-Pernil, D.; Berciano, A.; PeñA-Cantillana, F.; GutiéRrez-Naranjo, M.A. Segmenting images with gradient-based edge detection using membrane computing. Pattern Recognit. Lett.
**2013**, 34, 846–855. [Google Scholar] [CrossRef] - Zhang, G.; Gheorghe, M.; Li, Y. A membrane algorithm with quantum-inspired subalgorithms and its application to image processing. Nat. Comput.
**2012**, 11, 701–717. [Google Scholar] [CrossRef] - Zhang, G.; Shang, Z.; Verlan, S.; Martínez-del Amor, M.Á.; Yuan, C.; Valencia-Cabrera, L.; Pérez-Jiménez, M.J. An overview of hardware implementation of membrane computing models. ACM Comput. Surv. (CSUR)
**2020**, 53, 1–38. [Google Scholar] [CrossRef] - Sánchez Karhunen, E.; Valencia Cabrera, L. Membrane Computing Applications in Computational Economics. In Proceedings of the BWMC 2017: 15th Brainstorming Week on Membrane Computing, Andalusia, Spain, 31 January–3 February 2017; pp. 189–214. [Google Scholar]
- Liu, X.; Ren, Q. Spiking Neural Membrane Computing Models. Processes
**2021**, 9, 733. [Google Scholar] [CrossRef] - Martínez-del Amor, M.Á.; Orellana-Martín, D.; Pérez-Hurtado, I.; Cabarle, F.G.C.; Adorna, H.N. Simulation of Spiking Neural P Systems with Sparse Matrix-Vector Operations. Processes
**2021**, 9, 690. [Google Scholar] [CrossRef] - Hao, L.; Liu, J. Enhanced Membrane Computing Algorithm for SAT Problems Based on the Splitting Rule. Symmetry
**2019**, 11, 1412. [Google Scholar] [CrossRef] [Green Version] - Csuhaj-Varjú, E.; Margenstern, M.; Vaszil, G.; Verlan, S. On small universal antiport P systems. Theor. Comput. Sci.
**2007**, 372, 152–164. [Google Scholar] [CrossRef] [Green Version] - Battyányi, P.; Vaszil, G. Description of membrane systems with time Petri nets: Promoters/inhibitors, membrane dissolution, and priorities. J. Membr. Comput.
**2020**, 2, 341–354. [Google Scholar] [CrossRef] - Csuhaj-Varjú, E.; Vaszil, G. P automata or purely communicating accepting P systems. In Workshop on Membrane Computing; Springer: Berlin/Heidelberg, Germany, 2002; pp. 219–233. [Google Scholar]
- Csuhaj-Varjú, E.; Nola, A.D.; Păun, G.; Pérez-Jiménez, M.J.; Vaszil, G. Editing configurations of P systems. Fundam. Inform.
**2008**, 82, 29–46. [Google Scholar] - Ciencialová, L.; Cienciala, L.; Csuhaj-Varjú, E. P colonies and reaction systems. J. Membr. Comput.
**2020**, 2, 269–280. [Google Scholar] [CrossRef] - Bie, D.; Gutiérrez-Naranjo, M.A.; Zhao, J.; Zhu, Y. A membrane computing framework for self-reconfigurable robots. Nat. Comput.
**2019**, 18, 635–646. [Google Scholar] [CrossRef] - Muniyandi, R.C.; Maroosi, A. A Representation of Membrane Computing with a Clustering Algorithm on the Graphical Processing Unit. Processes
**2020**, 8, 1199. [Google Scholar] [CrossRef] - José-García, A.; Gómez-Flores, W. Automatic clustering using nature-inspired metaheuristics: A survey. Appl. Soft Comput.
**2016**, 41, 192–213. [Google Scholar] [CrossRef] - Peng, H.; Shi, P.; Wang, J.; Riscos-Núñez, A.; Pérez-Jiménez, M. Multiobjective fuzzy clustering approach based on tissue-like membrane systems. Knowl.-Based Syst.
**2017**, 125. [Google Scholar] [CrossRef] - Yang, J.; Chen, R.; Zhang, G.; Peng, H.; Wang, J.; Riscos-Núñez, A. A. A kernel-based membrane clustering algorithm. In Enjoying Natural Computing; Springer: Berlin/Heidelberg, Germany, 2018; pp. 318–329. [Google Scholar]
- Wang, L.; Liu, X.; Sun, M.; Qu, J. An Extended clustering membrane system based on particle swarm optimization and cell-like P system with active membranes. Math. Probl. Eng.
**2020**, 2020, 5097589. [Google Scholar] [CrossRef] [Green Version] - Kennedy, J. Particle Swarm Optimization. In Encyclopedia of Machine Learning; Sammut, C., Webb, G.I., Eds.; Springer: Boston, MA, USA, 2010. [Google Scholar] [CrossRef]
- Jiang, Y.; Peng, H.; Huang, X.; Zhang, J.; Shi, P. A novel clustering algorithm based on P systems. Int. J. Innov. Comput. Inf. Control. IJICIC
**2014**, 10, 753–765. [Google Scholar] - Peng, H.; Wang, J.; Shi, P.; Riscos-Núñez, A.; Pérez-Jiménez, M.J. An automatic clustering algorithm inspired by membrane computing. Pattern Recognit. Lett.
**2015**, 68, 34–40. [Google Scholar] [CrossRef] - Macedo, T.; Oliveira, F. Redis Cookbook: Practical Techniques for Fast Data Manipulation; O’Reilly Media, Inc.: Sebastopol, CA, USA, 2011. [Google Scholar]
- Plugge, E.; Hows, D.; Membrey, P.; Hawkins, T. The Definitive Guide to MongoDB: A Complete Guide to Dealing with Big Data Using MongoDB; Apress: New York, NY, USA, 2015. [Google Scholar]
- Punia, Y.; Aggarwal, R. Implementing Information System Using MongoDB and Redis. Int. J. Adv. Trends Comput. Sci. Eng.
**2014**, 3, 16–20. [Google Scholar] - Abramova, V.; Bernardino, J.; Furtado, P. Experimental evaluation of NoSQL databases. Int. J. Database Manag. Syst.
**2014**, 6, 1. [Google Scholar] [CrossRef] - Gessert, F.; Wingerath, W.; Friedrich, S.; Ritter, N. NoSQL database systems: A survey and decision guidance. Comput. Sci.-Res. Dev.
**2017**, 32, 353–365. [Google Scholar] [CrossRef] - Gupta, A.; Tyagi, S.; Panwar, N.; Sachdeva, S.; Saxena, U. NoSQL databases: Critical analysis and comparison. In Proceedings of the IEEE 2017 International Conference on Computing and Communication Technologies for Smart Nation (IC3TSN), Gurgaon, India, 12–14 October 2017; pp. 293–299. [Google Scholar]
- Indrawan-Santiago, M. Database research: Are we at a crossroad? Reflection on NoSQL. In Proceedings of the IEEE 2012 15th International Conference on Network-Based Information Systems, Melbourne, VIC, Australia, 26–28 September 2012; pp. 45–51. [Google Scholar]
- Armstrong, T.G.; Ponnekanti, V.; Borthakur, D.; Callaghan, M. LinkBench: A database benchmark based on the Facebook social graph. In Proceedings of the 2013 ACM SIGMOD International Conference on Management of Data, New York, NY, USA, 22–27 June 2013; pp. 1185–1196. [Google Scholar]
- Tarczali, T.; Lehotay-Kéry, P.; Kiss, A. Membrane Clustering Using the PostgreSQL Database Management System. In Proceedings of the SAI Intelligent Systems Conference; Springer: Berlin/Heidelberg, Germany, 2020; pp. 377–388. [Google Scholar]
- Dua, D.; Graff, C. UCI Machine Learning Repository. Available online: http://archive.ics.uci.edu/ml (accessed on 27 July 2021).
- Pedregosa, F.; Varoquaux, G.; Gramfort, A.; Michel, V.; Thirion, B.; Grisel, O.; Blondel, M.; Prettenhofer, P.; Weiss, R.; Dubourg, V.; et al. Scikit-learn: Machine Learning in Python. J. Mach. Learn. Res.
**2011**, 12, 2825–2830. [Google Scholar]

**Figure 2.**Example membrane structure [13].

**Figure 3.**Example initial configuration [13].

Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations. |

© 2021 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).

## Share and Cite

**MDPI and ACS Style**

Lehotay-Kéry, P.; Tarczali, T.; Kiss, A.
P System–Based Clustering Methods Using NoSQL Databases. *Computation* **2021**, *9*, 102.
https://doi.org/10.3390/computation9100102

**AMA Style**

Lehotay-Kéry P, Tarczali T, Kiss A.
P System–Based Clustering Methods Using NoSQL Databases. *Computation*. 2021; 9(10):102.
https://doi.org/10.3390/computation9100102

**Chicago/Turabian Style**

Lehotay-Kéry, Péter, Tamás Tarczali, and Attila Kiss.
2021. "P System–Based Clustering Methods Using NoSQL Databases" *Computation* 9, no. 10: 102.
https://doi.org/10.3390/computation9100102