From ddd211dd9e14c30792caacb22af9b4e7b3a6e110 Mon Sep 17 00:00:00 2001 From: Alelafar Date: Tue, 9 Apr 2024 16:52:10 +0200 Subject: [PATCH 1/6] Added fixed code for conditional effects --- unified_planning/io/pddl_writer.py | 49 ++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 10 deletions(-) diff --git a/unified_planning/io/pddl_writer.py b/unified_planning/io/pddl_writer.py index 49e6fa0ba..f5385107e 100644 --- a/unified_planning/io/pddl_writer.py +++ b/unified_planning/io/pddl_writer.py @@ -1098,6 +1098,19 @@ def _write_effect( positive_cond = (simplified_cond & effect.value).simplify() if not positive_cond.is_false(): out.write(forall_str) + if not positive_cond.is_true(): + out.write(" (when ") + if timing is not None: + if timing.is_from_start(): + out.write(f" (at start") + else: + out.write(f" (at end") + out.write(f"{converter.convert(positive_cond)}") + if ( + timing is not None + ): + out.write(")") + out.write(f" {converter.convert(effect.fluent)})") if timing is not None: if timing.is_from_start(): out.write(f" (at start") @@ -1105,10 +1118,6 @@ def _write_effect( out.write(f" (at end") if positive_cond.is_true(): out.write(f" {converter.convert(effect.fluent)}") - else: - out.write( - f" (when {converter.convert(positive_cond)} {converter.convert(effect.fluent)})" - ) if timing is not None: out.write(")") if effect.is_forall(): @@ -1116,6 +1125,20 @@ def _write_effect( negative_cond = (simplified_cond & effect.value.Not()).simplify() if not negative_cond.is_false(): out.write(forall_str) + if not negative_cond.is_true(): + out.write(" (when") + if timing is not None: + if timing.is_from_start(): + out.write(f" (at start") + else: + out.write(f" (at end") + out.write(f" (at start") + out.write(f" {converter.convert(negative_cond)}") + if ( + timing is not None + ): + out.write(")") + out.write(f" (not {converter.convert(effect.fluent)}))") if timing is not None: if timing.is_from_start(): out.write(f" (at start") @@ -1123,10 +1146,6 @@ def _write_effect( out.write(f" (at end") if negative_cond.is_true(): out.write(f" {converter.convert(effect.fluent)}") - else: - out.write( - f" (when {converter.convert(negative_cond)} (not {converter.convert(effect.fluent)}))" - ) if timing is not None: out.write(")") if effect.is_forall(): @@ -1136,13 +1155,23 @@ def _write_effect( if simplified_cond.is_false(): return out.write(forall_str) + if not simplified_cond.is_true(): + out.write(f" (when") + if timing is not None: + if timing.is_from_start(): + out.write(f" (at start") + else: + out.write(f" (at end") + out.write(f" {converter.convert(effect.condition)}") + if ( + timing is not None + ): + out.write(")") if timing is not None: if timing.is_from_start(): out.write(f" (at start") else: out.write(f" (at end") - if not simplified_cond.is_true(): - out.write(f" (when {converter.convert(effect.condition)}") simplified_value = effect.value.simplify() fluent = converter.convert(effect.fluent) if simplified_value.is_true(): From 5532b9d517d2e90b09069d37986d2c46989d3fc0 Mon Sep 17 00:00:00 2001 From: Alelafar Date: Tue, 9 Apr 2024 17:04:35 +0200 Subject: [PATCH 2/6] Fixed black check error --- unified_planning/io/pddl_writer.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/unified_planning/io/pddl_writer.py b/unified_planning/io/pddl_writer.py index f5385107e..d932c3d5e 100644 --- a/unified_planning/io/pddl_writer.py +++ b/unified_planning/io/pddl_writer.py @@ -1106,9 +1106,7 @@ def _write_effect( else: out.write(f" (at end") out.write(f"{converter.convert(positive_cond)}") - if ( - timing is not None - ): + if timing is not None: out.write(")") out.write(f" {converter.convert(effect.fluent)})") if timing is not None: @@ -1134,9 +1132,7 @@ def _write_effect( out.write(f" (at end") out.write(f" (at start") out.write(f" {converter.convert(negative_cond)}") - if ( - timing is not None - ): + if timing is not None: out.write(")") out.write(f" (not {converter.convert(effect.fluent)}))") if timing is not None: @@ -1163,9 +1159,7 @@ def _write_effect( else: out.write(f" (at end") out.write(f" {converter.convert(effect.condition)}") - if ( - timing is not None - ): + if timing is not None: out.write(")") if timing is not None: if timing.is_from_start(): From 372ed9bda43d5f69727516d8f59f94bf5bdd0641 Mon Sep 17 00:00:00 2001 From: Alelafar Date: Wed, 10 Apr 2024 10:46:47 +0200 Subject: [PATCH 3/6] fixed pddl_reader --- unified_planning/io/pddl_reader.py | 63 +++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/unified_planning/io/pddl_reader.py b/unified_planning/io/pddl_reader.py index 2ff161e45..425672a2c 100644 --- a/unified_planning/io/pddl_reader.py +++ b/unified_planning/io/pddl_reader.py @@ -760,6 +760,67 @@ def _add_timed_effects( if op == "and": for i in range(1, len(eff)): to_add.append((eff[i], forall_variables)) + elif op == "when": + if ( + len(eff) == 3 + and eff[1][0].value == "at" + and eff[1][1].value == "start" + ): + cond = self._parse_exp( + problem, + act, + types_map, + forall_variables, + eff[1][2], + complete_str, + ) + if len(eff[2]) == 3 and eff[2][1].value == "start": + self._add_effect( + problem, + act, + types_map, + eff[2][2], + complete_str, + cond, + timing=up.model.StartTiming(), + forall_variables=forall_variables, + ) + else: + raise UPUnsupportedProblemTypeError( + "Conditional effects with different timing are not supported." + ) + elif ( + len(eff) == 3 + and eff[1][0].value == "at" + and eff[1][1].value == "end" + ): + cond = self._parse_exp( + problem, + act, + types_map, + forall_variables, + eff[1][2], + complete_str, + ) + if len(eff[2]) == 3 and eff[2][1].value == "end": + self._add_effect( + problem, + act, + types_map, + eff[2][2], + complete_str, + cond, + timing=up.model.EndTiming(), + forall_variables=forall_variables, + ) + else: + raise UPUnsupportedProblemTypeError( + "Conditional effects with different timing are not supported." + ) + else: + raise UPUnsupportedProblemTypeError( + "Conditional durative effects syntax is not correct." + ) elif len(eff) == 3 and op == "at" and eff[1].value == "start": self._add_effect( problem, @@ -802,7 +863,7 @@ def _add_timed_effects( complete_str ) raise SyntaxError( - f"Not able to handle: {eff}, from line: {start_line}, col {start_col} to line: {end_line}, col {end_col}" + f"Not able to handle: {eff.value}, from line: {start_line}, col {start_col} to line: {end_line}, col {end_col}" ) def _parse_subtask( From 6d98fa4c6fa5de33250238dc8588bdb74e0be136 Mon Sep 17 00:00:00 2001 From: Alelafar Date: Thu, 11 Apr 2024 11:04:58 +0200 Subject: [PATCH 4/6] small fix --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0e5e13434..757bdc3c3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -219,7 +219,7 @@ jobs: - name: "Upload coverage to Codecov" if: ${{ github.repository == 'aiplan4eu/unified-planning' }} - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} files: ./coverage.xml From 0699e1e5afbb883c3047d29c279853a408dd428e Mon Sep 17 00:00:00 2001 From: Alelafar Date: Thu, 11 Apr 2024 11:28:31 +0200 Subject: [PATCH 5/6] small fix --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 757bdc3c3..ee9ba037c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -219,7 +219,7 @@ jobs: - name: "Upload coverage to Codecov" if: ${{ github.repository == 'aiplan4eu/unified-planning' }} - uses: codecov/codecov-action@v4 + uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN }} files: ./coverage.xml From 08e5ffc148b385d8cc01849dc376d15c078ea16c Mon Sep 17 00:00:00 2001 From: Alessandro Valentini Date: Fri, 12 Apr 2024 17:14:28 +0200 Subject: [PATCH 6/6] Fixed upload coverage to codecov in the CI --- .github/workflows/main.yml | 2 ++ .github/workflows/release.yml | 2 ++ .github/workflows/test.yml | 7 +++++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9ab94dca9..771780aa8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,3 +13,5 @@ jobs: with: python-version: "3.10" + + secrets: inherit diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3c8ac6184..212a66e4a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,6 +19,8 @@ jobs: with: python-version: ${{matrix.python-version}} + secrets: inherit + deploy: needs: [test] uses: ./.github/workflows/deploy.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ee9ba037c..c525ee0f4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,6 +6,9 @@ on: python-version: required: true type: string + secrets: + CODECOV_TOKEN: + required: true env: up_tamer_commit: "631dfd43a56e7c2dda44fe273ec6f5492e99cfe1" @@ -218,8 +221,8 @@ jobs: run: bash run_tests.sh - name: "Upload coverage to Codecov" - if: ${{ github.repository == 'aiplan4eu/unified-planning' }} - uses: codecov/codecov-action@v3 + if: ${{ github.repository == 'aiplan4eu/unified-planning' && inputs.python-version == '3.10' }} + uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} files: ./coverage.xml