Partition ======================= Description ----------- This example try to solve the well-known NP-complete problem of partition problem, by means of the so called simple Kernel P systems (skP systems). Model ----- The corresponding P-Lingua file is the following:: @model k=3; def main() { call partition(); } def partition() { call init_cells(); call init_multisets(); call init_rules(); } def init_cells() { @mu = [[]'1 []'2]'0; } def init_multisets() { @ms(1) = S; @ms(2) = A{1}; @ms(2) += v{i}*w{i} : 1<=i<=n; /* Environment alphabet: */ } def init_rules() { /* C1 */ /* r1,1 */ @guard {>=+T} ? [S]'1 --> [yes]'0; /* r1,2 */ @guard {>=+F} && {>=-T} ? [S]'1 --> [no]'0; /* C2 */ /* r2,i */ [A{i}]'2 |--> [B{i},A{i+1}]'2 [A{i+1}]'2 : 1<=i [B{n},X]'2 [X]'2; /* r2,i,j */ @guard {=+B{i}}&&{=-B{j}}&&{=+X} || {=-B{i}}&&{=+B{j}}&&{=+X} ? [v{i},v{j}]'2 --> [v]'2 : 1<=i [Y]'2; /* r2,n+2 */ @guard (|{{>=+v{l1}}}:{1<=l1<=n}) || {<>+v*k} ? [Y]'2 --> [F]'1; /* r2,n+3 */ @guard (&{{>=-v{l2}}}:{1<=l2<=n}) &&{=+v*k} ? [Y]'2 --> [T]'1; } Files ----- A first run +++++++++++ The initial **model** presented above was **extended** to solve not only the decission problem but also the collection of possible partitions for a given instance of the problem. .. container:: boldlink * `Custom application `_, defining the needed input and output tables for partition problem. * `Model file `_, P-Lingua file with the parametrized file specifying the family of P systems for solving the partition problem. The custom interface enable the user to introduce the data corresponding to each different scenario. * `Scenario file `_, for a specific instance of the problem (that is, a specific graph to set the partition to). Final results +++++++++++++ .. image:: images/PartitionChart.png :align: center :width: 70% The original model ++++++++++++++++++ These are the needed files for the original model: * `App `_, defining the needed input and output tables for partition problem. * `Model `_, P-Lingua file with the parametrized file specifying the family of P systems for solving the partition problem. The custom interface enable the user to introduce the data corresponding to each different scenario. * `Scenario `_, for a specific instance of the problem (that is, a specific graph to set the partition to). References ---------- * `Kernel P Systems - Version I `_ (`detailed publication info `_). * `Solving the partition problem by using tissue-like P systems with cell division `_ (`detailed info `_). * `A linear time solution to the partition problem in a cellular tissue-like model `_ (`detailed `_).