Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addition of Multi-Agent PDDL to ANTLR v4 #4034

Open
wants to merge 33 commits into
base: master
Choose a base branch
from
Open

Conversation

refracc
Copy link

@refracc refracc commented Mar 29, 2024

Still parses standard PDDL files, as well as new MA-PDDL files (which are almost up to the full specification of Kovacs, 2012).

pddl/Pddl.g4 Outdated
: (domain | problem) EOF
;

pddlDoc : domain | problem;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All Antlr4 grammars need an EOF-terminated start rule. Add EOF back in so the tester can find the rule.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@kaby76
Copy link
Contributor

kaby76 commented Mar 29, 2024

There is not a single test file for this grammar. I went to http://www.plg.inf.uc3m.es/ipc2011-deterministic/Resources , downloaded the .bz2 file (http://www.plg.inf.uc3m.es/ipc2011-deterministic/attachments/Resources/ipc2008-no-cybersec.tar.bz2), extracted the demos, and tried every single .pddl file. Some parsed (about 30 files in seq-opt/pegsol-strips/p[0-9][0-9].pddl) but most did not.

It's time to try to get this grammar up to a basic level of usability that people expect. Currently, I'm not sure how usable it is.

pddl/Pddl.g4 Outdated
// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false
// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging
// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false
// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why these formatting rules were changed. Please go to https://github.com/mike-lischke/antlr-format/blob/main/cli/ReadMe.md and install the antlr-formatter. Then, reformat this grammar antlr-format *.g4.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The formatting rules weren't changed - they just moved down ~15 lines?

Apologies for not formatting, I've now formatted the file.

@kaby76
Copy link
Contributor

kaby76 commented Mar 29, 2024

If it's not a problem, could you "fast forward" the branch for this PR with the current "master" branch in https://github.com/antlr/grammars-v4.git ?? It'll help me see how my new "perf" scripts handle your PR. Thanks!

@refracc
Copy link
Author

refracc commented Apr 3, 2024

There is not a single test file for this grammar. I went to http://www.plg.inf.uc3m.es/ipc2011-deterministic/Resources , downloaded the .bz2 file (http://www.plg.inf.uc3m.es/ipc2011-deterministic/attachments/Resources/ipc2008-no-cybersec.tar.bz2), extracted the demos, and tried every single .pddl file. Some parsed (about 30 files in seq-opt/pegsol-strips/p[0-9][0-9].pddl) but most did not.

It's time to try to get this grammar up to a basic level of usability that people expect. Currently, I'm not sure how usable it is.

Considering that there were no prior instances provided alongside the PDDL parser or its application to domains (i.e., their specification), I am perplexed as to why - particularly in light of the lack of examples initially presented in the folder - this seems to have become an apparent issue. Could you kindly clarify why the previous author was not prompted to include examples, or why none were included here initially?

I have taken the liberty of incorporating examples of the contrived "single-agent" problems, along with the contrived "multi-agent" domains that this file can parse, and they do align with some aspects of the Kovacs implementation. As articulated in my comment within the parser file itself, further refinement is necessary to bring it up to par with this standard. Nevertheless, this should serve as a commendable starting point towards achieving that objective.

Furthermore, the branch has been fast-forwarded to accommodate your new scripts.

@refracc refracc requested a review from kaby76 April 3, 2024 15:49
@kaby76
Copy link
Contributor

kaby76 commented Apr 3, 2024

Could you kindly clarify why the previous author was not prompted to include examples, or why none were included here initially?

@teverett added the grammar 9 years ago, probably as a task of translating the grammar from Antlr3 into Antlr4. But, he didn't have any sample input. I added the desc.xml last year in order to support testing of all targets, but again, I punted on finding any tests because I really don't have expertise in the language.

Nevertheless, this should serve as a commendable starting point towards achieving that objective.

Ty, Ty, Ty!!

;

objectDeclaration
: objectName '-' objectType
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change to objectName+. See http://www.plg.inf.uc3m.es/ipc2011-deterministic/attachments/Resources/kovacs-pddl-3.1-2011.pdf , specifically the rule <function typed list (x)> ::= x+ - <function type> <function typed list(x)>. Notice the "+" for "x", where it is used in rule <object declaration> ::= (:objects <typed list (name)>). Some of the tests don't parse without this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A single character escaped me - apologies. Resolved!

@kaby76
Copy link
Contributor

kaby76 commented Apr 5, 2024

Please change desc.xml to this so we can test both grammars.

<?xml version="1.0" encoding="UTF-8" ?>
<desc xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../_scripts/desc.xsd">
   <targets>CSharp;Dart;Go;Java;JavaScript;PHP;Python3;TypeScript;Antlr4ng</targets>
   <test>
      <name>multi</name>
      <grammar-files>MultiAgentPDDL.g4</grammar-files>
      <inputs>multi-agent-examples/**/*.pddl</inputs>
   </test>
   <test>
      <name>single</name>
      <grammar-files>SingleAgentPDDL.g4</grammar-files>
      <inputs>single-agent-examples/**/*.pddl</inputs>
   </test>
</desc>

@refracc
Copy link
Author

refracc commented Apr 5, 2024

Please change desc.xml to this so we can test both grammars.

<?xml version="1.0" encoding="UTF-8" ?>
<desc xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../_scripts/desc.xsd">
   <targets>CSharp;Dart;Go;Java;JavaScript;PHP;Python3;TypeScript;Antlr4ng</targets>
   <test>
      <name>multi</name>
      <grammar-files>MultiAgentPDDL.g4</grammar-files>
      <inputs>multi-agent-examples/**/*.pddl</inputs>
   </test>
   <test>
      <name>single</name>
      <grammar-files>SingleAgentPDDL.g4</grammar-files>
      <inputs>single-agent-examples/**/*.pddl</inputs>
   </test>
</desc>

All files should now parse under the one grammar file. See my latest commit. I've updated the test in desc.xml to reflect that.

@kaby76
Copy link
Contributor

kaby76 commented Apr 5, 2024

Yes, better.

Looks like still a few problems.

$ trgen -t CSharp
C:\msys64\home\Kenne\issues\g4-4034\g4-4034\pddl
CSharp  Pddl.g4 success 0.0484755
Rendering template file from CSharp/Other.csproj to ./Generated-CSharp-Pddl/Other.csproj
Rendering template file from CSharp/st.build.ps1 to ./Generated-CSharp-Pddl/st.build.ps1
Rendering template file from CSharp/st.build.sh to ./Generated-CSharp-Pddl/st.build.sh
Rendering template file from CSharp/st.clean.ps1 to ./Generated-CSharp-Pddl/st.clean.ps1
Rendering template file from CSharp/st.clean.sh to ./Generated-CSharp-Pddl/st.clean.sh
Rendering template file from CSharp/st.Encodings.cs to ./Generated-CSharp-Pddl/st.Encodings.cs
Rendering template file from CSharp/st.ErrorListener.cs to ./Generated-CSharp-Pddl/st.ErrorListener.cs
Rendering template file from CSharp/st.makefile to ./Generated-CSharp-Pddl/st.makefile
Rendering template file from CSharp/st.perf.sh to ./Generated-CSharp-Pddl/st.perf.sh
Rendering template file from CSharp/st.run.ps1 to ./Generated-CSharp-Pddl/st.run.ps1
Rendering template file from CSharp/st.run.sh to ./Generated-CSharp-Pddl/st.run.sh
Rendering template file from CSharp/st.test-cover.sh to ./Generated-CSharp-Pddl/st.test-cover.sh
Rendering template file from CSharp/st.Test.cs to ./Generated-CSharp-Pddl/st.Test.cs
Rendering template file from CSharp/st.test.ps1 to ./Generated-CSharp-Pddl/st.test.ps1
Rendering template file from CSharp/st.test.sh to ./Generated-CSharp-Pddl/st.test.sh
Rendering template file from CSharp/Test.csproj.st to ./Generated-CSharp-Pddl/Test.csproj.st
Copying source file from C:/msys64/home/Kenne/issues/g4-4034/g4-4034/pddl/README.md to ./Generated-CSharp-Pddl/README.md
Copying source file from C:/msys64/home/Kenne/issues/g4-4034/g4-4034/pddl/Pddl.g4 to ./Generated-CSharp-Pddl/Pddl.g4
Copying source file from C:/msys64/home/Kenne/issues/g4-4034/g4-4034/pddl/desc.xml to ./Generated-CSharp-Pddl/desc.xml
04/05-09:11:42 ~/issues/g4-4034/g4-4034/pddl
$ make
mingw32-make: *** No targets specified and no makefile found.  Stop.
04/05-09:11:43 ~/issues/g4-4034/g4-4034/pddl
$ cd Generated-CSharp-Pddl/
04/05-09:11:46 ~/issues/g4-4034/g4-4034/pddl/Generated-CSharp-Pddl
$ make
bash build.sh
  Determining projects to restore...
  Restored C:\msys64\home\Kenne\issues\g4-4034\g4-4034\pddl\Generated-CSharp-Pddl\Test.csproj (in 337 ms).
MSBuild version 17.9.4+90725d08d for .NET
  Determining projects to restore...
  All projects are up-to-date for restore.
  Test -> C:\msys64\home\Kenne\issues\g4-4034\g4-4034\pddl\Generated-CSharp-Pddl\bin\Debug\net8.0\Test.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:04.60
04/05-09:11:53 ~/issues/g4-4034/g4-4034/pddl/Generated-CSharp-Pddl
$ make test
bash test.sh
New errors in output.
examples/multi-agent/wireless/domain.pddl.errors
line 74:15 mismatched input '?sender' expecting {'(', 'at', 'over', NAME, NUMBER}
examples/single-agent/barman-sequential-satisficing/domain.pddl.errors
line 2:33 extraneous input ':action' expecting {')', REQUIRE_KEY}
examples/single-agent/depots-strips-hand-coded/instance-1.pddl.errors
line 28:15 extraneous input '-' expecting {')', 'at', 'over', NAME}
line 30:1 no viable alternative at input '(:predicates'
line 31:14 mismatched input 'on' expecting ':goal'
line 32:13 mismatched input '(' expecting <EOF>
examples/single-agent/openstacks-temporal-satisficing-adl-numeric-fluents/domain.pddl.errors
line 2:46 token recognition error at: ':nu'
line 2:49 extraneous input 'meric-fluents' expecting {')', REQUIRE_KEY}
examples/single-agent/openstacks-temporal-satisficing-adl-numeric-fluents/instance-1.pddl.errors
line 41:19 no viable alternative at input '(total-time'
line 43:0 extraneous input ')' expecting <EOF>
examples/single-agent/openstacks-temporal-satisficing-adl-numeric-fluents/instance-10.pddl.errors
line 77:19 no viable alternative at input '(total-time'
line 79:0 extraneous input ')' expecting <EOF>
examples/single-agent/openstacks-temporal-satisficing-adl-numeric-fluents/instance-20.pddl.errors
line 117:19 no viable alternative at input '(total-time'
line 119:0 extraneous input ')' expecting <EOF>
examples/single-agent/openstacks-temporal-satisficing-adl-numeric-fluents/instance-30.pddl.errors
line 157:19 no viable alternative at input '(total-time'
line 159:0 extraneous input ')' expecting <EOF>
examples/single-agent/road-traffic-accident-management-temporal-satisficing/instance-1.pddl.errors
line 395:19 no viable alternative at input '(total-time'
line 396:0 extraneous input ')' expecting <EOF>
examples/single-agent/road-traffic-accident-management-temporal-satisficing/instance-10.pddl.errors
line 446:19 no viable alternative at input '(total-time'
line 447:0 extraneous input ')' expecting <EOF>
examples/single-agent/road-traffic-accident-management-temporal-satisficing/instance-20.pddl.errors
line 697:19 no viable alternative at input '(total-time'
line 698:0 extraneous input ')' expecting <EOF>
examples/single-agent/sokoban-temporal-satisficing/instance-1.pddl.errors
line 344:21 no viable alternative at input '(total-time'
line 345:0 extraneous input ')' expecting <EOF>
examples/single-agent/sokoban-temporal-satisficing/instance-10.pddl.errors
line 383:21 no viable alternative at input '(total-time'
line 384:0 extraneous input ')' expecting <EOF>
examples/single-agent/sokoban-temporal-satisficing/instance-20.pddl.errors
line 375:21 no viable alternative at input '(total-time'
line 376:0 extraneous input ')' expecting <EOF>
examples/single-agent/transport-sequential-satisficing/domain.pddl.errors
line 5:25 extraneous input ':action' expecting {')', REQUIRE_KEY}
examples/single-agent/trucks-preferences-simple/instance-1.pddl.errors
line 66:2 no viable alternative at input '(preference'
line 68:1 missing ')' at '('
examples/single-agent/trucks-preferences-simple/instance-10.pddl.errors
line 410:2 no viable alternative at input '(preference'
line 412:1 missing ')' at '('
examples/single-agent/trucks-preferences-simple/instance-20.pddl.errors
line 993:2 no viable alternative at input '(preference'
line 994:1 missing ')' at '('
Test failed.
mingw32-make: *** [makefile:8: test] Error 1
04/05-09:12:11 ~/issues/g4-4034/g4-4034/pddl/Generated-CSharp-Pddl
$

@teverett teverett added the pddl label Apr 5, 2024
@refracc refracc requested a review from kaby76 April 30, 2024 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants