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.MixedDataStructureDanielWL;
23  import org.sat4j.minisat.core.DataStructureFactory;
24  import org.sat4j.minisat.core.SearchParams;
25  import org.sat4j.minisat.core.Solver;
26  import org.sat4j.minisat.learning.MiniSATLearning;
27  import org.sat4j.minisat.orders.VarOrderHeap;
28  import org.sat4j.minisat.restarts.MiniSATRestarts;
29  import org.sat4j.minisat.uip.FirstUIP;
30  import org.sat4j.pb.IPBSolver;
31  
32  public class SolverFactory extends ASolverFactory<IPBSolver> {
33  
34      private static final long serialVersionUID = 1L;
35  
36      /**
37       * Builds a SAT solver for the MAX sat evaluation. Full clause learning, no
38       * restarts,
39       * 
40       * @return a
41       */
42      public static Solver<DataStructureFactory> newMiniMaxSAT() {
43          MiniSATLearning<DataStructureFactory> learning = new MiniSATLearning<DataStructureFactory>();
44          Solver<DataStructureFactory> solver = new Solver<DataStructureFactory>(new FirstUIP(), learning,
45                  new MixedDataStructureDanielWL(), new SearchParams(1.2,
46                          100000), new VarOrderHeap(),
47                  new MiniSATRestarts());
48          learning.setDataStructureFactory(solver.getDSFactory());
49          learning.setVarActivityListener(solver);
50          return solver;
51      }
52      
53      @Override
54      public IPBSolver defaultSolver() {
55          return newDefault();
56      }
57  
58      @Override
59      public IPBSolver lightSolver() {
60          return newLight();
61      }
62  
63      public static IPBSolver newDefault() {
64          return org.sat4j.pb.SolverFactory.newDefault();
65      }
66   
67      public static IPBSolver newLight() {
68          return org.sat4j.pb.SolverFactory.newLight();
69      }
70  }