Keywords

1 Introduction

The maximum satisfiability problem (MaxSAT) is an optimization version of the satisfiability problem (SAT), aiming to minimize the number of falsified clauses, and it has various applications [23]. A generalization of MaxSAT is the weighted Partial MaxSAT problem, where clauses are divided into hard and soft clauses with weights (positive numbers). The goal is to find an assignment that satisfies all hard clauses and minimizes the total weight of falsified soft clauses. MaxSAT solvers have made substantial progress in recent years [2, 18, 20, 24, 26].

However, MaxSAT has limited expressiveness, and it can be generalized from the Boolean case to Satisfiability Modulo Theories (SMT), deciding the satisfiability of a first-order logic formula with respect to certain background theories, leading to a generalization called MaxSAT Modulo Theories (MaxSMT) [30]. With its enhanced expressive power, MaxSMT has various practical applications, such as safety verification [6], concurrency debugging [34], non-termination analysis [19] and superoptimization [1].

Compared to MaxSAT and SMT solving, the research on MaxSMT solving is still in its preliminary stage. Cimatti et al. [13] introduced the concept of “Theory of Costs” and developed a method to manage SMT with Pseudo-Boolean (PB) constraints and minimize PB cost functions. Sebastiani et al. [31, 32] proposed an approach to solve MaxSMT problem by encoding it into SMT with PB functions. A modular approach for MaxSMT called Lemma-Lifting was proposed by Cimatti et al. [14], which involves the iterative exchange of information between a lazy SMT solver and a purely propositional MaxSAT solver. The implicit hitting set approach was lifted from the propositional level to SMT [15]. Two well-known MaxSMT solvers are OptiMathSAT [33] and \(\nu Z\) [5], which are currently the state-of-the-art MaxSMT solvers. In this paper, we focus on the MaxSMT problem with the background theory of Linear Integer Arithmetic (LIA), denoted as MaxSMT(LIA), which consists of arithmetic atomic formulas in the form of linear equalities or inequalities over integer variables.

We apply the local search method to solve MaxSMT(LIA). Although local search has been successfully used to solve SAT [3, 4, 11, 12, 22] and recently to SMT on the theory of bit-vector theory [16, 27,28,29], integer arithmetic [9, 10] and real arithmetic [21, 25], this is the first time that it is applied to MaxSMT.

First, we propose a novel operator for integer variables, named pairwise operator, to enrich the search space by simultaneously operating on two variables. When the algorithm falls into a local optimum w.r.t. operations on a single variable, further exploring the neighborhood structure of the pairwise operator can help it escape from the local optimum.

Moreover, a novel method based on the concept of compensation is proposed to determine the pairwise operation. Specifically, the pairwise operation is determined as a pair of simultaneous modifications, one to satisfy a falsified clause, and the other to minimize the disruptions the first operation might wreak on the already satisfied clauses. Then, a two-level picking heuristic is proposed to distinguish these pairwise operations, by considering the potential of a literal becoming falsified.

Based on the above novel ideas, we design the first local search solver for MaxSMT(LIA) called PairLS, prioritizing hard clauses over soft clauses. Experiments are conducted on massive benchmarks. New instances based on SMT-LIB are generated to enrich the benchmarks for MaxSMT(LIA). We compare our solver with 2 state-of-the-art MaxSMT(LIA) solvers, OptiMathSAT and \(\nu Z\). Experimental results show that our solver is competitive with these state-of-the-art solvers. We also present the evolution of solution quality over time, showing that PairLS can efficiently find a promising solution within a short cutoff time. Ablation experiments are also conducted to confirm the effectiveness of proposed strategies. Moreover, we apply the pairwise operator to enhance the local search algorithm of Satisfiability Modulo Theories, demonstrating its extensibility.

2 Preliminary

2.1 MaxSMT on Linear Integer Arithmetics

The Satisfiability modulo theories (SMT) problem determines the satisfiability of a given quantifier-free first-order formula with respect to certain background theories. Here we consider the theory of Linear Integer Arithmetic (LIA), consisting of arithmetic formulae in the form of linear equalities or inequalities over integer variables (\(\sum _{i=0}^n{a_ix_i\le k}\) or \(\sum _{i=0}^n{a_ix_i = k}\))Footnote 1. An atomic formula can be a propositional variable or an arithmetic formula. A literal is an atomic formula, or the negation of an atomic formula. A clause is the disjunction of a set of literals, and a formula in conjunctive normal form (CNF) is the conjunction of a set of clauses. Given the sets of propositional variables and integer variables, denoted as P and X respectively, an assignment \(\alpha \) is a mapping \(X\rightarrow Z\) and \(P\rightarrow \{false, true\}\), and \(\alpha (x)\) denotes the value of a variable x under \(\alpha \).

The (weighted partial) MaxSAT Modulo Theories problem (MaxSMT for short) is generated from SMT. The clauses are divided into hard clauses and soft clauses with positive weight.

Definition 1

For a MaxSMT instance F, given the current assignment \(\alpha \), if it satisfies all hard clauses, then \(\alpha \) is a feasible solution, and the cost is defined as the total weight of all falsified soft clauses, denoted as \(cost(\alpha )\).

MaxSMT aims to find a feasible solution with minimal cost, that is, to find an assignment satisfying all hard clauses and minimizing the sum of the weights of the falsified soft clauses. The MaxSMT problem with the background theory of LIA is denoted as MaxSMT(LIA).

Example 1

Given a MaxSMT(LIA) formula \(F=c_1\wedge c_2 \wedge c_3 \wedge c_4=(a-b\le 1\vee a-c\le 0)\wedge (b-c\le -1)\wedge (a-d\le 1)\wedge (A)\), let \(c_1\) and \(c_4\) be hard clauses, \(c_2\) and \(c_3\) be soft clauses with weight 1 and 2. Given the current assignment \(\alpha =\{a=0,b=0,c=0,d=0, A=true\}\), \(cost(\alpha )=1\), since only \(c_2\) is falsified.

2.2 Local Search Components

The clause weighting scheme is a popular local search method that associates an additional property (which is an integer number) called penalty weight to clauses and dynamically adjusts them to prevent the search from getting stuck in a local optimum. We adopt the weighting scheme called Weighting-PMS [20] to instruct the search. Weighting-PMS has been applied in state-of-the-art local search solvers for MaxSAT, such as SATLIKE [20] and SATLIKE3.0 [8]. When the algorithm falls into a local optimum, the Weighting-PMS dynamically adjusts the penalty weights of hard and soft clauses to guide the search direction.

Note that the penalty weight and the original weight of soft clauses are different. The goal of MaxSMT is to minimize the total original weight of unsatisfied soft clauses, while the penalty weight is updated during the search process, guiding the search in a promising direction.

Another key component of a local search algorithm is the operator, defining how to modify the current solution. When an operator is instantiated by specifying the variable to operate and the value to assign, an operation is obtained.

Definition 2

The score of an operation op, denoted by score(op), is the decrease of the total penalty weight of falsified clauses caused by applying op.

An operation is decreasing if its score is greater than 0. Note that given a set of clauses, denoted as C, the score of operation op on the subformula composed of C is denoted as \(score_C(op)\).

3 Review of LS-LIA

As our algorithm adopts the two-mode framework of LS-LIA, which is the first local search algorithm for SMT(LIA) [9], we briefly review it in this section.

After the initialization, the algorithm switches between Integer mode and Boolean mode. In each mode, an operation on a variable of the corresponding data type is selected to modify the current assignment. The two modes switch to each other when the number of non-improving steps of the current mode reaches a threshold. The threshold is set to \(L\times P_b\) for the Boolean mode and \(L\times P_i\) for the Integer mode, where \(P_b\) and \(P_i\) denote the proportion of Boolean and integer literals to all literals in falsified clauses, and L is a parameter.

In the Boolean mode, the flip operator is adopted to modify a Boolean variable to the opposite of its current value. In the Integer mode as in Algorithm 1, a novel operator called critical move (cm for short) is proposed by considering the literal-level information.

Definition 3

The critical move operator, denoted as \(cm(x,\ell )\), assigns an integer variable x to the threshold value making literal \(\ell \) true, where \(\ell \) is a falsified literal containing x.

Specifically, the threshold value refers to the minimum modification to x that can make \(\ell \) true. Example 2 is given to help readers understand the definition.

Example 2

Given two falsified literals \(\ell _1:(2a-b\le -3)\) and \(\ell _2:(5c-d=5)\), and the current assignment is \(\alpha =\{a=0,b=0,c=0,d=0\}\). Then \(cm(a,\ell _1)\), \(cm(b,\ell _1)\), \(cm(c,\ell _2)\), and \(cm(d,\ell _2)\) refers to assigning a to -2, assigning b to 3, assigning c to 1 and assigning d to \(-5\) respectively.

An important property of the critical move operator is that after the execution, the corresponding literal must be true. Therefore, by picking a falsified literal and performing a cm operation on it, we can make the literal true.

In our algorithm for MaxSMT(LIA), the critical move operator is also adopted to make a falsified literal become true.

figure a

4 Pairwise Operator

In this section, we introduce a novel operator for integer variables, denoted as pairwise operator. It extends the original critical move operator to enrich the search space, serving as an extended neighborhood structure. We first introduce the motivation for the pairwise operator. Then, based on pairwise operator, the framework of our algorithm in Integer mode is proposed.

4.1 Motivation

The original critical move operator only considers one single variable each time. However, it may miss potential decreasing operations. Specifically, when there exists no decreasing critical move operation, operations that simultaneously modify two variables may be decreasing, which are not considered by critical move.

Example 3

Given a formula \(F=c_1\wedge c_2\wedge c_3=(a-b\le -2)\wedge (b-c\le 1)\wedge (c-a\le 1)\) where the penalty weight of each clause is 1. and the current assignment is \(\alpha =\{a=0,b=0,c=0\}\). There exist two critical move operations: \(cm(a,a-b\le -2)\) and \(cm(b,a-b\le -2)\), referring to assigning a to \(-2\) and b to 2, respectively. Both operations are not decreasing, since these two operations will respectively falsify \(c_3\) and \(c_2\). However, simultaneously assigning b to 2 and c to 1 can be decreasing, since after the operation, all clauses become satisfied.

Thus, the pairwise operator simultaneously modifying two variables is proposed to find a decreasing operation when there is no decreasing cm operation.

Definition 4

Pairwise operator, denoted as \(p(v_1,v_2,val_1,val_2)\), will simultaneously modify \(v_1\) to \(val_1\) and \(v_2\) to \(val_2\) respectively, where \(v_1\) and \(v_2\) are integer variables, and \(val_1\) and \(val_2\) are integer parameters.

The pairwise operator can be regarded as an extended neighborhood. When there exists no decreasing critical move operation, indicating that the local optimum of modifying individual variables is found, the search space can be expanded by simultaneously modifying two variables, and the solution may be further improved, thanks to the following property:

Proposition 1

Given a pairwise operation \(op_1=p(v_1,v_2,val_1,val_2)\), and two operations individually assigning \(v_1\) to \(val_1\) and \(v_2\) to \(val_2\), denoted as \(op_2\) and \(op_3\) respectively. \(op_1\) is decreasing while neither \(op_2\) nor \(op_3\) is decreasing, only if there exists a clause c containing both \(v_1\) and \(v_2\), and on clause c, \(score_{\{c\}}(op_1)>score_{\{c\}}(op_2)+score_{\{c\}}(op_3)\).

The proof can be found in Appendix A in [17]. Recall the Example 3, the pairwise operation that simultaneously assigns b to 2 and c to 1, denoted as \(op_1\), is decreasing, while none of the operations that individually assign b to 2 and c to 1, denoted as \(op_2\) and \(op_3\), is decreasing. The reason lies in that b and c both appear in the clause \(c_2\), and \(score_{\{c_2\}}(op_1)>score_{\{c_2\}}(op_2)+score_{\{c_2\}}(op_3)\).

5 Compensation-Based Picking Heuristic

To find a decreasing pairwise operation when there is no decreasing cm operation, we first introduce a method based on the concept of compensation to determine pairwise operations, which can satisfy the necessary condition in Proposition 1 (Details can be found in Lemma 1 of Appendix B in [17]). Then, among these pairwise operations, we propose a two-level heuristic to distinguish them, by considering the potential of the compensated literals becoming falsified.

5.1 Pairwise Operation Candidates for Compensation

Motivation for compensation: Since one variable may exist in multiple literals, changing a variable will affect all literals containing the variable, and may make some originally true literals become false. Moreover, if the literal is the reason for some clauses being satisfied, i.e., it is the only true literal in the clause, then falsifying the literal also falsifies the clause.

Formally, for an operation op, we define a special set of literals \(CL(op)=\{\ell | \ell \) is true and is the only true literal for some clauses, but \(\ell \) would become false after individually performing \(op\}\). After performing an operation op, the literals in the set CL(op) are of special interest since some clauses containing such a literal would become falsified.

Concept of compensation: Let \(op_1\) and \(op_2\) denote two operations modifying individual variables. To minimize the disruptions that \(op_1\) might wreak on the already satisfied clauses, another operation \(op_2\) is simultaneously executed to make a literal \(\ell \in CL(op_1)\) remain true under the assignment after operating \(op_1\). \(op_2\) is denoted as compensation for \(\ell \), and literals in the set CL are denoted as C ompensated L iterals.

Compensation-based pairwise operation: A pairwise operation p(\(v_1\),\(v_2\), \(val_1\),\(val_2\)) can be regarded as simultaneously performing a pair of operations modifying individual variables, \(op_1\) assigning \(v_1\) to \(val_1\) and \(op_2\) assigning \(v_2\) to \(val_2\). The procedure to determine \(op_1\) and \(op_2\) is described as follows.

First, a candidate \(op_1\) is chosen to satisfy a falsified clause. To this end, we pick a variable \(v_1\) from a false literal \(\ell _1\) in a random falsified clause, and \(op_1\) is the corresponding cm operation, \(cm(v_1,\ell _1)\). It prioritizes literals from hard clauses and soft clauses are considered only when all hard clauses are satisfied. To obtain sufficient candidates of \(op_1\), K (a parameter) literals are randomly selected from overall falsified clauses, and all variables in these literals are considered. The set of all candidate \(op_1\) found in this stage is denoted as CandOp.

Second, given a literal \(\ell _2\in CL(op_1)\), the \(op_2\) w.r.t \(op_1\in CandOp\) is determined to guarantee that \(\ell _2\) remains true after simultaneously performing \(op_1\) and \(op_2\), meaning that \(op_2\) is selected to compensate for \(\ell _2\). Specifically, to determine \(op_2\), we pick a variable \(v_2\) appearing in a literal \(\ell _2\in CL(op_1)\), and calculate the value \(val_2\) according to \(cm(v_2,\ell _2)\) assuming \(op_1\) performed.

Example 4

Let us consider the formula presented in Example 3: \(F=c_1\wedge c_2\wedge c_3=(a-b\le -2)\wedge (b-c\le 1)\wedge (c-a\le 1)\) where the penalty weight of each clause is 1, and the current assignment is \(\alpha =\{a=0,b=0,c=0\}\). There is no decreasing critical move operation. As shown in Fig. 1, performing \(op_1=cm(b,a-b\le -2)\) that assigns b to 2 would falsify the literal \(\ell =(b-c\le 1)\), the only true literal in \(c_2\). To compensate for \(\ell \), the operation \(op_2\) that assigns c to 1 is determined according to \(cm(c,\ell )\), assuming that \(op_1\) has been performed. All clauses become satisfied after simultaneously performing \(op_1\) and \(op_2\), and thus a decreasing pairwise operation p(bc, 2, 1) is found.

Fig. 1.
figure 1

Given the literal \(\ell =(b-c\le 1)\), the axis refers to the value of \((b-c)\). Individually performing \(op_1\) will falsify \(\ell \), while \(op_2\) can compensate for \(\ell \).

Note that there may exist multiple variables in the literal \(\ell _2\in CL(op_1)\), and thus given the operation \(op_1\), and the literal \(\ell _2\) selected in the second step, a set of pairwise operations is determined by considering all variables in \(\ell _2\) except the variable in \(op_1\), denoted as pair_set(\(\ell _2\),\(op_1\)).

5.2 Two-Level Heuristic

Among the literals selected in the second step of determining a pairwise operation, we consider that some literals are more likely to become false, and should be given higher priority. Thus, we distinguish such literals from others. They are formally defined as follows.

Definition 5

Given an assignment \(\alpha \), and a literal in the form of \(\sum _{i=0}^n {a_ix_i \le k}\), we denote \(\varDelta =\sum _{i=0}^n{a_i\alpha (x_i)}-k\). The literal is a fragile literal if \(\varDelta =0\) holds. Any true literal with \(\varDelta <0\) is safe.

A fragile literal with \(\varDelta =0\) is true as the inequality \(\varDelta \le 0\) holds, but it can be falsified by any little disturbance that enlarges \(\varDelta \) of the corresponding fragile literal. Comparatively, a literal is safe means that even if the value of a variable in the literal changes comparatively larger (as long as \(\varDelta \le 0\) after the modification), it remains true.

Example 5

Consider the formula: \(F=l_1\wedge l_2\wedge l_3= (b-a\le -1) \wedge (a-c\le 0)\wedge (a-d\le 3)\), where the current assignment is \(\alpha =\{a=0,b=0,c=0,d=0\}\). \(l_2\) and \(l_3\) are two true literals. \(l_2\) is a fragile literal since its \(\varDelta =0\), while \(l_3\) is a safe literal since its \(\varDelta <0\). We consider that \(l_2\) is more fragile than \(l_3\), since a small disturbance, \(cm(a,l_1)\) that assigns a to 1, can falsify \(l_2\) but not \(l_3\).

In the second step of determining a pairwise operation, among those compensated literals, we prefer fragile literals and prioritize the corresponding pairwise operations. Based on the intuition above, a two-level picking heuristic is defined:

  • We first choose the decreasing pairwise operation involving a fragile compensated literal.

  • If there exists no such decreasing pairwise operation, we further select the pairwise operation involving safe compensated literals.

5.3 Algorithm for Picking a Pairwise Operation

Based on the picking heuristic, the algorithm for picking a pairwise operation is described in Algorithm 2. In the beginning, we initialize the set of pairwise operations involving fragile and safe compensated literals, denoted as FragilePairs and SafePairs (line 1). Firstly, K (a parameter) false literals are picked from overall falsified clauses, and all critical move operations in these literals are added into CandOp (lines 2–7). Note that it prioritizes hard clauses over soft clauses.

Then, for each operation \(op_1\in CandOp\), we go through each compensated literal \(\ell _2\in CL(op_1)\). If \(\ell _2\) is fragile (resp. safe), the set of corresponding pairwise operations determined by \(pair\_set(\ell _2,op_1)\) are added to the FragilePairs (resp. SafePairs) (line 8–13).

According to the two-level picking heuristic, if there exist decreasing operations in FragilePairs, we pick the one with the greatest score (lines 14–15). Otherwise, we pick a decreasing operation in SafePairs if it exists (lines 16–17). An operation with the greatest score is selected via the BMS heuristic [7]. Specifically, the BMS heuristic samples t pairwise operations (a parameter), and selects the decreasing one with the greatest score.

figure b

6 Local Search Algorithm

Based on the above novel components, we propose our algorithm for MaxSMT(L

IA) called PairLS, prioritizing hard clauses over soft clauses. PairLS initializes the complete current solution \(\alpha \) by assigning all Integer variables to 0 and all Boolean variables to false. Then, PairLS switches between Integer mode and Boolean mode. When the time limit is reached, the best solution \(\alpha ^*\) and the corresponding best cost \(cost^*\) are reported if a feasible solution can be found. Otherwise, “No solution found” is reported.

The Integer mode of PairLS is described in Algorithm 3. The current solution \(\alpha \) is iteratively modified until the number of non-improving steps \(non\_impr\_step\) exceeds the threshold bounds (line 1). If a feasible solution with a smaller cost is found, then the best solution \(\alpha ^*\) and the best cost \(cost^*\) are updated (lines 2–3). In each iteration, the algorithm first tries to find a decreasing critical move operation with the greatest score via BMS heuristic [7] (line 4–7). Note that it prefers to pick operations from falsified hard clauses, and falsified soft clauses are picked only if all hard clauses are satisfied. If it fails to find any decreasing critical move operation, indicating that it falls into the local optimum of modifying individual variables, then it continues to search the neighborhood of pairwise operation (line 8). If there exists no decreasing operation in both neighborhoods, the algorithm further escapes from the local optimum by updating the penalty weight (line 10), and satisfying a random clause by performing a critical move operation in it, preferring the one with the greatest score (lines 11–13). Specifically, it also prioritizes hard clauses over soft clauses.

In the Boolean mode, the formula is reduced to a subformula that purely contains Boolean variables, which is indeed a MaxSAT instance. Thus, our algorithm performs in the same way as SATLike3.0Footnote 2, a state-of-the-art local search algorithm for MaxSAT [20].

figure c

7 Experiments

Experiments are conducted on 3 benchmarks to evaluate PairLS, comparing it with state-of-the-art MaxSMT solvers. The promising experimental result indicates that our algorithm is efficient and effective in most instances. We also present the evolution of solution quality over time, showing that PairLS can efficiently find promising solutions within a short time limit. Moreover, the ablation experiment is carried out to confirm the effectiveness of our proposed strategies.

7.1 Experiment Preliminaries

Implementation: PairLS is implemented in C++ and compiled by g++ with the ‘-O3’ option enabled. There are 3 parameters in the solver: L for switching modes; t (the number of samples) for the BMS heuristic; K denotes the size of CandOp. The parameters are tuned according to our preliminary experiments and suggestions from the previous literature. They are set as follows: \(L=20\), \(t=100\), \(K=10\).

Competitors: We compare PairLS with 2 state-of-the-art MaxSMT solvers, namely OptiMathSAT(version 1.7.3) and \(\nu Z\)(version 4.11.2). OptiMathSAT applies MaxRes as the MaxSAT engine, denoted as Opt_res, while the default configuration encodes the MaxSMT problem as an optimization problem, denoted as Opt_omt. \(\nu Z\) also has 2 configurations based on the MaxSAT engines MaxRes and WMax, denoted as \(\nu Z\)_res and \(\nu Z\)_wmax, respectively. The binary code of OptiMathSAT and \(\nu Z\) is downloaded from their websites.

Benchmarks: Our experiments are conducted on 3 benchmarks. Those instances where the hard constraints are unsatisfiable are excluded, as they do not have feasible solutions.

Benchmark MaxSMT-LIA: This benchmark consists of 5520 instances generated based on SMT(LIA) instances from SMT-LIBFootnote 3. The original SMT(LIA) benchmark consists of 690 instances from 3 families, namely bofill, convert, and wisaFootnote 4. We adopt the same method to generate instances as in previous literature [15]: adding randomly chosen arithmetic atoms in the original problem with a certain proportion as unit soft assertions. 4 proportions of soft clauses (denoted as SR) are applied, namely 10%, 25%, 50% and 100%. 2 MaxSMT instances can be generated from each original SMT instance, based on different ways to associate soft clauses with weights: one associates each soft clause with a unit weight of 1, and the other associates each soft clause with a random weight between 1 and the total number of atoms. Instances with unit weights and random weights are not distinguished as in [15]. The total number of instances is \(690\times 2\times 4=5520\), where 690 denotes the number of original SMT(LIA) instances, 2 denotes 2 kinds of weights associated with soft clauses, and 4 denotes the 4 proportions of soft clauses. Note that the “bofill” family was adopted in [15], while the family of “convert” and “wisa” are new instances.

Benchmark MaxSMT-IDL: This benchmark contains 12888 new MaxSM-T instances generated by the above method, based on 1611 SMT(IDL) instances including all families from SMT-LIBFootnote 5 (similar to MaxSMT-LIA benchmark, the total number of instances is \(1611\times 2\times 4=12888\)). Instances with unit weights and random weights are also not distinguished when reporting results.

Benchmark LL: The benchmark was proposed in [14]. Unsatisfiable instances and instances over linear real arithmetic are excluded, resulting in 114 instances in total. 56 instances contain soft clauses with unit weights of 1, and 58 instances contain soft clauses with random weights ranging from 1 to 100. Instances with Unit weights and Random weights are distinguished as in [14].

Experiment Setup: All experiments are conducted on a server with Intel Xeon Platinum 8153 2.00GHz and 2048G RAM under the system CentOS 7.7.1908. Each solver executes one run for each instance in these benchmarks, as they contain sufficient instances. The cutoff time is set to 300 s for the MaxSMT-LIA and MaxSMT-IDL benchmarks as previous work [15], and 1200 s for the LL benchmark as previous work [14]. The source code and generated benchmarks can be found in the repositoryFootnote 6.

For each family of instances, we report the number of instances where the corresponding solver can find the best solution with the smallest cost among all solvers, denoted by \(\#win\), and the average running time to yield those best solutions, denoted as time. Note that when multiple solvers find the best solution with the same cost within the cutoff time, they are all considered to be winners. The solvers with the most \( \#win\) in the table are emphasized with bold value.

The solution found by solvers and the corresponding time are defined as follows: As for complete solvers, \(\nu Z\) and OptiMathSAT, we take the best upper bound found within the cutoff time as their solution, and the time to find such upper bound is recorded by referring to the log file. Note that the proving time for complete solvers is excluded. As for PairLS, the best solution found so far within the cutoff time and the time to find such a solution are recorded.

7.2 Comparison to Other MaxSMT Solvers

Results on benchmark MaxSMT-LIA: As presented in Table 1, PairLS shows competitive and complementary performance on this benchmark. Except for the 25% category, PairLS always leads in the total number of winning instances regardless of the proportion of soft clauses SR. On the “bofill” family, PairLS performs better on instances with larger SR, confirming that PairLS is good at solving hard instances. On the “convert” family, PairLS outperforms all competitors regardless of SR. On the “wisa” family, PairLS cannot rival its competitors. In Fig. 3 of Appendix C in [17], we also present the run time comparison between PairLS and the best configuration of competitors, namely \(\nu Z\)_res and Opt_res. The run time comparison indicates that PairLS is more efficient than Opt_res and is complementary to \(\nu Z\)_res.

Results on benchmark MaxSMT-IDL: As presented in Table 2, PairLS can significantly outperform all competitors regardless of the proportion of soft clauses. In the overall benchmark, PairLS can find a better solution than all competitors on 53.5% of total instances, and it can lead the best competitor by 1224 “winning” instances, confirming its dominating performance. In Fig. 4 of Appendix C in [17], we also present the run time comparison between PairLS and the best configuration of competitors, namely \(\nu Z\)_res and Opt_omt, indicating that PairLS is more efficient than competitors in instances with small SR.

Results on LL benchmark: The results are shown in Table 3. PairLS shows comparable but overall poor performance compared to its competitors on this benchmark. One possible reason is that the front-end encoding for these benchmarks would generate many auxiliary Boolean variables, while PairLS cannot effectively explore the Boolean structure as LS-LIA [9]. Specifically, the average number of auxiliary variables in this benchmark is 1220, while the counterparts in MaxSMT-LIA and MaxSMT-IDL are 327 and 528.

Table 1. Results on benchmark MaxSMT-LIA. The results are classified according to the proportion of soft clauses, SR. Sum presents the overall performance.
Table 2. Results on MaxSMT-IDL benchmark. The results are classified according to the proportion of soft clauses, SR. Sum presents the overall performance.
Table 3. Results on LL benchmark. Instances with Unit weights and Random weights are distinguished. Sum presents the overall performance.

7.3 Evolution of Solution Quality

To be more informative in understanding how the solvers compare in practice, the evolution of the solution quality over time is presented. Specifically, we evaluate the overall performance on the MaxSMT-LIA and MaxSMT-IDL benchmark with 4 cutoff times, denoted as cutoff: 50, 100, 200, 300 s. Given an instance, the proportion of the cost to the sum of soft clause weights is denoted as \(cost_P\)Footnote 7. The average \(cost_P\) over time is presented in Fig. 2, showing that PairLS can efficiently find high-quality solutions within a short time. Moreover, we also report the “winning” instances over time. As shown in Appendix D in [17], on each benchmark, PairLS leads the best competitor by at least 645 “winning” instances regardless of the cutoff time, confirming its dominating performance.

7.4 Effectiveness of Proposed Strategies

To analyze the effectiveness of our proposed strategies, two modified versions of PairLS are proposed as follows.

  • To analyze the effectiveness of pairwise operation, we modify PairLS by only using the critical move operator, leading to the version \(v_{no\_pair}\).

  • To analyze the effectiveness of two-level heuristic in compensation-based picking heuristic for picking a pairwise operation, PairLS is modified by selecting pairwise operation without distinguishing the fragile and safe compensated literals, leading to the version \(v_{one\_level}\).

We compare PairLS with these modified versions on 3 benchmarks. The results of this ablation experiment are presented in Table 4, confirming the effectiveness of the proposed strategies.

Moreover, we also analyze the extension for simultaneously operating on more variables. PairLS is modified by simultaneously modifying three variables, where the third variable is modified to compensate for the second one, leading to the version \(v_{tuple}\). We conduct our experiments on MaxSMT-LIA. The results are in Appendix E in [17]. When \(N = 3\), the number of possible operations increases from O(\(k^2\)) to O(\(k^3\)), where k is the number of variables in unsatisfied clauses. This might significantly slow down the searching process, indicating that modifying 2 variables simultaneously is the best choice of trade-off between cost and effectiveness.

Fig. 2.
figure 2

Evolution of average \(cost_P\)

Table 4. Comparing PairLS with its modified versions. The number of instances where PairLS performs better and worse are presented, denoted as #better and #worse respectively. An algorithm is better than its competitor on a certain instance if it can find a solution with a lower cost.

8 Discussion on the Extension of Pairwise Operation

Since pairwise operator can be adapted to SMT(LIA) instances without additional modifications, a potential extension is incorporating it into the local search algorithm for SMT(LIA). When there is no decreasing cm operation in the integer mode of LS-LIA (Algorithm 1 in Page 5), we apply the pairwise operator to LS-LIA to enrich the search space as in PairLS, resulting in the corresponding version called LS-LIA-Pair. We compare LS-LIA-Pair with LS-LIA and other complete SMT solvers on SMT(LIA) instances, reporting the number of unsolved instances for each solver (Details are in Appendix F in [17]). Without any specific customization tailored for SMT, in both categories, LS-LIA-Pair can solve 20 more instances compared to LS-LIA, which demonstrates that pairwise operator is an extensible method and could be further explored to enhance the local search algorithm for SMT.

9 Conclusion and Future Work

In this paper, we propose the first local search algorithm for MaxSMT(LIA), called PairLS, based on the following components. A novel pairwise operator is proposed to enrich the search space. A compensation-based picking heuristic is proposed to determine and distinguish pairwise operations. Experiments show that PairLS is competitive with state-of-the-art MaxSMT solvers, and pairwise operator is a general method. Moreover, we also would like to develop a local search algorithm for MaxSMT on non-linear integer arithmetic and Optimization Modulo Theory problems. Lastly, we hope to combine PairLS with complete solvers, since PairLS can efficiently find a solution with promising cost, serving as an upper bound for complete solvers to prune the search space.