class Gecode::IntEnum::Sort::SortConstraint
Public Instance Methods
post()
click to toggle source
# File doc/tmp/rdoc_dev/gecoder/interface/constraints/int_enum/sort.rb, line 104 def post lhs, strength, kind, reif_var = @params.values_at(:lhs, :strength, :kind, :reif) using_reification = !reif_var.nil? # We translate the constraint into n-1 relation constraints. options = { :strength => Gecode::Util::PROPAGATION_STRENGTHS.invert[strength], :kind => Gecode::Util::PROPAGATION_KINDS.invert[kind] } if using_reification reification_variables = @model.bool_var_array(lhs.size - 1) end (lhs.size - 1).times do |i| first, second = lhs[i, 2] rel_options = options.clone if using_reification # Reify each relation constraint and then bind them all together. rel_options[:reify] = reification_variables[i] end first.must_be.less_than_or_equal_to(second, rel_options) end if using_reification reification_variables.conjunction.must == reif_var end end