Skip to content

Commit

Permalink
Optimize foralls expansion in HDDL_Parser
Browse files Browse the repository at this point in the history
  • Loading branch information
Maumagnaguagno committed Feb 25, 2024
1 parent e5b3b76 commit 90abc33
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions parsers/HDDL_Parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,15 @@ def parse_problem(problem_filename)
parse_objects(group)
# Expand foralls
@foralls.each {|pos,neg,(_,(fv,_,fvtype),g),mutable|
@state[fvtype]&.each {|obj,|
g.each {|pre|
pre[0] != NOT ? pos << pre.map {|j| j == fv ? obj : j} : pre.size == 2 ? neg << pre = pre[1].map {|j| j == fv ? obj : j} : raise('Unexpected not in forall')
@predicates[pre[0].freeze] ||= mutable
}
fvtype = @state[fvtype] and g.each {|pre|
if pre[0] != NOT
fvtype.each {|obj,| pos << pre.map {|j| j == fv ? obj : j}}
elsif pre.size == 2
pre = pre[1]
fvtype.each {|obj,| neg << pre.map {|j| j == fv ? obj : j}}
else raise('Unexpected not in forall')
end
@predicates[pre[0].freeze] ||= mutable
}
}
raise 'Repeated object definition' if @objects.uniq!
Expand Down

0 comments on commit 90abc33

Please sign in to comment.