View Javadoc

1   /*******************************************************************************
2   * SAT4J: a SATisfiability library for Java Copyright (C) 2004-2008 Daniel Le Berre
3   *
4   * All rights reserved. This program and the accompanying materials
5   * are made available under the terms of the Eclipse Public License v1.0
6   * which accompanies this distribution, and is available at
7   * http://www.eclipse.org/legal/epl-v10.html
8   *
9   * Alternatively, the contents of this file may be used under the terms of
10  * either the GNU Lesser General Public License Version 2.1 or later (the
11  * "LGPL"), in which case the provisions of the LGPL are applicable instead
12  * of those above. If you wish to allow use of your version of this file only
13  * under the terms of the LGPL, and not to allow others to use your version of
14  * this file under the terms of the EPL, indicate your decision by deleting
15  * the provisions above and replace them with the notice and other provisions
16  * required by the LGPL. If you do not delete the provisions above, a recipient
17  * may use your version of this file under the terms of the EPL or the LGPL.
18  *******************************************************************************/
19  package org.sat4j.maxsat;
20  
21  import org.sat4j.core.ASolverFactory;
22  import org.sat4j.minisat.constraints.MixedDataStructureDaniel;
23  import org.sat4j.minisat.core.DataStructureFactory;
24  import org.sat4j.minisat.core.ILits;
25  import org.sat4j.minisat.core.SearchParams;
26  import org.sat4j.minisat.core.Solver;
27  import org.sat4j.minisat.learning.MiniSATLearning;
28  import org.sat4j.minisat.orders.VarOrderHeap;
29  import org.sat4j.minisat.restarts.MiniSATRestarts;
30  import org.sat4j.minisat.uip.FirstUIP;
31  import org.sat4j.pb.IPBSolver;
32  
33  public class SolverFactory extends ASolverFactory<IPBSolver> {
34  
35      private static final long serialVersionUID = 1L;
36  
37      /**
38       * Builds a SAT solver for the MAX sat evaluation. Full clause learning, no
39       * restarts,
40       * 
41       * @return a
42       */
43      public static Solver<ILits,DataStructureFactory<ILits>> newMiniMaxSAT() {
44          MiniSATLearning<ILits,DataStructureFactory<ILits>> learning = new MiniSATLearning<ILits,DataStructureFactory<ILits>>();
45          Solver<ILits,DataStructureFactory<ILits>> solver = new Solver<ILits,DataStructureFactory<ILits>>(new FirstUIP(), learning,
46                  new MixedDataStructureDaniel(), new SearchParams(1.2,
47                          100000), new VarOrderHeap<ILits>(),
48                  new MiniSATRestarts());
49          learning.setDataStructureFactory(solver.getDSFactory());
50          learning.setVarActivityListener(solver);
51          return solver;
52      }
53      
54      @Override
55      public IPBSolver defaultSolver() {
56          return newDefault();
57      }
58  
59      @Override
60      public IPBSolver lightSolver() {
61          return newLight();
62      }
63  
64      public static IPBSolver newDefault() {
65          return org.sat4j.pb.SolverFactory.newDefault();
66      }
67   
68      public static IPBSolver newLight() {
69          return org.sat4j.pb.SolverFactory.newLight();
70      }
71  }