Issue1187

Title Failing Assertion in Enforced Hill Climbing on Trivial Problem
Priority bug Status in-progress
Superseder Nosy List davidspeck, jendrik, malte
Assigned To Keywords
Optional summary
When running Enforced Hill Climbing independently of the heuristic on a trivial 
PDDL instance where the initial state already satisfies the goal, an assertion 
fails in debug mode because the number of EHC phases is zero.

https://github.com/aibasel/downward/blob/02f3f92f889f61a1f14a72ba934a5cdde274593
3/src/search/search_algorithms/enforced_hill_climbing_search.cc#L246

Created on 2025-07-23.18:02:39 by davidspeck, last changed by davidspeck.

Summary
When running Enforced Hill Climbing independently of the heuristic on a trivial 
PDDL instance where the initial state already satisfies the goal, an assertion 
fails in debug mode because the number of EHC phases is zero.

https://github.com/aibasel/downward/blob/02f3f92f889f61a1f14a72ba934a5cdde274593
3/src/search/search_algorithms/enforced_hill_climbing_search.cc#L246
Messages
msg11870 (view) Author: davidspeck Date: 2025-07-24.14:53:51
We discussed this issue both offline and in the PR.

Summary:
The assertion exists because we log the average expansion per EHC phase. This can also lead 
to a planner crash if run in release mode because C++ does not define what happens when you 
divide by zero.

Therefore, we decided to remove logging of this average and the associated assertion. The 
average can still be calculated from the output, as we log both the total number of 
expansions and the EHC phases. Furthermore, it seems that Lab does not parse "Average 
expansions per EHC phase:", which should hopefully avoid parsing issues for experiments.
msg11869 (view) Author: malte Date: 2025-07-24.13:28:05
I commented on the pull request.

Short story: there's a reason why it must be "assert != 0".
The assertion is there because 0 will cause a problem in the following code. (Negative values would not.)
msg11866 (view) Author: davidspeck Date: 2025-07-23.18:29:32
PR: https://github.com/aibasel/downward/pull/267
msg11865 (view) Author: davidspeck Date: 2025-07-23.18:06:52
Easy fix would be to change assert(num_ehc_phases != 0); to assert(num_ehc_phases 
>= 0);
msg11864 (view) Author: davidspeck Date: 2025-07-23.18:03:25
Domain:

(define (domain trivial)
  (:predicates (p))
)

Problem:

(define (problem already-solved)
  (:domain trivial)
  (:init (p))
  (:goal (p))
)
History
Date User Action Args
2025-07-24 14:53:51davidspecksetmessages: + msg11870
2025-07-24 13:28:05maltesetmessages: + msg11869
2025-07-23 18:29:32davidspecksetmessages: + msg11866
2025-07-23 18:06:52davidspecksetmessages: + msg11865
2025-07-23 18:04:00davidspecksetnosy: + malte, jendrik
2025-07-23 18:03:25davidspecksetnosy: + davidspeck
messages: + msg11864
2025-07-23 18:02:39davidspeckcreate