Code
stringlengths
103
85.9k
Summary
listlengths
0
94
Please provide a description of the function:def prop_budget(self, budget): if self.glucose: pysolvers.glucose41_pbudget(self.glucose, budget)
[ "\n Set limit on the number of propagations.\n " ]
Please provide a description of the function:def set_phases(self, literals=[]): if self.glucose: pysolvers.glucose41_setphases(self.glucose, literals)
[ "\n Sets polarities of a given list of variables.\n " ]
Please provide a description of the function:def get_model(self): if self.glucose and self.status == True: model = pysolvers.glucose41_model(self.glucose) return model if model != None else []
[ "\n Get a model if the formula was previously satisfied.\n " ]
Please provide a description of the function:def get_core(self): if self.glucose and self.status == False: return pysolvers.glucose41_core(self.glucose)
[ "\n Get an unsatisfiable core if the formula was previously\n unsatisfied.\n " ]
Please provide a description of the function:def enum_models(self, assumptions=[]): if self.glucose: done = False while not done: if self.use_timer: start_time = time.clock() self.status = pysolvers.glucose41_solve(self.gluco...
[ "\n Iterate over models of the internal formula.\n " ]
Please provide a description of the function:def new(self, bootstrap_with=None, use_timer=False, with_proof=False): if not self.lingeling: self.lingeling = pysolvers.lingeling_new() if bootstrap_with: for clause in bootstrap_with: self.add_c...
[ "\n Actual constructor of the solver.\n " ]
Please provide a description of the function:def delete(self): if self.lingeling: pysolvers.lingeling_del(self.lingeling, self.prfile) self.lingeling = None if self.prfile: self.prfile.close()
[ "\n Destructor.\n " ]
Please provide a description of the function:def solve(self, assumptions=[]): if self.lingeling: if self.use_timer: start_time = time.clock() # saving default SIGINT handler def_sigint_handler = signal.signal(signal.SIGINT, signal.SIG_DFL) ...
[ "\n Solve internal formula.\n " ]
Please provide a description of the function:def set_phases(self, literals=[]): if self.lingeling: pysolvers.lingeling_setphases(self.lingeling, literals)
[ "\n Sets polarities of a given list of variables.\n " ]
Please provide a description of the function:def get_model(self): if self.lingeling and self.status == True: model = pysolvers.lingeling_model(self.lingeling) return model if model != None else []
[ "\n Get a model if the formula was previously satisfied.\n " ]
Please provide a description of the function:def get_core(self): if self.lingeling and self.status == False: return pysolvers.lingeling_core(self.lingeling, self.prev_assumps)
[ "\n Get an unsatisfiable core if the formula was previously\n unsatisfied.\n " ]
Please provide a description of the function:def get_proof(self): if self.lingeling and self.prfile: self.prfile.seek(0) return [line.rstrip() for line in self.prfile.readlines()]
[ "\n Get a proof produced when deciding the formula.\n " ]
Please provide a description of the function:def add_clause(self, clause, no_return=True): if self.lingeling: pysolvers.lingeling_add_cl(self.lingeling, clause)
[ "\n Add a new clause to solver's internal formula.\n " ]
Please provide a description of the function:def append_formula(self, formula, no_return=True): if self.lingeling: for clause in formula: self.add_clause(clause, no_return)
[ "\n Appends list of clauses to solver's internal formula.\n " ]
Please provide a description of the function:def new(self, bootstrap_with=None, use_timer=False, with_proof=False): if not self.maplesat: self.maplesat = pysolvers.maplechrono_new() if bootstrap_with: for clause in bootstrap_with: self.add_c...
[ "\n Actual constructor of the solver.\n " ]
Please provide a description of the function:def delete(self): if self.maplesat: pysolvers.maplechrono_del(self.maplesat) self.maplesat = None if self.prfile: self.prfile.close()
[ "\n Destructor.\n " ]
Please provide a description of the function:def solve(self, assumptions=[]): if self.maplesat: if self.use_timer: start_time = time.clock() # saving default SIGINT handler def_sigint_handler = signal.signal(signal.SIGINT, signal.SIG_DFL) ...
[ "\n Solve internal formula.\n " ]
Please provide a description of the function:def solve_limited(self, assumptions=[]): if self.maplesat: if self.use_timer: start_time = time.clock() # saving default SIGINT handler def_sigint_handler = signal.signal(signal.SIGINT, signal.SIG_DFL) ...
[ "\n Solve internal formula using given budgets for conflicts and\n propagations.\n " ]
Please provide a description of the function:def conf_budget(self, budget): if self.maplesat: pysolvers.maplechrono_cbudget(self.maplesat, budget)
[ "\n Set limit on the number of conflicts.\n " ]
Please provide a description of the function:def prop_budget(self, budget): if self.maplesat: pysolvers.maplechrono_pbudget(self.maplesat, budget)
[ "\n Set limit on the number of propagations.\n " ]
Please provide a description of the function:def propagate(self, assumptions=[], phase_saving=0): if self.maplesat: if self.use_timer: start_time = time.clock() # saving default SIGINT handler def_sigint_handler = signal.signal(signal.SIGINT, signa...
[ "\n Propagate a given set of assumption literals.\n " ]
Please provide a description of the function:def set_phases(self, literals=[]): if self.maplesat: pysolvers.maplechrono_setphases(self.maplesat, literals)
[ "\n Sets polarities of a given list of variables.\n " ]
Please provide a description of the function:def get_model(self): if self.maplesat and self.status == True: model = pysolvers.maplechrono_model(self.maplesat) return model if model != None else []
[ "\n Get a model if the formula was previously satisfied.\n " ]
Please provide a description of the function:def get_core(self): if self.maplesat and self.status == False: return pysolvers.maplechrono_core(self.maplesat)
[ "\n Get an unsatisfiable core if the formula was previously\n unsatisfied.\n " ]
Please provide a description of the function:def get_proof(self): if self.maplesat and self.prfile: self.prfile.seek(0) return [line.rstrip() for line in self.prfile.readlines()]
[ "\n Get a proof produced while deciding the formula.\n " ]
Please provide a description of the function:def append_formula(self, formula, no_return=True): if self.maplesat: res = None for clause in formula: res = self.add_clause(clause, no_return) if not no_return: return res
[ "\n Appends list of clauses to solver's internal formula.\n " ]
Please provide a description of the function:def new(self, bootstrap_with=None, use_timer=False, with_proof=False): if not self.maplesat: self.maplesat = pysolvers.maplecm_new() if bootstrap_with: for clause in bootstrap_with: self.add_claus...
[ "\n Actual constructor of the solver.\n " ]
Please provide a description of the function:def delete(self): if self.maplesat: pysolvers.maplecm_del(self.maplesat) self.maplesat = None if self.prfile: self.prfile.close()
[ "\n Destructor.\n " ]
Please provide a description of the function:def conf_budget(self, budget): if self.maplesat: pysolvers.maplecm_cbudget(self.maplesat, budget)
[ "\n Set limit on the number of conflicts.\n " ]
Please provide a description of the function:def prop_budget(self, budget): if self.maplesat: pysolvers.maplecm_pbudget(self.maplesat, budget)
[ "\n Set limit on the number of propagations.\n " ]
Please provide a description of the function:def set_phases(self, literals=[]): if self.maplesat: pysolvers.maplecm_setphases(self.maplesat, literals)
[ "\n Sets polarities of a given list of variables.\n " ]
Please provide a description of the function:def get_model(self): if self.maplesat and self.status == True: model = pysolvers.maplecm_model(self.maplesat) return model if model != None else []
[ "\n Get a model if the formula was previously satisfied.\n " ]
Please provide a description of the function:def get_core(self): if self.maplesat and self.status == False: return pysolvers.maplecm_core(self.maplesat)
[ "\n Get an unsatisfiable core if the formula was previously\n unsatisfied.\n " ]
Please provide a description of the function:def new(self, bootstrap_with=None, use_timer=False, with_proof=False): if not self.maplesat: self.maplesat = pysolvers.maplesat_new() if bootstrap_with: for clause in bootstrap_with: self.add_clau...
[ "\n Actual constructor of the solver.\n " ]
Please provide a description of the function:def delete(self): if self.maplesat: pysolvers.maplesat_del(self.maplesat) self.maplesat = None if self.prfile: self.prfile.close()
[ "\n Destructor.\n " ]
Please provide a description of the function:def conf_budget(self, budget): if self.maplesat: pysolvers.maplesat_cbudget(self.maplesat, budget)
[ "\n Set limit on the number of conflicts.\n " ]
Please provide a description of the function:def prop_budget(self, budget): if self.maplesat: pysolvers.maplesat_pbudget(self.maplesat, budget)
[ "\n Set limit on the number of propagations.\n " ]
Please provide a description of the function:def set_phases(self, literals=[]): if self.maplesat: pysolvers.maplesat_setphases(self.maplesat, literals)
[ "\n Sets polarities of a given list of variables.\n " ]
Please provide a description of the function:def get_model(self): if self.maplesat and self.status == True: model = pysolvers.maplesat_model(self.maplesat) return model if model != None else []
[ "\n Get a model if the formula was previously satisfied.\n " ]
Please provide a description of the function:def get_core(self): if self.maplesat and self.status == False: return pysolvers.maplesat_core(self.maplesat)
[ "\n Get an unsatisfiable core if the formula was previously\n unsatisfied.\n " ]
Please provide a description of the function:def add_clause(self, clause, no_return=True): if self.maplesat: res = pysolvers.maplesat_add_cl(self.maplesat, clause) if res == False: self.status = False if not no_return: return res
[ "\n Add a new clause to solver's internal formula.\n " ]
Please provide a description of the function:def new(self, bootstrap_with=None, use_timer=False): if not self.minicard: self.minicard = pysolvers.minicard_new() if bootstrap_with: for clause in bootstrap_with: self.add_clause(clause) ...
[ "\n Actual constructor of the solver.\n " ]
Please provide a description of the function:def delete(self): if self.minicard: pysolvers.minicard_del(self.minicard) self.minicard = None
[ "\n Destructor.\n " ]
Please provide a description of the function:def solve(self, assumptions=[]): if self.minicard: if self.use_timer: start_time = time.clock() # saving default SIGINT handler def_sigint_handler = signal.signal(signal.SIGINT, signal.SIG_DFL) ...
[ "\n Solve internal formula.\n " ]
Please provide a description of the function:def solve_limited(self, assumptions=[]): if self.minicard: if self.use_timer: start_time = time.clock() # saving default SIGINT handler def_sigint_handler = signal.signal(signal.SIGINT, signal.SIG_DFL) ...
[ "\n Solve internal formula using given budgets for conflicts and\n propagations.\n " ]
Please provide a description of the function:def conf_budget(self, budget): if self.minicard: pysolvers.minicard_cbudget(self.minicard, budget)
[ "\n Set limit on the number of conflicts.\n " ]
Please provide a description of the function:def prop_budget(self, budget): if self.minicard: pysolvers.minicard_pbudget(self.minicard, budget)
[ "\n Set limit on the number of propagations.\n " ]
Please provide a description of the function:def set_phases(self, literals=[]): if self.minicard: pysolvers.minicard_setphases(self.minicard, literals)
[ "\n Sets polarities of a given list of variables.\n " ]
Please provide a description of the function:def get_model(self): if self.minicard and self.status == True: model = pysolvers.minicard_model(self.minicard) return model if model != None else []
[ "\n Get a model if the formula was previously satisfied.\n " ]
Please provide a description of the function:def get_core(self): if self.minicard and self.status == False: return pysolvers.minicard_core(self.minicard)
[ "\n Get an unsatisfiable core if the formula was previously\n unsatisfied.\n " ]
Please provide a description of the function:def add_clause(self, clause, no_return=True): if self.minicard: res = pysolvers.minicard_add_cl(self.minicard, clause) if res == False: self.status = False if not no_return: return res
[ "\n Add a new clause to solver's internal formula.\n " ]
Please provide a description of the function:def add_atmost(self, lits, k, no_return=True): if self.minicard: res = pysolvers.minicard_add_am(self.minicard, lits, k) if res == False: self.status = False if not no_return: return res
[ "\n Add a new atmost constraint to solver's internal formula.\n " ]
Please provide a description of the function:def new(self, bootstrap_with=None, use_timer=False): if not self.minisat: self.minisat = pysolvers.minisat22_new() if bootstrap_with: for clause in bootstrap_with: self.add_clause(clause) ...
[ "\n Actual constructor of the solver.\n " ]
Please provide a description of the function:def delete(self): if self.minisat: pysolvers.minisat22_del(self.minisat) self.minisat = None
[ "\n Destructor.\n " ]
Please provide a description of the function:def conf_budget(self, budget): if self.minisat: pysolvers.minisat22_cbudget(self.minisat, budget)
[ "\n Set limit on the number of conflicts.\n " ]
Please provide a description of the function:def prop_budget(self, budget): if self.minisat: pysolvers.minisat22_pbudget(self.minisat, budget)
[ "\n Set limit on the number of propagations.\n " ]
Please provide a description of the function:def set_phases(self, literals=[]): if self.minisat: pysolvers.minisat22_setphases(self.minisat, literals)
[ "\n Sets polarities of a given list of variables.\n " ]
Please provide a description of the function:def get_model(self): if self.minisat and self.status == True: model = pysolvers.minisat22_model(self.minisat) return model if model != None else []
[ "\n Get a model if the formula was previously satisfied.\n " ]
Please provide a description of the function:def get_core(self): if self.minisat and self.status == False: return pysolvers.minisat22_core(self.minisat)
[ "\n Get an unsatisfiable core if the formula was previously\n unsatisfied.\n " ]
Please provide a description of the function:def delete(self): if self.minisat: pysolvers.minisatgh_del(self.minisat) self.minisat = None
[ "\n Destructor.\n " ]
Please provide a description of the function:def solve(self, assumptions=[]): if self.minisat: if self.use_timer: start_time = time.clock() # saving default SIGINT handler def_sigint_handler = signal.signal(signal.SIGINT, signal.SIG_DFL) ...
[ "\n Solve internal formula.\n " ]
Please provide a description of the function:def solve_limited(self, assumptions=[]): if self.minisat: if self.use_timer: start_time = time.clock() # saving default SIGINT handler def_sigint_handler = signal.signal(signal.SIGINT, signal.SIG_DFL) ...
[ "\n Solve internal formula using given budgets for conflicts and\n propagations.\n " ]
Please provide a description of the function:def conf_budget(self, budget): if self.minisat: pysolvers.minisatgh_cbudget(self.minisat, budget)
[ "\n Set limit on the number of conflicts.\n " ]
Please provide a description of the function:def prop_budget(self, budget): if self.minisat: pysolvers.minisatgh_pbudget(self.minisat, budget)
[ "\n Set limit on the number of propagations.\n " ]
Please provide a description of the function:def set_phases(self, literals=[]): if self.minisat: pysolvers.minisatgh_setphases(self.minisat, literals)
[ "\n Sets polarities of a given list of variables.\n " ]
Please provide a description of the function:def get_model(self): if self.minisat and self.status == True: model = pysolvers.minisatgh_model(self.minisat) return model if model != None else []
[ "\n Get a model if the formula was previously satisfied.\n " ]
Please provide a description of the function:def get_core(self): if self.minisat and self.status == False: return pysolvers.minisatgh_core(self.minisat)
[ "\n Get an unsatisfiable core if the formula was previously\n unsatisfied.\n " ]
Please provide a description of the function:def add_clause(self, clause, no_return=True): if self.minisat: res = pysolvers.minisatgh_add_cl(self.minisat, clause) if res == False: self.status = False if not no_return: return res
[ "\n Add a new clause to solver's internal formula.\n " ]
Please provide a description of the function:def restart(self, start_from=1, occupied=[]): # initial ID self.top = start_from - 1 # occupied IDs self._occupied = sorted(occupied, key=lambda x: x[0]) # main dictionary storing the mapping from objects to variable IDs ...
[ "\n Restart the manager from scratch. The arguments replicate those of\n the constructor of :class:`IDPool`.\n " ]
Please provide a description of the function:def id(self, obj): vid = self.obj2id[obj] if vid not in self.id2obj: self.id2obj[vid] = obj return vid
[ "\n The method is to be used to assign an integer variable ID for a\n given new object. If the object already has an ID, no new ID is\n created and the old one is returned instead.\n\n An object can be anything. In some cases it is convenient to use\n string va...
Please provide a description of the function:def occupy(self, start, stop): self._occupied.append([start, stop]) self._occupied.sort(key=lambda x: x[0])
[ "\n Mark a given interval as occupied so that the manager could skip\n the values from ``start`` to ``stop`` (**inclusive**).\n\n :param start: beginning of the interval.\n :param stop: end of the interval.\n\n :type start: int\n :type stop: int\n ...
Please provide a description of the function:def _next(self): self.top += 1 while self._occupied and self.top >= self._occupied[0][0]: if self.top <= self._occupied[0][1]: self.top = self._occupied[0][1] + 1 self._occupied.pop(0) return self.t...
[ "\n Get next variable ID. Skip occupied intervals if any.\n " ]
Please provide a description of the function:def from_file(self, fname, comment_lead=['c'], compressed_with='use_ext'): with FileObject(fname, mode='r', compression=compressed_with) as fobj: self.from_fp(fobj.fp, comment_lead)
[ "\n Read a CNF formula from a file in the DIMACS format. A file name is\n expected as an argument. A default argument is ``comment_lead`` for\n parsing comment lines. A given file can be compressed by either\n gzip, bzip2, or lzma.\n\n :param fname: name of a f...
Please provide a description of the function:def from_fp(self, file_pointer, comment_lead=['c']): self.nv = 0 self.clauses = [] self.comments = [] comment_lead = tuple('p') + tuple(comment_lead) for line in file_pointer: line = line.strip() if l...
[ "\n Read a CNF formula from a file pointer. A file pointer should be\n specified as an argument. The only default argument is\n ``comment_lead``, which can be used for parsing specific comment\n lines.\n\n :param file_pointer: a file pointer to read the formula...
Please provide a description of the function:def from_clauses(self, clauses): self.clauses = copy.deepcopy(clauses) for cl in self.clauses: self.nv = max([abs(l) for l in cl] + [self.nv])
[ "\n This methods copies a list of clauses into a CNF object.\n\n :param clauses: a list of clauses.\n :type clauses: list(list(int))\n\n Example:\n\n .. code-block:: python\n\n >>> from pysat.formula import CNF\n >>> cnf = CNF(from...
Please provide a description of the function:def copy(self): cnf = CNF() cnf.nv = self.nv cnf.clauses = copy.deepcopy(self.clauses) cnf.comments = copy.deepcopy(self.comments) return cnf
[ "\n This method can be used for creating a copy of a CNF object. It\n creates another object of the :class:`CNF` class and makes use of\n the *deepcopy* functionality to copy the clauses.\n\n :return: an object of class :class:`CNF`.\n\n Example:\n\n ...
Please provide a description of the function:def to_file(self, fname, comments=None, compress_with='use_ext'): with FileObject(fname, mode='w', compression=compress_with) as fobj: self.to_fp(fobj.fp, comments)
[ "\n The method is for saving a CNF formula into a file in the DIMACS\n CNF format. A file name is expected as an argument. Additionally,\n supplementary comment lines can be specified in the ``comments``\n parameter. Also, a file can be compressed using either gzip, bzip2...
Please provide a description of the function:def to_fp(self, file_pointer, comments=None): # saving formula's internal comments for c in self.comments: print(c, file=file_pointer) # saving externally specified comments if comments: for c in comments: ...
[ "\n The method can be used to save a CNF formula into a file pointer.\n The file pointer is expected as an argument. Additionally,\n supplementary comment lines can be specified in the ``comments``\n parameter.\n\n :param fname: a file name where to store the f...
Please provide a description of the function:def append(self, clause): self.nv = max([abs(l) for l in clause] + [self.nv]) self.clauses.append(clause)
[ "\n Add one more clause to CNF formula. This method additionally\n updates the number of variables, i.e. variable ``self.nv``, used in\n the formula.\n\n :param clause: a new clause to add.\n :type clause: list(int)\n\n .. code-block:: python\n\n ...
Please provide a description of the function:def weighted(self): wcnf = WCNF() wcnf.nv = self.nv wcnf.hard = [] wcnf.soft = copy.deepcopy(self.clauses) wcnf.wght = [1 for cl in wcnf.soft] self.topw = len(wcnf.wght) + 1 wcnf.comments = self.comments[:] ...
[ "\n This method creates a weighted copy of the internal formula. As a\n result, an object of class :class:`WCNF` is returned. Every clause\n of the CNF formula is *soft* in the new WCNF formula and its weight\n is equal to ``1``. The set of hard clauses of the formula is ...
Please provide a description of the function:def negate(self, topv=None): negated = CNF() negated.nv = topv if not negated.nv: negated.nv = self.nv negated.clauses = [] negated.auxvars = [] for cl in self.clauses: auxv = -cl[0] ...
[ "\n Given a CNF formula :math:`\\mathcal{F}`, this method creates a CNF\n formula :math:`\\\\neg{\\mathcal{F}}`. The negation of the formula is\n encoded to CNF with the use of *auxiliary* Tseitin variables [1]_.\n A new CNF formula is returned keeping all the newly intro...
Please provide a description of the function:def from_fp(self, file_pointer, comment_lead=['c']): self.nv = 0 self.hard = [] self.soft = [] self.wght = [] self.topw = 0 self.comments = [] comment_lead = tuple('p') + tuple(comment_lead) for line ...
[ "\n Read a WCNF formula from a file pointer. A file pointer should be\n specified as an argument. The only default argument is\n ``comment_lead``, which can be used for parsing specific comment\n lines.\n\n :param file_pointer: a file pointer to read the formul...
Please provide a description of the function:def copy(self): wcnf = WCNF() wcnf.nv = self.nv wcnf.topw = self.topw wcnf.hard = copy.deepcopy(self.hard) wcnf.soft = copy.deepcopy(self.soft) wcnf.wght = copy.deepcopy(self.wght) wcnf.comments = copy.deepcop...
[ "\n This method can be used for creating a copy of a WCNF object. It\n creates another object of the :class:`WCNF` class and makes use of\n the *deepcopy* functionality to copy both hard and soft clauses.\n\n :return: an object of class :class:`WCNF`.\n\n Examp...
Please provide a description of the function:def to_fp(self, file_pointer, comments=None): # saving formula's internal comments for c in self.comments: print(c, file=file_pointer) # saving externally specified comments if comments: for c in comments: ...
[ "\n The method can be used to save a WCNF formula into a file pointer.\n The file pointer is expected as an argument. Additionally,\n supplementary comment lines can be specified in the ``comments``\n parameter.\n\n :param fname: a file name where to store the ...
Please provide a description of the function:def append(self, clause, weight=None): self.nv = max([abs(l) for l in clause] + [self.nv]) if weight: self.soft.append(clause) self.wght.append(weight) else: self.hard.append(clause)
[ "\n Add one more clause to WCNF formula. This method additionally\n updates the number of variables, i.e. variable ``self.nv``, used in\n the formula.\n\n The clause can be hard or soft depending on the ``weight``\n argument. If no weight is set, the clause is ...
Please provide a description of the function:def extend(self, clauses, weights=None): if weights: # clauses are soft for i, cl in enumerate(clauses): self.append(cl, weight=weights[i]) else: # clauses are hard for cl in clauses: ...
[ "\n Add several clauses to WCNF formula. The clauses should be given in\n the form of list. For every clause in the list, method\n :meth:`append` is invoked.\n\n The clauses can be hard or soft depending on the ``weights``\n argument. If no weights are set, the...
Please provide a description of the function:def unweighed(self): cnf = CNF() cnf.nv = self.nv cnf.clauses = copy.deepcopy(self.hard) + copy.deepcopy(self.soft) cnf.commends = self.comments[:] return cnf
[ "\n This method creates a *plain* (unweighted) copy of the internal\n formula. As a result, an object of class :class:`CNF` is returned.\n Every clause (both hard or soft) of the WCNF formula is copied to\n the ``clauses`` variable of the resulting plain formula, i.e. all...
Please provide a description of the function:def from_fp(self, file_pointer, comment_lead=['c']): self.nv = 0 self.clauses = [] self.atmosts = [] self.comments = [] comment_lead = tuple('p') + tuple(comment_lead) for line in file_pointer: line = lin...
[ "\n Read a CNF+ formula from a file pointer. A file pointer should be\n specified as an argument. The only default argument is\n ``comment_lead``, which can be used for parsing specific comment\n lines.\n\n :param file_pointer: a file pointer to read the formul...
Please provide a description of the function:def to_fp(self, file_pointer, comments=None): # saving formula's internal comments for c in self.comments: print(c, file=file_pointer) # saving externally specified comments if comments: for c in comments: ...
[ "\n The method can be used to save a CNF+ formula into a file pointer.\n The file pointer is expected as an argument. Additionally,\n supplementary comment lines can be specified in the ``comments``\n parameter.\n\n :param fname: a file name where to store the ...
Please provide a description of the function:def append(self, clause, is_atmost=False): if not is_atmost: self.nv = max([abs(l) for l in clause] + [self.nv]) self.clauses.append(clause) else: self.nv = max([abs(l) for l in clause[0]] + [self.nv]) ...
[ "\n Add a single clause or a single AtMostK constraint to CNF+ formula.\n This method additionally updates the number of variables, i.e.\n variable ``self.nv``, used in the formula.\n\n If the clause is an AtMostK constraint, this should be set with the\n use o...
Please provide a description of the function:def from_fp(self, file_pointer, comment_lead=['c']): self.nv = 0 self.hard = [] self.atms = [] self.soft = [] self.wght = [] self.topw = 0 self.comments = [] comment_lead = tuple('p') + tuple(comment_l...
[ "\n Read a WCNF+ formula from a file pointer. A file pointer should be\n specified as an argument. The only default argument is\n ``comment_lead``, which can be used for parsing specific comment\n lines.\n\n :param file_pointer: a file pointer to read the formu...
Please provide a description of the function:def append(self, clause, weight=None, is_atmost=False): if not is_atmost: self.nv = max([abs(l) for l in clause] + [self.nv]) if weight: self.soft.append(clause) self.wght.append(weight) e...
[ "\n Add a single clause or a single AtMostK constraint to WCNF+\n formula. This method additionally updates the number of variables,\n i.e. variable ``self.nv``, used in the formula.\n\n If the clause is an AtMostK constraint, this should be set with the\n use...
Please provide a description of the function:def init(self, with_soft=True): self.oracle = Solver(name=self.solver, bootstrap_with=self.hard, use_timer=True) # self.atm1 is not empty only in case of minicard for am in self.atm1: self.oracle.add_atmost(*am) if with...
[ "\n The method for the SAT oracle initialization. Since the oracle is\n is used non-incrementally, it is reinitialized at every iteration\n of the MaxSAT algorithm (see :func:`reinit`). An input parameter\n ``with_soft`` (``False`` by default) regulates whether or not the...
Please provide a description of the function:def delete(self): if self.oracle: self.time += self.oracle.time_accum() # keep SAT solving time self.oracle.delete() self.oracle = None
[ "\n Explicit destructor of the internal SAT oracle.\n " ]
Please provide a description of the function:def compute(self): if self.oracle.solve(): # hard part is satisfiable # create selectors and a mapping from selectors to clause ids self.sels, self.vmap = [], {} self.scpy = [True for cl in self.soft] ...
[ "\n Compute a MaxSAT solution. First, the method checks whether or\n not the set of hard clauses is satisfiable. If not, the method\n returns ``False``. Otherwise, add soft clauses to the oracle and\n call the MaxSAT algorithm (see :func:`_compute`).\n\n Note t...
Please provide a description of the function:def _compute(self): while True: if self.oracle.solve(assumptions=self.sels): self.model = self.oracle.get_model() self.model = filter(lambda l: abs(l) <= self.orig_nv, self.model) return ...
[ "\n This method implements WMSU1 algorithm. The method is essentially a\n loop, which at each iteration calls the SAT oracle to decide\n whether the working formula is satisfiable. If it is, the method\n derives a model (stored in variable ``self.model``) and returns.\n ...
Please provide a description of the function:def treat_core(self): # extracting the core self.core = [self.vmap[sel] for sel in self.oracle.get_core()] minw = min(map(lambda i: self.wght[i], self.core)) # updating the cost self.cost += minw # splitting clauses...
[ "\n Now that the previous SAT call returned UNSAT, a new unsatisfiable\n core should be extracted and relaxed. Core extraction is done\n through a call to the :func:`pysat.solvers.Solver.get_core` method,\n which returns a subset of the selector literals deemed responsibl...
Please provide a description of the function:def split_core(self, minw): for clid in self.core: sel = self.sels[clid] if self.wght[clid] > minw: self.topv += 1 cl_new = [] for l in self.soft[clid]: if l != -s...
[ "\n Split clauses in the core whenever necessary.\n\n Given a list of soft clauses in an unsatisfiable core, the method\n is used for splitting clauses whose weights are greater than the\n minimum weight of the core, i.e. the ``minw`` value computed in\n :func:...
Please provide a description of the function:def relax_core(self): if len(self.core) > 1: # relaxing rels = [] for clid in self.core: self.topv += 1 rels.append(self.topv) self.soft[clid].append(self.topv) ...
[ "\n Relax and bound the core.\n\n After unsatisfiable core splitting, this method is called. If the\n core contains only one clause, i.e. this clause cannot be satisfied\n together with the hard clauses of the formula, the formula gets\n augmented with the nega...
Please provide a description of the function:def remove_unit_core(self): self.scpy[self.core[0]] = False for l in self.soft[self.core[0]]: self.hard.append([-l])
[ "\n If an unsatisfiable core contains only one clause :math:`c`, this\n method is invoked to add a bunch of new unit size hard clauses. As\n a result, the SAT oracle gets unit clauses :math:`(\\\\neg{l})` for\n all literals :math:`l` in clause :math:`c`.\n " ]