1 package org.sat4j.tools;
2
3 import org.sat4j.core.VecInt;
4 import org.sat4j.specs.ISolver;
5 import org.sat4j.specs.IVecInt;
6
7 public class AbstractMinimalModel extends SolverDecorator<ISolver> {
8
9
10
11
12 private static final long serialVersionUID = 1L;
13 protected final IVecInt pLiterals;
14 protected final SolutionFoundListener modelListener;
15
16 public static IVecInt positiveLiterals(ISolver solver) {
17 IVecInt literals = new VecInt(solver.nVars());
18 for (int i = 1; i <= solver.nVars(); i++) {
19 literals.push(i);
20 }
21 return literals;
22 }
23
24 public static IVecInt negativeLiterals(ISolver solver) {
25 IVecInt literals = new VecInt(solver.nVars());
26 for (int i = 1; i <= solver.nVars(); i++) {
27 literals.push(-i);
28 }
29 return literals;
30 }
31
32 public AbstractMinimalModel(ISolver solver) {
33 this(solver, SolutionFoundListener.VOID);
34 }
35
36 public AbstractMinimalModel(ISolver solver, IVecInt p) {
37 this(solver, p, SolutionFoundListener.VOID);
38 }
39
40 public AbstractMinimalModel(ISolver solver,
41 SolutionFoundListener modelListener) {
42 this(solver, negativeLiterals(solver), modelListener);
43 }
44
45 public AbstractMinimalModel(ISolver solver, IVecInt p,
46 SolutionFoundListener modelListener) {
47 super(solver);
48 this.pLiterals = new VecInt(p.size());
49 p.copyTo(this.pLiterals);
50 this.modelListener = modelListener;
51
52 }
53
54 }