1 Introduction

One of the initial models in membrane computing was the P systems; this model was originally introduced by Gheorghe Păun in [1]. Various adaptations and enhancements of P systems have subsequently emerged; refer, for example, to [2]. It has been observed that many of the subsequent P system models have shifted their focus toward computation, particularly parallel and distributed computation, rather than being primarily driven by biological computation. Radu Nicolescu introduced a recent variant of P systems called cP systems [3], which are characterized by compound terms. These expressive cP systems have proven to be effective in efficiently solving NP-complete problems such as the Hamiltonian path, traveling salesman [4], 3-coloring [5], and software verification problems [6]. Moreover, this versatile framework can address PSPACE-hard problems such as TQBF in linear time [7].

This paper uses cP systems to give an efficient parallel solution to the integer-valued quadratic unconstrained Boolean optimization (QUBO) problem. These QUBO instances are generated from many combinatorial NP-hard optimization problems, which is a fundamental framework for adiabatic quantum computations [8, 9]. Here, these quantum computers, such as those produced by D-Wave Systems, are designed to solve explicitly one type of hard optimization problem (e.g., QUBO problem). To solve other NP-hard problems, one does the traditional polynomial-time reduction to QUBO on a classical computer, then attempts to solve the QUBO on these adiabatic quantum machines, and then post-process the quantum output on a classical machine to get a solution to the original NP-hard problem.

The first development of simple polynomial-time reductions from well-known NP-hard problems to QUBO (equivalently Ising) was given by Lucas in [10]. Later many other problems such as dominating set [11], sub/graph isomorphism [12, 13], bounded Steiner tree [14], broadcast-time [15] were developed. The focus recently has been on reducing the input sizes when mapped to QUBO so as to be able to run on the currently sized quantum annealers, such as for MAX-3SAT [16] and k-densest common subgraph [17].

For the remaining part of this paper, we first describe cP systems in Sect. 2, then address how to represent negative numbers with complex objects in Sect. 3, formally define the QUBO problem in Sect. 4, and then show how to solve them efficiently in Sect. 5. Finally, we end with some final comments in Sect. 6.

2 Introduction to cP systems

A cP system is a kind of P system with a structure of separated cells called top-level cells and their sub-cell systems. The functioning of a system is based on rewriting rules. Rules are associated only with top-level cells, and cells inside top-level cells are used as structured storage.

In this paper, we use a simplified version of the cP system with only one top-level cell.

Let us focus on sub-cells and the objects inside them. The elementary object is called term. It can be contained directly inside the top-level cell or inside a sub-cell. These sub-cells are called compound terms and can contain both terms and compound terms. The name of a compound term is a label of the sub-cell. Terms and compound terms are written using lower-case letters, typically from the Latin alphabet, numbers or special symbols, e.g., ab, 1 for terms and \(f(), g(), +()\) for compound terms. As it is common in the literature on membrane systems, we use upper indices for the multiplicity appearance of an object, e.g., \(a^3b^2\) and \(\lambda\) for the empty term—empty multiset. These terms and compound terms are called ground terms. For a better understanding of the relation between the cell system and the compound terms, see Fig. 1.

Fig. 1
figure 1

Relation between cells and terms

The rules associated with top-level cell can manipulate with terms and compound terms. They are designed as rewriting rules of the form

$$\begin{aligned} { current\_state}\,{ lhs} \rightarrow { target\_state}\,{ rhs}, \end{aligned}$$

where lhs and rhs are left-hand side and right-hand side of the rule. States of the top-level cell are objects—terms that are involved in the system only for the purpose of determining the state of the cell. If a rule application does not depend on the state of the cell, the state can be omitted from both sides of the rule.

The speciality of the rules used in cP systems is variables. They are usually labeled with uppercase letters, for example ABC. The variables can be replaced by any multiset of objects—terms. Anonymous variables (discarded) are denoted by an underscore(\(\_\)) in cP systems.

The rules used in lhs and rhs can contain terms and compound terms with variables. As an illustration, \(+(aXY^2)\) may be included in a rule. This compound term, denoted by \(+\), consists of the term a and three instances of the variables X and \(Y^2\).

Before applying the rule that involves variables, all symbols present in the rules can be compared with ground terms through a first-order syntactic unification process (pattern matching). The authors of the paper [18] developed an effective algorithm to address unification challenges related to labeled nested multiset unification efficiently. The unification problem is formed from two parts—terms with variables and the part with ground terms only. The unification lies in finding a set of unifiers for the left-hand side of the rule that contain variables and content of the top-level cell, as follows. A term can only match another copy of itself, but a variable can match any multiset of ground terms (including \(\lambda\)). This may create combinatorial non-determinism when a combination of two or more variables are matched against the same multiset, in which case an arbitrary matching is chosen. For example:

  • Matching \(+(aX)Y^2=+(a^2c)b^2\) deterministically creates a single set of unifiers: \(X=ac,\ Y=b\).

  • Matching \(+(XY^2) = +(de^2f)\) deterministically creates a single set of unifiers: \(X = df, Y = e\).

  • Matching \(+(b(X)c(1 X)) = +(b(1^2)c(1^3))\) deterministically creates one single unifier: \(X = 1^2\).

  • Matching \(+(b(X)c(1 X)) = +(b(1^2)c(1^2))\) fails.

  • Matching \(+(XY)=+(ab)\) non-deterministically creates one of the following four sets of unifiers: \(X=a,\ Y=b;\ X=b,\ Y=a;\ X=\lambda ,\ Y=ab;\ X=ab,\ Y=\lambda\).

So, the rule with variables can be unified in more than one way. Such a rule can be seen as a template for applicable rules that are made by matching the current configuration of the corresponding top-level cell.

The authors of [18] demonstrated that the unification process can be linear with respect to the size of problem (the number of terms in both parts) for well-formed labeled nested multiset unification problems. In well-formed labeled nested multisets there is at most one variable that is not deterministically unifiable by another equation or inclusion relation of the same goal.

The rhs can contain promoters or (and) inhibitors. Promoters are objects that must be present within the top-level cell for the rule to be applicable but are not removed by the rule. Inhibitors are objects that must not be present for the rule to be applicable. If promoters are present in the rule, they are indicated by a | per promoter, and inhibitors by \(\lnot\). To expressly define additional useful matchings, promoters and inhibitors may also use virtual ’equality’ terms, written in infix format, with the \(=\) operator. For example, including the term \((ab = X)\) indicates that, in a valid matching, X equals ab.

For example[19], let us examine a top-level cell that includes a(c) and a(ccc) and compare two rules with the promoter/inhibitor pairs provided (other rule specifics are not included for conciseness).

$$\begin{aligned} \begin{array}{rll} \cdots &{}| a(cXY ) \lnot a(X) &{}\qquad (r1)\\ \cdots &{}| a(cZ) \lnot (Z = XY ) a(X)&{}\qquad (r2). \end{array} \end{aligned}$$

The two rules seem quite alike, and their inhibition tests have the common requirement that there should be no a(X) in the top-level cell. The first rule only tests the non-existence of a(x) for X. The second rule can be read as Z cannot be divided into XY (there is no pair XY equal to Z) so that a(X) is present in the top-level cell. Rule (r1) employs two global variables, X and Y. According to its promoter, a(cXY), these variables can be matched in four different ways: \((r1a)\ X=\lambda , Y=\lambda ;\ (r1b)\ X=cc, Y =\lambda ;\ (r1c) X=\lambda , Y=cc;\ (r1d) X=c, Y=c\). Three different unifications, (r1a), (r1b), (r1c), pass the inhibitor test, as there are no cell terms a( ), a(cc), a( ), respectively. Unification (r1d) fails the inhibitor test because there is one cell term a(c). Rule (r2) uses one global variable, Z, and two local inhibitor variables, XY (their values depend on Z). According to its promoter, a(cZ), variable Z can be matched in two different ways: \((r2a) Z = \lambda ;\ (r2b) Z = cc\). Unification (r2a) passes the inhibitor test because it only generates one local unification, \(X=\lambda , Y = \lambda\), and there is no cell term a( ). Unification (r2b) fails the inhibitor test because it generates all three following local unifications: \((r2b1)\ X=cc, Y= \lambda ;\ (r2b2)\ X=\lambda , Y=cc;\ (r2b3)\ X=c, Y=c\); and there is a cell term corresponding to \((r2b3),\ a(c)\).

There are two modes of application of the rules: min and max. If the rule is applied in min mode, the system non-deterministically selects and applies one of the applicable rules arising from the matching of this rule. If the rule is applied in max mode, then all the applicable rules are executed. The mode of application is associated with every rule and is stated as the sub-index of \(\rightarrow\) (\(\rightarrow _{\min }\) and \(\rightarrow _{\max }\)).

In cP systems with more than one top-level cell, there is another type of rule that determines how the top-level cells can communicate with each other. These are the rules by which objects (messages) are sent through channels. A top-level cell sends objects to a channel buffer from where another top-level cell can retrieve them if they match its receive rule. Variables are also used in these rules, and pattern matching takes place.

In this paper, we use cP systems with one top-level cell only, so we can follow a simplified definition of a cP system with one top-level cell without cell communication rules and channels.

Formally, a single top-level cell cP system is a construct

$$\begin{aligned} \Pi =(A, O, R, S, \overline{s}, f)\text{, } \text{ where } \end{aligned}$$

A is the alphabet of the system formed from atomic objects—terms; all atomic objects can be labels of complex objects—compound terms; O is the set of multisets of initial objects (atomic and complex) in the top-level cell; R is the set of rewriting rules; S is the set of possible states of the top-level cell; and \(\overline{s}\in S\) is the starting state of the top-level cell in the system; \(f \in A\) is the name of the compound object that contains the result of the computation.

The system initiates a computation in the initial configuration (the initial content of the top-level cell) specified by the definition of the cP system. At each step of the computation, all rules are analyzed to identify all potential unifications that match the current configuration. A set of rules is generated based on valid unifications from a single rule with variables. Depending on the rule’s mode (either min or max), a non-deterministically chosen rule from this set or all rules can be applied. If there is no unification to the pair (the rule, top-level cell content), the rule is not applicable and cannot be used in a given step of the computation.

If in a given configuration, the ruleset does not contain any rule that has a non-empty set of applicable rules after unification, the system computation halts. From this halting configuration we can obtain the result of the computation, which is the contents of a compound object labeled f. If there is no such object in the halting configuration, the computation halts without giving a result. In the case of more than one resulting object in the top-level cell, the result is obtained by the union of these multisets.

3 Representing and operating on integers

When solving discrete numerical problems, we encounter the problem of representing negative integers in terms of cP systems.

In cP systems, as in other membrane systems, to represent natural numbers, a multiset of identical objects whose number is just that number is used. For example, the number 4 can be represented as four occurrences of the object 1, and the absence of such an object can represent the number 0.

Consider a representation where each integer consists of two components, a positive and a negative, just as a complex number consists of a real and an imaginary component. For every integer a, there is

$$\begin{aligned} i(x,y), \text{ where } x,y\in \mathbb {N}_0 \Longleftrightarrow a=x-y. \end{aligned}$$

For example:

$$\begin{aligned} i(1,4) \Longleftrightarrow -3=1-4. \end{aligned}$$

Note that there are multiple such representations for each integer. We consider a number representation in canonical form if at least one of its components is equal to zero.

$$\begin{aligned} i(5,8)\Longleftrightarrow & {} -3=5-8,\\ i(8,11)\Longleftrightarrow & {} -3=8-11,\\ i(0,3)\Longleftrightarrow & {} -3=0-3. \end{aligned}$$

Every representation i(xy) can be converted into canonical form:

$$\begin{aligned} i(x,y) \sim \left\{ \begin{array}{lll} i(x',0)\qquad &{}\text{ for } x\ge y,&{} \text{ where } x'=x-y,\\ i(0,y')&{}\text{ for } x<y, &{} \text{ where } y'=y-x.\\ \end{array} \right. \end{aligned}$$

We can also define operations similar to those with integers, such as addition, subtraction, and multiplication. Division is not given because the set of integers is not closed under division.

$$\begin{aligned} i(x,y) + i(x',y')= & {} i(x+x', y+y'),\\ i(x,y) + i(x',y')\Longleftrightarrow & {} (x-y) + (x'-y') \\ = x+x'-y-y'= & {} (x+x') - (y+y') \\\Longleftrightarrow & {} i(x+x', y+y'),\\ i(x,y) - i(x',y')= & {} i(x+y', y+x'),\\ i(x,y) - i(x',y')\Longleftrightarrow & {} (x-y) - (x'-y') \\ = x-x'-y+y'= & {} (x+y') - (y+x') \\\Longleftrightarrow & {} i(x+y', y+x'),\\ i(x,y) \cdot i(x',y')= & {} i(x\cdot x'+x'\cdot y', y\cdot x'+x\cdot y'),\\ i(x,y) \cdot i(x',y')\Longleftrightarrow & {} (x-y) \cdot (x'-y') \\ = x\cdot x'-x\cdot y'-y\cdot x' + y\cdot y'= & {} (x\cdot x' + y\cdot y') - (x\cdot y' + y\cdot x')\\\Longleftrightarrow & {} i(x\cdot x'+x'\cdot y', y\cdot x'+x\cdot y'). \end{aligned}$$

For the simulation of QUBO, we do not need to use multiplication; only addition and subtraction are needed.

3.1 Counting with integers in cP systems

In cP systems, the number i(xy) can be seen as a cell that contains two sub-cells labeled by \(\mathord {+}\) and \(\mathord {-}\), \(i\left( \mathord {+}(x)\ \mathord {-}(y)\right)\). For example

$$\begin{aligned} \begin{array}{rcl}i(3,2) &{}\rightsquigarrow &{} i\left( \mathord {+}(111)\ \mathord {-}(11)\right) = i\left( \mathord {+}(3)\ \mathord {-}(2)\right) ,\\ i(1,4) &{}\rightsquigarrow &{} i\left( \mathord {+}(1)\ \mathord {-}(1111)\right) = i\left( \mathord {+}(1)\ \mathord {-}(4)\right) ,\\ i(2,0) &{}\rightsquigarrow &{} i\left( \mathord {+}(11)\ \mathord {-}()\right) = i\left( \mathord {+}(2)\ \mathord {-}()\right) , \\ i(0,0) &{}\rightsquigarrow &{} i\left( \mathord {+}()\ \mathord {-}()\right) . \end{array} \end{aligned}$$

In cP systems, one rule is sufficient to implement the addition and subtraction of two integers:

$$\begin{aligned}{} & {} \longrightarrow _{\min } k\left( \mathord {+}(AC)\ \mathord {-}(BD)\right) \ |\ i\left( \mathord {+}(A)\ \mathord {-}(B)\right) \ j\left( \mathord {+}(C)\ \mathord {-}(D)\right) ,\\{} & {} \longrightarrow _{\min } k\left( \mathord {+}(AD)\ \mathord {-}(BC)\right) \ |\ i\left( \mathord {+}(A)\ \mathord {-}(B)\right) \ j\left( \mathord {+}(C)\ \mathord {-}(D)\right) . \end{aligned}$$

Both rules contain promoters in the form of two integers with which to perform addition or subtraction operations. The first is denoted by i and the second by j. The unifiers ABCD always take values according to the contents of the corresponding objects denoted by \(\mathord {+}\) and \(\mathord {-}\) within objects ij. Applying the rule will thus create a new object denoted by k, whose contents are the modified compound object \(\mathord {+}\) and \(\mathord {-}\) as shown in the previous equations for numerical operations with integers.

4 QUBO

Motivated recently by the emerging popularity of adiabatic quantum computing, QUBO (quadratic unconstrained binary optimization) is an NP-hard mathematical optimization problem. Optimization seeks the best solution for a problem based on conflicting criteria, such as minimizing time or distance in logistics planning. QUBO problems involve binary variables with at most quadratic terms, making them suitable for binary optimization.

For this paper, we are interested in the integer version of the problem of minimizing a quadratic objective function

$$\begin{aligned} x^* = \min _{\vec {x}}\vec {x}^TQ\vec {x}, \end{aligned}$$

where

  • \(n \in \mathbb {N}_0\)—the number of variables in \(\vec {x},\)

  • \(i,j \in \mathbb {N}_0\),

  • \(\vec {x}\) is a n-vector of binary (Boolean) variables \(x_i \in \left\{ 0;1\right\} , 0\le i \le n-1\),

  • Q is an upper-triangular \(n \times n\) matrix where \(q_{i,j} \in \mathbb {Z}, 0\le i\le j\le n-1\) are possibly non-zero coefficients.

Formally, QUBO problems are of the form:

$$\begin{aligned} x^* = \min _{\vec {x}}\sum _{i\le j}x_iq_{i,j}x_j,\quad \text{ where } x_i,x_j\in \{0,1\}. \end{aligned}$$

The constraint that the matrix Q must have integer values does not diminish the effectiveness of the QUBO problem, as many reductions from other NP-hard problems to it can be transformed into this format. (See, for example, [10, 11, 15].)

5 cP system QUBO solver

We now develop a cP system that finds the minimal value of a QUBO in three phases of computation.

  1. 1.

    In the first phase, all possible values assignment is generated.

  2. 2.

    The second phase is devoted to the generation of all polynomials.

  3. 3.

    In the third phase, related coefficients are added together to evaluate potential solutions for the assignments produced from phases 1 and 2.

We write the number \(z\in \mathbb {N}\) instead of \(1^z\) in the elemental cells.

Input:

  • For every variable \(x_i\) that stores the value \(y_i\in \{0,1\}\) there is a complex object

    $$\begin{aligned} a\left( in(i)val(y'_i)\right) , \text{ where } y'_i\in \{\lambda ,1\}. \end{aligned}$$
  • For every coefficient \(q_{i,j}\) there is complex object

    $$\begin{aligned} q\left( in1(i) in2(j) val(\mathord {+}(x)\ \mathord {-}(y))\right) , \text{ where } q_{i,j}=x-y. \end{aligned}$$
  • Two counters (counter-like objects): \(C_1(\lambda ), C_2(n)\).

  • Empty list (complex object) of the values of variables: \(l(C_1(\lambda ))\) with counter \(C_1(\lambda )\) inside.

5.1 The first phase

The first phase aims to generate all possible combinations of values to which variables \(x_0,\dots x_{n-1}\) can be set.

$$\begin{aligned} S_1\quad C_2(1X) \longrightarrow _{\min } S_2\quad v(\lambda )v(1)C_2(X). \end{aligned}$$
(1)

By the execution of rule (1), two complex objects—\(v(\lambda )\) and v(1) are generated and the number of 1s inside \(C_2()\) is decreased by one.

$$\begin{aligned} \begin{array}{llclll} S_2\quad &{} &{}\longrightarrow _{\max }&{}S_1\quad &{} l\left( a\left( in(X)val(Y)\right) C_1(X1)Z\right) &{}|\ l\left( C_1(X)Z\right) \\ &{}&{}&{}&{}&{}|\ v(Y).\\ \end{array} \end{aligned}$$
(2)

For every combination of XZ and Y, there can be one unified rule. Because X is the same for all objects in the cP system in the current step of computation, Z is unique for every object l(), and there are two possible evaluations for Y. In total, \(1\times |l()| \times 2\) rules that can be executed in parallel.

$$\begin{aligned}{} & {} \begin{array}{llclll} S_2\quad &{}l(\_) &{}\longrightarrow _{\max }&{}S_1,\quad &{} &{}\\ \end{array} \end{aligned}$$
(3)
$$\begin{aligned}{} & {} \begin{array}{llclll} S_2\quad &{}v(\_) &{}\longrightarrow _{\max }&{}S_1.\quad &{} &{}\\ \end{array} \end{aligned}$$
(4)

Rules (3) and (4) can erase all objects l() and v() inside the cell.

An example will be used to illustrate how the rules work.

$$\begin{aligned} \begin{array}{ll} S_2:&{} l(C_1(\lambda )) C_2(n-1)\quad v(\lambda ) v(1)\qquad \hbox {example configuration}\\ &{}(2)_1\qquad X=\lambda , Y=\lambda , Z=\lambda \\ &{}\begin{array}{llclll} S_2\quad &{} &{}\longrightarrow _{\max }&{}S_1\quad &{} l\left( a\left( in(\lambda )val(\lambda )\right) C_1(1)\right) &{}|\ l\left( C_1(\lambda )\right) \\ &{}&{}&{}&{}&{}|\ v(\lambda )\\ \end{array}\\ &{}(2)_2\qquad X=\lambda , Y=1, Z=\lambda \\ &{}\begin{array}{llclll} S_2\quad &{} &{}\longrightarrow _{\max }&{}S_1\quad &{} l\left( a\left( in(\lambda )val(1)\right) C_1(1)\right) &{}|\ l\left( C_1(\lambda )\right) \\ &{}&{}&{}&{}&{}|\ v(1)\\ \end{array}\\ &{}(3)\\ &{}S_2\quad l\left( C_1(\lambda )\right) \longrightarrow _{\max } S_1\\ &{}(4)_1\\ &{}S_2\quad v(\lambda ) \longrightarrow _{\max } S_1\\ &{}(4)_2\\ &{}S_2\quad v(1) \longrightarrow _{\max } S_1\quad \\ &{}S_1:\quad l\left( a\left( in(\lambda )val(\lambda )\right) C_1(1)\right) \ l\left( a\left( in(\lambda )val(1)\right) C_1(1)\right) C_2(n-1). \end{array} \end{aligned}$$

When the number stored in the counter \(C_2\) is reduced to zero, rule (1) is no longer applicable. The top-level cell contains \(2^n\) complex objects l() having different combinations of variable values. To move on to the next stage, we need to restore the counter value \(C_2\) and insert a component m() into the objects l() for use in the next stage. The object \(l'()\) stores the values of variables.

$$\begin{aligned}{} & {} S_1\; C_2()\;\longrightarrow _{\min } S'_2\;C_2(X1)|\ l\left( ZC_1(X)\right) , \end{aligned}$$
(5)
$$\begin{aligned}{} & {} S'_2\; l\left( ZC_1(X)\right) \;\longrightarrow _{\max } S_3\; l\left( ZC_1()m()l'(Z)\right) . \end{aligned}$$
(6)

5.2 The second phase

The idea of the second phase is to generate objects p(), which will contain representatives of quadratic elements that will be multiplied by the coefficients of one row (say i-th) of the matrix Q. However, if the value of the variable \(x_i\) is zero, the generation of the row is omitted since its value will be zero.

Since Q is upper-triangular, the i-th row has at most \(n-i\) non-zero coefficients that will be multiplied by quadratic elements consisting of \(x_i\) and \(x_j\), where \(n-1 \ge j \ge i \ge 0\).

For example: Let \(\vec {x}=(1,1,1,1)\). After the second phase, the complex object m() will contain the following objects:

$$\begin{aligned} \begin{array}{lcccc} p(w(\lambda )&{}a(in(\lambda )val(1))&{}a(in(1)val(1))&{}a(in(11)val(1))&{}a(in(111)val(1)))\\ p(w(1)&{}&{}a(in(1)val(1))&{}a(in(11)val(1))&{}a(in(111)val(1)))\\ p(w(11)&{}&{}&{}a(in(11)val(1))&{}a(in(111)val(1)))\\ {p(w(111)}&{}&{}&{}&{}a(in(111)val(1))).\\ \end{array} \end{aligned}$$

When there is some zero value in the vector \(\vec {x}\), the corresponding p() is present in m() in “an empty" form. For example, if \(\vec {x}=(1,0,1,0)\):

$$\begin{aligned} \begin{array}{lcccc} p(w(\lambda )&{}a(in(\lambda )val(1))&{}a(in(1)val(0))&{}a(in(11)val(1))&{}a(in(111)val(0)))\\ p(w(1))\\ p(w(11)&{}&{}&{}a(in(11)val(1))&{}a(in(111)val(0)))\\ {p(w(111)}&{}&{}&{}\\ \end{array} \end{aligned}$$
$$\begin{aligned}{} & {} S_3\quad l\left( m\left( Z'\right) a\left( in(X)val(1)\right) Zl'(Y)C_1(X)\right) \longrightarrow _{\max } S'_3\nonumber \\{} & {} \quad l\left( m\left( p\left( w(X)a\left( in(X)val(1)\right) Z\right) Z'\right) Zl'(Y)C_1(X)\right) \end{aligned}$$
(7)
$$\begin{aligned}{} & {} S_3\quad l\left( m\left( p\left( w(X)\right) Z'\right) a\left( in(X)val(\lambda )\right) Zl'(Y)C_1(X)\right) \longrightarrow _{\max } S'_3\nonumber \\{} & {} \quad l\left( m\left( Z'\right) Zl'(Y)C_1(X)\right) . \end{aligned}$$
(8)

Suppose the top-level cell is in state \(S_3\), exactly one rule is applied to each object l(), either rule (7) or rule (8). In the state \(S'_3\), rule (9) is executed in max mode, causing the counter \(C_1\) to increase inside all objects l(). After that, rule (10) is applied to decrease the value of counter \(C_2\) by one.

$$\begin{aligned}{} & {} S'_3\quad l\left( C_1(X)Z\right) \longrightarrow _{\max } S''_3\; l\left( C_1(1X)Z\right) , \end{aligned}$$
(9)
$$\begin{aligned}{} & {} S''_3\quad C_2(1X) \longrightarrow _{\min } S_3\;C_2(X). \end{aligned}$$
(10)

If the counter \(C_2\) is empty, all objects p() have been generated, and it is time to proceed to the next stage. First, using rule (11), we delete the counter, and the top-left cell goes to state \(S_4\). Then, we also delete unnecessary objects from all objects l() using rule (12).

$$\begin{aligned}{} & {} S_3\quad C_2()\longrightarrow _{\min } S_4, \end{aligned}$$
(11)
$$\begin{aligned}{} & {} S_4\quad l\left( m(X)l'(Z)C_1(Y)\right) \longrightarrow _{\max } S_4\; l\left( X\,r(+(\lambda ) -(\lambda )) l'(Z)C_1(Y)\right) . \end{aligned}$$
(12)

5.3 The third phase

In the third stage, for each combination of non-zero values of \(x_ix_j\), we will add the value of the coefficient \(q_{ij}\) to the result in the object l().

$$\begin{aligned}{} & {} S_4\quad l\left( r\left( \mathord {+}(U')\, {-}(V')\right) p\left( w(X)a\left( in(Y)val(1)\right) Z\right) Z'C_1(X)\right) \nonumber \\{} & {} \quad \longrightarrow _{\max } S_4\quad l\left( r\left( \mathord {+}(UU') -(VV')\right) p\left( w(X)Z\right) Z'C_1(X)\right) \nonumber \\{} & {} \quad |\ q\left( in1(X)in2(Y)val(\mathord {+}(U){-}(V))\right) , \end{aligned}$$
(13)
$$\begin{aligned}{} & {} S_4\quad l\left( p\left( w(X)a\left( in(Y)val()\right) Z\right) Z'C_1(X)\right) \nonumber \\{} & {} \quad \longrightarrow _{\max } S_4\quad l\left( p\left( w(X)Z\right) Z'C_1(X)\right) \nonumber \\{} & {} \quad |\ q\left( in1(X)in2(Y)val(Z'')\right) . \end{aligned}$$
(14)

When an object p() with a leading variable \(x_i\) no longer contains any object a(), i.e., a complex object l() contains an object p(w(i)) and an inner counter \(C_1(i)\), the internal counter needs to be decreased. If counter \(C_1()\) is already zero, the top-level cell changes its state to \(S_5\).

$$\begin{aligned}{} & {} S_4\quad l(p(w(1X))ZC_1(1X))\longrightarrow _{\max } S_4\quad l(ZC_1(X)), \end{aligned}$$
(15)
$$\begin{aligned}{} & {} S_4\quad l(p(w())Zl'(Y)C_1())\longrightarrow _{\max } S_5\quad l(Zl'(Y))\quad \lnot l(C_1(1X)\_). \end{aligned}$$
(16)

Normalization:

$$\begin{aligned}{} & {} S_5\quad l(r({+}(XY) {-}(Y))\_) \longrightarrow _{\max } S_6\quad l(r({+}(X) {-}(\lambda ))\_), \end{aligned}$$
(17)
$$\begin{aligned}{} & {} S_5\quad l(r({+}(X) {-}(XY))\_) \longrightarrow _{\max } S_6\quad l(r({+}(\lambda ) {-}(Y))\_). \end{aligned}$$
(18)

If there is at least one negative integer in r()s we will search for maximum of negative part of r(). If there are only positive integers (including zero) we will search for the minimum of the positive part of r().

$$\begin{aligned}{} & {} S_6\quad l(r({+}(Z) {-}(1Y))Z') \longrightarrow _{\min } S_7\quad l(r(\mathord {+}(Z)\ \mathord {-}(1Y))Z'), \end{aligned}$$
(19)
$$\begin{aligned}{} & {} S_6\quad l(r({+}(X) {-}(\lambda ))Z) \longrightarrow _{\min } S_8\quad l(r(\mathord {+}(X) {-}(\lambda ))Z)\nonumber \\{} & {} \quad \lnot l(r({+}(Z') {-}(1Y))\_). \end{aligned}$$
(20)

When the top-level cell is in the state \(S_7\), there is at least one negative result stored in r(). Then, we need to find the maximum of the negative part of r().

$$\begin{aligned}{} & {} S_7\,\longrightarrow _{\min } S_F\, f(val({+}(\lambda ) {-}(X))Z)\quad |\ l(r({+}(\lambda ) {-}(X))Z)\nonumber \\{} & {} \quad \lnot l(r({+}(\lambda ) {-}(X1Y))\_). \end{aligned}$$
(21)

To find a minimum of positive and zero values, we need to add one to the content of \(\mathord {+}()\) so the value of each r() is at least one. Then, we find a minimum of positive parts of r()s.

$$\begin{aligned}{} & {} S_8\quad l(r({+}(X) {-}(\lambda ))Z) \longrightarrow _{\max } S_9\; l(r({+}(X1) {-}(\lambda ))Z), \end{aligned}$$
(22)
$$\begin{aligned}{} & {} S_9\quad \longrightarrow _{\min } S_F\;f(val({+}(X) {-}(\lambda ))Z)\nonumber \\{} & {} \quad |\ l(r(\mathord {+}(1X)\ \mathord {-}(\lambda ))Z)\nonumber \\{} & {} \quad \lnot (X=YW)\ l(r(\mathord {+}(Y)\ \mathord {-}(\lambda ))\_). \end{aligned}$$
(23)

The result of the computation is a complex object that contains variable values in the sub-cell f().

In the initial phase, the simulation algorithm for the QUBO system generates all possible combinations of evaluations for logic variables (binary values 0,1). This phase operates in linear time, thanks to the utilization of the max mode of the rules. Subsequently, in the second phase, the combinations of variables found in terms of the quadratic form are produced, with this process running at worst in quadratic time. In the third phase, the system performs the multiplication of the terms in quadratic form by the coefficients obtained from the matrix Q, which is also accomplished in linear time. Finally, normalization and selection of results are performed, both of which require constant time. An aspect that could significantly extend the duration of the algorithm is the identification of all unifiers that meet the matching criteria. Traditional unification algorithms like Robinson’s [20, 21] exhibit exponential time complexity. However, the authors of the paper “An efficient labeled nested multiset unification algorithm”[18] have introduced an algorithm named LNMU (labeled nested multiset unification algorithm). LNMU is a non-deterministic algorithm that consists of eight transformations and achieves unification in linear time for well-structured labeled nested multisets. There are only two functions (Functor and Variable) called during LNMU that are non-deterministic. They can lead to exponential time duration. While solving well-structured labeled nested multiset unification problems, function Variable is called that finds one valid match for a given variable (with the other matches being invalid). In our model, most of the rules are defined in such a way that the problem is well structured for all possible configurations of the top-level cell. However, for rules that are used in the max mode to generate all possible combinations of given objects, the time required for the matching is exponential. Given that all possible combinations of variable assignments are generated in the initial phase, the spatial complexity grows exponentially in relation to the size of the problem (number of variables).

6 Conclusions

The paper explores the use of P systems with compound objects (cP systems) to efficiently solve the quadratic unconstrained Boolean optimization (QUBO) problem. It introduces cP systems as an extension of P systems, focusing on parallel and distributed computation. The study details the structure of cP systems, the representation of integers, and the formal definition of the QUBO problem. Highlights the application of cP systems for solving NP-complete problems and provides information on addressing QUBO instances derived from NP-hard optimization problems. The research showcases the potential of cP systems to revolutionize problem-solving strategies, particularly in the context of complex optimization challenges and adiabatic quantum computing.