Skip to content

Commit

Permalink
Merge pull request #71 from aefrank/forall-fix
Browse files Browse the repository at this point in the history
Forall fix
  • Loading branch information
haz committed May 31, 2023
2 parents ddcb467 + 45411ee commit b9091a9
Show file tree
Hide file tree
Showing 30 changed files with 81,148 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ that gives:
(:constants a b c)
(:predicates (p1 ?x - type_1 ?y - type_1 ?z - type_1) (p2 ?x - type_1 ?y - type_1))
(:action action-1
:parameters (?x - type_1 ?y - type_1 ?z - type_1 )
:parameters (?x - type_1 ?y - type_1 ?z - type_1)
:precondition (and (p1 ?x ?y ?z) (not (p2 ?y ?z)))
:effect (p2 ?y ?z)
)
Expand Down
2 changes: 1 addition & 1 deletion pddl/helpers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def _typed_parameters(parameters) -> str:
result += f"?{p.name} - {' '.join(map(str, p.type_tags))} "
else:
result += str(p) + " "
return result
return result.strip()


class RegexConstrainedString(str):
Expand Down
4 changes: 2 additions & 2 deletions pddl/logic/effects.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import functools
from typing import AbstractSet, Collection, Generic, Optional, Sequence, TypeVar, Union

from pddl.helpers.base import ensure_set
from pddl.helpers.base import _typed_parameters, ensure_set
from pddl.helpers.cache_hash import cache_hash
from pddl.logic import Variable
from pddl.logic.base import Atomic, Formula, Not, OneOf
Expand Down Expand Up @@ -140,7 +140,7 @@ def variables(self) -> AbstractSet[Variable]:

def __str__(self) -> str:
"""Get the string representation."""
return f"({Symbols.FORALL.value} ({' '.join(map(str, self.variables))}) {self.effect})"
return f"({Symbols.FORALL.value} ({_typed_parameters(self.variables)}) {self.effect})"

def __repr__(self) -> str:
"""Get an unambiguous string representation."""
Expand Down
6 changes: 5 additions & 1 deletion pddl/logic/terms.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,11 @@ def __repr__(self):

def __eq__(self, other) -> bool:
"""Compare with another object."""
return isinstance(other, Variable) and self.name == other.name
return (
isinstance(other, Variable)
and self.name == other.name
and self.type_tags == other.type_tags
)

def __hash__(self) -> int:
"""Get the hash."""
Expand Down
3 changes: 2 additions & 1 deletion pddl/parser/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ def c_effect(self, args):
if len(args) == 1:
return args[0]
if args[1] == Symbols.FORALL.value:
return Forall(effect=args[-2], variables=args[3])
variables = [Variable(name, tags) for name, tags in args[3].items()]
return Forall(effect=args[-2], variables=variables)
if args[1] == Symbols.WHEN.value:
return When(args[2], args[3])
if args[1] == Symbols.ONEOF.value:
Expand Down
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
# "faults-ipc08",
# "first-responders-ipc08",
"islands",
"maintenance-sequential-satisficing-ipc2014",
"miner",
"rovers_fond",
"spiky-tireworld",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Maintenance (Sequential, Satisficing)

## Domain Description

This is a simple planning/scheduling problem.
There are mechanics/equipment that on any day may work at one of several airports (hubs), where the maintenance facilities are present.
There are airplanes, each of which has to be checked or repaired during the given time period.
The airplanes are guaranteed to visit some of the airports on given days.
The problem is to schedule the presence of the mechanics/equipment so that each plane will get maintenance once during the time period.

## Authors

Jussi Rintanen

## Original File Names

| file | original name |
|------------------|------------------------------------|
| domain.pddl | domain.pddl |
| instance-1.pddl | maintenance.1.3.060.180.5-000.pddl |
| instance-2.pddl | maintenance.1.3.060.180.5-001.pddl |
| instance-3.pddl | maintenance.1.3.060.180.5-002.pddl |
| instance-4.pddl | maintenance.1.3.100.300.5-000.pddl |
| instance-5.pddl | maintenance.1.3.100.300.5-001.pddl |
| instance-6.pddl | maintenance.1.3.100.300.7-000.pddl |
| instance-7.pddl | maintenance.1.3.100.300.7-001.pddl |
| instance-8.pddl | maintenance.1.3.100.300.7-002.pddl |
| instance-9.pddl | maintenance.1.3.150.500.6-001.pddl |
| instance-10.pddl | maintenance.1.3.200.500.5-001.pddl |
| instance-11.pddl | maintenance.1.3.200.500.5-002.pddl |
| instance-12.pddl | maintenance.1.3.200.700.7-000.pddl |
| instance-13.pddl | maintenance.1.3.200.700.7-001.pddl |
| instance-14.pddl | maintenance.1.3.200.700.7-002.pddl |
| instance-15.pddl | maintenance.1.3.200.900.5-000.pddl |
| instance-16.pddl | maintenance.1.3.200.900.5-001.pddl |
| instance-17.pddl | maintenance.1.3.200.900.5-002.pddl |
| instance-18.pddl | maintenance.1.3.200.900.8-000.pddl |
| instance-19.pddl | maintenance.1.3.200.900.8-001.pddl |
| instance-20.pddl | maintenance.1.3.200.900.8-002.pddl |
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
; There are mechanics who on any day may work at one
; of several cities where the airplane maintenance
; company has facilities. There are airplanes each of
; which has to be maintained during the given time period.
; The airplanes are guaranteed to visit some of the cities
; on given days. The problem is to schedule the presence
; of the mechanics so that each plane will get maintenance.

(define (domain maintenance-scheduling-domain)
(:requirements :adl :typing :conditional-effects)
(:types plane day airport)
(:predicates (done ?p - plane)
(today ?d - day)
(at ?p - plane ?d - day ?c - airport)
(next ?d - day ?d2 - day) )

(:action workat
:parameters (?day - day ?airport - airport)
:precondition (today ?day)
:effect (and
(not (today ?day))
(forall (?plane - plane) (when (at ?plane ?day ?airport) (done ?plane)))))

)
Loading

0 comments on commit b9091a9

Please sign in to comment.