Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alvalentini committed Dec 1, 2023
1 parent 8f60a7b commit 9fc25cc
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions unified_planning/engines/plan_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def _apply_effects(
if v.bool_constant_value():
updates[f] = v
else:
raise ValueError("Double effect")
raise UPConflictingEffectsException("Double effect")
else:
updates[f] = v
if eff.is_assignment():
Expand Down Expand Up @@ -575,9 +575,23 @@ def _validate(
scheduled_effects
)
now_effects.append((add_effs, add_sim_effs, opt_ai))
new_state = self._apply_effects(
state=last_state, se=se, effects=now_effects, problem=problem
)
try:
new_state = self._apply_effects(
state=last_state, se=se, effects=now_effects, problem=problem
)
except UPConflictingEffectsException as e:
logs = [
LogMessage(LogLevel.INFO, f"Conflicting effects at time {time}")
]
return ValidationResult(
status=ValidationResultStatus.INVALID,
engine_name=self.name,
log_messages=logs,
metric_evaluations=None,
reason=FailedValidationReason.INAPPLICABLE_ACTION,
inapplicable_action=opt_ai,
trace=trace,
)
trace[time] = new_state
last_state = new_state

Expand All @@ -595,7 +609,7 @@ def _validate(
metric_evaluations=None,
reason=FailedValidationReason.INAPPLICABLE_ACTION,
inapplicable_action=opt_ai,
trace=trace,
trace={k: v for k, v in trace.items() if k <= end},
)
else:
return ValidationResult(
Expand All @@ -605,7 +619,7 @@ def _validate(
metric_evaluations=None,
reason=FailedValidationReason.UNSATISFIED_GOALS,
inapplicable_action=None,
trace=trace,
trace={k: v for k, v in trace.items() if k <= end},
)

for g in problem.goals:
Expand Down

0 comments on commit 9fc25cc

Please sign in to comment.