org.sat4j.opt
Class AbstractSelectorVariablesDecorator

java.lang.Object
  extended by org.sat4j.tools.SolverDecorator<ISolver>
      extended by org.sat4j.opt.AbstractSelectorVariablesDecorator
All Implemented Interfaces:
java.io.Serializable, IProblem, ISolver
Direct Known Subclasses:
MaxSatDecorator

public abstract class AbstractSelectorVariablesDecorator
extends SolverDecorator<ISolver>

Abstract class which adds a new "selector" variable for each clause entered in the solver. As a consequence, an original problem with n variables and m clauses will end up with n+m variables.

Author:
daniel
See Also:
Serialized Form

Constructor Summary
AbstractSelectorVariablesDecorator(ISolver solver)
           
 
Method Summary
 boolean admitABetterSolution()
           
 int getExpectedNumberOfClauses()
           
 int[] model()
          Provide a model (if any) for a satisfiable formula.
 int newVar(int howmany)
          Create howmany variables in the solver (and thus in the vocabulary).
 void reset()
          Clean up the internal state of the solver.
 void setExpectedNumberOfClauses(int nb)
          To inform the solver of the expected number of clauses to read.
 
Methods inherited from class org.sat4j.tools.SolverDecorator
addAllClauses, addAtLeast, addAtMost, addClause, clearDecorated, clearLearntClauses, decorated, expireTimeout, findModel, findModel, getStat, getTimeout, isSatisfiable, isSatisfiable, isSatisfiable, isSatisfiable, model, nConstraints, newVar, nVars, printInfos, printStat, printStat, removeConstr, setTimeout, setTimeoutMs, setTimeoutOnConflicts, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractSelectorVariablesDecorator

public AbstractSelectorVariablesDecorator(ISolver solver)
Method Detail

model

public int[] model()
Description copied from interface: IProblem
Provide a model (if any) for a satisfiable formula. That method should be called AFTER isSatisfiable() or isSatisfiable(IVecInt) if the formula is satisfiable. Else an exception UnsupportedOperationException is launched.

Specified by:
model in interface IProblem
Overrides:
model in class SolverDecorator<ISolver>
Returns:
a model of the formula as an array of literals to satisfy.
See Also:
IProblem.isSatisfiable(), IProblem.isSatisfiable(IVecInt)

newVar

public int newVar(int howmany)
Description copied from interface: ISolver
Create howmany variables in the solver (and thus in the vocabulary).

Specified by:
newVar in interface ISolver
Overrides:
newVar in class SolverDecorator<ISolver>
Parameters:
howmany - number of variables to create
Returns:
the total number of variables available in the solver (the highest variable number)

setExpectedNumberOfClauses

public void setExpectedNumberOfClauses(int nb)
Description copied from interface: ISolver
To inform the solver of the expected number of clauses to read. This is an optional method, that is called when the p cnf line is read in dimacs formatted input file. Note that this method is supposed to be called AFTER a call to newVar(int)

Specified by:
setExpectedNumberOfClauses in interface ISolver
Overrides:
setExpectedNumberOfClauses in class SolverDecorator<ISolver>
Parameters:
nb - the expected number of clauses.
See Also:
ISolver.newVar(int)

getExpectedNumberOfClauses

public int getExpectedNumberOfClauses()

reset

public void reset()
Description copied from interface: ISolver
Clean up the internal state of the solver.

Specified by:
reset in interface ISolver
Overrides:
reset in class SolverDecorator<ISolver>

admitABetterSolution

public boolean admitABetterSolution()
                             throws TimeoutException
Throws:
TimeoutException