Пример #1
0
def solve(agent, predString, argList):
    imp = agent.getImp(Symbol(predString))
    b, z = optBZ(argList)
    solutions = []
    for solved in imp.solutions(agent, b, z):
        if solved:
            solutions.append([termEvalEnd(agent, b, zi) for zi in z])
    return tuple(solutions)
Пример #2
0
def solve(agent, predString, argList):
    imp = agent.getImp(Symbol(predString))
    b, z = optBZ(argList)
    solutions = []
    for solved in imp.solutions(agent, b, z):
        if solved:
            solutions.append([termEvalEnd(agent, b, zi) for zi in z])
    return tuple(solutions)
Пример #3
0
def generateBZ(partial):
    b, z = optBZ(partial)
    yield (partial, b, z)
    raise LowError("Only one solution to PartialBZ is allowed to be returned")
Пример #4
0
def generateBZ(partial):
    b, z = optBZ(partial)
    yield (partial, b, z)
    raise LowError("Only one solution to PartialBZ is allowed to be returned")
Пример #5
0
            NEWPM.displayError()
            errOutput.write('[%s.%s]: %s\n' %
                            (pred.name, impl.__class__.__name__, str(f)))

    #Print predicate definitions to file
    for impl in predimpls:
        try:
            #Testing Script. Begin:
            #            #esm = str(type(impl))
            #            #if not chronometers.has_key(esm):
            #            #    chronometers[esm] = chronometer(esm)
            #            #chronometers[esm].start()
            #Testing Script. End.
            arityOrFacts = impl.persist_arity_or_facts(agent)
            if isinstance(arityOrFacts, int):
                b, z = optBZ([None] * arityOrFacts)
                facts = [[b.bTermEval(agent, x) for x in z] \
                        for s in impl.solutions(agent, b, z) if s]
            elif arityOrFacts == None:
                raise LowError(
                    "persist_arity_or_facts method for %s returned None" %
                    impl.symbol)
            else:
                facts = arityOrFacts
            for fact in facts:
                writeFact(agent, impl.symbol, fact, output)
        except AnyException, f:
            errid = NEWPM.displayError()
            NEWPM.pm(errid)
            if isinstance(impl, DefaultImp):
                #use the predsym
Пример #6
0
        except AnyException, f:
            NEWPM.displayError()
            errOutput.write('[%s.%s]: %s\n'%(pred.name, impl.__class__.__name__, str(f)))
    
    #Print predicate definitions to file
    for impl in predimpls:
        try:
            #Testing Script. Begin:
#            #esm = str(type(impl))
#            #if not chronometers.has_key(esm):
#            #    chronometers[esm] = chronometer(esm)
#            #chronometers[esm].start()            
            #Testing Script. End.
            arityOrFacts = impl.persist_arity_or_facts(agent)
            if isinstance(arityOrFacts, int):
                b, z = optBZ([None]*arityOrFacts)
                facts = [[b.bTermEval(agent, x) for x in z] \
                        for s in impl.solutions(agent, b, z) if s]
            elif arityOrFacts == None:
                raise LowError("persist_arity_or_facts method for %s returned None"%impl.symbol)
            else:
                facts = arityOrFacts
            for fact in facts:
                writeFact(agent, impl.symbol, fact, output)
        except AnyException, f:
            errid = NEWPM.displayError()
            NEWPM.pm(errid)
            if isinstance(impl, DefaultImp):
                #use the predsym
                errOutput.write("%s(DefaultImp): %s\n"%(impl.symbol,str(f)))
            else: