View Javadoc

1   /*
2    * SAT4J: a SATisfiability library for Java Copyright (C) 2004-2006 Daniel Le Berre
3    * 
4    * Based on the original minisat specification from:
5    * 
6    * An extensible SAT solver. Niklas E?n and Niklas S?rensson. Proceedings of the
7    * Sixth International Conference on Theory and Applications of Satisfiability
8    * Testing, LNCS 2919, pp 502-518, 2003.
9    * 
10   * This library is free software; you can redistribute it and/or modify it under
11   * the terms of the GNU Lesser General Public License as published by the Free
12   * Software Foundation; either version 2.1 of the License, or (at your option)
13   * any later version.
14   * 
15   * This library is distributed in the hope that it will be useful, but WITHOUT
16   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
18   * details.
19   * 
20   * You should have received a copy of the GNU Lesser General Public License
21   * along with this library; if not, write to the Free Software Foundation, Inc.,
22   * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23   * 
24   */
25  
26  package org.sat4j.minisat.core;
27  
28  import java.io.Serializable;
29  import java.lang.reflect.Field;
30  
31  /**
32   * Some parameters used during the search.
33   * 
34   * @author daniel
35   * 
36   */
37  public class SearchParams implements Serializable {
38  
39      private static final long serialVersionUID = 1L;
40  
41      /**
42       * Default search parameters.
43       *
44       */
45      public SearchParams() {
46          this(0.95, 0.999, 1.5, 100);
47      }
48  
49      /** 
50       * 
51       * @param conflictBound the initial conflict bound for the first restart.
52       */
53      public SearchParams(int conflictBound) {
54          this(0.95, 0.999, 1.5, conflictBound);
55      }
56  
57      public SearchParams(double confincfactor, int conflictBound) {
58          this(0.95, 0.999, confincfactor, conflictBound);
59      }
60  
61      /**
62       * @param d
63       *            variable decay
64       * @param e
65       *            clause decay
66       * @param f
67       *            conflict bound increase factor
68       * @param i
69       *            initialConflictBound
70       */
71      public SearchParams(double d, double e, double f, int i) {
72          varDecay = d;
73          claDecay = e;
74          conflictBoundIncFactor = f;
75          initConflictBound = i;
76      }
77  
78      /**
79       * @return la valeur de clause decay
80       */
81      public double getClaDecay() {
82          return claDecay;
83      }
84  
85      /**
86       * @return la valeur de var decay
87       */
88      public double getVarDecay() {
89          return varDecay;
90      }
91  
92      private double claDecay;
93  
94      private double varDecay;
95  
96      private double conflictBoundIncFactor;
97  
98      private int initConflictBound;
99  
100     /*
101      * (non-Javadoc)
102      * 
103      * @see java.lang.Object#toString()
104      */
105     @Override
106     public String toString() {
107         StringBuilder stb = new StringBuilder();
108         for (Field field : SearchParams.class.getDeclaredFields()) {
109             if (!field.getName().startsWith("serial")) {
110                 stb.append(field.getName());
111                 stb.append("="); //$NON-NLS-1$
112                 try {
113                     stb.append(field.get(this));
114                 } catch (IllegalArgumentException e) {
115                     e.printStackTrace();
116                 } catch (IllegalAccessException e) {
117                     e.printStackTrace();
118                 }
119                 stb.append(" "); //$NON-NLS-1$
120             }
121         }
122         return stb.toString();
123     }
124 
125     /**
126      * @param conflictBoundIncFactor
127      *            the conflictBoundIncFactor to set
128      */
129     public void setConflictBoundIncFactor(double conflictBoundIncFactor) {
130         this.conflictBoundIncFactor = conflictBoundIncFactor;
131     }
132 
133     /**
134      * @param initConflictBound
135      *            the initConflictBound to set
136      */
137     public void setInitConflictBound(int initConflictBound) {
138         this.initConflictBound = initConflictBound;
139     }
140 
141     /**
142      * @return the conflictBoundIncFactor
143      */
144     public double getConflictBoundIncFactor() {
145         return conflictBoundIncFactor;
146     }
147 
148     /**
149      * @return the initConflictBound
150      */
151     public int getInitConflictBound() {
152         return initConflictBound;
153     }
154 
155     /**
156      * @param claDecay
157      *            the claDecay to set
158      */
159     public void setClaDecay(double claDecay) {
160         this.claDecay = claDecay;
161     }
162 
163     /**
164      * @param varDecay
165      *            the varDecay to set
166      */
167     public void setVarDecay(double varDecay) {
168         this.varDecay = varDecay;
169     }
170 }