def test_action_costs_numeric_fluents_requirements():
    problem = parcprinter.create_small_task()
    writer = FstripsWriter(problem)

    # action costs should be required if there is a metric defined.
    domain_string = writer.print_domain()
    assert 'numeric-fluents' not in domain_string
    assert 'action-costs' in domain_string
Beispiel #2
0
def write_problem(problem, domain_constants: Optional[List[Constant]] = None):
    domain_filename = tempfile.NamedTemporaryFile(delete=True)
    instance_filename = tempfile.NamedTemporaryFile(delete=True)
    writer = FstripsWriter(problem)
    writer.write(domain_filename=domain_filename.name,
                 instance_filename=instance_filename.name,
                 domain_constants=domain_constants)
    return domain_filename, instance_filename
Beispiel #3
0
def main():

    for gridsize in [3, 5, 7, 10, 15, 20, 25]:
        for run in range(0, 5):
            num_blocks_and_rewards = gridsize
            problem = generate_propositional_domain(gridsize, num_blocks_and_rewards-2, num_blocks_and_rewards-2, False)
            writer = FstripsWriter(problem)
            writer.write(domain_filename=os.path.join(_CURRENT_DIR_, "domain.pddl"),  # We can overwrite the domain
                         instance_filename=os.path.join(_CURRENT_DIR_, f"instance_{gridsize}x{gridsize}_{run}.pddl"))
Beispiel #4
0
def main():

    for gridsize in [3, 4, 5, 7, 9]:
        for npacks in [2, 3]:
            for run in range(0, 3):
                problem = generate_domain(gridsize, npackages=npacks, add_fuel=False)
                writer = FstripsWriter(problem)
                writer.write(domain_filename=os.path.join(_CURRENT_DIR_, "domain.pddl"),  # We can overwrite the domain
                             instance_filename=os.path.join(_CURRENT_DIR_, f"instance_{gridsize}_{npacks}_{run}.pddl"),
                             domain_constants=[])
Beispiel #5
0
def main():

    add_noop = True
    for nnodes in [5, 10, 15]:
        nedges = int(nnodes**2 / 2)
        problem = generate_propositional_domain(nnodes, nedges, add_noop)
        writer = FstripsWriter(problem)
        writer.write(
            domain_filename=os.path.join(
                _CURRENT_DIR_, "domain.pddl"),  # We can overwrite the domain
            instance_filename=os.path.join(
                _CURRENT_DIR_, "instance_{}_{}.pddl".format(nnodes, nedges)))
Beispiel #6
0
def main():
    for nblocks in range(10, 31):
        for run in range(0, 5):
            problem, domain_constants = generate_problem(nblocks=nblocks,
                                                         run=run)
            writer = FstripsWriter(problem)
            writer.write(domain_filename=os.path.join(_CURRENT_DIR_,
                                                      "domain_atomic.pddl"),
                         instance_filename=os.path.join(
                             _CURRENT_DIR_,
                             f"test_atomic_{nblocks}_{run}.pddl"),
                         domain_constants=domain_constants)
Beispiel #7
0
def main():

    for gridsize in [3, 5, 7, 10]:
        problem = generate_domain(gridsize)
        writer = FstripsWriter(problem)
        writer.write(domain_filename=os.path.join(_CURRENT_DIR_, "domain.pddl"),  # We can overwrite the domain
                     instance_filename=os.path.join(_CURRENT_DIR_, "instance_{}.pddl".format(gridsize)))

        problem = generate_propositional_domain(gridsize)
        writer = FstripsWriter(problem)
        writer.write(domain_filename=os.path.join(_CURRENT_DIR_, "domain_strips.pddl"),  # We can overwrite the domain
                     instance_filename=os.path.join(_CURRENT_DIR_, "instance_strips_{}.pddl".format(gridsize)))
Beispiel #8
0
def main():
    writer = None
    for nb in range(6, 101, 2):
        problem = generate_strips_3op_blocksworld_problem(nb)
        writer = FstripsWriter(problem)
        writer.write_instance(HERE / f'instance_{nb}.pddl',
                              constant_objects=[])

    # Write the domain just once
    writer.write_domain(HERE / f'domain.pddl', constant_objects=[])
Beispiel #9
0
def test_blocksworld_writing_with_different_constants():
    problem, loc, clear, b1, table = get_bw_elements()
    writer = FstripsWriter(problem)
    instance_model_string = writer.print_instance()
    domain_model_string = writer.print_domain()
    assert "b1" not in domain_model_string
    assert "b1 b2 b3 b4 - block\n        table - place" in instance_model_string

    constant_objects = [b1, table]
    instance_model_string = writer.print_instance(constant_objects=constant_objects)
    domain_model_string = writer.print_domain(constant_objects=constant_objects)

    assert "b1 - block" in domain_model_string
    assert "table - place" in domain_model_string
    assert """(:objects
        b2 b3 b4 - block
    )""" in instance_model_string
Beispiel #10
0
def write_problem(problem):
    domain_filename = tempfile.NamedTemporaryFile(delete=True)
    instance_filename = tempfile.NamedTemporaryFile(delete=True)
    writer = FstripsWriter(problem)
    writer.write(domain_filename=domain_filename.name,
                 instance_filename=instance_filename.name)