import time import itertools from functools import partial from powergrasp.commons import ASP_ARG_UPPERBOUND, ASP_ARG_CC from powergrasp.commons import ASP_ARG_LOWERBOUND, ASP_ARG_STEP from powergrasp import observers from powergrasp import solving from powergrasp import commons from powergrasp import atoms from powergrasp import utils from powergrasp.observers import Signals # shortcut LOGGER = commons.logger() # under this minimal score, the found concept is not interesting MINIMAL_SCORE = 2 def search_concept(input_atoms, score_min, score_max, cc, step, aspconfig): """Return the concept found and its score. if no concept found: return (None, None) if concept found: return (atoms, concept score) """ if score_min > score_max: return None, None search_clique = commons.ASP_SRC_FINDCC in aspconfig.files CONCEPT_NAME = ('' if search_clique else 'BI') + 'CLIQUE' LOGGER.debug('FIND BEST ' + CONCEPT_NAME + ' [' + str(score_min) + ';' +
# -*- coding: utf-8 -*- """ definition of the NNF format converter. """ from powergrasp.converter.output_converter import OutConverter import powergrasp.commons as commons import itertools logger = commons.logger() class OutNNF(OutConverter): """Convert given atoms in NNF format""" def _convert(self, powernodes, cliques): """Operate convertion on given atoms""" # get first item for obtain global data cc, k, s, node = next(atoms) atoms = itertools.chain(((cc, k, s, node), ), atoms) # generate lines nnf = ('{0}_{1}_{2}\t{3}'.format(*g) for g in atoms) return itertools.chain( nnf, ('{0}_{1}\t{2}_{3}_{4}\tpp\t{5}_{6}_{7}'.format( cc, k, cc, k, 1, cc, k, 2), ), ('{0}_cc\t{1}_{2}'.format(cc, cc, k), ), ) def _convert_edge(self, atoms): """Perform the convertion and return its results"""