-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new test and fixed a number of upcoming issues
- Loading branch information
Enrico Scala
authored and
Enrico Scala
committed
Nov 4, 2024
1 parent
b7f61f0
commit 0d6b4de
Showing
9 changed files
with
98 additions
and
48 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,43 @@ | ||
from unified_planning.shortcuts import * | ||
from unified_planning.model.action import Process | ||
|
||
|
||
on = Fluent("on") | ||
d = Fluent("d", RealType()) | ||
|
||
a = InstantaneousAction("turn_on") | ||
a.add_precondition(Not(on)) | ||
a.add_effect(on, True) | ||
|
||
evt = Event("turn_off_automatically") | ||
evt.add_precondition(GE(d, 200)) | ||
evt.add_effect(on, False) | ||
|
||
b = Process("moving") | ||
b.add_precondition(on) | ||
b.add_derivative(d, 1) | ||
|
||
problem = Problem("1D Movement") | ||
problem.add_fluent(on) | ||
problem.add_fluent(d) | ||
problem.add_action(a) | ||
problem.add_action(b) | ||
problem.add_action(evt) | ||
problem.set_initial_value(on, False) | ||
problem.set_initial_value(d, 0) | ||
problem.add_goal(GE(d, 10)) | ||
|
||
z = Fluent("z", BoolType()) | ||
pr = Process("Name") | ||
pr.add_precondition(z) | ||
|
||
with OneshotPlanner(problem_kind=problem.kind) as planner: | ||
result = planner.solve(problem) | ||
if result.status in unified_planning.engines.results.POSITIVE_OUTCOMES: | ||
print(f"{planner.name} found this plan: {result.plan}") | ||
else: | ||
print("No plan found.") | ||
from unified_planning.test import TestCase | ||
|
||
|
||
def get_example_problems(): | ||
problems = {} | ||
on = Fluent("on") | ||
d = Fluent("d", RealType()) | ||
|
||
a = InstantaneousAction("turn_on") | ||
a.add_precondition(Not(on)) | ||
a.add_effect(on, True) | ||
|
||
evt = Event("turn_off_automatically") | ||
evt.add_precondition(GE(d, 200)) | ||
evt.add_effect(on, False) | ||
|
||
b = Process("moving") | ||
b.add_precondition(on) | ||
b.add_derivative(d, 1) | ||
|
||
problem = Problem("1d_Movement") | ||
problem.add_fluent(on) | ||
problem.add_fluent(d) | ||
problem.add_action(a) | ||
problem.add_action(b) | ||
problem.add_action(evt) | ||
problem.set_initial_value(on, False) | ||
problem.set_initial_value(d, 0) | ||
problem.add_goal(GE(d, 10)) | ||
|
||
z = Fluent("z", BoolType()) | ||
pr = Process("Name") | ||
pr.add_precondition(z) | ||
problem = TestCase( | ||
problem=problem, | ||
solvable=True, | ||
valid_plans=[], | ||
invalid_plans=[], | ||
) | ||
problems["1d_movement"] = problem | ||
return problems |
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