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   * Based on the pseudo boolean algorithms described in:
20   * A fast pseudo-Boolean constraint solver Chai, D.; Kuehlmann, A.
21   * Computer-Aided Design of Integrated Circuits and Systems, IEEE Transactions on
22   * Volume 24, Issue 3, March 2005 Page(s): 305 - 317
23   * 
24   * and 
25   * Heidi E. Dixon, 2004. Automating Pseudo-Boolean Inference within a DPLL 
26   * Framework. Ph.D. Dissertation, University of Oregon.
27   *******************************************************************************/
28  package org.sat4j.pb;
29  
30  import org.sat4j.core.ASolverFactory;
31  import org.sat4j.minisat.core.IOrder;
32  import org.sat4j.minisat.core.IPhaseSelectionStrategy;
33  import org.sat4j.minisat.learning.ClauseOnlyLearning;
34  import org.sat4j.minisat.learning.MiniSATLearning;
35  import org.sat4j.minisat.learning.NoLearningButHeuristics;
36  import org.sat4j.minisat.orders.PhaseInLastLearnedClauseSelectionStrategy;
37  import org.sat4j.minisat.orders.RSATPhaseSelectionStrategy;
38  import org.sat4j.minisat.orders.UserFixedPhaseSelectionStrategy;
39  import org.sat4j.minisat.orders.VarOrderHeap;
40  import org.sat4j.minisat.restarts.ArminRestarts;
41  import org.sat4j.minisat.restarts.MiniSATRestarts;
42  import org.sat4j.minisat.uip.FirstUIP;
43  import org.sat4j.pb.constraints.AbstractPBDataStructureFactory;
44  import org.sat4j.pb.constraints.CompetMinHTmixedClauseCardConstrDataStructureFactory;
45  import org.sat4j.pb.constraints.CompetResolutionPBMixedHTClauseCardConstrDataStructure;
46  import org.sat4j.pb.constraints.CompetResolutionPBMixedWLClauseCardConstrDataStructure;
47  import org.sat4j.pb.constraints.PBMaxCBClauseCardConstrDataStructure;
48  import org.sat4j.pb.constraints.PBMaxClauseAtLeastConstrDataStructure;
49  import org.sat4j.pb.constraints.PBMaxClauseCardConstrDataStructure;
50  import org.sat4j.pb.constraints.PBMaxDataStructure;
51  import org.sat4j.pb.constraints.PBMinClauseCardConstrDataStructure;
52  import org.sat4j.pb.constraints.PBMinDataStructure;
53  import org.sat4j.pb.constraints.PuebloPBMinClauseAtLeastConstrDataStructure;
54  import org.sat4j.pb.constraints.PuebloPBMinClauseCardConstrDataStructure;
55  import org.sat4j.pb.constraints.PuebloPBMinDataStructure;
56  import org.sat4j.pb.core.PBDataStructureFactory;
57  import org.sat4j.pb.core.PBSolverCP;
58  import org.sat4j.pb.core.PBSolverCautious;
59  import org.sat4j.pb.core.PBSolverClause;
60  import org.sat4j.pb.core.PBSolverResCP;
61  import org.sat4j.pb.core.PBSolverResolution;
62  import org.sat4j.pb.core.PBSolverWithImpliedClause;
63  import org.sat4j.pb.orders.VarOrderHeapObjective;
64  import org.sat4j.specs.ISolver;
65  import org.sat4j.tools.DimacsOutputSolver;
66  
67  /**
68   * User friendly access to pre-constructed solvers.
69   * 
70   * @author leberre
71   * @since 2.0
72   */
73  public class SolverFactory extends ASolverFactory<IPBSolver> {
74  
75  	/**
76       * 
77       */
78  	private static final long serialVersionUID = 1L;
79  
80  	// thread safe implementation of the singleton design pattern
81  	private static SolverFactory instance;
82  
83  	/**
84  	 * Private contructor. Use singleton method instance() instead.
85  	 * 
86  	 * @see #instance()
87  	 */
88  	private SolverFactory() {
89  
90  	}
91  
92  	private static synchronized void createInstance() {
93  		if (instance == null) {
94  			instance = new SolverFactory();
95  		}
96  	}
97  
98  	/**
99  	 * Access to the single instance of the factory.
100 	 * 
101 	 * @return the singleton of that class.
102 	 */
103 	public static SolverFactory instance() {
104 		if (instance == null) {
105 			createInstance();
106 		}
107 		return instance;
108 	}
109 
110 	/**
111 	 * @return MiniSAT with Counter-based pseudo boolean constraints and clause
112 	 *         learning.
113 	 */
114 	public static PBSolverResolution newPBResAllPB() {
115 		return newPBRes(new PBMaxDataStructure());
116 	}
117 
118 	/**
119 	 * @return MiniSAT with Counter-based pseudo boolean constraints and
120 	 *         constraint learning.
121 	 */
122 	public static PBSolverCP newPBCPAllPB() {
123 		return newPBCP(new PBMaxDataStructure());
124 	}
125 
126 	/**
127 	 * @return Solver used to display in a string the pb-instance in OPB format.
128 	 */
129 	public static IPBSolver newOPBStringSolver() {
130 		return new OPBStringSolver();
131 	}
132 
133 	/**
134 	 * @return MiniSAT with Counter-based pseudo boolean constraints and
135 	 *         constraint learning. Clauses and cardinalities with watched
136 	 *         literals are also handled (and learnt).
137 	 */
138 	public static PBSolverCP newPBCPMixedConstraints() {
139 		return newPBCP(new PBMaxClauseCardConstrDataStructure());
140 	}
141 
142 	/**
143 	 * @return MiniSAT with Counter-based pseudo boolean constraints and
144 	 *         constraint learning. Clauses and cardinalities with watched
145 	 *         literals are also handled (and learnt). A specific heuristics
146 	 *         taking into account the objective value is used.
147 	 */
148 	public static PBSolverCP newPBCPMixedConstraintsObjective() {
149 		return newPBCP(new PBMaxClauseCardConstrDataStructure(),
150 				new VarOrderHeapObjective());
151 	}
152 
153 	public static PBSolverCP newCompetPBCPMixedConstraintsObjective() {
154 		return newPBCP(new PBMaxClauseCardConstrDataStructure(),
155 				new VarOrderHeapObjective());
156 	}
157 
158 	/**
159 	 * @return MiniLearning with Counter-based pseudo boolean constraints and
160 	 *         constraint learning. Clauses and cardinalities with watched
161 	 *         literals are also handled (and learnt). A specific heuristics
162 	 *         taking into account the objective value is used. Conflict
163 	 *         analysis with full cutting plane inference. Only clauses are
164 	 *         recorded.
165 	 */
166 	public static PBSolverCP newPBCPMixedConstraintsObjectiveLearnJustClauses() {
167 		ClauseOnlyLearning<PBDataStructureFactory> learning = new ClauseOnlyLearning<PBDataStructureFactory>();
168 		PBSolverCP solver = new PBSolverCP(new FirstUIP(), learning,
169 				new PBMaxClauseCardConstrDataStructure(),
170 				new VarOrderHeapObjective());
171 		learning.setSolver(solver);
172 		return solver;
173 	}
174 
175 	public static PBSolverCP newCompetPBCPMixedConstraintsObjectiveLearnJustClauses() {
176 		ClauseOnlyLearning<PBDataStructureFactory> learning = new ClauseOnlyLearning<PBDataStructureFactory>();
177 		PBSolverCP solver = new PBSolverCP(new FirstUIP(), learning,
178 				new PBMaxClauseCardConstrDataStructure(),
179 				new VarOrderHeapObjective());
180 		learning.setSolver(solver);
181 		return solver;
182 	}
183 
184 	private static PBSolverCP newPBKiller(IPhaseSelectionStrategy phase) {
185 		ClauseOnlyLearning<PBDataStructureFactory> learning = new ClauseOnlyLearning<PBDataStructureFactory>();
186 		PBSolverCP solver = new PBSolverCP(new FirstUIP(), learning,
187 				new PBMaxClauseCardConstrDataStructure(),
188 				new VarOrderHeapObjective(phase));
189 		learning.setSolver(solver);
190 		return solver;
191 	}
192 
193 	public static PBSolverCP newPBKillerRSAT() {
194 		return newPBKiller(new RSATPhaseSelectionStrategy());
195 	}
196 
197 	public static PBSolverCP newPBKillerClassic() {
198 		return newPBKiller(new PhaseInLastLearnedClauseSelectionStrategy());
199 	}
200 
201 	public static PBSolverCP newPBKillerFixed() {
202 		return newPBKiller(new UserFixedPhaseSelectionStrategy());
203 	}
204 
205 	private static PBSolverCP newCompetPBKiller(IPhaseSelectionStrategy phase) {
206 		ClauseOnlyLearning<PBDataStructureFactory> learning = new ClauseOnlyLearning<PBDataStructureFactory>();
207 		PBSolverCP solver = new PBSolverCP(new FirstUIP(), learning,
208 				new PBMaxClauseCardConstrDataStructure(),
209 				new VarOrderHeapObjective(phase));
210 		learning.setSolver(solver);
211 		return solver;
212 	}
213 
214 	public static PBSolverCP newCompetPBKillerRSAT() {
215 		return newCompetPBKiller(new RSATPhaseSelectionStrategy());
216 	}
217 
218 	public static PBSolverCP newCompetPBKillerClassic() {
219 		return newCompetPBKiller(new PhaseInLastLearnedClauseSelectionStrategy());
220 	}
221 
222 	public static PBSolverCP newCompetPBKillerFixed() {
223 		return newCompetPBKiller(new UserFixedPhaseSelectionStrategy());
224 	}
225 
226 	/**
227 	 * @return MiniLearning with Counter-based pseudo boolean constraints and
228 	 *         constraint learning. Clauses and cardinalities with watched
229 	 *         literals are also handled (and learnt). A specific heuristics
230 	 *         taking into account the objective value is used. Conflict
231 	 *         analysis reduces to clauses to avoid computations
232 	 */
233 	public static PBSolverCP newMiniLearningOPBClauseCardConstrMaxSpecificOrderIncrementalReductionToClause() {
234 		// LimitedLearning learning = new LimitedLearning(10);
235 		MiniSATLearning<PBDataStructureFactory> learning = new MiniSATLearning<PBDataStructureFactory>();
236 		// LearningStrategy learning = new NoLearningButHeuristics();
237 		PBSolverCP solver = new PBSolverClause(new FirstUIP(), learning,
238 				new PBMaxClauseCardConstrDataStructure(),
239 				new VarOrderHeapObjective());
240 		learning.setDataStructureFactory(solver.getDSFactory());
241 		learning.setVarActivityListener(solver);
242 		return solver;
243 	}
244 
245 	/**
246 	 * @return MiniLearning with Counter-based pseudo boolean constraints and
247 	 *         constraint learning. Clauses and cardinalities with watched
248 	 *         literals are also handled (and learnt). A specific heuristics
249 	 *         taking into account the objective value is used. The PB
250 	 *         constraints are not learnt (watched), just used for backjumping.
251 	 */
252 	public static PBSolverCP newPBCPMixedConstraintsObjectiveNoLearning() {
253 		NoLearningButHeuristics<PBDataStructureFactory> learning = new NoLearningButHeuristics<PBDataStructureFactory>();
254 		// SearchParams params = new SearchParams(1.1,100);
255 		PBSolverCP solver = new PBSolverCP(new FirstUIP(), learning,
256 				new PBMaxClauseCardConstrDataStructure(),
257 				new VarOrderHeapObjective());
258 		learning.setSolver(solver);
259 		learning.setVarActivityListener(solver);
260 		return solver;
261 	}
262 
263 	public static PBSolverResolution newPBResMixedConstraintsObjective() {
264 		MiniSATLearning<PBDataStructureFactory> learning = new MiniSATLearning<PBDataStructureFactory>();
265 		PBSolverResolution solver = new PBSolverResolution(new FirstUIP(),
266 				learning, new PBMaxClauseCardConstrDataStructure(),
267 				new VarOrderHeapObjective(), new MiniSATRestarts());
268 		learning.setDataStructureFactory(solver.getDSFactory());
269 		learning.setVarActivityListener(solver);
270 		return solver;
271 	}
272 
273 	public static PBSolverResolution newCompetPBResWLMixedConstraintsObjective() {
274 		return newCompetPBResMixedConstraintsObjective(new CompetResolutionPBMixedWLClauseCardConstrDataStructure());
275 	}
276 
277 	public static PBSolverResolution newCompetPBResHTMixedConstraintsObjective() {
278 		return newCompetPBResMixedConstraintsObjective(new CompetResolutionPBMixedHTClauseCardConstrDataStructure());
279 	}
280 
281 	public static PBSolverResolution newCompetPBResMixedConstraintsObjective(
282 			PBDataStructureFactory dsf) {
283 		MiniSATLearning<PBDataStructureFactory> learning = new MiniSATLearning<PBDataStructureFactory>();
284 		PBSolverResolution solver = new PBSolverResolution(new FirstUIP(),
285 				learning, dsf, new VarOrderHeapObjective(
286 						new RSATPhaseSelectionStrategy()), new ArminRestarts());
287 		learning.setDataStructureFactory(solver.getDSFactory());
288 		learning.setVarActivityListener(solver);
289 		return solver;
290 	}
291 
292 	public static PBSolverResolution newPBResHTMixedConstraintsObjective() {
293 		MiniSATLearning<PBDataStructureFactory> learning = new MiniSATLearning<PBDataStructureFactory>();
294 		AbstractPBDataStructureFactory ds = new CompetResolutionPBMixedHTClauseCardConstrDataStructure();
295 		ds.setNormalizer(AbstractPBDataStructureFactory.NO_COMPETITION);
296 		PBSolverResolution solver = new PBSolverResolution(new FirstUIP(),
297 				learning, ds, new VarOrderHeapObjective(),
298 				new MiniSATRestarts());
299 		learning.setDataStructureFactory(solver.getDSFactory());
300 		learning.setVarActivityListener(solver);
301 		return solver;
302 	}
303 
304 	public static PBSolverResolution newCompetPBResMinHTMixedConstraintsObjective() {
305 		MiniSATLearning<PBDataStructureFactory> learning = new MiniSATLearning<PBDataStructureFactory>();
306 		PBSolverResolution solver = new PBSolverResolution(new FirstUIP(),
307 				learning,
308 				new CompetMinHTmixedClauseCardConstrDataStructureFactory(),
309 				new VarOrderHeapObjective(), new MiniSATRestarts());
310 		learning.setDataStructureFactory(solver.getDSFactory());
311 		learning.setVarActivityListener(solver);
312 		return solver;
313 	}
314 
315 	public static PBSolverResolution newPBResMinHTMixedConstraintsObjective() {
316 		MiniSATLearning<PBDataStructureFactory> learning = new MiniSATLearning<PBDataStructureFactory>();
317 		AbstractPBDataStructureFactory ds = new CompetMinHTmixedClauseCardConstrDataStructureFactory();
318 		ds.setNormalizer(AbstractPBDataStructureFactory.NO_COMPETITION);
319 		PBSolverResolution solver = new PBSolverResolution(new FirstUIP(),
320 				learning, ds, new VarOrderHeapObjective(),
321 				new MiniSATRestarts());
322 		learning.setDataStructureFactory(solver.getDSFactory());
323 		learning.setVarActivityListener(solver);
324 		return solver;
325 	}
326 
327 	public static PBSolverResolution newCompetPBResMixedConstraintsObjectiveExpSimp() {
328 		PBSolverResolution solver = newPBResMixedConstraintsObjective();
329 		solver.setSimplifier(solver.EXPENSIVE_SIMPLIFICATION);
330 		return solver;
331 	}
332 
333 	public static PBSolverResolution newCompetPBResWLMixedConstraintsObjectiveExpSimp() {
334 		PBSolverResolution solver = newCompetPBResWLMixedConstraintsObjective();
335 		solver.setSimplifier(solver.EXPENSIVE_SIMPLIFICATION);
336 		return solver;
337 	}
338 
339 	public static PBSolverResolution newPBResHTMixedConstraintsObjectiveExpSimp() {
340 		PBSolverResolution solver = newPBResHTMixedConstraintsObjective();
341 		solver.setSimplifier(solver.EXPENSIVE_SIMPLIFICATION);
342 		return solver;
343 	}
344 
345 	public static PBSolverResolution newCompetPBResMinHTMixedConstraintsObjectiveExpSimp() {
346 		PBSolverResolution solver = newCompetPBResMinHTMixedConstraintsObjective();
347 		solver.setSimplifier(solver.EXPENSIVE_SIMPLIFICATION);
348 		return solver;
349 	}
350 
351 	/**
352 	 * @return MiniSAT with Counter-based pseudo boolean constraints and
353 	 *         constraint learning. Clauses and cardinalities with watched
354 	 *         literals are also handled (and learnt). A reduction of
355 	 *         PB-constraints to clauses is made in order to simplify cutting
356 	 *         planes.
357 	 */
358 	public static PBSolverClause newPBCPMixedConstraintsReduceToClause() {
359 		MiniSATLearning<PBDataStructureFactory> learning = new MiniSATLearning<PBDataStructureFactory>();
360 		PBSolverClause solver = new PBSolverClause(new FirstUIP(), learning,
361 				new PBMaxClauseCardConstrDataStructure(), new VarOrderHeap());
362 		learning.setDataStructureFactory(solver.getDSFactory());
363 		learning.setVarActivityListener(solver);
364 		return solver;
365 	}
366 
367 	/**
368 	 * @return MiniSAT with Counter-based pseudo boolean constraints and
369 	 *         constraint learning. Clauses and cardinalities with watched
370 	 *         literals are also handled (and learnt). A reduction of
371 	 *         PB-constraints to clauses is made in order to simplify cutting
372 	 *         planes (if coefficients are larger than bound).
373 	 */
374 	public static PBSolverCautious newPBCPMixedConstraintsCautious(int bound) {
375 		MiniSATLearning<PBDataStructureFactory> learning = new MiniSATLearning<PBDataStructureFactory>();
376 		PBSolverCautious solver = new PBSolverCautious(new FirstUIP(),
377 				learning, new PBMaxClauseCardConstrDataStructure(),
378 				new VarOrderHeapObjective(), bound);
379 		learning.setDataStructureFactory(solver.getDSFactory());
380 		learning.setVarActivityListener(solver);
381 		return solver;
382 	}
383 
384 	public static PBSolverCautious newPBCPMixedConstraintsCautious() {
385 		return newPBCPMixedConstraintsCautious(PBSolverCautious.BOUND);
386 	}
387 
388 	/**
389 	 * @return MiniSAT with Counter-based pseudo boolean constraints and
390 	 *         constraint learning. Clauses and cardinalities with watched
391 	 *         literals are also handled (and learnt). A reduction of
392 	 *         PB-constraints to clauses is made in order to simplify cutting
393 	 *         planes (if coefficients are larger than bound).
394 	 */
395 	public static PBSolverResCP newPBCPMixedConstraintsResCP(long bound) {
396 		MiniSATLearning<PBDataStructureFactory> learning = new MiniSATLearning<PBDataStructureFactory>();
397 		PBSolverResCP solver = new PBSolverResCP(new FirstUIP(), learning,
398 				new PBMaxClauseCardConstrDataStructure(),
399 				new VarOrderHeapObjective(), bound);
400 		learning.setDataStructureFactory(solver.getDSFactory());
401 		learning.setVarActivityListener(solver);
402 		solver.setSimplifier(solver.EXPENSIVE_SIMPLIFICATION);
403 		return solver;
404 	}
405 
406 	public static PBSolverResCP newPBCPMixedConstraintsResCP() {
407 		return newPBCPMixedConstraintsResCP(PBSolverResCP.MAXCONFLICTS);
408 	}
409 
410 	/**
411 	 * @return MiniSAT with Counter-based pseudo boolean constraints and
412 	 *         constraint learning. Clauses and cardinalities with watched
413 	 *         literals are also handled (and learnt). a pre-processing is
414 	 *         applied which adds implied clauses from PB-constraints.
415 	 */
416 	public static PBSolverWithImpliedClause newPBCPMixedConstrainsImplied() {
417 		MiniSATLearning<PBDataStructureFactory> learning = new MiniSATLearning<PBDataStructureFactory>();
418 		PBSolverWithImpliedClause solver = new PBSolverWithImpliedClause(
419 				new FirstUIP(), learning,
420 				new PBMaxClauseCardConstrDataStructure(), new VarOrderHeap());
421 		learning.setDataStructureFactory(solver.getDSFactory());
422 		learning.setVarActivityListener(solver);
423 		return solver;
424 	}
425 
426 	/**
427 	 * @return MiniSAT with Counter-based pseudo boolean constraints,
428 	 *         counter-based cardinalities, watched clauses and constraint
429 	 *         learning. methods isAssertive() and getBacktrackLevel() are
430 	 *         totally incremental. Conflicts for PB-constraints use a Map
431 	 *         structure
432 	 */
433 	public static PBSolverCP newMiniOPBClauseAtLeastConstrMax() {
434 		return newPBCP(new PBMaxClauseAtLeastConstrDataStructure());
435 	}
436 
437 	/**
438 	 * @return MiniSAT with Counter-based pseudo boolean constraints and
439 	 *         clauses, watched cardinalities, and constraint learning.
440 	 */
441 	public static PBSolverCP newMiniOPBCounterBasedClauseCardConstrMax() {
442 		return newPBCP(new PBMaxCBClauseCardConstrDataStructure());
443 	}
444 
445 	/**
446 	 * @return MiniSAT with WL-based pseudo boolean constraints and clause
447 	 *         learning.
448 	 */
449 	public static PBSolverResolution newPBResAllPBWL() {
450 		return newPBRes(new PBMinDataStructure());
451 	}
452 
453 	/**
454 	 * @return MiniSAT with WL-based pseudo boolean constraints and constraint
455 	 *         learning.
456 	 */
457 	public static PBSolverCP newPBCPAllPBWL() {
458 		return newPBCP(new PBMinDataStructure());
459 	}
460 
461 	/**
462 	 * @return MiniSAT with WL-based pseudo boolean constraints and clause
463 	 *         learning.
464 	 */
465 	public static PBSolverResolution newPBResAllPBWLPueblo() {
466 		return newPBRes(new PuebloPBMinDataStructure());
467 	}
468 
469 	private static PBSolverResolution newPBRes(PBDataStructureFactory dsf) {
470 		MiniSATLearning<PBDataStructureFactory> learning = new MiniSATLearning<PBDataStructureFactory>();
471 		PBSolverResolution solver = new PBSolverResolution(new FirstUIP(),
472 				learning, dsf, new VarOrderHeap(), new MiniSATRestarts());
473 		learning.setDataStructureFactory(solver.getDSFactory());
474 		learning.setVarActivityListener(solver);
475 		return solver;
476 	}
477 
478 	/**
479 	 * @return MiniSAT with WL-based pseudo boolean constraints and constraint
480 	 *         learning.
481 	 */
482 	public static PBSolverCP newPBCPAllPBWLPueblo() {
483 		return newPBCP(new PuebloPBMinDataStructure());
484 	}
485 
486 	/**
487 	 * @return MiniSAT with WL-based pseudo boolean constraints and clauses,
488 	 *         cardinalities, and constraint learning.
489 	 */
490 	public static PBSolverCP newMiniOPBClauseCardMinPueblo() {
491 		return newPBCP(new PuebloPBMinClauseCardConstrDataStructure());
492 	}
493 
494 	/**
495 	 * @return MiniSAT with WL-based pseudo boolean constraints and clauses,
496 	 *         cardinalities, and constraint learning.
497 	 */
498 	public static PBSolverCP newMiniOPBClauseCardMin() {
499 		return newPBCP(new PBMinClauseCardConstrDataStructure());
500 	}
501 
502 	/**
503 	 * @return MiniSAT with WL-based pseudo boolean constraints and clauses,
504 	 *         counter-based cardinalities, and constraint learning.
505 	 */
506 	public static PBSolverCP newMiniOPBClauseAtLeastMinPueblo() {
507 		return newPBCP(new PuebloPBMinClauseAtLeastConstrDataStructure());
508 	}
509 
510 	private static PBSolverCP newPBCP(PBDataStructureFactory dsf, IOrder order) {
511 		MiniSATLearning<PBDataStructureFactory> learning = new MiniSATLearning<PBDataStructureFactory>();
512 		PBSolverCP solver = new PBSolverCP(new FirstUIP(), learning, dsf, order);
513 		learning.setDataStructureFactory(solver.getDSFactory());
514 		learning.setVarActivityListener(solver);
515 		solver.setRestartStrategy(new ArminRestarts());
516 		solver.setLearnedConstraintsDeletionStrategy(solver.glucose);
517 		return solver;
518 	}
519 
520 	private static PBSolverCP newPBCP(PBDataStructureFactory dsf) {
521 		return newPBCP(dsf, new VarOrderHeap());
522 	}
523 
524 	/**
525 	 * Cutting Planes based solver. The inference during conflict analysis is
526 	 * based on cutting planes instead of resolution as in a SAT solver.
527 	 * 
528 	 * @return the best available cutting planes based solver of the library.
529 	 */
530 	public static IPBSolver newCuttingPlanes() {
531 		return newCompetPBCPMixedConstraintsObjective();
532 	}
533 
534 	/**
535 	 * Resolution based solver (i.e. classic SAT solver able to handle generic
536 	 * constraints. No specific inference mechanism.
537 	 * 
538 	 * @return the best available resolution based solver of the library.
539 	 */
540 	public static IPBSolver newResolution() {
541 		return newResolutionGlucose();
542 	}
543 
544 	/**
545 	 * Resolution based solver (i.e. classic SAT solver able to handle generic
546 	 * constraints. No specific inference mechanism). Uses glucose based memory
547 	 * management.
548 	 * 
549 	 * @return the best available resolution based solver of the library.
550 	 */
551 	public static IPBSolver newResolutionGlucose() {
552 		PBSolverResolution solver = newCompetPBResWLMixedConstraintsObjectiveExpSimp();
553 		solver.setLearnedConstraintsDeletionStrategy(solver.glucose);
554 		return solver;
555 	}
556 
557 	/**
558 	 * Resolution based solver (i.e. classic SAT solver able to handle generic
559 	 * constraints. No specific inference mechanism). Uses glucose based memory
560 	 * management. Uses a simple restart strategy (original Minisat's one).
561 	 * 
562 	 * @return the best available resolution based solver of the library.
563 	 */
564 	public static IPBSolver newResolutionSimpleRestarts() {
565 		PBSolverResolution solver = newCompetPBResWLMixedConstraintsObjectiveExpSimp();
566 		solver.setLearnedConstraintsDeletionStrategy(solver.glucose);
567 		solver.setRestartStrategy(new MiniSATRestarts());
568 		return solver;
569 	}
570 
571 	/**
572 	 * Resolution based solver (i.e. classic SAT solver able to handle generic
573 	 * constraints. No specific inference mechanism).
574 	 * 
575 	 * Keeps the constraints as long as there is enough memory available.
576 	 * 
577 	 * @return the best available resolution based solver of the library.
578 	 */
579 	public static IPBSolver newResolutionMaxMemory() {
580 		return newCompetPBResWLMixedConstraintsObjectiveExpSimp();
581 	}
582 
583 	/**
584 	 * Default solver of the SolverFactory. This solver is meant to be used on
585 	 * challenging SAT benchmarks.
586 	 * 
587 	 * @return the best "general purpose" SAT solver available in the factory.
588 	 * @see #defaultSolver() the same method, polymorphic, to be called from an
589 	 *      instance of ASolverFactory.
590 	 */
591 	public static IPBSolver newDefault() {
592 		return newResolutionGlucose();
593 	}
594 
595 	/**
596 	 * Default solver of the SolverFactory for instances not normalized. This
597 	 * solver is meant to be used on challenging SAT benchmarks.
598 	 * 
599 	 * @return the best "general purpose" SAT solver available in the factory.
600 	 * @see #defaultSolver() the same method, polymorphic, to be called from an
601 	 *      instance of ASolverFactory.
602 	 */
603 	public static IPBSolver newDefaultNonNormalized() {
604 		return newPBResHTMixedConstraintsObjectiveExpSimp();
605 	}
606 
607 	@Override
608 	public IPBSolver defaultSolver() {
609 		return newDefault();
610 	}
611 
612 	/**
613 	 * Small footprint SAT solver.
614 	 * 
615 	 * @return a SAT solver suitable for solving small/easy SAT benchmarks.
616 	 * @see #lightSolver() the same method, polymorphic, to be called from an
617 	 *      instance of ASolverFactory.
618 	 */
619 	public static IPBSolver newLight() {
620 		return newCompetPBResMixedConstraintsObjectiveExpSimp();
621 	}
622 
623 	@Override
624 	public IPBSolver lightSolver() {
625 		return newLight();
626 	}
627 
628 	public static ISolver newDimacsOutput() {
629 		return new DimacsOutputSolver();
630 	}
631 
632 	public static IPBSolver newEclipseP2() {
633 		MiniSATLearning<PBDataStructureFactory> learning = new MiniSATLearning<PBDataStructureFactory>();
634 		PBSolverResolution solver = new PBSolverResolution(new FirstUIP(),
635 				learning,
636 				new CompetResolutionPBMixedHTClauseCardConstrDataStructure(),
637 				new VarOrderHeapObjective(new RSATPhaseSelectionStrategy()),
638 				new ArminRestarts());
639 		learning.setDataStructureFactory(solver.getDSFactory());
640 		learning.setVarActivityListener(solver);
641 		solver.setTimeoutOnConflicts(300);
642 		solver.setVerbose(false);
643 		return new OptToPBSATAdapter(new PseudoOptDecorator(solver));
644 	}
645 
646 }