Solver Module
Solver
class lib_satprob.solver.Solver()
Report
class lib_satprob.solver.Report(
status: Optional[bool]
stats: Dict[str, float]
model: List[int]
cost: int
)
KeyLimit
type lib_satprob.solver.KeyLimit = Tuple[str, float]
Example:
time_limit = ('time', 5) # 5 seconds
conflicts_limit = ('conflicts', 1000) # 1000 conflicts
propagations_limit = ('propagations', 1000) # 1000 propagations
Solver Methods
- get_instance(formula, use_timer)
- This method creates an instance of solver for given
formula. Created solver instance allows to propagate or solve a givenformulamultiple times on different Supplements without reinitialising the wrapped solver.Note
Currently, reinitialising is skipped only if the
formulais a pysat.formula.CNF instance (that is, the encoding is CNF or CNFPlus instance) instance and the passedsupplementscontains only an Assumptions part.Input arguments:formula(Formula) - a encoding formula returned by Encoding.get_formula(…) method.use_timer(Optional[boolean]) - a flag to enable timer while solving. If timer disabled then resulting Report doesn’t contain time value in stats dictionary. Default:True.
Return type: _Solver
- propagate(formula, supplements, use_timer)
- This method makes propagation for given formula. First, all Constraints from the passed
supplementsare substituted into the formula, then the pysat.solvers.Solver.propagate(…) method is called with the list of Assumptions from the passedsupplements.Note
The method Solver.propagate(…) works only for CNF or CNFPlus encodings (that is, for SAT problems specified by the implementation of SatProblem).
Input arguments:formula(Formula) - a encoding formula returned by Encoding.get_formula(…) method.supplements(Supplements) - a formula supplements that are added while formula solving or propagating.use_timer(Optional[boolean]) - a flag to enable timer while solving. If timer disabled then resulting Report doesn’t contain time value in stats dictionary. Default:True.
Return type: Report
- solve(formula, supplements, limit, extract_model, use_timer)
- This method solves given formula. First, Constraints from the passed
supplementsare substituted into the formula, then the pysat.solvers.Solver.solve(…) method is called with the list of Assumptions from the passedsupplementsand resourcelimit. Theextract_modelargument determines whether the satisfying assignment for theformulawill be extracted from pysat solver.Input arguments:formula(Formula) - a encoding formula returned by Encoding.get_formula(…) method.supplements(Supplements) - a formula supplements that are added while formula solving or propagating.limit(Optional[KeyLimit]) - a solving limit. Default:(None, 0).extract_model(Optional[boolean]) - a flag to extract a satisfying assignment for theformulagiven to the solver. Default:True.use_timer(Optional[boolean]) - a flag to enable timer while solving. If timer disabled then resulting Report doesn’t contain time value in stats dictionary. Default:True.
Return type: Report
PySatSolver
class lib_satprob.solver.PySatSolver(sat_name='m22': str, max_sat_alg='rc2': str)
sat_name(Optional[str]) - argument specifies …max_sat_alg(Optional[str]) - argument specifies …