org.sat4j.opt
Class MaxSatDecorator

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

public class MaxSatDecorator
extends AbstractSelectorVariablesDecorator
implements IOptimizationProblem

Computes a solution that satisfies the maximum of clauses.

Author:
daniel
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.sat4j.opt.AbstractSelectorVariablesDecorator
nbnewvar, nborigvars, prevfullmodel
 
Constructor Summary
MaxSatDecorator(ISolver solver)
           
 
Method Summary
 IConstr addClause(IVecInt literals)
          Create a clause from a set of literals The literals are represented by non null integers such that opposite literals a represented by opposite values.
 java.lang.Number calculateObjective()
          Compute the value of the objective function for the current solution.
 void discard()
          Discard the current solution in the optimization problem.
 boolean hasNoObjectiveFunction()
          If the optimization problem has no objective function, then it is a simple decision problem.
 boolean nonOptimalMeansSatisfiable()
          A suboptimal solution has different meaning depending of the optimization problem considered.
 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.opt.AbstractSelectorVariablesDecorator
admitABetterSolution, getExpectedNumberOfClauses, model, model, newVar
 
Methods inherited from class org.sat4j.tools.SolverDecorator
addAllClauses, addAtLeast, addAtMost, clearDecorated, clearLearntClauses, decorated, expireTimeout, findModel, findModel, getStat, getTimeout, getTimeoutMs, isDBSimplificationAllowed, isSatisfiable, isSatisfiable, isSatisfiable, isSatisfiable, nConstraints, newVar, nVars, printInfos, printStat, printStat, removeConstr, setDBSimplificationAllowed, setTimeout, setTimeoutMs, setTimeoutOnConflicts, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.sat4j.specs.IOptimizationProblem
admitABetterSolution
 
Methods inherited from interface org.sat4j.specs.IProblem
findModel, findModel, isSatisfiable, isSatisfiable, isSatisfiable, isSatisfiable, model, model, nConstraints, nVars, printInfos
 

Constructor Detail

MaxSatDecorator

public MaxSatDecorator(ISolver solver)
Method Detail

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 AbstractSelectorVariablesDecorator
Parameters:
nb - the expected number of clauses.
See Also:
ISolver.newVar(int)

addClause

public IConstr addClause(IVecInt literals)
                  throws ContradictionException
Description copied from interface: ISolver
Create a clause from a set of literals The literals are represented by non null integers such that opposite literals a represented by opposite values. (classical Dimacs way of representing literals).

Specified by:
addClause in interface ISolver
Overrides:
addClause in class SolverDecorator<ISolver>
Parameters:
literals - a set of literals
Returns:
a reference to the constraint added in the solver, to use in removeConstr().
Throws:
ContradictionException - iff the vector of literals is empty or if it contains only falsified literals after unit propagation
See Also:
ISolver.removeConstr(IConstr)

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 AbstractSelectorVariablesDecorator

hasNoObjectiveFunction

public boolean hasNoObjectiveFunction()
Description copied from interface: IOptimizationProblem
If the optimization problem has no objective function, then it is a simple decision problem.

Specified by:
hasNoObjectiveFunction in interface IOptimizationProblem
Returns:
true if the problem is a decision problem, false if the problem is an optimization problem.

nonOptimalMeansSatisfiable

public boolean nonOptimalMeansSatisfiable()
Description copied from interface: IOptimizationProblem
A suboptimal solution has different meaning depending of the optimization problem considered. For instance, in the case of MAXSAT, a suboptimal solution does not mean that the problem is satisfiable, while in pseudo boolean optimization, it is true.

Specified by:
nonOptimalMeansSatisfiable in interface IOptimizationProblem
Returns:
true if founding a suboptimal solution means that the problem is satisfiable.

calculateObjective

public java.lang.Number calculateObjective()
Description copied from interface: IOptimizationProblem
Compute the value of the objective function for the current solution. A call to that method only makes sense if hasNoObjectiveFunction()==false.

Specified by:
calculateObjective in interface IOptimizationProblem
Returns:
the value of the objective function.

discard

public void discard()
             throws ContradictionException
Description copied from interface: IOptimizationProblem
Discard the current solution in the optimization problem.

Specified by:
discard in interface IOptimizationProblem
Throws:
ContradictionException - if a trivial inconsistency is detected.


Copyright © 2009 Centre de Recherche en Informatique de Lens (CRIL). All Rights Reserved.