From fa28600d159d148f530c06b2c0b9f20fe0793313 Mon Sep 17 00:00:00 2001 From: hfoffani Date: Wed, 19 Jan 2022 16:39:52 +0100 Subject: [PATCH 01/13] Ignoring files --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 5ba1cd0..cd45b69 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,6 @@ TestResult.xml *.zip pddlnet/output/ + +.python-version +*.pyc From 203f0229876785e39972fafba51b2c2001e757da Mon Sep 17 00:00:00 2001 From: hfoffani Date: Wed, 19 Jan 2022 16:40:41 +0100 Subject: [PATCH 02/13] Reapply patch by @Visgean --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 32cd5f5..796b2f9 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ This library publishes one object class whose API exposes methods for obtaining: This is enough for the user to focus on the implementation of state-space or plan-space search algorithms. -The development of this tool was inspired from Univerty of Edimburgh's Artificial Intelligence Planning course by Dr. Gerhard Wickler and Prof. Austin Tate. The terms used in this API (and the API itself) closely resembles the ones proposed by the lecturers. +The development of this tool was inspired from Univerty of Edinburgh's Artificial Intelligence Planning course by Dr. Gerhard Wickler and Prof. Austin Tate. The terms used in this API (and the API itself) closely resembles the ones proposed by the lecturers. As of today it supports Python 3 and .NET. While project name is `pddl-lib` to emphasize its language agnosticy each target library has its own name. For Python is `pddlpy`. For .NET the library is `pddlnet.dll`. From 121ced09a59f036d063089cda282450b1d03f8f8 Mon Sep 17 00:00:00 2001 From: hfoffani Date: Wed, 19 Jan 2022 16:58:10 +0100 Subject: [PATCH 03/13] Revert to working commit and drop .NET --- Makefile | 56 +-- pddlnet/pddl.cs | 926 ------------------------------------- pddlnet/pddlnet.dll.nuspec | 42 -- pddlnet/pddltest.cs | 121 ----- requirements.txt | 1 + setup.py | 10 +- 6 files changed, 9 insertions(+), 1147 deletions(-) delete mode 100644 pddlnet/pddl.cs delete mode 100644 pddlnet/pddlnet.dll.nuspec delete mode 100644 pddlnet/pddltest.cs create mode 100644 requirements.txt diff --git a/Makefile b/Makefile index ab29a6d..bc83985 100644 --- a/Makefile +++ b/Makefile @@ -1,37 +1,19 @@ -ANTLRDIR=/usr/local/opt/antlr -ANTLRLIB=$(ANTLRDIR)/antlr-4.7-complete.jar -ANTLR=$(ANTLRDIR)/bin/antlr4 + +ANTLRDIR=/usr/local/Cellar/antlr/4.9.3 +ANTLRLIB=$(ANTLRDIR)/antlr-4.9.3-complete.jar +ANTLR=$(ANTLRDIR)/bin/antlr GRUN=$(ANTLRDIR)/bin/grun -# For dotnet -NUNITVERSION=3.6.1 -ANTLRNET=Antlr4.Runtime.Standard -ANTLRDLL=Antlr4.Runtime.Standard.4.7.0/lib/net35/Antlr4.Runtime.Standard.dll -DLLSPATH=../pddlnet -CSANTLR=pddlListener.cs pddlBaseListener.cs pddlLexer.cs pddlParser.cs -NUNITLIB=NUnit.$(NUNITVERSION)/lib/net45/nunit.framework.dll -NUNITLITE=NUnitLite.$(NUNITVERSION)/lib/net45/nunitlite.dll -LIBSTEST=-reference:output/$(NUNITLIB),output/$(NUNITLITE),Microsoft.CSharp,pddlnet -MONOBIN=/Library/Frameworks/Mono.framework/Commands -NUGET=$(MONOBIN)/nuget -pyversion ?= 3 -ifeq ($(pyversion),3) -PIP=pip -PYTHON=python ANTLRLANG=-Dlanguage=Python3 -else -PIP=pip PYTHON=python -ANTLRLANG=-Dlanguage=Python2 -encoding utf8 -endif +PIP=pip export CLASSPATH:=.:$(ANTLRLIB) -all: testgrammar parsers +all: testgrammar pytest -parsers: pyparser csparser testgrammar: pddl.g4 mkdir -p tmp && \ @@ -40,7 +22,6 @@ testgrammar: pddl.g4 $(GRUN) pddl domain ../examples-pddl/domain-01.pddl && \ $(GRUN) pddl problem ../examples-pddl/problem-01.pddl - pyparser: pddl.g4 mkdir -p pddlpy && \ $(ANTLR) $(ANTLRLANG) -o pddlpy pddl.g4 @@ -66,28 +47,3 @@ pydemo: pydist $(PYTHON) demo.py 2 && \ $(PYTHON) demo.py 3 -csparser: pddl.g4 pddlnet/pddl.cs - mkdir -p pddlnet && \ - $(ANTLR) -Dlanguage=CSharp -package PDDLNET -o pddlnet pddl.g4 && \ - (cd pddlnet && \ - $(NUGET) install $(ANTLRNET) && \ - $(MONOBIN)/mcs -out:pddlnet.dll -reference:$(ANTLRDLL) -t:library pddl.cs $(CSANTLR)) - -cstest: csparser pddlnet/pddltest.cs - (cd pddlnet && \ - mkdir -p output && \ - $(NUGET) install NUnitLite -Verbosity quiet -OutputDirectory output && \ - $(MONOBIN)/mcs -d:NUNIT $(LIBSTEST) -out:output/pddlnettest.exe -reference:$(ANTLRDLL) -t:exe pddltest.cs && \ - cp pddlnet.dll $(ANTLRDLL) output/$(NUNITLIB) output/$(NUNITLITE) output && \ - cd output && \ - $(MONOBIN)/mono pddlnettest.exe ) - -csnuget: cstest - (cd pddlnet && \ - rm -f pddlnet.dll.*.nupkg && \ - $(NUGET) pack pddlnet.dll.nuspec ) - -csnugetpublish: csnuget - (cd pddlnet && \ - $(NUGET) push pddlnet.dll.*.nupkg ) - diff --git a/pddlnet/pddl.cs b/pddlnet/pddl.cs deleted file mode 100644 index f2d1920..0000000 --- a/pddlnet/pddl.cs +++ /dev/null @@ -1,926 +0,0 @@ - -/* - * Copyright 2015 Hernán M. Foffani - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -using System.Collections.Generic; -using System.IO; -using System.Linq; - -using Antlr4.Runtime; - -[assembly: System.CLSCompliant(true)] - -namespace PDDLNET { - -/// -/// Represents a strongly-typed, read-only collection of elements. -/// -/// The type of the elements. -/// This type parameter is covariant. That is, you can use either the -/// type you specified or any type that is more derived. -/// -/// IReadOnlyCollection is BUILTIN IN 4.5 -/// -public interface IROCollection : IEnumerable, System.Collections.IEnumerable { - /// - /// Gets the number of elements in the collection. - /// - int Count { get; } -} - - -class HashFunctions { - - static object sync = new object(); - static int[] aes = null; - static HashFunctions _provider = null; - - public int Universal(T[] x) { - if (x.Length == 0) - return 0; - var h = x[0].GetHashCode(); - var p = (1 << 61) - 1; - for (int i = 1; i < x.Length; i++) - h = ((h * aes[i % 100]) + x[i].GetHashCode()) % p; - return h; - } - - public static HashFunctions Provider { - get { - lock (sync) { - if (HashFunctions._provider == null) { - HashFunctions._provider = new HashFunctions(); - } - return HashFunctions._provider; - } - } - } - - private HashFunctions() { - if (aes == null) { - aes = new int[100]; - var rnd = new System.Random(); - for (int i = 0; i < 100; i++) { - aes[i] = 0; - do { - aes[i] = rnd.Next(); - } while (aes[i] == 0 || aes[i] % 2 == 0); - } - } - } - -} - -/// -/// Implements a strongly-typed, read-only collection of elements. -/// -/// The type of the elements. -/// This type parameter is covariant. That is, you can use either the -/// type you specified or any type that is more derived. -public class ROCollection : IROCollection { - - private T[] _internalArray = new T[0]; - int _hash = 0; - - /// - /// Constructor. - /// - public ROCollection() { } - - /// - /// Constructor and factory. - /// - /// The source of elements for this instance. - public ROCollection(IEnumerable collection) { - _internalArray = collection.ToArray(); - _hash = HashFunctions.Provider.Universal(_internalArray); - } - - /// - /// Gets the number of elements in the collection. - /// - public int Count { - get { return _internalArray.Length; } - } - - /// - /// Returns an enumerator that iterates through the collection. - /// - /// An enumerator that can be used to iterate through the collection. - public IEnumerator GetEnumerator() { - return _internalArray.AsEnumerable().GetEnumerator(); - } - - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { - return _internalArray.GetEnumerator(); - } - - /// - /// Determines whether the specified object is equal to the current object. - /// - /// The object to compare with the current object. - /// true if the specified object is equal to the current object; otherwise, false. - public bool Equals(ROCollection other) { - if ((object)other == null) - return false; - return this.GetHashCode() == other.GetHashCode(); - } - - /// - /// Serves as the default hash function. - /// - /// A hash code for the current object. - public override int GetHashCode() { - return _hash; - } - - /// - /// Determines whether the specified object is equal to the current object. - /// - /// The object to compare with the current object. - /// true if the specified object is equal to the current object; otherwise, false. - public override bool Equals(object obj) { - return this.Equals(obj as ROCollection); - } - - /// - /// Determines whether two objects are equal. - /// - /// The first object. - /// The second object - /// true if the both object are equal; otherwise, false. - public static bool operator ==(ROCollection a, ROCollection b) { - if (System.Object.ReferenceEquals(a, b)) { - return true; - } - // null,null have already been considered in the previous if. - if ((object)a == null) { - return false; - } - return a.Equals(b); - } - - /// - /// Determines whether two objects are different. - /// - /// The first object. - /// The second object - /// true if the both object are different; otherwise, false. - public static bool operator !=(ROCollection a, ROCollection b) { - return !(a == b); - } - - /// - /// Returns a string that represents the current object. - /// - /// A string that represents the current object. - public override string ToString() { - var s = new System.Text.StringBuilder(); - s.Append("("); - foreach (var it in this._internalArray) { - s.Append(it.ToString()); - s.Append(", "); - } - s.Append(")"); - return s.ToString(); - } -} - - -interface IScopeItem { -} - -internal class Scope : IScopeItem { - public List> atoms = new List>(); - public List> negatoms = new List>(); - - public void addatom(IList atompredicate) { - atoms.Add(new ROCollection(atompredicate)); - } - - public void addnegatom(IList atompredicate) { - negatoms.Add(new ROCollection(atompredicate)); - } -} - -internal class Obj : IScopeItem { - public Dictionary variable_list = new Dictionary(); -} - -public class Operator : IScopeItem { - public string operator_name = ""; - public HashSet> precondition_pos = null; - public HashSet> precondition_neg = null; - public HashSet> effect_pos = null; - public HashSet> effect_neg = null; - public Dictionary variable_list = new Dictionary(); - - public Operator(string name) { - this.operator_name = name; - } -} - -internal class DomainListener : pddlBaseListener { - internal Dictionary objects = new Dictionary(); - internal Dictionary operators = new Dictionary(); - Stack scopes = new Stack(); - Stack negativescopes = new Stack(); - bool typesdef = false; - - - public override void EnterActionDef(pddlParser.ActionDefContext ctx) { - /* - opname = ctx.actionSymbol().getText() - opvars = {} - self.scopes.append(Operator(opname)) - */ - var opname = ctx.actionSymbol().GetText(); - this.scopes.Push(new Operator(opname) ); - } - - public override void ExitActionDef(pddlParser.ActionDefContext ctx) { - /* - action = self.scopes.pop() - self.operators[action.operator_name] = action - */ - var action = (Operator)this.scopes.Pop(); - this.operators.Add(action.operator_name, action); - } - - public override void EnterPredicatesDef(pddlParser.PredicatesDefContext ctx) { - /* - self.scopes.append(Operator(None)) - */ - this.scopes.Push(new Operator( null) ); - } - - public override void ExitPredicatesDef(pddlParser.PredicatesDefContext ctx) { - /* - dummyop = self.scopes.pop() - */ - this.scopes.Pop(); - } - - public override void EnterTypesDef(pddlParser.TypesDefContext ctx) { - /* - self.scopes.append(Obj()) - */ - this.scopes.Push(new Obj() ); - } - - public override void ExitTypesDef(pddlParser.TypesDefContext ctx) { - /* - self.typesdef = True - self.scopes.pop() - */ - this.typesdef = true; - this.scopes.Pop(); - } - - public override void EnterTypedVariableList(pddlParser.TypedVariableListContext ctx) { - /* - # print("-> tvar") - for v in ctx.VARIABLE(): - vname = v.getText() - self.scopes[-1].variable_list[v.getText()] = None - for vs in ctx.singleTypeVarList(): - t = vs.r_type().getText() - for v in vs.VARIABLE(): - vname = v.getText() - self.scopes[-1].variable_list[vname] = t - */ - // System.Console.WriteLine("-> tvar"); - foreach (var v in ctx.VARIABLE()) { - var vname = v.GetText(); - var op = (Operator)this.scopes.Peek(); - op.variable_list.Add(vname, null); - } - foreach (var vs in ctx.singleTypeVarList()) { - var t = vs.r_type().GetText(); - foreach (var v in vs.VARIABLE()) { - var vname = v.GetText(); - var op = (Operator)this.scopes.Peek(); - op.variable_list.Add(vname, t); - } - } - } - - public override void EnterAtomicTermFormula(pddlParser.AtomicTermFormulaContext ctx) { - /* - # print("-> terf") - neg = self.negativescopes[-1] - pred = [] - for c in ctx.getChildren(): - n = c.getText() - if n == '(' or n == ')': - continue - pred.append(n) - scope = self.scopes[-1] - if not neg: - scope.addatom(Atom(pred)) - else: - scope.addnegatom(Atom(pred)) - - */ - // System.Console.WriteLine("-> terf"); - var neg = this.negativescopes.Peek(); - var pred = new List(); - for (int i = 0; i < ctx.ChildCount; i++) { - var c = ctx.GetChild(i); - var n = c.GetText(); - if (n == "(" || n == ")") - continue; - pred.Add(n); - } - var scope = (Scope) this.scopes.Peek(); - if (!neg) { - scope.addatom(pred); - } else { - scope.addnegatom(pred); - } - } - - public override void EnterPrecondition(pddlParser.PreconditionContext ctx) { - /* - self.scopes.append(Scope()) - */ - this.scopes.Push( new Scope()); - } - - public override void ExitPrecondition(pddlParser.PreconditionContext ctx) { - /* - scope = self.scopes.pop() - self.scopes[-1].precondition_pos = set( scope.atoms ) - self.scopes[-1].precondition_neg = set( scope.negatoms ) - */ - var scope = (Scope) this.scopes.Pop(); - var op = (Operator)this.scopes.Peek(); - op.precondition_pos = new HashSet>( scope.atoms ); - op.precondition_neg = new HashSet>( scope.negatoms ); - } - - public override void EnterEffect(pddlParser.EffectContext ctx) { - /* - self.scopes.append(Scope()) - */ - this.scopes.Push(new Scope()); - } - - public override void ExitEffect(pddlParser.EffectContext ctx) { - /* - scope = self.scopes.pop() - self.scopes[-1].effect_pos = set( scope.atoms ) - self.scopes[-1].effect_neg = set( scope.negatoms ) - */ - var scope = (Scope) this.scopes.Pop(); - var op = (Operator)this.scopes.Peek(); - op.effect_pos = new HashSet>( scope.atoms ); - op.effect_neg = new HashSet>( scope.negatoms ); - } - - public override void EnterGoalDesc(pddlParser.GoalDescContext ctx) { - /* - negscope = False - for c in ctx.getChildren(): - if c.getText() == 'not': - negscope = True - break - self.negativescopes.append(negscope) - */ - var negscope = false; - for (int i = 0; i < ctx.ChildCount; i++) { - var c = ctx.GetChild(i); - if (c.GetText() == "not") { - negscope = true; - break; - } - } - this.negativescopes.Push(negscope); - } - - public override void ExitGoalDesc(pddlParser.GoalDescContext ctx) { - /* - self.negativescopes.pop() - */ - this.negativescopes.Pop(); - } - - public override void EnterPEffect(pddlParser.PEffectContext ctx) { - /* - negscope = False - for c in ctx.getChildren(): - if c.getText() == 'not': - negscope = True - break - self.negativescopes.append(negscope) - */ - var negscope = false; - for (int i = 0; i < ctx.ChildCount; i++) { - var c = ctx.GetChild(i); - if (c.GetText() == "not") { - negscope = true; - break; - } - } - this.negativescopes.Push(negscope); - } - - public override void ExitPEffect(pddlParser.PEffectContext ctx) { - /* - self.negativescopes.pop() - */ - this.negativescopes.Pop(); - } - - public override void EnterTypedNameList(pddlParser.TypedNameListContext ctx) { - /* - # print("-> tnam") - for v in ctx.name(): - vname = v.getText() - self.scopes[-1].variable_list[v.getText()] = None - for vs in ctx.singleTypeNameList(): - t = vs.r_type().getText() - for v in vs.name(): - vname = v.getText() - self.scopes[-1].variable_list[vname] = t - */ - // System.Console.WriteLine("-> tnam"); - foreach (var v in ctx.name()) { - var vname = v.GetText(); - var op = (Operator)this.scopes.Peek(); - op.variable_list.Add(vname, null); - } - foreach (var vs in ctx.singleTypeNameList()) { - var t = vs.r_type().GetText(); - foreach (var v in vs.name()) { - var vname = v.GetText(); - var op = (Operator)this.scopes.Peek(); - op.variable_list.Add(vname, t); - } - } - } - - public override void EnterConstantsDef(pddlParser.ConstantsDefContext ctx) { - /* - self.scopes.append(Obj()) - */ - this.scopes.Push(new Obj()); - } - - public override void ExitConstantsDef(pddlParser.ConstantsDefContext ctx) { - /* - scope = self.scopes.pop() - self.objects = scope.variable_list - */ - var scope = (Obj)this.scopes.Pop(); - this.objects = scope.variable_list; - } - - public override void ExitDomain(pddlParser.DomainContext ctx) { - /* - if not self.objects and not self.typesdef: - vs = set() - for opn, oper in self.operators.items(): - alls = oper.precondition_pos | oper.precondition_neg | oper.effect_pos | oper. effect_neg - for a in alls: - for s in a.predicate: - if s[0] != '?': - vs.add( (s, None) ) - self.objects = dict( vs) - */ - if (this.objects.Count() == 0 && !this.typesdef) { - var vs = new HashSet(); - foreach (var opn in this.operators.Keys) { - var oper = (Operator)this.operators[opn]; - var alls = new HashSet>(); - alls.UnionWith(oper.precondition_pos); - alls.UnionWith(oper.precondition_neg); - alls.UnionWith(oper.effect_pos); - alls.UnionWith(oper.effect_neg); - foreach (ROCollection atom in alls) { - foreach (var vname in atom) { - if (!vname.StartsWith("?")) { - vs.Add(vname); - } - } - } - } - this.objects = vs.ToDictionary(h => h, h => (string)null); - } - } -} - -internal class ProblemListener : pddlBaseListener { - /* - self.objects = {} - self.initialstate = [] - self.goals = [] - self.scopes = [] - */ - internal Dictionary objects = new Dictionary(); - internal HashSet> initialstate = - new HashSet>(); - internal HashSet> goals = - new HashSet>(); - Stack scopes = new Stack(); - - public override void EnterInit(pddlParser.InitContext ctx) { - /* - self.scopes.append(Scope()) - */ - // System.Console.WriteLine("-> ini"); - this.scopes.Push(new Scope()); - } - - public override void ExitInit(pddlParser.InitContext ctx) { - /* - self.initialstate = set( self.scopes.pop().atoms ) - */ - // System.Console.WriteLine("<- ini"); - var scope = (Scope)this.scopes.Pop(); - this.initialstate = new HashSet>( scope.atoms); - } - - public override void EnterGoal(pddlParser.GoalContext ctx) { - /* - self.scopes.append(Scope()) - */ - // System.Console.WriteLine("-> goal"); - this.scopes.Push(new Scope()); - } - - public override void ExitGoal(pddlParser.GoalContext ctx) { - /* - self.goals = set( self.scopes.pop().atoms ) - */ - // System.Console.WriteLine("<- goal"); - var scope = (Scope)this.scopes.Pop(); - this.goals = new HashSet>( scope.atoms); - } - - public override void EnterAtomicNameFormula(pddlParser.AtomicNameFormulaContext ctx) { - /* - pred = [] - for c in ctx.getChildren(): - n = c.getText() - if n == '(' or n == ')': - continue - pred.append(n) - scope = self.scopes[-1] - scope.addatom(Atom(pred)) - */ - // System.Console.WriteLine("-> namf"); - var pred = new List(); - for (int i = 0; i < ctx.ChildCount; i++) { - var c = ctx.GetChild(i); - var n = c.GetText(); - if (n == "(" || n == ")") - continue; - pred.Add(n); - } - var scope = (Scope) this.scopes.Peek(); - scope.addatom(pred); - } - - public override void EnterAtomicTermFormula(pddlParser.AtomicTermFormulaContext ctx) { - /* - # with a NOT! - pred = [] - for c in ctx.getChildren(): - n = c.getText() - if n == '(' or n == ')': - continue - pred.append(n) - scope = self.scopes[-1] - scope.addatom(Atom(pred)) - */ - // System.Console.WriteLine("-> terf"); - var pred = new List(); - for (int i = 0; i < ctx.ChildCount; i++) { - var c = ctx.GetChild(i); - var n = c.GetText(); - if (n == "(" || n == ")") - continue; - pred.Add(n); - } - var scope = (Scope) this.scopes.Peek(); - scope.addatom(pred); - } - - public override void EnterTypedNameList(pddlParser.TypedNameListContext ctx) { - /* - for v in ctx.NAME(): - vname = v.getText() - self.scopes[-1].variable_list[v.getText()] = None - for vs in ctx.singleTypeNameList(): - t = vs.r_type().getText() - for v in vs.NAME(): - vname = v.getText() - self.scopes[-1].variable_list[vname] = t - */ - // System.Console.WriteLine("-> tnam"); - foreach (var v in ctx.name()) { - var vname = v.GetText(); - var op = (Operator)this.scopes.Peek(); - op.variable_list.Add(vname, null); - } - foreach (var vs in ctx.singleTypeNameList()) { - var t = vs.r_type().GetText(); - foreach (var v in vs.name()) { - var vname = v.GetText(); - var op = (Operator)this.scopes.Peek(); - op.variable_list.Add(vname, t); - } - } - } - - public override void EnterObjectDecl(pddlParser.ObjectDeclContext ctx) { - /* - self.scopes.append(Obj()) - */ - this.scopes.Push(new Obj()); - } - - public override void ExitObjectDecl(pddlParser.ObjectDeclContext ctx) { - /* - scope = self.scopes.pop() - self.objects = scope.variable_list - */ - var scope = (Obj)this.scopes.Pop(); - this.objects = scope.variable_list; - } - - public override void ExitProblem(pddlParser.ProblemContext ctx) { - /* - if not self.objects: - vs = set() - for a in self.initialstate: - for s in a.predicate: - vs.add( (s, None) ) - for a in self.goals: - for s in a.predicate: - vs.add( (s, None) ) - self.objects = dict( vs ) - */ - if (this.objects.Count() == 0) { - var vs = new HashSet(); - foreach (var a in this.initialstate) { - foreach (var s in a) { - vs.Add(s); - } - } - foreach (var a in this.goals) { - foreach (var s in a) { - vs.Add(s); - } - } - this.objects = vs.ToDictionary(h => h, h => (string)null); - } - } -} - -public class DomainProblem { - - private DomainListener domain; - private ProblemListener problem; - - public DomainProblem() { - } - - /// - /// Returns an iterator of the names of the actions defined in - /// the domain file. - /// - public IEnumerable operators { - get { return this.domain.operators.Keys; } - } - - /// - /// Returns a set of atoms (tuples of strings) corresponding to the intial - /// state defined in the problem file. - /// - public ISet> initialstate { - get { return this.problem.initialstate; } - } - - /// - /// Returns a set of atoms (tuples of strings) corresponding to the goals - /// defined in the problem file. - /// - public ISet> goals { - get { return this.problem.goals; } - } - - /// - /// Returns a dictionary of key value pairs where the key is the name of - /// an object and the value is it's type (None in case is untyped.) - /// - public IDictionary worldobjects { - get { - return this.domain.objects - .Concat(this.problem.objects - .Where(kvp => !this.domain.objects.ContainsKey(kvp.Key))) - .ToDictionary(kvp => kvp.Key, kvp => kvp.Value); - } - } - - /// - /// Constructor. - /// - public DomainProblem(string domainfile, string problemfile) : this() { - using (var domstream = new StreamReader(domainfile)) { - var inp = new Antlr4.Runtime.AntlrInputStream(domstream); - var lexer = new pddlLexer(inp); - var stream = new Antlr4.Runtime.CommonTokenStream(lexer); - var parser = new pddlParser(stream); - var tree = parser.domain(); - this.domain = new DomainListener(); - var walker = new Antlr4.Runtime.Tree.ParseTreeWalker(); - walker.Walk(this.domain, tree); - } - - using (var probstream = new StreamReader(problemfile)) { - var inp = new Antlr4.Runtime.AntlrInputStream(probstream); - var lexer = new pddlLexer(inp); - var stream = new Antlr4.Runtime.CommonTokenStream(lexer); - var parser = new pddlParser(stream); - var tree = parser.problem(); - this.problem = new ProblemListener(); - var walker = new Antlr4.Runtime.Tree.ParseTreeWalker(); - walker.Walk(this.problem, tree); - } - } - - /* - * ground - * - */ - - public Operator get_operator(string op_name) { - return (Operator) this.domain.operators[op_name]; - } - - public IEnumerable ground_operator(string op_name) { - var op = (Operator)this.domain.operators[op_name]; - set_operator_groundspace(op_name, op.variable_list); - foreach (var groundvars in this.instantiate(op_name)) { - var st = groundvars.ToDictionary(kvp=>kvp.Key, kvp=>kvp.Value); - var gop = new Operator(op_name); - gop.variable_list = st; - gop.precondition_pos = ground(op.precondition_pos, st); - gop.precondition_neg = ground(op.precondition_neg, st); - gop.effect_pos = ground(op.effect_pos, st); - gop.effect_neg = ground(op.effect_neg, st); - yield return gop; - } - } - - public string to_string(HashSet> set) { - var sb = new System.Text.StringBuilder(); - sb.Append("{ "); - foreach (var p in set) { - sb.Append(p.ToString()); - sb.Append("; "); - } - sb.Append("}"); - return sb.ToString(); - } - - private HashSet> ground( - HashSet> predvars, - Dictionary varvals) { - /* - * g = [ varvals[v] if v in varvals else v for v in self.predicate ] - * return tuple(g) - * set( [ a.ground( st ) for a in op.precondition_pos ] ) - * - */ - var r = new List>(); - foreach (var p in predvars) { - var l = new List(); - foreach (var v in p) { - l.Add( varvals.ContainsKey(v) ? varvals[v] : v); - } - var pg = new ROCollection(l); - r.Add( pg); - } - return new HashSet>(r); - } - - private IEnumerable typesymbols(string t) { - // return ( k for k,v in self.worldobjects().items() if v == t ) - return this.worldobjects - .Where(kvp => kvp.Value == t) - .Select(kvp => kvp.Key); - } - - Dictionary>> vargroundspace = - new Dictionary>>(); - - private void set_operator_groundspace(string opname, - IDictionary variables) { - /* - * def _set_operator_groundspace(self, opname, variables): - * # cache the variables ground space for each operator. - * if opname not in self.vargroundspace: - * d = self.vargroundspace.setdefault(opname, {}) - * for vname, t in variables: - * for symb in self._typesymbols(t): - * d.setdefault(vname, []).append(symb) - */ - if (!this.vargroundspace.ContainsKey(opname)) { - // this.vargroundspace.Add(opname, new Dictionary>()); - var d = this.vargroundspace[opname] = new Dictionary>(); - foreach (var kvp in variables) { - var varname = kvp.Key; - d[varname] = new List(); - foreach (var symb in this.typesymbols(kvp.Value)) { - d[varname].Add( symb); - } - } - } - } - - private IEnumerable>> instantiate(string opname) { - /* - * d = self.vargroundspace[opname] - * # expands the dict to something like: - * #[ [('?x1','A'),('?x1','B')..], [('?x2','M'),('?x2','N')..],..] - * expanded = [ [ (vname, symb) for symb in d[vname] ] for vname in d ] - * # cartesian product. - * return itertools.product(*expanded) - */ - //var expanded = List>>(); - var d = this.vargroundspace[opname]; - var expanded = new List>>(); - foreach (var vname in d.Keys) { - var p = new List>(); - foreach (var s in d[vname]) { - p.Add(new KeyValuePair(vname, s)); - } - expanded.Add(p); - } - var cp = CartesianProduct>( expanded); - return cp; - } - - - public static IEnumerable> CartesianProduct( - IEnumerable> inputs) { - - return inputs.Aggregate( - Return(Enumerable.Empty()), - (soFar, input) => - from prevProductItem in soFar - from item in input - select prevProductItem.Append(item)); - } - private static IEnumerable Return(T item) { - return new T[] { item }; - } - -/* - public static IEnumerable> CartesianProduct( - IEnumerable> inputs) { - - return inputs.Aggregate( - (IEnumerable>) new T[][] { new T[0] }, - (soFar, input) => - from prevProductItem in soFar - from item in input - select prevProductItem.Concat(new T[] { item })); - } - - public static IEnumerable> CartesianProduct( - params IEnumerable[] inputs) { - - IEnumerable> e = inputs; - return CartesianProduct(e); - } -*/ - -} - -static class AppendExtension { - public static IEnumerable Append(this IEnumerable that, T item) { - IEnumerable itemAsSequence = new T[] { item }; - return that.Concat(itemAsSequence); - } -} - -} - diff --git a/pddlnet/pddlnet.dll.nuspec b/pddlnet/pddlnet.dll.nuspec deleted file mode 100644 index 22414d3..0000000 --- a/pddlnet/pddlnet.dll.nuspec +++ /dev/null @@ -1,42 +0,0 @@ - - - - pddlnet.dll - 0.2.0 - Hernán Foffani - Hernán Foffani - http://www.apache.org/licenses/LICENSE-2.0 - https://github.com/hfoffani/pddl-lib - false - - This is a PDDL parser library using an ANTLR 4 grammar that provides a very simple interface to - interact with domain-problems. - - - This is a PDDL parser library using an ANTLR 4 grammar that provides a very simple interface to - interact with domain-problems. - This library publishes one object class whose API exposes methods for obtaining: - - * The initial state. - * The goals. - * The list of operators. - * The positive and negative preconditions and the positive and negative effects. - * The _grounded_ states of a given operator (grounded variables, preconditions and effects). - - This is enough for the user to focus on the implementation of state-space or plan-space search algorithms. - - See examples at the project site. - - - Better grounding mechanism. - - Copyright 2015-2017 - PDDL parser - - - - - - - - diff --git a/pddlnet/pddltest.cs b/pddlnet/pddltest.cs deleted file mode 100644 index b21dab7..0000000 --- a/pddlnet/pddltest.cs +++ /dev/null @@ -1,121 +0,0 @@ - -/* - * Copyright 2015 Hernán M. Foffani - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -using System; -using System.Collections.Generic; -using System.Linq; - -#if NUNIT -using TestClass = NUnit.Framework.TestFixtureAttribute; -using TestMethod = NUnit.Framework.TestAttribute; -using TestCleanup = NUnit.Framework.TearDownAttribute; -using TestInitialize = NUnit.Framework.SetUpAttribute; -using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute; -using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute; -using NUnit.Framework; -#else -using Microsoft.VisualStudio.TestTools.UnitTesting; -#endif - -using PDDLNET; - -namespace PDDLNETTEST { - -[TestClass] -public class TS_PDDLNET { - - [TestMethod] - public void UseCase_01() { - var d1 = "../../examples-pddl/domain-01.pddl"; - var p1 = "../../examples-pddl/problem-01.pddl"; - var pd = new PDDLNET.DomainProblem(d1, p1); - - Assert.IsNotNull(pd); - } - - [TestMethod] - public void UseCase_02() { - var d1 = "../../examples-pddl/domain-01.pddl"; - var p1 = "../../examples-pddl/problem-01.pddl"; - var pd = new PDDLNET.DomainProblem(d1, p1); - - Assert.IsNotNull(pd); - Assert.IsNotNull(pd.initialstate); - Assert.AreEqual(5, pd.initialstate.Count); - Assert.IsNotNull(pd.goals); - Assert.AreEqual(1, pd.goals.Count); - - Assert.IsNotNull(pd.worldobjects); - Assert.AreEqual(5, pd.worldobjects.Keys.Count); - - Assert.IsNotNull(pd.operators); - var ops = new List(pd.operators); - Assert.AreEqual(2, ops.Count); - Assert.IsTrue(ops.Contains("op1")); - Assert.IsTrue(ops.Contains("op2")); - } - - [TestMethod] - public void UseCase_03() { - var d1 = "../../examples-pddl/domain-01.pddl"; - var p1 = "../../examples-pddl/problem-01.pddl"; - var pd = new PDDLNET.DomainProblem(d1, p1); - - Assert.IsNotNull(pd); - var op1_grounds = pd.ground_operator("op1"); - Assert.IsNotNull(op1_grounds); - var lops = op1_grounds.ToList(); - Assert.AreEqual(125, lops.Count); - } - - [TestMethod] - public void TestGround() { - // look for set( [('S','R','C'),('S','R','S')] ) - var expect = new HashSet>(); - expect.Add(new PDDLNET.ROCollection(new string[] {"S","R","C"})); - expect.Add(new PDDLNET.ROCollection(new string[] {"S","R","S"})); - - var d1 = "../../examples-pddl/domain-01.pddl"; - var p1 = "../../examples-pddl/problem-01.pddl"; - var pd = new PDDLNET.DomainProblem(d1, p1); - - var op2_grounds = pd.ground_operator("op2"); - var lops = op2_grounds.ToList(); - foreach (var gop in lops) { - if (gop.precondition_pos.SetEquals( expect) ) { - return; - } - } - Assert.Fail("Expected value not in result"); - - } - - [TestInitialize()] - public void BeforeTest() { - System.Threading.SynchronizationContext.SetSynchronizationContext( - new System.Threading.SynchronizationContext()); - } - -public static int Main(string[] args) { - return new NUnitLite.AutoRun().Execute(args); -} - -} - -} - diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..7545404 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +antlr4-python3-runtime==4.9.3 diff --git a/setup.py b/setup.py index 91c227b..92a9692 100644 --- a/setup.py +++ b/setup.py @@ -61,13 +61,8 @@ # Specify the Python versions you support here. In particular, ensure # that you indicate whether you support Python 2, Python 3 or both. - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.6', - 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.2', - 'Programming Language :: Python :: 3.3', - 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.8', ], # What does your project relate to? @@ -82,8 +77,7 @@ # requirements files see: # https://packaging.python.org/en/latest/requirements.html install_requires=[ - 'antlr4-python2-runtime>=4.7,<4.8;python_version<"3"', - 'antlr4-python3-runtime>=4.7,<4.8;python_version>="3"', + 'antlr4-python3-runtime>=4.9;python_version>="3"', ], # List additional groups of dependencies here (e.g. development dependencies). From 62f2ab1d987124925ad99bfa943602b5efdf0ff1 Mon Sep 17 00:00:00 2001 From: hfoffani Date: Wed, 19 Jan 2022 17:06:10 +0100 Subject: [PATCH 04/13] Remove .NET from the docs --- README.md | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 796b2f9..9c78618 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ This is enough for the user to focus on the implementation of state-space or pla The development of this tool was inspired from Univerty of Edinburgh's Artificial Intelligence Planning course by Dr. Gerhard Wickler and Prof. Austin Tate. The terms used in this API (and the API itself) closely resembles the ones proposed by the lecturers. -As of today it supports Python 3 and .NET. While project name is `pddl-lib` to emphasize its language agnosticy each target library has its own name. For Python is `pddlpy`. For .NET the library is `pddlnet.dll`. +As of today it supports Python 3. The orginal grammar file was authored by Zeyn Saigol from University of Birmingham. I cleaned up it, made it language agnostic and upgraded to ANTLR 4. @@ -84,10 +84,6 @@ There are wonderful material at the the University of Edinburgh: * [Videos on YouTube](http://bit.ly/aiplanmooc) -### Using the PDDL .NET library ### - -The .NET library is available from nuget as `pddlnet.dll`. - ### Future development ### @@ -95,7 +91,6 @@ The .NET library is available from nuget as `pddlnet.dll`. * Add more examples (a simple planner maybe?). * Add API documentation. * More unit tests. -* Java version (it will be published in Java Central Repository). ### Adavanced ### @@ -106,14 +101,12 @@ In case you want to tweak the grammar, add other target languages or modify the * Install ANTLR version 4. I used `brew install antlr4` (a Mac). Your mileage may vary depending on your environment. -* Install Python 3 (it works with Python 2 too). +* Install Python 3 For this I also used brew. * Install antlr4 runtime. - `pip install antlr4-python3-runtime` (or `antlr4-python2-runtime` if building for Python 2) + `pip install antlr4-python3-runtime` * The package is built using wheel. `pip install wheel` -* mono development. -* Antlr4.Runtime.Standard.dll #### Building @@ -122,9 +115,6 @@ In case you want to tweak the grammar, add other target languages or modify the * Run `make` (it includes tests.) If you are using Python 2 you will need to call `make pyversion=2`. -To build the .NET library you must download the Antlr4.Runtime.Standard.dll from www.antlr4.org and -place it under the pddlnet directory. Currently it works with 4.7.0 - ### Contribution guidelines ### From 45d2d06f72177efb8c3d262e87b031fedc1b3a28 Mon Sep 17 00:00:00 2001 From: hfoffani Date: Wed, 19 Jan 2022 17:19:50 +0100 Subject: [PATCH 05/13] Test demos --- examples-python/demo.py => demo.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) rename examples-python/demo.py => demo.py (87%) diff --git a/examples-python/demo.py b/demo.py similarity index 87% rename from examples-python/demo.py rename to demo.py index af05878..d29ff7d 100644 --- a/examples-python/demo.py +++ b/demo.py @@ -17,13 +17,13 @@ # import sys -from pddlpy import DomainProblem +import pddlpy def main(argv): demonumber = int(argv[1]) - domainfile = "../examples-pddl/domain-0%d.pddl" % demonumber - problemfile = "../examples-pddl/problem-0%d.pddl" % demonumber - domprob = DomainProblem(domainfile, problemfile) + domainfile = "./examples-pddl/domain-0%d.pddl" % demonumber + problemfile = "./examples-pddl/problem-0%d.pddl" % demonumber + domprob = pddlpy.DomainProblem(domainfile, problemfile) print() print("DOMAIN PROBLEM") print("objects") From 72a6961b2768033517170371be2d99cd75ca5edd Mon Sep 17 00:00:00 2001 From: hfoffani Date: Wed, 19 Jan 2022 17:27:54 +0100 Subject: [PATCH 06/13] Fix in this branch will go to 0.3.0 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 92a9692..b44db1f 100644 --- a/setup.py +++ b/setup.py @@ -29,7 +29,7 @@ # Versions should comply with PEP440. For a discussion on single-sourcing # the version across setup.py and the project code, see # https://packaging.python.org/en/latest/single_source_version.html - version='0.2.0', + version='0.3.0', description='Python PDDL parser', long_description=long_description, From 06283678826af9a9d56b3af08f4d8431fa4d0988 Mon Sep 17 00:00:00 2001 From: hfoffani Date: Wed, 19 Jan 2022 17:33:31 +0100 Subject: [PATCH 07/13] Add setuptools to requirements.txt --- requirements.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/requirements.txt b/requirements.txt index 7545404..704eb80 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,4 @@ antlr4-python3-runtime==4.9.3 +pip==19.2.3 +setuptools==41.2.0 +wheel==0.37.1 From 76f4df2b8f30266b69badc375313be085bc3a0df Mon Sep 17 00:00:00 2001 From: hfoffani Date: Wed, 19 Jan 2022 17:42:53 +0100 Subject: [PATCH 08/13] Updating setup to pypi --- Makefile | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index bc83985..b2e5f8a 100644 --- a/Makefile +++ b/Makefile @@ -30,19 +30,19 @@ pytest: pyparser pddlpy/pddl.py $(PYTHON) -m pddlpy.test pydist: pytest - $(PYTHON) setup.py bdist_wheel - $(PIP) install -e . + $(PYTHON) setup.py sdist bdist_wheel pypitest: pydist - $(PYTHON) setup.py register -r pypitest && \ - $(PYTHON) setup.py bdist_wheel upload -r pypitest + echo hello + # $(PYTHON) setup.py register -r pypitest && \ + # $(PYTHON) setup.py bdist_wheel upload -r pypitest pypipublish: pydist - $(PYTHON) setup.py register -r pypi && \ - $(PYTHON) setup.py bdist_wheel upload -r pypi + echo hello + # $(PYTHON) setup.py register -r pypi && \ + # $(PYTHON) setup.py bdist_wheel upload -r pypi -pydemo: pydist - cd examples-python && \ +pydemo: pytest $(PYTHON) demo.py 1 && \ $(PYTHON) demo.py 2 && \ $(PYTHON) demo.py 3 From 1e94eb454aaec30475035e614b9e76f4f4777c7e Mon Sep 17 00:00:00 2001 From: hfoffani Date: Wed, 19 Jan 2022 19:40:04 +0100 Subject: [PATCH 09/13] Demo with cli args and help message --- demo.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/demo.py b/demo.py index d29ff7d..f15f436 100644 --- a/demo.py +++ b/demo.py @@ -18,9 +18,15 @@ import sys import pddlpy +import argparse -def main(argv): - demonumber = int(argv[1]) +parser = argparse.ArgumentParser(description='Demo PDDLPY.') +parser.add_argument('demonumber', metavar='N', type=int, nargs='+', + help='the number(s) of the demo') + +def run_demo(demonumber): + print('===') + print(f'Run DEMO {demonumber}') domainfile = "./examples-pddl/domain-0%d.pddl" % demonumber problemfile = "./examples-pddl/problem-0%d.pddl" % demonumber domprob = pddlpy.DomainProblem(domainfile, problemfile) @@ -47,8 +53,10 @@ def main(argv): print( "\tpre-", o.precondition_neg ) print( "\teff+", o.effect_pos ) print( "\teff-", o.effect_neg ) + print() if __name__ == '__main__': - main(sys.argv) - + args = parser.parse_args() + for n in args.demonumber: + run_demo(n) From e8e6b6250b2d4f3029ea9ecd333f1b02916131eb Mon Sep 17 00:00:00 2001 From: hfoffani Date: Wed, 19 Jan 2022 20:26:28 +0100 Subject: [PATCH 10/13] Adding twine --- requirements.txt | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/requirements.txt b/requirements.txt index 704eb80..6a1d489 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,26 @@ antlr4-python3-runtime==4.9.3 +bleach==4.1.0 +certifi==2021.10.8 +charset-normalizer==2.0.10 +colorama==0.4.4 +docutils==0.18.1 +idna==3.3 +importlib-metadata==4.10.1 +keyring==23.5.0 +packaging==21.3 pip==19.2.3 +pkginfo==1.8.2 +Pygments==2.11.2 +pyparsing==3.0.6 +readme-renderer==32.0 +requests==2.27.1 +requests-toolbelt==0.9.1 +rfc3986==2.0.0 setuptools==41.2.0 +six==1.16.0 +tqdm==4.62.3 +twine==3.7.1 +urllib3==1.26.8 +webencodings==0.5.1 wheel==0.37.1 +zipp==3.7.0 From e9dacb642c4faf03f6330362f0144b8dcd3f89d0 Mon Sep 17 00:00:00 2001 From: hfoffani Date: Wed, 19 Jan 2022 21:09:10 +0100 Subject: [PATCH 11/13] New install with twin and new pypi --- Makefile | 10 +++------- setup.py | 6 +++--- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index b2e5f8a..c03893b 100644 --- a/Makefile +++ b/Makefile @@ -30,17 +30,13 @@ pytest: pyparser pddlpy/pddl.py $(PYTHON) -m pddlpy.test pydist: pytest - $(PYTHON) setup.py sdist bdist_wheel + $(PYTHON) setup.py bdist_wheel pypitest: pydist - echo hello - # $(PYTHON) setup.py register -r pypitest && \ - # $(PYTHON) setup.py bdist_wheel upload -r pypitest + $(PYTHON) -m twine upload --repository testpypi dist/`ls -t dist | head -1` pypipublish: pydist - echo hello - # $(PYTHON) setup.py register -r pypi && \ - # $(PYTHON) setup.py bdist_wheel upload -r pypi + $(PYTHON) -m twine upload dist/`ls -t dist | head -1` pydemo: pytest $(PYTHON) demo.py 1 && \ diff --git a/setup.py b/setup.py index b44db1f..547fd4f 100644 --- a/setup.py +++ b/setup.py @@ -29,7 +29,7 @@ # Versions should comply with PEP440. For a discussion on single-sourcing # the version across setup.py and the project code, see # https://packaging.python.org/en/latest/single_source_version.html - version='0.3.0', + version='0.3.2', description='Python PDDL parser', long_description=long_description, @@ -77,8 +77,8 @@ # requirements files see: # https://packaging.python.org/en/latest/requirements.html install_requires=[ - 'antlr4-python3-runtime>=4.9;python_version>="3"', - ], + 'antlr4-python3-runtime>=4.9.3', + ], # List additional groups of dependencies here (e.g. development dependencies). # You can install these using the following syntax, for example: From 48066902b6c68a5df65c2ad38aef9de07fbf9fe7 Mon Sep 17 00:00:00 2001 From: hfoffani Date: Thu, 20 Jan 2022 12:13:21 +0100 Subject: [PATCH 12/13] Update doc --- README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 9c78618..7472dbc 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ This is enough for the user to focus on the implementation of state-space or pla The development of this tool was inspired from Univerty of Edinburgh's Artificial Intelligence Planning course by Dr. Gerhard Wickler and Prof. Austin Tate. The terms used in this API (and the API itself) closely resembles the ones proposed by the lecturers. -As of today it supports Python 3. +As of today it supports Python 3.8 and up. The orginal grammar file was authored by Zeyn Saigol from University of Birmingham. I cleaned up it, made it language agnostic and upgraded to ANTLR 4. @@ -49,29 +49,29 @@ Using the library is easy. ``` ~hernan$ python -Python 3.4.3 (default, Feb 25 2015, 21:28:45) -[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)] on darwin +Python 3.8.0 (default, Nov 20 2019, 14:40:03) +[Clang 11.0.0 (clang-1100.0.33.12)] on darwin Type "help", "copyright", "credits" or "license" for more information. ->>> +>>> >>> import pddlpy >>> domprob = pddlpy.DomainProblem('domain-03.pddl', 'problem-03.pddl') >>> >>> domprob.initialstate() -{('adjacent', 'loc2', 'loc1'), ('unloaded', 'robr'), ('atl', 'robr', 'loc1'), ('unloaded', 'robq'), ('in', 'conta', 'loc1'), ('atl', 'robq', 'loc2'), ('adjacent', 'loc1', 'loc2'), ('in', 'contb', 'loc2')} +{('unloaded', 'robr'), ('adjacent', 'loc2', 'loc1'), ('unloaded', 'robq'), ('in', 'conta', 'loc1'), ('in', 'contb', 'loc2'), ('atl', 'robr', 'loc1'), ('atl', 'robq', 'loc2'), ('adjacent', 'loc1', 'loc2')} >>> >>> list( domprob.operators() ) -['load', 'unload', 'move'] +['move', 'load', 'unload'] >>> >>> list( domprob.ground_operator('move') ) -[, , , , , , , ] +[, , , , , , , ] >>> >>> list( domprob.ground_operator('move') )[0].precondition_pos -{('atl', 'robq', 'loc1'), ('adjacent', 'loc1', 'loc1')} ->>> +{('atl', 'robq', 'loc2'), ('adjacent', 'loc2', 'loc2')} +>>> ``` The pddl files are examples obtained from the course material. @@ -88,7 +88,7 @@ There are wonderful material at the the University of Edinburgh: ### Future development ### * Implement the `:requirements` directive. -* Add more examples (a simple planner maybe?). +* Add more examples (time durataion, a simple planner maybe?). * Add API documentation. * More unit tests. From ad4eaa454a728f10f0a752ef725b1d78a1bf1954 Mon Sep 17 00:00:00 2001 From: hfoffani Date: Thu, 20 Jan 2022 12:16:15 +0100 Subject: [PATCH 13/13] Publish 0.3.3 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 547fd4f..c9679cf 100644 --- a/setup.py +++ b/setup.py @@ -29,7 +29,7 @@ # Versions should comply with PEP440. For a discussion on single-sourcing # the version across setup.py and the project code, see # https://packaging.python.org/en/latest/single_source_version.html - version='0.3.2', + version='0.3.3', description='Python PDDL parser', long_description=long_description,