gecoder 0.7.1 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. data/CHANGES +7 -0
  2. data/README +10 -1
  3. data/example/sudoku-set.rb +16 -13
  4. data/ext/extconf.rb +26 -9
  5. data/ext/missing.cpp +1 -1
  6. data/ext/missing.h +1 -1
  7. data/ext/vararray.h +4 -4
  8. data/lib/gecoder/bindings.rb +21 -1
  9. data/lib/gecoder/bindings/bindings.rb +408 -731
  10. data/lib/gecoder/interface/binding_changes.rb +1 -1
  11. data/lib/gecoder/interface/branch.rb +25 -25
  12. data/lib/gecoder/interface/constraints.rb +47 -4
  13. data/lib/gecoder/interface/constraints/bool/boolean.rb +18 -16
  14. data/lib/gecoder/interface/constraints/bool_enum/boolean.rb +13 -11
  15. data/lib/gecoder/interface/constraints/int/arithmetic.rb +5 -4
  16. data/lib/gecoder/interface/constraints/int/domain.rb +8 -9
  17. data/lib/gecoder/interface/constraints/int/linear.rb +10 -8
  18. data/lib/gecoder/interface/constraints/int_enum/arithmetic.rb +4 -4
  19. data/lib/gecoder/interface/constraints/int_enum/channel.rb +2 -2
  20. data/lib/gecoder/interface/constraints/int_enum/count.rb +4 -5
  21. data/lib/gecoder/interface/constraints/int_enum/distinct.rb +7 -2
  22. data/lib/gecoder/interface/constraints/int_enum/element.rb +2 -2
  23. data/lib/gecoder/interface/constraints/int_enum/equality.rb +6 -3
  24. data/lib/gecoder/interface/constraints/int_enum/sort.rb +17 -5
  25. data/lib/gecoder/interface/constraints/set_enum/distinct.rb +0 -36
  26. data/lib/gecoder/interface/constraints/set_var_constraints.rb +5 -0
  27. data/lib/gecoder/interface/model.rb +3 -3
  28. data/lib/gecoder/interface/search.rb +5 -4
  29. data/lib/gecoder/version.rb +1 -1
  30. data/specs/branch.rb +27 -27
  31. data/specs/constraints/arithmetic.rb +48 -30
  32. data/specs/constraints/bool_enum.rb +39 -19
  33. data/specs/constraints/boolean.rb +10 -10
  34. data/specs/constraints/cardinality.rb +12 -9
  35. data/specs/constraints/channel.rb +6 -6
  36. data/specs/constraints/connection.rb +22 -26
  37. data/specs/constraints/constraint_helper.rb +125 -41
  38. data/specs/constraints/count.rb +22 -15
  39. data/specs/constraints/distinct.rb +10 -64
  40. data/specs/constraints/element.rb +14 -12
  41. data/specs/constraints/equality.rb +4 -4
  42. data/specs/constraints/int_domain.rb +8 -7
  43. data/specs/constraints/int_relation.rb +12 -8
  44. data/specs/constraints/linear.rb +4 -4
  45. data/specs/constraints/reification_sugar.rb +22 -4
  46. data/specs/constraints/selection.rb +2 -2
  47. data/specs/constraints/set_domain.rb +7 -3
  48. data/specs/constraints/set_operation.rb +2 -2
  49. data/specs/constraints/set_relation.rb +2 -6
  50. data/specs/constraints/sort.rb +20 -16
  51. data/specs/distribution.rb +14 -0
  52. data/specs/model.rb +4 -4
  53. data/tasks/dependencies.txt +21 -0
  54. data/tasks/distribution.rake +81 -8
  55. data/tasks/svn.rake +6 -3
  56. data/vendor/rust/include/rust_checks.hh +2 -1
  57. data/vendor/rust/include/rust_conversions.hh +2 -2
  58. data/vendor/rust/rust/attribute.rb +2 -2
  59. data/vendor/rust/rust/class.rb +2 -2
  60. data/vendor/rust/rust/cxxclass.rb +0 -2
  61. data/vendor/rust/rust/function.rb +2 -2
  62. data/vendor/rust/rust/templates/AttributeDefinition.rusttpl +1 -1
  63. data/vendor/rust/rust/templates/StandaloneClassDeclarations.rusttpl +1 -1
  64. data/vendor/rust/rust/templates/VariableFunctionCall.rusttpl +1 -1
  65. data/vendor/rust/rust/type.rb +1 -1
  66. metadata +159 -157
@@ -67,9 +67,8 @@ module Gecode::Constraints::IntEnum::Count #:nodoc:
67
67
  # :strength => :domain)
68
68
  class CountConstraint < Gecode::Constraints::ReifiableConstraint
69
69
  def post
70
- lhs, element, relation_type, rhs, strength, reif_var =
71
- @params.values_at(:lhs, :element, :relation_type, :rhs, :strength,
72
- :reif)
70
+ lhs, element, relation_type, rhs, reif_var =
71
+ @params.values_at(:lhs, :element, :relation_type, :rhs, :reif)
73
72
 
74
73
  # Bind variables if needed.
75
74
  element = element.bind if element.respond_to? :bind
@@ -78,14 +77,14 @@ module Gecode::Constraints::IntEnum::Count #:nodoc:
78
77
  # Post the constraint to gecode.
79
78
  if reif_var.nil?
80
79
  Gecode::Raw::count(@model.active_space, lhs.to_int_var_array,
81
- element, relation_type, rhs, strength)
80
+ element, relation_type, rhs, *propagation_options)
82
81
  else
83
82
  # We use a proxy int variable to get the reification.
84
83
  proxy = @model.int_var(rhs.min..rhs.max)
85
84
  rel = Gecode::Constraints::Util::RELATION_TYPES.invert[relation_type]
86
85
  proxy.must.send(rel, @params[:rhs], :reify => reif_var)
87
86
  Gecode::Raw::count(@model.active_space, lhs.to_int_var_array,
88
- element, Gecode::Raw::IRT_EQ, proxy.bind, strength)
87
+ element, Gecode::Raw::IRT_EQ, proxy.bind, *propagation_options)
89
88
  end
90
89
  end
91
90
  end
@@ -25,7 +25,11 @@ module Gecode::Constraints::IntEnum
25
25
  raise Gecode::MissingConstraintError, 'A negated distinct is not ' +
26
26
  'implemented.'
27
27
  end
28
-
28
+ unless options[:reify].nil?
29
+ raise ArgumentError, 'Reification is not supported by the distinct ' +
30
+ 'constraint.'
31
+ end
32
+
29
33
  @model.add_constraint Distinct::DistinctConstraint.new(@model,
30
34
  @params.update(Gecode::Constraints::Util.decode_options(options)))
31
35
  end
@@ -60,8 +64,9 @@ module Gecode::Constraints::IntEnum
60
64
  @params[:lhs] = @params[:lhs].to_int_var_array
61
65
 
62
66
  # Fetch the parameters to Gecode.
63
- params = @params.values_at(:offsets, :lhs, :strength)
67
+ params = @params.values_at(:offsets, :lhs)
64
68
  params.delete_if{ |x| x.nil? }
69
+ params.concat propagation_options
65
70
  Gecode::Raw::distinct(@model.active_space, *params)
66
71
  end
67
72
  end
@@ -23,7 +23,7 @@ module Gecode::Constraints::IntEnum::Element #:nodoc:
23
23
  # int_enum[x].must_be.in(7..17, :reify => bool, :strength => :domain)
24
24
  class ExpressionStub < Gecode::Constraints::Int::CompositeStub
25
25
  def constrain_equal(variable, params, constrain)
26
- enum, position, strength = @params.values_at(:lhs, :position, :strength)
26
+ enum, position = @params.values_at(:lhs, :position)
27
27
  if constrain
28
28
  variable.must_be.in enum.domain_range
29
29
  end
@@ -31,7 +31,7 @@ module Gecode::Constraints::IntEnum::Element #:nodoc:
31
31
  # The enum can be a constant array.
32
32
  enum = enum.to_int_var_array if enum.respond_to? :to_int_var_array
33
33
  Gecode::Raw::element(@model.active_space, enum,
34
- position.bind, variable.bind, strength)
34
+ position.bind, variable.bind, *propagation_options)
35
35
  end
36
36
  end
37
37
 
@@ -8,6 +8,10 @@ module Gecode::Constraints::IntEnum
8
8
  raise Gecode::MissingConstraintError, 'A negated equality is not ' +
9
9
  'implemented.'
10
10
  end
11
+ unless options[:reify].nil?
12
+ raise ArgumentError, 'Reification is not supported by the equality ' +
13
+ 'constraint.'
14
+ end
11
15
 
12
16
  @model.add_constraint Equality::EqualityConstraint.new(@model,
13
17
  @params.update(Gecode::Constraints::Util.decode_options(options)))
@@ -27,11 +31,10 @@ module Gecode::Constraints::IntEnum
27
31
  class EqualityConstraint < Gecode::Constraints::Constraint
28
32
  def post
29
33
  # Bind lhs.
30
- @params[:lhs] = @params[:lhs].to_int_var_array
34
+ lhs = @params[:lhs].to_int_var_array
31
35
 
32
36
  # Fetch the parameters to Gecode.
33
- params = @params.values_at(:lhs, :strength)
34
- Gecode::Raw::eq(@model.active_space, *params)
37
+ Gecode::Raw::eq(@model.active_space, lhs, *propagation_options)
35
38
  end
36
39
  end
37
40
  end
@@ -29,6 +29,7 @@ module Gecode::Constraints::IntEnum
29
29
  end
30
30
 
31
31
  # Extract standard options and convert to constraint.
32
+ reified = !options[:reify].nil?
32
33
  @params.update(Gecode::Constraints::Util.decode_options(options))
33
34
  if target.nil? and order.nil?
34
35
  @model.add_constraint Sort::SortConstraint.new(@model, @params)
@@ -38,6 +39,10 @@ module Gecode::Constraints::IntEnum
38
39
  raise Gecode::MissingConstraintError, 'A negated sort with options ' +
39
40
  'is not implemented.'
40
41
  end
42
+ if reified
43
+ raise ArgumentError, 'Reification is not supported by the sorted ' +
44
+ 'constraint.'
45
+ end
41
46
 
42
47
  @params.update(:target => target, :order => order)
43
48
  @model.add_constraint Sort::SortConstraintWithOptions.new(@model,
@@ -72,15 +77,17 @@ module Gecode::Constraints::IntEnum
72
77
  end
73
78
 
74
79
  # Prepare the parameters.
75
- params = @params.values_at(:lhs, :target, :order, :strength).map do |param|
80
+ params = @params.values_at(:lhs, :target, :order).map do |param|
76
81
  if param.respond_to? :to_int_var_array
77
82
  param.to_int_var_array
78
83
  else
79
84
  param
80
85
  end
81
86
  end.delete_if{ |param| param.nil? }
87
+ params.concat propagation_options
88
+
82
89
  # Post the constraint.
83
- Gecode::Raw::sortedness(@model.active_space, *params)
90
+ Gecode::Raw::sorted(@model.active_space, *params)
84
91
  end
85
92
  end
86
93
 
@@ -98,12 +105,17 @@ module Gecode::Constraints::IntEnum
98
105
  # int_enum.must_be.sorted(:reify => :is_sorted, :strength => :domain)
99
106
  class SortConstraint < Gecode::Constraints::ReifiableConstraint
100
107
  def post
101
- lhs, strength, reif_var = @params.values_at(:lhs, :strength, :reif)
108
+ lhs, strength, kind, reif_var =
109
+ @params.values_at(:lhs, :strength, :kind, :reif)
102
110
  using_reification = !reif_var.nil?
103
111
 
104
112
  # We translate the constraint into n-1 relation constraints.
105
- options = {:strength =>
106
- Gecode::Constraints::Util::PROPAGATION_STRENGTHS.invert[strength]}
113
+ options = {
114
+ :strength =>
115
+ Gecode::Constraints::Util::PROPAGATION_STRENGTHS.invert[strength],
116
+ :kind =>
117
+ Gecode::Constraints::Util::PROPAGATION_KINDS.invert[kind]
118
+ }
107
119
  if using_reification
108
120
  reification_variables = @model.bool_var_array(lhs.size - 1)
109
121
  end
@@ -1,24 +1,5 @@
1
1
  module Gecode::Constraints::SetEnum
2
2
  class Expression
3
- # Adds a distinct constraint on the sets in the enum. The "option" :size
4
- # must be specified, the sets will be constrained to that size.
5
- def distinct(options = {})
6
- unless options.has_key? :size
7
- raise ArgumentError, 'Option :size has to be specified.'
8
- end
9
- unless options.size == 1
10
- raise ArgumentError, 'Only the option :size is accepted, got ' +
11
- "#{options.keys.join(', ')}."
12
- end
13
- if @params[:negate]
14
- raise Gecode::MissingConstraintError, 'A negated distinct is not ' +
15
- 'implemented.'
16
- end
17
-
18
- @model.add_constraint Distinct::DistinctConstraint.new(
19
- @model, @params.update(options))
20
- end
21
-
22
3
  # Adds a constraint on the sets that specifies that they must have at most
23
4
  # one element in common. The "option" :size must be specified, the sets
24
5
  # will be constrained to that size.
@@ -42,23 +23,6 @@ module Gecode::Constraints::SetEnum
42
23
 
43
24
  # A module that gathers the classes and modules used in distinct constraints.
44
25
  module Distinct #:nodoc:
45
- # Describes a set distinct constraint, which constrains all set variables
46
- # in the enumeration to be distinct and of a specified size. Providing a
47
- # size is not optional.
48
- #
49
- # Neither negation nor reification is supported.
50
- #
51
- # == Examples
52
- #
53
- # # All set variables in +sets+ must have cardinality 4 and be different.
54
- # sets.must_be.distinct(:size => 4)
55
- class DistinctConstraint < Gecode::Constraints::Constraint
56
- def post
57
- sets, size = @params.values_at(:lhs, :size)
58
- Gecode::Raw::distinct(@model.active_space, sets.to_set_var_array, size)
59
- end
60
- end
61
-
62
26
  # Describes an at most one constraint, which constrains all pairs of set
63
27
  # variables in the enumeration to at most have one element in common and be
64
28
  # of a specified size. Providing a size is not optional.
@@ -26,6 +26,11 @@ module Gecode
26
26
  raise ArgumentError, 'Set constraints do not support the strength ' +
27
27
  'option.'
28
28
  end
29
+ if options.has_key? :kind
30
+ raise ArgumentError, 'Set constraints do not support the kind ' +
31
+ 'option.'
32
+ end
33
+
29
34
  Gecode::Constraints::Util.decode_options(options)
30
35
  end
31
36
  end
@@ -5,7 +5,7 @@ module Gecode
5
5
  # either be a range, a single element, or an enumeration of elements. If no
6
6
  # domain is specified then the largest possible domain is used.
7
7
  def int_var(domain =
8
- Gecode::Raw::Limits::Int::INT_MIN..Gecode::Raw::Limits::Int::INT_MAX)
8
+ Gecode::Raw::IntLimits::MIN..Gecode::Raw::IntLimits::MAX)
9
9
  enum = domain_enum(domain)
10
10
  index = variable_creation_space.new_int_vars(enum).first
11
11
  FreeIntVar.new(self, index)
@@ -74,7 +74,7 @@ module Gecode
74
74
  # default range (anything) will be used. If only a single Fixnum is
75
75
  # specified as cardinality_range then it's used as lower bound.
76
76
  def set_var(glb_domain = [], lub_domain =
77
- Gecode::Raw::Limits::Set::INT_MIN..Gecode::Raw::Limits::Set::INT_MAX,
77
+ Gecode::Raw::SetLimits::MIN..Gecode::Raw::SetLimits::MAX,
78
78
  cardinality_range = nil)
79
79
  check_set_bounds(glb_domain, lub_domain)
80
80
 
@@ -198,7 +198,7 @@ module Gecode
198
198
  # otherwise if the argument is a fixnum it's used as lower bound.
199
199
  def to_set_cardinality_range(arg)
200
200
  if arg.kind_of? Fixnum
201
- arg..Gecode::Raw::Limits::Set::CARD_MAX
201
+ arg..Gecode::Raw::SetLimits::MAX
202
202
  else
203
203
  arg
204
204
  end
@@ -64,10 +64,11 @@ module Gecode
64
64
  end
65
65
 
66
66
  # Perform the search.
67
- result = Gecode::Raw::bab(selected_space,
68
- Gecode::Raw::Search::Config::MINIMAL_DISTANCE,
69
- Gecode::Raw::Search::Config::ADAPTIVE_DISTANCE,
70
- nil)
67
+ options = Gecode::Raw::Search::Options.new
68
+ options.c_d = Gecode::Raw::Search::Config::MINIMAL_DISTANCE
69
+ options.a_d = Gecode::Raw::Search::Config::ADAPTIVE_DISTANCE
70
+ options.stop = nil
71
+ result = Gecode::Raw::bab(selected_space, options)
71
72
 
72
73
  # Reset the method used constrain calls and return the result.
73
74
  Model.constrain_proc = nil
@@ -1,4 +1,4 @@
1
1
  module GecodeR
2
2
  # A string representation of the Gecode/R version.
3
- VERSION = '0.7.1'
3
+ VERSION = '0.8.0'
4
4
  end
data/specs/branch.rb CHANGED
@@ -22,7 +22,7 @@ describe Gecode::Model, ' (integer branch)' do
22
22
  it 'should default to :none and :min' do
23
23
  Gecode::Raw.should_receive(:branch).once.with(
24
24
  an_instance_of(Gecode::Raw::Space),
25
- anything, Gecode::Raw::BVAR_NONE, Gecode::Raw::BVAL_MIN)
25
+ anything, Gecode::Raw::INT_VAR_NONE, Gecode::Raw::INT_VAL_MIN)
26
26
  @model.branch_on @vars
27
27
  @model.solve!
28
28
  end
@@ -38,19 +38,19 @@ describe Gecode::Model, ' (integer branch)' do
38
38
  end
39
39
 
40
40
  supported_var_selectors = {
41
- :none => Gecode::Raw::BVAR_NONE,
42
- :smallest_min => Gecode::Raw::BVAR_MIN_MIN,
43
- :largest_min => Gecode::Raw::BVAR_MIN_MAX,
44
- :smallest_max => Gecode::Raw::BVAR_MAX_MIN,
45
- :largest_max => Gecode::Raw::BVAR_MAX_MAX,
46
- :smallest_size => Gecode::Raw::BVAR_SIZE_MIN,
47
- :largest_size => Gecode::Raw::BVAR_SIZE_MAX,
48
- :smallest_degree => Gecode::Raw::BVAR_DEGREE_MIN,
49
- :largest_degree => Gecode::Raw::BVAR_DEGREE_MAX,
50
- :smallest_min_regret => Gecode::Raw::BVAR_REGRET_MIN_MIN,
51
- :largest_min_regret => Gecode::Raw::BVAR_REGRET_MIN_MAX,
52
- :smallest_max_regret => Gecode::Raw::BVAR_REGRET_MAX_MIN,
53
- :largest_max_regret => Gecode::Raw::BVAR_REGRET_MAX_MAX
41
+ :none => Gecode::Raw::INT_VAR_NONE,
42
+ :smallest_min => Gecode::Raw::INT_VAR_MIN_MIN,
43
+ :largest_min => Gecode::Raw::INT_VAR_MIN_MAX,
44
+ :smallest_max => Gecode::Raw::INT_VAR_MAX_MIN,
45
+ :largest_max => Gecode::Raw::INT_VAR_MAX_MAX,
46
+ :smallest_size => Gecode::Raw::INT_VAR_SIZE_MIN,
47
+ :largest_size => Gecode::Raw::INT_VAR_SIZE_MAX,
48
+ :smallest_degree => Gecode::Raw::INT_VAR_DEGREE_MIN,
49
+ :largest_degree => Gecode::Raw::INT_VAR_DEGREE_MAX,
50
+ :smallest_min_regret => Gecode::Raw::INT_VAR_REGRET_MIN_MIN,
51
+ :largest_min_regret => Gecode::Raw::INT_VAR_REGRET_MIN_MAX,
52
+ :smallest_max_regret => Gecode::Raw::INT_VAR_REGRET_MAX_MIN,
53
+ :largest_max_regret => Gecode::Raw::INT_VAR_REGRET_MAX_MAX
54
54
  }.each_pair do |name, gecode_const|
55
55
  it "should support #{name} as variable selection strategy" do
56
56
  Gecode::Raw.should_receive(:branch).once.with(
@@ -62,11 +62,11 @@ describe Gecode::Model, ' (integer branch)' do
62
62
  end
63
63
 
64
64
  supported_val_selectors = {
65
- :min => Gecode::Raw::BVAL_MIN,
66
- :med => Gecode::Raw::BVAL_MED,
67
- :max => Gecode::Raw::BVAL_MAX,
68
- :split_min => Gecode::Raw::BVAL_SPLIT_MIN,
69
- :split_max => Gecode::Raw::BVAL_SPLIT_MAX
65
+ :min => Gecode::Raw::INT_VAL_MIN,
66
+ :med => Gecode::Raw::INT_VAL_MED,
67
+ :max => Gecode::Raw::INT_VAL_MAX,
68
+ :split_min => Gecode::Raw::INT_VAL_SPLIT_MIN,
69
+ :split_max => Gecode::Raw::INT_VAL_SPLIT_MAX
70
70
  }.each_pair do |name, gecode_const|
71
71
  it "should support #{name} as value selection strategy" do
72
72
  Gecode::Raw.should_receive(:branch).once.with(
@@ -111,7 +111,7 @@ describe Gecode::Model, ' (set branch)' do
111
111
  it 'should default to :none and :min' do
112
112
  Gecode::Raw.should_receive(:branch).once.with(
113
113
  an_instance_of(Gecode::Raw::Space),
114
- anything, Gecode::Raw::SETBVAR_NONE, Gecode::Raw::SETBVAL_MIN)
114
+ anything, Gecode::Raw::SET_VAR_NONE, Gecode::Raw::SET_VAL_MIN)
115
115
  @model.branch_on @sets
116
116
  @model.solve!
117
117
  end
@@ -122,11 +122,11 @@ describe Gecode::Model, ' (set branch)' do
122
122
  end
123
123
 
124
124
  supported_var_selectors = {
125
- :none => Gecode::Raw::SETBVAR_NONE,
126
- :smallest_cardinality => Gecode::Raw::SETBVAR_MIN_CARD,
127
- :largest_cardinality => Gecode::Raw::SETBVAR_MAX_CARD,
128
- :smallest_unknown => Gecode::Raw::SETBVAR_MIN_UNKNOWN_ELEM,
129
- :largest_unknown => Gecode::Raw::SETBVAR_MAX_UNKNOWN_ELEM
125
+ :none => Gecode::Raw::SET_VAR_NONE,
126
+ :smallest_cardinality => Gecode::Raw::SET_VAR_MIN_CARD,
127
+ :largest_cardinality => Gecode::Raw::SET_VAR_MAX_CARD,
128
+ :smallest_unknown => Gecode::Raw::SET_VAR_MIN_UNKNOWN_ELEM,
129
+ :largest_unknown => Gecode::Raw::SET_VAR_MAX_UNKNOWN_ELEM
130
130
  }.each_pair do |name, gecode_const|
131
131
  it "should support #{name} as variable selection strategy" do
132
132
  Gecode::Raw.should_receive(:branch).once.with(
@@ -138,8 +138,8 @@ describe Gecode::Model, ' (set branch)' do
138
138
  end
139
139
 
140
140
  supported_val_selectors = {
141
- :min => Gecode::Raw::SETBVAL_MIN,
142
- :max => Gecode::Raw::SETBVAL_MAX
141
+ :min => Gecode::Raw::SET_VAL_MIN,
142
+ :max => Gecode::Raw::SET_VAL_MAX
143
143
  }.each_pair do |name, gecode_const|
144
144
  it "should support #{name} as value selection strategy" do
145
145
  Gecode::Raw.should_receive(:branch).once.with(
@@ -25,8 +25,9 @@ describe 'arithmetic constraint', :shared => true do
25
25
  @stub.must_be.greater_than(@target, hash)
26
26
  @model.solve!
27
27
  end
28
- @expect_options = lambda do |strength, reif_var|
29
- @expect.call(Gecode::Raw::IRT_GR, @target, strength, reif_var, false)
28
+ @expect_options = option_expectation do |strength, kind, reif_var|
29
+ @expect.call(Gecode::Raw::IRT_GR, @target, strength, kind, reif_var,
30
+ false)
30
31
  end
31
32
 
32
33
  # For composite spec.
@@ -39,20 +40,21 @@ describe 'arithmetic constraint', :shared => true do
39
40
  @model.solve!
40
41
  end
41
42
  @expect_relation = lambda do |relation, target, negated|
42
- @expect.call(relation, target, Gecode::Raw::ICL_DEF, nil, negated)
43
+ @expect.call(relation, target, Gecode::Raw::ICL_DEF, Gecode::Raw::PK_DEF,
44
+ nil, negated)
43
45
  end
44
46
  end
45
47
 
46
48
  it 'should translate reification when using equality' do
47
49
  bool_var = @model.bool_var
48
- @expect.call(Gecode::Raw::IRT_EQ, @target, Gecode::Raw::ICL_DEF, bool_var,
49
- false)
50
+ @expect.call(Gecode::Raw::IRT_EQ, @target, Gecode::Raw::ICL_DEF,
51
+ Gecode::Raw::PK_DEF, bool_var, false)
50
52
  @stub.must_be.equal_to(@target, :reify => bool_var)
51
53
  @model.solve!
52
54
  end
53
55
 
54
56
  it_should_behave_like 'composite constraint'
55
- it_should_behave_like 'constraint with options'
57
+ it_should_behave_like 'reifiable constraint'
56
58
  end
57
59
 
58
60
  describe Gecode::Constraints::IntEnum::Arithmetic, ' (max)' do
@@ -63,7 +65,7 @@ describe Gecode::Constraints::IntEnum::Arithmetic, ' (max)' do
63
65
  @stub = @numbers.max
64
66
 
65
67
  # Creates an expectation corresponding to the specified input.
66
- @expect = lambda do |relation, rhs, strength, reif_var, negated|
68
+ @expect = lambda do |relation, rhs, strength, kind, reif_var, negated|
67
69
  @model.allow_space_access do
68
70
  rhs = an_instance_of(Gecode::Raw::IntVar) if rhs.respond_to? :bind
69
71
  if reif_var.nil?
@@ -71,27 +73,31 @@ describe Gecode::Constraints::IntEnum::Arithmetic, ' (max)' do
71
73
  !rhs.kind_of? Fixnum
72
74
  Gecode::Raw.should_receive(:max).once.with(
73
75
  an_instance_of(Gecode::Raw::Space),
74
- an_instance_of(Gecode::Raw::IntVarArray), rhs, strength)
76
+ an_instance_of(Gecode::Raw::IntVarArray),
77
+ rhs, strength, kind)
75
78
  Gecode::Raw.should_receive(:rel).exactly(0).times
76
79
  else
77
80
  Gecode::Raw.should_receive(:max).once.with(
78
81
  an_instance_of(Gecode::Raw::Space),
79
82
  an_instance_of(Gecode::Raw::IntVarArray),
80
- an_instance_of(Gecode::Raw::IntVar), strength)
83
+ an_instance_of(Gecode::Raw::IntVar),
84
+ strength, kind)
81
85
  Gecode::Raw.should_receive(:rel).once.with(
82
86
  an_instance_of(Gecode::Raw::Space),
83
- an_instance_of(Gecode::Raw::IntVar), relation, rhs, strength)
87
+ an_instance_of(Gecode::Raw::IntVar),
88
+ relation, rhs, strength, kind)
84
89
  end
85
90
  else
86
91
  Gecode::Raw.should_receive(:max).once.with(
87
92
  an_instance_of(Gecode::Raw::Space),
88
93
  an_instance_of(Gecode::Raw::IntVarArray),
89
- an_instance_of(Gecode::Raw::IntVar), strength)
94
+ an_instance_of(Gecode::Raw::IntVar),
95
+ strength, kind)
90
96
  Gecode::Raw.should_receive(:rel).once.with(
91
97
  an_instance_of(Gecode::Raw::Space),
92
98
  an_instance_of(Gecode::Raw::IntVar), relation, rhs,
93
99
  an_instance_of(Gecode::Raw::BoolVar),
94
- strength)
100
+ strength, kind)
95
101
  end
96
102
  end
97
103
  end
@@ -113,7 +119,7 @@ describe Gecode::Constraints::IntEnum::Arithmetic, ' (min)' do
113
119
  @stub = @numbers.min
114
120
 
115
121
  # Creates an expectation corresponding to the specified input.
116
- @expect = lambda do |relation, rhs, strength, reif_var, negated|
122
+ @expect = lambda do |relation, rhs, strength, kind, reif_var, negated|
117
123
  @model.allow_space_access do
118
124
  rhs = an_instance_of(Gecode::Raw::IntVar) if rhs.respond_to? :bind
119
125
  if reif_var.nil?
@@ -121,27 +127,31 @@ describe Gecode::Constraints::IntEnum::Arithmetic, ' (min)' do
121
127
  !rhs.kind_of? Fixnum
122
128
  Gecode::Raw.should_receive(:min).once.with(
123
129
  an_instance_of(Gecode::Raw::Space),
124
- an_instance_of(Gecode::Raw::IntVarArray), rhs, strength)
130
+ an_instance_of(Gecode::Raw::IntVarArray),
131
+ rhs, strength, kind)
125
132
  Gecode::Raw.should_receive(:rel).exactly(0).times
126
133
  else
127
134
  Gecode::Raw.should_receive(:min).once.with(
128
135
  an_instance_of(Gecode::Raw::Space),
129
136
  an_instance_of(Gecode::Raw::IntVarArray),
130
- an_instance_of(Gecode::Raw::IntVar), strength)
137
+ an_instance_of(Gecode::Raw::IntVar),
138
+ strength, kind)
131
139
  Gecode::Raw.should_receive(:rel).once.with(
132
140
  an_instance_of(Gecode::Raw::Space),
133
- an_instance_of(Gecode::Raw::IntVar), relation, rhs, strength)
141
+ an_instance_of(Gecode::Raw::IntVar),
142
+ relation, rhs, strength, kind)
134
143
  end
135
144
  else
136
145
  Gecode::Raw.should_receive(:min).once.with(
137
146
  an_instance_of(Gecode::Raw::Space),
138
147
  an_instance_of(Gecode::Raw::IntVarArray),
139
- an_instance_of(Gecode::Raw::IntVar), strength)
148
+ an_instance_of(Gecode::Raw::IntVar),
149
+ strength, kind)
140
150
  Gecode::Raw.should_receive(:rel).once.with(
141
151
  an_instance_of(Gecode::Raw::Space),
142
152
  an_instance_of(Gecode::Raw::IntVar), relation, rhs,
143
153
  an_instance_of(Gecode::Raw::BoolVar),
144
- strength)
154
+ strength, kind)
145
155
  end
146
156
  end
147
157
  end
@@ -163,7 +173,7 @@ describe Gecode::Constraints::Int::Arithmetic, ' (abs)' do
163
173
  @stub = @var.abs
164
174
 
165
175
  # Creates an expectation corresponding to the specified input.
166
- @expect = lambda do |relation, rhs, strength, reif_var, negated|
176
+ @expect = lambda do |relation, rhs, strength, kind, reif_var, negated|
167
177
  @model.allow_space_access do
168
178
  rhs = an_instance_of(Gecode::Raw::IntVar) if rhs.respond_to? :bind
169
179
  if reif_var.nil?
@@ -171,26 +181,31 @@ describe Gecode::Constraints::Int::Arithmetic, ' (abs)' do
171
181
  !rhs.kind_of? Fixnum
172
182
  Gecode::Raw.should_receive(:abs).once.with(
173
183
  an_instance_of(Gecode::Raw::Space),
174
- an_instance_of(Gecode::Raw::IntVar), rhs, strength)
184
+ an_instance_of(Gecode::Raw::IntVar),
185
+ rhs, strength, kind)
175
186
  Gecode::Raw.should_receive(:rel).exactly(0).times
176
187
  else
177
188
  Gecode::Raw.should_receive(:abs).once.with(
178
189
  an_instance_of(Gecode::Raw::Space),
179
190
  an_instance_of(Gecode::Raw::IntVar),
180
- an_instance_of(Gecode::Raw::IntVar), strength)
191
+ an_instance_of(Gecode::Raw::IntVar),
192
+ strength, kind)
181
193
  Gecode::Raw.should_receive(:rel).once.with(
182
194
  an_instance_of(Gecode::Raw::Space),
183
- an_instance_of(Gecode::Raw::IntVar), relation, rhs, strength)
195
+ an_instance_of(Gecode::Raw::IntVar),
196
+ relation, rhs, strength, kind)
184
197
  end
185
198
  else
186
199
  Gecode::Raw.should_receive(:abs).once.with(
187
200
  an_instance_of(Gecode::Raw::Space),
188
201
  an_instance_of(Gecode::Raw::IntVar),
189
- an_instance_of(Gecode::Raw::IntVar), strength)
202
+ an_instance_of(Gecode::Raw::IntVar),
203
+ strength, kind)
190
204
  Gecode::Raw.should_receive(:rel).once.with(
191
205
  an_instance_of(Gecode::Raw::Space),
192
206
  an_instance_of(Gecode::Raw::IntVar), relation, rhs,
193
- an_instance_of(Gecode::Raw::BoolVar), strength)
207
+ an_instance_of(Gecode::Raw::BoolVar),
208
+ strength, kind)
194
209
  end
195
210
  end
196
211
  end
@@ -214,7 +229,7 @@ describe Gecode::Constraints::Int::Arithmetic, ' (multiplication)' do
214
229
  @target = @model.var3
215
230
 
216
231
  # Creates an expectation corresponding to the specified input.
217
- @expect = lambda do |relation, rhs, strength, reif_var, negated|
232
+ @expect = lambda do |relation, rhs, strength, kind, reif_var, negated|
218
233
  @model.allow_space_access do
219
234
  rhs = an_instance_of(Gecode::Raw::IntVar) if rhs.respond_to? :bind
220
235
  if reif_var.nil?
@@ -223,7 +238,8 @@ describe Gecode::Constraints::Int::Arithmetic, ' (multiplication)' do
223
238
  Gecode::Raw.should_receive(:mult).once.with(
224
239
  an_instance_of(Gecode::Raw::Space),
225
240
  an_instance_of(Gecode::Raw::IntVar),
226
- an_instance_of(Gecode::Raw::IntVar), rhs, strength)
241
+ an_instance_of(Gecode::Raw::IntVar),
242
+ rhs, strength, kind)
227
243
  Gecode::Raw.should_receive(:rel).exactly(0).times
228
244
  else
229
245
  Gecode::Raw.should_receive(:mult).once.with(
@@ -231,22 +247,24 @@ describe Gecode::Constraints::Int::Arithmetic, ' (multiplication)' do
231
247
  an_instance_of(Gecode::Raw::IntVar),
232
248
  an_instance_of(Gecode::Raw::IntVar),
233
249
  an_instance_of(Gecode::Raw::IntVar),
234
- strength)
250
+ strength, kind)
235
251
  Gecode::Raw.should_receive(:rel).once.with(
236
252
  an_instance_of(Gecode::Raw::Space),
237
- an_instance_of(Gecode::Raw::IntVar), relation, rhs, strength)
253
+ an_instance_of(Gecode::Raw::IntVar),
254
+ relation, rhs, strength, kind)
238
255
  end
239
256
  else
240
257
  Gecode::Raw.should_receive(:mult).once.with(
241
258
  an_instance_of(Gecode::Raw::Space),
242
259
  an_instance_of(Gecode::Raw::IntVar),
243
260
  an_instance_of(Gecode::Raw::IntVar),
244
- an_instance_of(Gecode::Raw::IntVar), strength)
261
+ an_instance_of(Gecode::Raw::IntVar),
262
+ strength, kind)
245
263
  Gecode::Raw.should_receive(:rel).once.with(
246
264
  an_instance_of(Gecode::Raw::Space),
247
265
  an_instance_of(Gecode::Raw::IntVar), relation, rhs,
248
266
  an_instance_of(Gecode::Raw::BoolVar),
249
- strength)
267
+ strength, kind)
250
268
  end
251
269
  end
252
270
  end