Class: Gecode::Constraints::Set::Relation::ElementRelationConstraint
- Inherits:
-
Constraint
- Object
- Constraint
- Gecode::Constraints::Set::Relation::ElementRelationConstraint
- Defined in:
- lib/gecoder/interface/constraints/set/relation.rb
Overview
Describes an element relation constraint which constrains all elements in a set variable to satisfy an integer relation constraint. The relations supported are the same as in Int::Linear::SimpleRelationConstraint
.
Reification is not supported.
Examples
# All elements in +set+ must be larger than 5.
set.elements.must > 5
# No element in +set+ may equal 0.
set.elements.must_not == 0
# No element in +set+ may contain the value of the integer variable
# +forbidden_number+.
set.elements.must_not == forbidden_number
Instance Method Summary collapse
Methods inherited from Constraint
Constructor Details
This class inherits a constructor from Gecode::Constraints::Constraint
Instance Method Details
#post ⇒ Object
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/gecoder/interface/constraints/set/relation.rb', line 142 def post var, rhs, relation = @params.values_at(:lhs, :rhs, :relation) if @params[:negate] type = Gecode::Constraints::Util::NEGATED_RELATION_TYPES[relation] else type = Gecode::Constraints::Util::RELATION_TYPES[relation] end if rhs.kind_of? Fixnum # Use a proxy int variable to cover. rhs = @model.int_var(rhs) end Gecode::Raw::rel(@model.active_space, var.bind, type, rhs.bind) end |