Skip to content

Commit

Permalink
Refactor Pullup dead branch removal
Browse files Browse the repository at this point in the history
  • Loading branch information
Maumagnaguagno committed Apr 6, 2024
1 parent 70929db commit 4b9ba7a
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions extensions/Pullup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ def apply(operators, methods, predicates, state, tasks, goal_pos, goal_not, debu
name = decompositions.shift
param = decompositions.shift
decompositions.select! {|_,free,precond_pos,precond_not,subtasks|
possible_decomposition = true
# Remove unnecessary free variables
substitutions = {}
precond_pos.each {|pre,*terms|
Expand All @@ -158,27 +157,18 @@ def apply(operators, methods, predicates, state, tasks, goal_pos, goal_not, debu
precond_not.each {|pre| pre.map! {|i| substitutions[i] || i}}
subtasks.each {|t| t.map! {|i| substitutions[i] || i}}
end
precond_pos.reject! {|pre|
precond_pos.delete_if {|pre|
if not predicates[pre[0]] and pre.none? {|i| i.start_with?('?')}
unless state[pre[0]]&.include?(pre.drop(1))
possible_decomposition = false
break
end
break unless state[pre[0]]&.include?(pre.drop(1))
true
end
} &&
precond_not.delete_if {|pre|
if not predicates[pre[0]] and pre.none? {|i| i.start_with?('?')}
break if state[pre[0]]&.include?(pre.drop(1))
true
end
}
if possible_decomposition
precond_not.reject! {|pre|
if not predicates[pre[0]] and pre.none? {|i| i.start_with?('?')}
if state[pre[0]]&.include?(pre.drop(1))
possible_decomposition = false
break
end
true
end
}
end
possible_decomposition
}
decompositions.unshift(name, param)
}
Expand Down

0 comments on commit 4b9ba7a

Please sign in to comment.