| 
 1 | 
  
 | package org.sat4j; | 
| 
 2 | 
  
 |  | 
| 
 3 | 
  
 | import java.io.FileNotFoundException; | 
| 
 4 | 
  
 | import java.io.IOException; | 
| 
 5 | 
  
 |  | 
| 
 6 | 
  
 | import org.sat4j.minisat.SolverFactory; | 
| 
 7 | 
  
 | import org.sat4j.reader.InstanceReader; | 
| 
 8 | 
  
 | import org.sat4j.reader.ParseFormatException; | 
| 
 9 | 
  
 | import org.sat4j.reader.Reader; | 
| 
 10 | 
  
 | import org.sat4j.specs.ContradictionException; | 
| 
 11 | 
  
 | import org.sat4j.specs.IProblem; | 
| 
 12 | 
  
 | import org.sat4j.specs.ISolver; | 
| 
 13 | 
  
 | import org.sat4j.specs.IVecInt; | 
| 
 14 | 
  
 | import org.sat4j.specs.TimeoutException; | 
| 
 15 | 
  
 | import org.sat4j.tools.RemiUtils; | 
| 
 16 | 
  
 | import org.sat4j.tools.SolutionCounter; | 
| 
 17 | 
  
 |  | 
| 
 18 | 
  
 |  | 
| 
 19 | 
  
 |  | 
| 
 20 | 
  
 |  | 
| 
 21 | 
  
 |  | 
| 
 22 | 
  
 |  | 
| 
 23 | 
  
 |  | 
| 
 24 | 
  
 |  | 
| 
 25 | 
  
 |  | 
| 
 26 | 
  
 |  | 
| 
 27 | 
  
 |  | 
| 
 28 | 
  
 |  | 
| 
 29 | 
  
 |  | 
| 
 30 | 
  
 |  | 
| 
 31 | 
  
 |  | 
| 
 32 | 
  
 |  | 
| 
 33 | 
  
 | public class MoreThanSAT { | 
| 
 34 | 
  
 |  | 
| 
 35 | 
  
 |      | 
| 
 36 | 
  
 |  | 
| 
 37 | 
  
 |  | 
| 
 38 | 
  
 |  | 
| 
 39 | 
  
 |  | 
| 
 40 | 
 0
 |     private MoreThanSAT() {
 | 
| 
 41 | 
  
 |          | 
| 
 42 | 
  
 |     } | 
| 
 43 | 
  
 |      | 
| 
 44 | 
 0
 |     public static void main(String[] args) {
 | 
| 
 45 | 
 0
 |         ISolver solver = SolverFactory.newMiniLearning();
 | 
| 
 46 | 
 0
 |         SolutionCounter sc = new SolutionCounter(solver);
 | 
| 
 47 | 
 0
 |         solver.setTimeout(3600); 
 | 
| 
 48 | 
 0
 |         Reader reader = new InstanceReader(solver);
 | 
| 
 49 | 
  
 |  | 
| 
 50 | 
  
 |          | 
| 
 51 | 
 0
 |         try {
 | 
| 
 52 | 
 0
 |             IProblem problem = reader.parseInstance(args[0]);
 | 
| 
 53 | 
 0
 |             if (problem.isSatisfiable()) {
 | 
| 
 54 | 
 0
 |                 System.out.println(Messages.getString("MoreThanSAT.0")); 
 | 
| 
 55 | 
 0
 |                 System.out.println(reader.decode(problem.model()));
 | 
| 
 56 | 
 0
 |                 IVecInt backbone = RemiUtils.backbone(solver);
 | 
| 
 57 | 
 0
 |                 System.out.println(Messages.getString("MoreThanSAT.1") + backbone); 
 | 
| 
 58 | 
 0
 |                 System.out.println(Messages.getString("MoreThanSAT.2")); 
 | 
| 
 59 | 
 0
 |                 System.out.println(Messages.getString("MoreThanSAT.3") 
 | 
| 
 60 | 
  
 |                         + sc.countSolutions()); | 
| 
 61 | 
  
 |             } else { | 
| 
 62 | 
 0
 |                 System.out.println(Messages.getString("MoreThanSAT.4")); 
 | 
| 
 63 | 
  
 |             } | 
| 
 64 | 
  
 |         } catch (FileNotFoundException e) { | 
| 
 65 | 
 0
 |             e.printStackTrace();
 | 
| 
 66 | 
  
 |         } catch (ParseFormatException e) { | 
| 
 67 | 
 0
 |             e.printStackTrace();
 | 
| 
 68 | 
  
 |         } catch (IOException e) { | 
| 
 69 | 
 0
 |             e.printStackTrace();
 | 
| 
 70 | 
  
 |         } catch (ContradictionException e) { | 
| 
 71 | 
 0
 |             System.out.println(Messages.getString("MoreThanSAT.5")); 
 | 
| 
 72 | 
  
 |         } catch (TimeoutException e) { | 
| 
 73 | 
 0
 |             System.out.println(Messages.getString("MoreThanSAT.6")); 
 | 
| 
 74 | 
  
 |         } | 
| 
 75 | 
  
 |     } | 
| 
 76 | 
  
 | } |