View Javadoc

1   /*******************************************************************************
2    * SAT4J: a SATisfiability library for Java Copyright (C) 2004, 2012 Artois University and CNRS
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   * Based on the original MiniSat specification from:
20   *
21   * An extensible SAT solver. Niklas Een and Niklas Sorensson. Proceedings of the
22   * Sixth International Conference on Theory and Applications of Satisfiability
23   * Testing, LNCS 2919, pp 502-518, 2003.
24   *
25   * See www.minisat.se for the original solver in C++.
26   *
27   * Contributors:
28   *   CRIL - initial API and implementation
29   *******************************************************************************/
30  package org.sat4j.minisat.core;
31  
32  import java.io.Serializable;
33  import java.lang.reflect.Field;
34  
35  /**
36   * Some parameters used during the search.
37   * 
38   * @author daniel
39   * 
40   */
41  public class SearchParams implements Serializable {
42  
43      private static final long serialVersionUID = 1L;
44  
45      /**
46       * Default search parameters.
47       * 
48       */
49      public SearchParams() {
50          this(0.95, 0.999, 1.5, 100);
51      }
52  
53      /**
54       * 
55       * @param conflictBound
56       *            the initial conflict bound for the first restart.
57       */
58      public SearchParams(int conflictBound) {
59          this(0.95, 0.999, 1.5, conflictBound);
60      }
61  
62      public SearchParams(double confincfactor, int conflictBound) {
63          this(0.95, 0.999, confincfactor, conflictBound);
64      }
65  
66      /**
67       * @param d
68       *            variable decay
69       * @param e
70       *            clause decay
71       * @param f
72       *            conflict bound increase factor
73       * @param i
74       *            initialConflictBound
75       */
76      public SearchParams(double d, double e, double f, int i) {
77          this.varDecay = d;
78          this.claDecay = e;
79          this.conflictBoundIncFactor = f;
80          this.initConflictBound = i;
81      }
82  
83      /**
84       * @return la valeur de clause decay
85       */
86      public double getClaDecay() {
87          return this.claDecay;
88      }
89  
90      /**
91       * @return la valeur de var decay
92       */
93      public double getVarDecay() {
94          return this.varDecay;
95      }
96  
97      private double claDecay;
98  
99      private double varDecay;
100 
101     private double conflictBoundIncFactor;
102 
103     private int initConflictBound;
104 
105     /*
106      * (non-Javadoc)
107      * 
108      * @see java.lang.Object#toString()
109      */
110     @Override
111     public String toString() {
112         StringBuffer stb = new StringBuffer();
113         for (Field field : SearchParams.class.getDeclaredFields()) {
114             if (!field.getName().startsWith("serial")
115                     && !field.getName().startsWith("class")) {
116                 stb.append(field.getName());
117                 stb.append("="); //$NON-NLS-1$
118                 try {
119                     stb.append(field.get(this));
120                 } catch (IllegalArgumentException e) {
121                     e.printStackTrace();
122                 } catch (IllegalAccessException e) {
123                     e.printStackTrace();
124                 }
125                 stb.append(" "); //$NON-NLS-1$
126             }
127         }
128         return stb.toString();
129     }
130 
131     /**
132      * @param conflictBoundIncFactor
133      *            the conflictBoundIncFactor to set
134      */
135     public void setConflictBoundIncFactor(double conflictBoundIncFactor) {
136         this.conflictBoundIncFactor = conflictBoundIncFactor;
137     }
138 
139     /**
140      * @param initConflictBound
141      *            the initConflictBound to set
142      */
143     public void setInitConflictBound(int initConflictBound) {
144         this.initConflictBound = initConflictBound;
145     }
146 
147     /**
148      * @return the conflictBoundIncFactor
149      */
150     public double getConflictBoundIncFactor() {
151         return this.conflictBoundIncFactor;
152     }
153 
154     /**
155      * @return the initConflictBound
156      */
157     public int getInitConflictBound() {
158         return this.initConflictBound;
159     }
160 
161     /**
162      * @param claDecay
163      *            the claDecay to set
164      */
165     public void setClaDecay(double claDecay) {
166         this.claDecay = claDecay;
167     }
168 
169     /**
170      * @param varDecay
171      *            the varDecay to set
172      */
173     public void setVarDecay(double varDecay) {
174         this.varDecay = varDecay;
175     }
176 }