From cebe70824994c14f6e5157ce88a2fcdc52b45381 Mon Sep 17 00:00:00 2001 From: Alelafar Date: Fri, 16 Feb 2024 15:38:44 +0100 Subject: [PATCH] updates some functions added loop on continuous_effects --- unified_planning/io/pddl_writer.py | 2 +- unified_planning/plans/time_triggered_plan.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/unified_planning/io/pddl_writer.py b/unified_planning/io/pddl_writer.py index a02e5b06a..ab320656b 100644 --- a/unified_planning/io/pddl_writer.py +++ b/unified_planning/io/pddl_writer.py @@ -810,7 +810,7 @@ def _format_action_instance(action_instance: ActionInstance) -> str: out.write(f"{start}: {_format_action_instance(ai)}") if dur is not None: duration = dur.numerator if dur.denominator == 1 else float(dur) - out.write(f"[{duration}]") + out.write(f" [{duration}]") out.write("\n") else: raise NotImplementedError diff --git a/unified_planning/plans/time_triggered_plan.py b/unified_planning/plans/time_triggered_plan.py index 1101038ed..52c050a4c 100644 --- a/unified_planning/plans/time_triggered_plan.py +++ b/unified_planning/plans/time_triggered_plan.py @@ -440,6 +440,24 @@ def _get_timepoint_effects( return timepoint_effects +# def _get_timepoint_continuous_effects( +# action: DurativeAction, +# timing: Fraction, +# start: Fraction, +# duration: Fraction, +# ) -> List[Effect]: +# """ +# Returns the List of continuous effects of the given action in the given timing. +# start and duration are the start and duration of the given action +# """ +# timepoint_continuous_effects = [] +# for c_effects_timing, el in action.continuous_effects.items(): +# absolute_effect_time = _absolute_time(c_effects_timing, start, duration) +# if absolute_effect_time == timing: +# timepoint_continuous_effects.extend(el) +# return timepoint_continuous_effects + + def _get_timepoint_simulated_effects( action: DurativeAction, timing: Fraction, @@ -512,6 +530,7 @@ def _extract_instantenous_actions( inst_action.add_precondition(cond) for eff in _get_timepoint_effects(action, timing, start, duration): inst_action._add_effect_instance(eff) + # va aggiunto qualcosa? Come traformo il continuous change in istantenuous action? sim_eff = _get_timepoint_simulated_effects(action, timing, start, duration) if sim_eff is not None: inst_action.set_simulated_effect(sim_eff)