Class LingelingSatSolver
- All Implemented Interfaces:
AutoCloseable
,SatSolver
This class handles the interaction with the native Lingeling solver via bindings, allowing for the creation of variables, addition of clauses, and checking satisfiability under assumptions.
Author: [Your Name]
-
Constructor Summary
ConstructorDescriptionInitializes a new instance of the Lingeling SAT solver. -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(int[] clause) Adds a clause to the current formula in the Lingeling solver.void
close()
Releases resources associated with the Lingeling solver instance.int
newVar()
Creates and returns a new variable in the Lingeling solver.boolean
satisfiable
(int[] assumptions) Checks if the current formula is satisfiable under the given assumptions.boolean[]
witness
(int[] literals, int[] assumptions) Returns a witness (truth assignment) for the given literals under the given assumptions.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.tweetyproject.sat.SatSolver
satisfiable, witness
-
Constructor Details
-
LingelingSatSolver
public LingelingSatSolver()Initializes a new instance of the Lingeling SAT solver.This constructor initializes the Lingeling solver instance by calling the native `init` method through the `Binding` class. The handle to the Lingeling instance is stored in the `handle` field.
-
-
Method Details
-
satisfiable
public boolean satisfiable(int[] assumptions) Checks if the current formula is satisfiable under the given assumptions.- Specified by:
satisfiable
in interfaceSatSolver
- Parameters:
assumptions
- an array of literals that are assumed to be true- Returns:
- `true` if the formula is satisfiable under the given assumptions, `false` otherwise
-
witness
public boolean[] witness(int[] literals, int[] assumptions) Returns a witness (truth assignment) for the given literals under the given assumptions.This method checks if the formula is satisfiable under the given assumptions, and if it is, returns a witness that represents the truth values of the specified literals.
- Specified by:
witness
in interfaceSatSolver
- Parameters:
literals
- an array of literals for which the truth assignment is requestedassumptions
- an array of literals that are assumed to be true- Returns:
- a boolean array representing the truth assignment of the given literals, or an empty array if unsatisfiable
-
add
-
newVar
public int newVar()Creates and returns a new variable in the Lingeling solver.This method increments the internal variable counter and returns the new variable index. This ensures that each variable created by the solver is unique.
-
close
public void close()Releases resources associated with the Lingeling solver instance.This method calls the native `release` method to free the resources held by the Lingeling instance associated with the `handle`.
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceSatSolver
-