Class Paramita::NonIncrSatSolver¶
A SAT solver.
Note:
Use SATSOLVER_C_INTERFACE to register any subclass of this interface.
#include <NonIncrSatSolver.hpp>
Inherits the following classes: Paramita::ClauseContainer
Public Static Attributes¶
| Type | Name |
|---|---|
| constexpr const char *const | m_interface_id = /* multi line expression */ |
Public Static Attributes inherited from Paramita::ClauseContainer¶
| Type | Name |
|---|---|
| constexpr const char *const | m_interface_id = "Paramita::ClauseContainer" |
Public Static Attributes inherited from Paramita::Plugin¶
See Paramita::Plugin
| Type | Name |
|---|---|
| constexpr const char *const | m_interface_id = "Paramita::Plugin" |
Public Functions¶
| Type | Name |
|---|---|
| NonIncrSatSolver () = default |
|
| NonIncrSatSolver (const NonIncrSatSolver &) = delete Deleted copy constructor (pure interface). |
|
| NonIncrSatSolver (NonIncrSatSolver &&) = delete Deleted move constructor (pure interface). |
|
| virtual | assume (Literal lit) Add an assumption for the next solve orpropagate call. |
| virtual NonIncrSatSolver * | clone () override Clones the SAT solver. |
| virtual std::vector< Literal > | core () Retrieve the unsatisfiable core. |
| virtual bool | failed (Literal lit) Check if a literal belongs to the unsatisfiable core. |
| virtual | freeze (Literal lit) Freeze a variable. |
| virtual std::optional< bool > | get_phase (Literal lit) Returns the default phase for a decision variable. |
| virtual | interrupt () Interrupts the resolution process. |
| virtual std::optional< bool > | is_fixed (Literal lit) Detect if a variable is implied at root level. |
| virtual bool | is_frozen (Literal lit) Checks if a variable is frozen. |
| virtual | melt (Literal lit) Melts a variable. |
| virtual std::vector< Literal > | model () const = 0 Get the model (solution) after solving. |
| virtual int | num_active_vars () Counts how many variables are active. |
| virtual long | num_conflicts () Get the number of conflicts encountered. |
| NonIncrSatSolver & | operator= (const NonIncrSatSolver & container) = delete Deleted copy assignment (pure interface). |
| NonIncrSatSolver & | operator= (NonIncrSatSolver &&) = delete Deleted move assignment (pure interface). |
| virtual | phase (Literal lit) Set the default phase for a decision variable during branching. |
| virtual std::pair< bool, std::vector< Literal > > | propagate (const std::vector< Literal > & assumptions) Propagate the given assumptions. |
| virtual | simplify (unsigned int num_rounds) Simplify the formula. |
| virtual std::optional< bool > | solve (const std::vector< Literal > & assumptions, const SolvingBudget & budget) = 0 Solve the underlying formula under the given assumptions. |
| virtual | unphase (Literal lit) Removes the default phase for a decision variable. |
| virtual std::optional< bool > | val_lit (Literal lit) Get the truth value for a literal. |
| ~NonIncrSatSolver () override |
Public Functions inherited from Paramita::ClauseContainer¶
| Type | Name |
|---|---|
| ClauseContainer () = default Constructor that initializes an empty container. |
|
| ClauseContainer (const ClauseContainer &) = delete Deleted copy constructor (pure interface). |
|
| ClauseContainer (ClauseContainer &&) = delete Deleted move constructor (pure interface). |
|
| virtual | add_clause (const Clause & clause) = 0 Add a single clause. |
| virtual | add_clauses (const std::vector< Clause > & clauses) Add multiple clauses to the container. |
| virtual | add_lit (Literal lit) Add a clause literal by literal. |
| virtual ClauseContainer * | clone () Clones the current CNF Container. |
| virtual std::uint64_t | max_var () const = 0 Get the largest variable used by the container. |
| virtual int | num_clauses () const Get the number of clauses hold currently by the container. |
| ClauseContainer & | operator= (const ClauseContainer & container) = delete Deleted copy assignment (pure interface). |
| ClauseContainer & | operator= (ClauseContainer &&) = delete Deleted move assignment (pure interface). |
| virtual | set_minimum_var (std::uint64_t var) = 0 Sets the maximum variable known to the container to at least this one. |
| ~ClauseContainer () override Virtual destructor for the container. |
Public Functions inherited from Paramita::Plugin¶
See Paramita::Plugin
| Type | Name |
|---|---|
| Plugin () = default |
|
| Plugin (const Plugin &) = delete Deleted constructor (pure interface). |
|
| Plugin (Plugin &&) = delete Deleted constructor (pure interface). |
|
| virtual ParameterType | get (const std::string & name) Get the parameter's value. |
| virtual ParameterSpace | get_parameter_space () Get the parameter space for this class. |
| Plugin & | operator= (const Plugin & container) = delete Deleted constructor (pure interface). |
| Plugin & | operator= (Plugin &&) = delete Deleted constructor (pure interface). |
| virtual | set (const std::string & name, const ParameterType & value) Set a parameter. |
| virtual | ~Plugin () = default |
Public Static Attributes Documentation¶
variable m_interface_id¶
Public Functions Documentation¶
function NonIncrSatSolver [1/3]¶
function NonIncrSatSolver [2/3]¶
Deleted copy constructor (pure interface).
function NonIncrSatSolver [3/3]¶
Deleted move constructor (pure interface).
function assume¶
Add an assumption for the next solve orpropagate call.
See BALYO201645 for more details.
Exception:
- UnsupportedMethodException This method is optional.
function clone¶
Clones the SAT solver.
Returns:
The cloned SAT solver.
Exception:
- UnsupportedMethodException This method is optional.
Implements Paramita::ClauseContainer::clone
function core¶
Retrieve the unsatisfiable core.
Returns:
A vector filled with a subset of the assumptions that are jointly unsatisfiable.
Precondition:
solve was called with assumptions.
Precondition:
The instance must be unsatisfiable under the given assumptions.
Exception:
- UnsupportedMethodException This method is optional.
function failed¶
Check if a literal belongs to the unsatisfiable core.
Parameters:
litThe literal to be checked.
Returns:
true if the literal belongs to the unsatisfiable core, false otherwise.
Precondition:
The instance must be unsatisfiable under the given assumptions.
See BALYO201645 for more details.
Exception:
- UnsupportedMethodException This method is optional.
function freeze¶
Freeze a variable.
A frozen variable is a variable that is potentially needed in the future (for example, new assumptions). Internally, the solver can decide to perform variable elimination.
A variable can be frozen multiple times, as in Lingeling or CaDiCaL. You must call melt the same number of times to "unfreeze" a variable.
See
Parameters:
litThe literal representing the variable. Only its absolute value (i.e. the variable) is considered.
See also: melt, is_frozen
Exception:
- UnsupportedMethodException This method is optional.
function get_phase¶
Returns the default phase for a decision variable.
Parameters:
litThe literal representing the decision variable. Only its absolute value (i.e. the variable) is considered.
Returns:
True if the phase is positive, False if negative, or std::nothing if it was not set.
Exception:
- UnsupportedMethodException This method is optional.
function interrupt¶
Interrupts the resolution process.
This method instructs the solver to stop solving or propagating. Note that this is a notification, not an immediate stop, when the solver is interrupted is implementation defined.
Precondition:
The solver is solving or propagating.
Postcondition:
After interrupting, the solver must stay in a stable state.
Exception:
- UnsupportedMethodException This method is optional.
function is_fixed¶
Detect if a variable is implied at root level.
Parameters:
litThe literal representing the variable. Only its absolute value (i.e. the variable) is considered.
Returns:
True if the variable is implied by the formula, False if its negation is implied, or std::nothing if it has not yet been determined.
Exception:
- UnsupportedMethodException This method is optional.
function is_frozen¶
Checks if a variable is frozen.
Parameters:
litThe literal representing the variable. Only its absolute value (i.e. the variable) is considered.
Returns:
See also: freeze, melt
Exception:
- UnsupportedMethodException This method is optional.
function melt¶
Melts a variable.
Parameters:
litThe literal representing the variable. Only its absolute value (i.e. the variable) is considered.
See also: freeze, is_frozen
Exception:
- UnsupportedMethodException This method is optional.
function model¶
Get the model (solution) after solving.
Returns:
The vector where the solution will be stored. Each element of the vector is a literal that was set to true.
Precondition:
The method solve was called.
Precondition:
A solution was found by solve.
Warning:
Undefined behaviour if solve returned std::nothing.
Exception:
- NotSolvedException if
solvewas not called before. - UnsatisfiableException if
solvefound the instance to be unsatisfiable.
function num_active_vars¶
Counts how many variables are active.
An active variable is a variable that exists in an irredundant clause (i.e. not satisfied, subsumed, or eliminated). Variable become inactive if they are eliminated or fixed at the root level.
Returns:
The number of active variables.
Exception:
- UnsupportedMethodException This method is optional.
function num_conflicts¶
Get the number of conflicts encountered.
Returns:
The total number of conflicts found during solve.
Exception:
- UnsupportedMethodException This method is optional.
function operator=¶
Deleted copy assignment (pure interface).
NonIncrSatSolver & Paramita::NonIncrSatSolver::operator= (
const NonIncrSatSolver & container
) = delete
function operator=¶
Deleted move assignment (pure interface).
function phase¶
Set the default phase for a decision variable during branching.
Parameters:
litThe literal representing the decision variable and its phase (positive if we want the phase to be True and negative if we want it to be False).
Exception:
- UnsupportedMethodException This method is optional.
function propagate¶
Propagate the given assumptions.
virtual std::pair< bool, std::vector< Literal > > Paramita::NonIncrSatSolver::propagate (
const std::vector< Literal > & assumptions
)
Parameters:
assumptionsA list of literals assumed to be true.
Returns:
A pair with a) true if propagation succeeded without a conflict, false if a conflict was found; and b) a vector with the literals propagated as a result of the assumptions. In case the propagation fails, the vector might be empty.
Exception:
- UnsupportedMethodException This method is optional.
function simplify¶
Simplify the formula.
Parameters:
num_roundsThe number of simplification rounds to apply.
Exception:
- UnsupportedMethodException This method is optional.
function solve¶
Solve the underlying formula under the given assumptions.
virtual std::optional< bool > Paramita::NonIncrSatSolver::solve (
const std::vector< Literal > & assumptions,
const SolvingBudget & budget
) = 0
If interrupted, the solver is responsible from clearing the interruption.
See also: interrupt
Parameters:
assumptionsA vector with literals that will be fixed during this solve call.budgetSolving limits for this call.
Precondition:
The method solve was not called previously OR no the formula has not been modified since the last solve call.
Postcondition:
The solving budget is reset to unlimited.
Returns:
An option with a boolean representing the satisfiability status of the formula under the specified assumptions, or std::nullopt if it could not be determined.
function unphase¶
Removes the default phase for a decision variable.
Parameters:
litThe literal representing the decision variable. Only its absolute value (i.e. the variable) is considered.
Exception:
- UnsupportedMethodException This method is optional.
- UnsupportedMethodException This method is optional.
function val_lit¶
Get the truth value for a literal.
Parameters:
litThe literal to check.
Returns:
lit if the literal belongs to the model, -lit if its negation belongs to the model, and 0 if it is not determined.
Precondition:
solve was called.
Precondition:
A solution was found by solve.
See BALYO201645 for more details.
Exception:
- UnsupportedMethodException This method is optional.