-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the translator from PDDLSharp into this project
- Loading branch information
Showing
27 changed files
with
1,510 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
FlashPlanner.Tests/Translator/Components/ConditionalDeconstructorTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using FlashPlanner.Translator.Components; | ||
using PDDLSharp.Models.PDDL; | ||
using PDDLSharp.Models.PDDL.Domain; | ||
using PDDLSharp.Models.PDDL.Expressions; | ||
using PDDLSharp.Models.PDDL.Problem; | ||
using PDDLSharp.Translators.Grounders; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace PDDLSharp.Translators.Tests.Tools | ||
{ | ||
[TestClass] | ||
public class ConditionalDeconstructorTests | ||
{ | ||
public static IEnumerable<object[]> DeconstructWhen_Valid() | ||
{ | ||
yield return new object[] { | ||
new ActionDecl( | ||
"act", | ||
new ParameterExp(), | ||
new PredicateExp("a"), | ||
new WhenExp(new PredicateExp("b"), new PredicateExp("c")) | ||
), | ||
2 | ||
}; | ||
yield return new object[] { | ||
new ActionDecl( | ||
"act", | ||
new ParameterExp(), | ||
new PredicateExp("a"), | ||
new AndExp(new List<IExp>(){ | ||
new WhenExp(new PredicateExp("b"), new PredicateExp("c")), | ||
new WhenExp(new PredicateExp("d"), new PredicateExp("e")) | ||
}) | ||
), | ||
4 | ||
}; | ||
yield return new object[] { | ||
new ActionDecl( | ||
"act", | ||
new ParameterExp(), | ||
new PredicateExp("a"), | ||
new AndExp(new List<IExp>(){ | ||
new WhenExp(new PredicateExp("b"), new PredicateExp("c")), | ||
new WhenExp(new PredicateExp("d"), new PredicateExp("e")), | ||
new WhenExp(new PredicateExp("f"), new PredicateExp("g")) | ||
}) | ||
), | ||
8 | ||
}; | ||
} | ||
|
||
[TestMethod] | ||
[DynamicData(nameof(DeconstructWhen_Valid), DynamicDataSourceType.Method)] | ||
public void Can_DeconstructWhen(ActionDecl input, int expectedPermutations) | ||
{ | ||
// ARRANGE | ||
var deconstructor = new ConditionalDeconstructor(); | ||
|
||
// ACT | ||
var result = deconstructor.DecontructConditionals(input); | ||
|
||
// ASSERT | ||
Assert.AreEqual(expectedPermutations, result.Count); | ||
} | ||
} | ||
} |
102 changes: 102 additions & 0 deletions
102
FlashPlanner.Tests/Translator/Components/ExistsDeconstructorTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
using FlashPlanner.Translator.Components; | ||
using PDDLSharp.Models.PDDL; | ||
using PDDLSharp.Models.PDDL.Domain; | ||
using PDDLSharp.Models.PDDL.Expressions; | ||
using PDDLSharp.Models.PDDL.Problem; | ||
using PDDLSharp.Translators.Grounders; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace PDDLSharp.Translators.Tests.Tools | ||
{ | ||
[TestClass] | ||
public class ExistsDeconstructorTests | ||
{ | ||
public static IEnumerable<object[]> DeconstructExists_Valid() | ||
{ | ||
yield return new object[] { | ||
new AndExp(new List<IExp>(){ | ||
new ExistsExp( | ||
new ParameterExp(new List<NameExp>(){ new NameExp("?a") }), | ||
new PredicateExp("pred", new List<NameExp>(){ new NameExp("?a") })) | ||
}), | ||
new AndExp(new List<IExp>(){ | ||
new OrExp(new List<IExp>() | ||
{ | ||
new PredicateExp("pred", new List<NameExp>(){ new NameExp("obj1") }), | ||
new PredicateExp("pred", new List<NameExp>(){ new NameExp("obj2") }) | ||
}) | ||
}), | ||
new List<NameExp>(){ | ||
new NameExp("obj1"), | ||
new NameExp("obj2"), | ||
} | ||
}; | ||
|
||
yield return new object[] { | ||
new AndExp(new List<IExp>(){ | ||
new ExistsExp( | ||
new ParameterExp(new List<NameExp>(){ new NameExp("?a") }), | ||
new PredicateExp("pred", new List<NameExp>(){ new NameExp("?a") })) | ||
}), | ||
new AndExp(new List<IExp>(){ | ||
new OrExp(new List<IExp>() | ||
{ | ||
new PredicateExp("pred", new List<NameExp>(){ new NameExp("obj1") }), | ||
new PredicateExp("pred", new List<NameExp>(){ new NameExp("obj2") }), | ||
new PredicateExp("pred", new List<NameExp>(){ new NameExp("obj3") }), | ||
}) | ||
}), | ||
new List<NameExp>(){ | ||
new NameExp("obj1"), | ||
new NameExp("obj2"), | ||
new NameExp("obj3"), | ||
} | ||
}; | ||
|
||
yield return new object[] { | ||
new AndExp(new List<IExp>(){ | ||
new ExistsExp( | ||
new ParameterExp(new List<NameExp>(){ new NameExp("?a"), new NameExp("?b") }), | ||
new PredicateExp("pred", new List<NameExp>(){ new NameExp("?a"), new NameExp("?b") })) | ||
}), | ||
new AndExp(new List<IExp>(){ | ||
new OrExp(new List<IExp>() | ||
{ | ||
new PredicateExp("pred", new List<NameExp>(){ new NameExp("obj1"), new NameExp("obj1") }), | ||
new PredicateExp("pred", new List<NameExp>(){ new NameExp("obj1"), new NameExp("obj2") }), | ||
new PredicateExp("pred", new List<NameExp>(){ new NameExp("obj2"), new NameExp("obj1") }), | ||
new PredicateExp("pred", new List<NameExp>(){ new NameExp("obj2"), new NameExp("obj2") }), | ||
}) | ||
}), | ||
new List<NameExp>(){ | ||
new NameExp("obj1"), | ||
new NameExp("obj2"), | ||
} | ||
}; | ||
} | ||
|
||
[TestMethod] | ||
[DynamicData(nameof(DeconstructExists_Valid), DynamicDataSourceType.Method)] | ||
public void Can_DeconstructExists(INode input, INode expected, List<NameExp> objects) | ||
{ | ||
// ARRANGE | ||
(input as AndExp).Children[0].Parent = input; | ||
(expected as AndExp).Children[0].Parent = expected; | ||
var decl = new PDDLDecl(new DomainDecl(), new ProblemDecl()); | ||
decl.Problem.Objects = new ObjectsDecl(); | ||
decl.Problem.Objects.Objs = objects; | ||
var grounder = new ParametizedGrounder(decl); | ||
var deconstructor = new ExistsDeconstructor(grounder); | ||
|
||
// ACT | ||
var result = deconstructor.DeconstructExists(input); | ||
|
||
// ASSERT | ||
Assert.AreEqual(expected, result); | ||
} | ||
} | ||
} |
102 changes: 102 additions & 0 deletions
102
FlashPlanner.Tests/Translator/Components/ForAllDeconstructorTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
using FlashPlanner.Translator.Components; | ||
using PDDLSharp.Models.PDDL; | ||
using PDDLSharp.Models.PDDL.Domain; | ||
using PDDLSharp.Models.PDDL.Expressions; | ||
using PDDLSharp.Models.PDDL.Problem; | ||
using PDDLSharp.Translators.Grounders; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace PDDLSharp.Translators.Tests.Tools | ||
{ | ||
[TestClass] | ||
public class ForAllDeconstructorTests | ||
{ | ||
public static IEnumerable<object[]> DeconstrucForAllData_Valid() | ||
{ | ||
yield return new object[] { | ||
new AndExp(new List<IExp>(){ | ||
new ForAllExp( | ||
new ParameterExp(new List<NameExp>(){ new NameExp("?a") }), | ||
new PredicateExp("pred", new List<NameExp>(){ new NameExp("?a") })) | ||
}), | ||
new AndExp(new List<IExp>(){ | ||
new AndExp(new List<IExp>() | ||
{ | ||
new PredicateExp("pred", new List<NameExp>(){ new NameExp("obj1") }), | ||
new PredicateExp("pred", new List<NameExp>(){ new NameExp("obj2") }) | ||
}) | ||
}), | ||
new List<NameExp>(){ | ||
new NameExp("obj1"), | ||
new NameExp("obj2"), | ||
} | ||
}; | ||
|
||
yield return new object[] { | ||
new AndExp(new List<IExp>(){ | ||
new ForAllExp( | ||
new ParameterExp(new List<NameExp>(){ new NameExp("?a") }), | ||
new PredicateExp("pred", new List<NameExp>(){ new NameExp("?a") })) | ||
}), | ||
new AndExp(new List<IExp>(){ | ||
new AndExp(new List<IExp>() | ||
{ | ||
new PredicateExp("pred", new List<NameExp>(){ new NameExp("obj1") }), | ||
new PredicateExp("pred", new List<NameExp>(){ new NameExp("obj2") }), | ||
new PredicateExp("pred", new List<NameExp>(){ new NameExp("obj3") }), | ||
}) | ||
}), | ||
new List<NameExp>(){ | ||
new NameExp("obj1"), | ||
new NameExp("obj2"), | ||
new NameExp("obj3"), | ||
} | ||
}; | ||
|
||
yield return new object[] { | ||
new AndExp(new List<IExp>(){ | ||
new ForAllExp( | ||
new ParameterExp(new List<NameExp>(){ new NameExp("?a"), new NameExp("?b") }), | ||
new PredicateExp("pred", new List<NameExp>(){ new NameExp("?a"), new NameExp("?b") })) | ||
}), | ||
new AndExp(new List<IExp>(){ | ||
new AndExp(new List<IExp>() | ||
{ | ||
new PredicateExp("pred", new List<NameExp>(){ new NameExp("obj1"), new NameExp("obj1") }), | ||
new PredicateExp("pred", new List<NameExp>(){ new NameExp("obj1"), new NameExp("obj2") }), | ||
new PredicateExp("pred", new List<NameExp>(){ new NameExp("obj2"), new NameExp("obj1") }), | ||
new PredicateExp("pred", new List<NameExp>(){ new NameExp("obj2"), new NameExp("obj2") }), | ||
}) | ||
}), | ||
new List<NameExp>(){ | ||
new NameExp("obj1"), | ||
new NameExp("obj2"), | ||
} | ||
}; | ||
} | ||
|
||
[TestMethod] | ||
[DynamicData(nameof(DeconstrucForAllData_Valid), DynamicDataSourceType.Method)] | ||
public void Can_DeconstructForAll(INode input, INode expected, List<NameExp> objects) | ||
{ | ||
// ARRANGE | ||
(input as AndExp).Children[0].Parent = input; | ||
(expected as AndExp).Children[0].Parent = expected; | ||
var decl = new PDDLDecl(new DomainDecl(), new ProblemDecl()); | ||
decl.Problem.Objects = new ObjectsDecl(); | ||
decl.Problem.Objects.Objs = objects; | ||
var grounder = new ParametizedGrounder(decl); | ||
var deconstructor = new ForAllDeconstructor(grounder); | ||
|
||
// ACT | ||
var result = deconstructor.DeconstructForAlls(input); | ||
|
||
// ASSERT | ||
Assert.AreEqual(expected, result); | ||
} | ||
} | ||
} |
Oops, something went wrong.