示例#1
0
def ground_generate_task(domain_file,
                         problem_file,
                         out_task=None,
                         verbose_flag=False,
                         lenient_flag=False):
    """
    Uses Tarski Grounder to generate the output task using pddl

    Arguments
    =========
    domain_file  : domain pddl file location
    problem_file : problem pddl file location
    output_task  : C++ container to store/process domain and problem

    Returns
    =======
    None
    """
    global VERBOSE
    VERBOSE = verbose_flag
    global LENIENT_MODE
    LENIENT_MODE = lenient_flag
    parsing_timer = time.process_time()
    #Setup a reader to read the domain and problem pddl files
    with time_taken("reading and parsing pddl file"):
        if LENIENT_MODE:
            problem = FstripsReader( raise_on_error=True,
                theories=None, strict_with_requirements=False).\
            read_problem( domain_file, problem_file)
        else:
            problem = FstripsReader( raise_on_error=True,
                theories=None).\
            read_problem( domain_file, problem_file)

    with time_taken("preprocessing tarski problem"):
        process_problem(problem)
        init = problem.init_bk

    with time_taken("grounding"):
        grounding = LPGroundingStrategy(problem)
        reachable_action_params = copy.deepcopy(grounding.ground_actions())
        fluents = copy.deepcopy(grounding.ground_state_variables())
        del grounding
        count_params = 0
        for x, y in reachable_action_params.items():
            for z in y:
                count_params += 1
        if VERBOSE:
            print("Total number of reachable action params = ", count_params)

    return True
示例#2
0
def reader(theories=None,
           strict_with_requirements=True,
           case_insensitive=False):
    """ Return a reader configured to raise exceptions on syntax errors """
    return FstripsReader(raise_on_error=True,
                         theories=theories,
                         strict_with_requirements=strict_with_requirements,
                         case_insensitive=case_insensitive)
示例#3
0
def parse_pddl(domain_file, instance_file=None):
    """ Parse the given PDDL domain and instance files, the latter only if provided """
    reader = FstripsReader()
    reader.parse_domain(domain_file)
    problem = reader.problem

    # The generic constants are those which are parsed before parsing the instance file
    generic_constants = problem.language.constants()

    if instance_file is not None:
        reader.parse_instance(instance_file)

    return problem, problem.language, generic_constants
示例#4
0
def reader(theories=None):
    """ Return a reader configured to raise exceptions on syntax errors """
    return FstripsReader(raise_on_error=True, theories=theories)
示例#5
0
    """
    syms = []
    instantiations = []
    cardinality = 1
    for st in variables :
        if st.sort.builtin :
            raise TransformationError("universal effect elimination", phi,
                    "Variable found of built-in sort '{}', domain is too large!".
                    format(st.sort.name))
        syms.append(st)
        instantiations.append(list(st.sort.domain()))
        cardinality *= len(instantiations[-1])
    return cardinality, syms, instantiations

if __name__ == "__main__" :
    reader = FstripsReader(raise_on_error=True, theories=None)
    ### Uncomment this for PARCPRINTER test
    """
    problem = reader.read_problem("parcprinter_p01-domain.pddl","parcprinter_p01.pddl")
    problem.init.function_extensions = dict()
    for _,action in problem.actions.items():
        new_effects = []
        for effect in action.effects:
            if not isinstance(effect, FunctionalEffect):
                new_effects.append(effect)
        action.effects = new_effects
    """
    ### Uncomment this for FLOORTILE TEST
    #problem = reader.read_problem("floortile_domain.pddl","floortile_p01-4-3-2.pddl")

    # Comment this
示例#6
0
def parse_problem_with_tarski(domain_file, inst_file):
    reader = FstripsReader(raise_on_error=True,
                           theories=None,
                           strict_with_requirements=False)
    return reader.read_problem(domain_file, inst_file)