Skip to content

Commit

Permalink
updates some functions added loop on continuous_effects
Browse files Browse the repository at this point in the history
  • Loading branch information
Alelafar committed Feb 16, 2024
1 parent e878692 commit cebe708
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion unified_planning/io/pddl_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions unified_planning/plans/time_triggered_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit cebe708

Please sign in to comment.