Skip to content

Commit

Permalink
Fix unordered condition in UHyper_Compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
Maumagnaguagno committed Oct 8, 2023
1 parent 42c819a commit 572d75b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions UHyper_Compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -378,18 +378,18 @@ def compile_problem(domain_name, problem_name, operators, methods, predicates, s
# Objects
objects.uniq!
objects.each {|i| problem_str << "_#{i} = '#{i}'\n" if i.instance_of?(String) and not i.match?(/^-?\d/)}
problem_str << "\n#{namespace = "#{domain_name.capitalize}."}problem(\n # Start\n {\n"
problem_str << "\n#{namespace = "#{domain_name.capitalize}."}problem(\n # Start\n {"
# Start
predicates.each_key {|i| state[i] ||= []}
state.each_with_index {|(k,v),i|
problem_str << " '#{k}' => ["
problem_str << "\n '#{k}' => ["
problem_str << "\n [" << v.map! {|obj| obj.map! {|o| o.instance_of?(String) ? o.match?(/^-?\d/) ? "'#{o.to_f}'" : '_' << o : evaluate(o, namespace)}.join(', ')}.join("],\n [") << "]\n " unless v.empty?
problem_str << (state.size.pred == i ? ']' : "],\n")
problem_str << (state.size.pred == i ? ']' : '],')
}
# Tasks
problem_str << "\n },\n # Tasks\n [" <<
tasks.map! {|task,*terms| "\n ['#{task}'#{terms.map! {|o| o.instance_of?(String) ? o.match?(/^-?\d/) ? ", '#{o.to_f}'" : ', _' << o : ', ' << evaluate(o, namespace)}.join}]"}.join(',') <<
"\n ],\n # Debug\n ARGV.first == 'debug',\n # Maximum plans found\n ARGV[1] ? ARGV[1].to_i : -1,\n # Minimum probability for plans\n ARGV[2] ? ARGV[2].to_f : 0#{",\n # Ordered\n false" unless ordered}"
"\n ],\n # Debug\n ARGV.first == 'debug',\n # Maximum plans found\n ARGV[1] ? ARGV[1].to_i : -1,\n # Minimum probability for plans\n ARGV[2] ? ARGV[2].to_f : 0#{",\n # Ordered\n false" if ordered == false}"
tasks.unshift(ordered) unless tasks.empty?
problem_str.gsub!(/\b-\b/,'_')
domain_filename ? "# Generated by Hype\nrequire_relative '#{domain_filename}'\n\n#{problem_str}\n)" : "#{problem_str}\n)"
Expand Down

0 comments on commit 572d75b

Please sign in to comment.