Python implementation for paper "Inferring P Systems From Their Computing Steps: An Evolutionary Approach": Alberto Leporatia, Luca Manzoni, Giancarlo Mauria, Gloria Pietropolli, Claudio Zandrona, 2021.
Inferring the structure and operation of a computing model, given some observations of its behavior, is in general a desirable but daunting task. In this paper we try to solve a constrained version of this problem. Given a P system Π with active membranes and using cooperative rewriting, communication, and division rules, let C be a collection of pairs (Ci, Ci+1) of consecutive configurations of Π, for 0 ≤ i < n. We feed this collection as input to a (µ+λ) evolutionary algorithm that evolves a population of (initially random) P systems, each with its own rules, with the aim of obtaining an individual that approximates Π as well as possible. We discuss the results obtained on four different benchmark problems, designed to test the ability to infer cooperative rewriting, communication, and membrane division rules. We will also provide a description of how fitness results are influenced by different setting of the hyperparameters of the evolutionary algorithm. The results show that the proposed approach is able to find correct solutions for small problems, and it is a promising research direction for the automatic synthesis of P systems.
Code runs with python 3.8.5 on Ubuntu 20.04, after installing the following requirements:
pip install -r requirements.txt
To run the code, enter the following command:
python3 experiments.py --problem --size --number_run==1 --conf_file==conf.json --prefix=='out'
where the inputs arguments stands for:
-
--problem
is the benchmark considered (that can be: send-in, send-out, assignment and tm) -
--size
is the size of the problem considered (in this paper have been considered size: 2, 3, 4 and 5) -
--size
is the number of run performed for the experiment considered (in this paper 30 run has been performed for each experiment) -
--conf_file
is the .json configuration file containing the values of the hyperparameters:max_lhs
: maximum left-hand side dimensionmax_rhs
: maximum right-hand side dimensionmin_ruleset_size
: miminum dimension for the rulesetmax_ruleset_size
: maximum dimension for the rulesetmax_mutation
: maximum number of mutation allowedmu
: population sizelmbd
: number of offspringsgenerations
: number of generations
-
--prefix
is the name of the .csv file where results are saved
The codes that reproduce the plots of the paper are contained in the folder plot
.
To get Figure 2-5 it is sufficient to run:
python3 Fitness.py
For example, for the send-in problem, the results obtained with different hyperparameters setting are plotted as:
To get Figure 1 is sufficent to run:
python3 Fitness.py --problem --mu --max_ruleset_size
For example, for mu=1 and m=20 we obtain: