gecoder 0.6.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,285 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+ require File.dirname(__FILE__) + '/constraint_helper'
3
+
4
+ describe Gecode::Constraints::Set::Operation do
5
+ before do
6
+ @model = Gecode::Model.new
7
+ @set1 = @model.set_var([], 0..20)
8
+ @set2 = @model.set_var([], 0..20)
9
+ @rhs = @model.set_var([], 0..20)
10
+ @model.branch_on @model.wrap_enum([@set1, @set2, @rhs])
11
+ @constant_set = [4,9,17]
12
+ @wrapped_constant_set = @model.wrap_enum(@constant_set)
13
+
14
+ @expect = lambda do |op1, operation_type, op2, relation_type, rhs, reif_var, negated|
15
+ op1, op2, rhs = [op1, op2, rhs].map do |expression|
16
+ # Convert the expression to the corresponding expected class.
17
+ if expression.respond_to? :bind
18
+ an_instance_of(Gecode::Raw::SetVar)
19
+ else
20
+ an_instance_of(Gecode::Raw::IntSet)
21
+ end
22
+ end
23
+
24
+ Gecode::Raw.should_receive(:rel).once.with(
25
+ an_instance_of(Gecode::Raw::Space), op1, operation_type, op2,
26
+ relation_type, rhs)
27
+ end
28
+
29
+ # For options spec.
30
+ @invoke_options = lambda do |hash|
31
+ @set1.union(@set2).must_be.superset_of(@rhs, hash)
32
+ @model.solve!
33
+ end
34
+ @expect_options = lambda do |strength, reif_var|
35
+ @expect.call(@set1, Gecode::Raw::SOT_SUP, @set2, Gecode::Raw::SRT_SUP,
36
+ @rhs, reif_var, false)
37
+ end
38
+ end
39
+
40
+ Gecode::Constraints::Util::SET_OPERATION_TYPES.each_pair do |relation, type|
41
+ it "should translate #{relation} with variable operands and variable rhs" do
42
+ @expect.call(@set1, type, @set2, Gecode::Raw::SRT_SUP, @rhs, nil, false)
43
+ @set1.send(relation, @set2).must_be.superset_of(@rhs)
44
+ @model.solve!
45
+ end
46
+
47
+ it "should translate #{relation} with variable operands and constant rhs" do
48
+ @expect.call(@set1, type, @set2, Gecode::Raw::SRT_SUP, @constant_set,
49
+ nil, false)
50
+ @set1.send(relation, @set2).must_be.superset_of(@constant_set)
51
+ @model.solve!
52
+ end
53
+
54
+ it "should translate #{relation} with variable lhs, constant operand and variable rhs" do
55
+ @expect.call(@set1, type, @constant_set, Gecode::Raw::SRT_SUP, @rhs, nil,
56
+ false)
57
+ @set1.send(relation, @constant_set).must_be.superset_of(@rhs)
58
+ @model.solve!
59
+ end
60
+
61
+ it "should translate #{relation} with variable lhs, constant operand and constant rhs" do
62
+ @expect.call(@set1, type, @constant_set, Gecode::Raw::SRT_SUP,
63
+ @constant_set, nil, false)
64
+ @set1.send(relation, @constant_set).must_be.superset_of(@constant_set)
65
+ @model.solve!
66
+ end
67
+
68
+ it "should translate #{relation} with constant lhs, variable operand and variable rhs" do
69
+ @expect.call(@constant_set, type, @set2, Gecode::Raw::SRT_SUP,
70
+ @rhs, nil, false)
71
+ @wrapped_constant_set.send(relation, @set2).must_be.superset_of(@rhs)
72
+ @model.solve!
73
+ end
74
+
75
+ it "should translate #{relation} with constant lhs, variable operand and constant rhs" do
76
+ @expect.call(@constant_set, type, @set2, Gecode::Raw::SRT_SUP,
77
+ @constant_set, nil, false)
78
+ @wrapped_constant_set.send(relation, @set2).must_be.superset_of(@constant_set)
79
+ @model.solve!
80
+ end
81
+
82
+ it "should raise error for #{relation} with constant lhs, operand and rhs" do
83
+ lambda do
84
+ @wrapped_constant_set.send(relation, @constant_set).must_be.superset_of(
85
+ @constant_set)
86
+ end.should raise_error(ArgumentError)
87
+ end
88
+ end
89
+
90
+ it 'should raise error if negated' do
91
+ lambda do
92
+ @set1.union(@set2).must_not_be.subset_of(@rhs)
93
+ end.should raise_error(Gecode::MissingConstraintError)
94
+ end
95
+
96
+ it 'should constrain the sets according to the operation (variable operands, variable rhs)' do
97
+ @set1.intersection(@set2).must == @rhs
98
+ @rhs.must == @constant_set
99
+ @model.solve!.should_not be_nil
100
+ (@set1.value.to_a & @set2.value.to_a).sort.should == @constant_set
101
+ end
102
+
103
+ it 'should constrain the sets according to the operation (variable operands, constant rhs)' do
104
+ @set1.intersection(@set2).must == @constant_set
105
+ @model.solve!.should_not be_nil
106
+ (@set1.value.to_a & @set2.value.to_a).sort.should == @constant_set
107
+ end
108
+
109
+ it 'should constrain the sets according to the operation (variable lhs, constant operand and rhs)' do
110
+ @set1.union(@constant_set).must == @constant_set
111
+ @model.solve!.should_not be_nil
112
+ (@set1.value.to_a + @constant_set).uniq.sort.should == @constant_set.sort
113
+ end
114
+
115
+ it 'should constrain the sets according to the operation (variable lhs and rhs, constant operand)' do
116
+ @set1.union(@constant_set).must == @rhs
117
+ @model.solve!.should_not be_nil
118
+ (@set1.value.to_a + @constant_set).uniq.sort.should == @rhs.value.to_a.sort
119
+ end
120
+
121
+ it 'should constrain the sets according to the operation (constant lhs, variable operand and rhs)' do
122
+ @wrapped_constant_set.minus(@set2).must == @rhs
123
+ @model.solve!.should_not be_nil
124
+ (@constant_set - @set2.value.to_a).sort.should == @rhs.value.sort
125
+ end
126
+
127
+ it 'should constrain the sets according to the operation (constant lhs and rhs, variable operand)' do
128
+ @wrapped_constant_set.minus(@set2).must == @constant_set
129
+ @model.solve!.should_not be_nil
130
+ (@constant_set - @set2.value.to_a).sort.should == @constant_set
131
+ end
132
+
133
+ it_should_behave_like 'non-reifiable set constraint'
134
+ end
135
+
136
+ describe 'set enum operation constraint', :shared => true do
137
+ include GecodeR::Specs::SetHelper
138
+
139
+ before do
140
+ @expect = lambda do |enum, operation_type, relation, rhs, reif_var, negated|
141
+ if rhs.respond_to? :bind
142
+ expected_target = [an_instance_of(Gecode::Raw::SetVar)]
143
+ relation_constraint = :rel
144
+ else
145
+ expected_target = expect_constant_set(rhs)
146
+ relation_constraint = :dom
147
+ end
148
+
149
+ if reif_var.nil?
150
+ if !negated and relation == Gecode::Raw::IRT_EQ and
151
+ !rhs.kind_of? Enumerable
152
+ Gecode::Raw.should_receive(:rel).once.with(
153
+ an_instance_of(Gecode::Raw::Space), operation_type,
154
+ an_instance_of(Gecode::Raw::SetVarArray),
155
+ *expected_target)
156
+ Gecode::Raw.should_receive(:dom).exactly(0).times
157
+ else
158
+ if relation_constraint == :rel
159
+ Gecode::Raw.should_receive(:rel).twice
160
+ else
161
+ Gecode::Raw.should_receive(:rel).once.with(
162
+ an_instance_of(Gecode::Raw::Space), operation_type,
163
+ an_instance_of(Gecode::Raw::SetVarArray),
164
+ an_instance_of(Gecode::Raw::SetVar))
165
+ Gecode::Raw.should_receive(relation_constraint).at_most(:twice)
166
+ end
167
+ end
168
+ else
169
+ if relation_constraint == :rel
170
+ Gecode::Raw.should_receive(:rel).twice
171
+ else
172
+ Gecode::Raw.should_receive(:rel).once.with(
173
+ an_instance_of(Gecode::Raw::Space), operation_type,
174
+ an_instance_of(Gecode::Raw::SetVarArray),
175
+ an_instance_of(Gecode::Raw::SetVar))
176
+ expected_target << an_instance_of(Gecode::Raw::BoolVar)
177
+ Gecode::Raw.should_receive(relation_constraint).once.with(
178
+ an_instance_of(Gecode::Raw::Space),
179
+ an_instance_of(Gecode::Raw::SetVar), relation, *expected_target)
180
+ end
181
+ end
182
+ end
183
+
184
+ # For composite spec.
185
+ @invoke_relation = lambda do |relation, target, negated|
186
+ if negated
187
+ @stub.must_not.send(relation, target)
188
+ else
189
+ @stub.must.send(relation, target)
190
+ end
191
+ @model.solve!
192
+ end
193
+ @expect_relation = lambda do |relation, target, negated|
194
+ @expect.call(@sets, @operation_type, relation, target, nil, negated)
195
+ end
196
+
197
+ # For options spec.
198
+ @invoke_options = lambda do |hash|
199
+ @stub.must_be.superset_of(@rhs, hash)
200
+ @model.solve!
201
+ end
202
+ @expect_options = lambda do |strength, reif_var|
203
+ @expect.call(@sets, @operation_type, Gecode::Raw::SRT_SUP, @rhs,
204
+ reif_var, false)
205
+ end
206
+ end
207
+
208
+ it_should_behave_like 'reifiable set constraint'
209
+ it_should_behave_like 'composite set constraint'
210
+ end
211
+
212
+ describe Gecode::Constraints::SetEnum::Operation, ' (union)' do
213
+ before do
214
+ @model = Gecode::Model.new
215
+ @sets = @model.set_var_array(10, [], 0..20)
216
+ @target = @rhs = @model.set_var([], 0..20)
217
+ @model.branch_on @sets
218
+
219
+ @stub = @sets.union
220
+ @operation_type = Gecode::Raw::SOT_UNION
221
+ end
222
+
223
+ it 'should constrain the union of the sets' do
224
+ @sets.union.must_be.subset_of [1,4,17]
225
+ @sets.union.must_be.superset_of 1
226
+ @model.solve!.should_not be_nil
227
+ union = @sets.values.inject([]){ |union, set| union += set.to_a }.uniq
228
+ union.should include(1)
229
+ (union - [1,4,17]).should be_empty
230
+ end
231
+
232
+ it_should_behave_like 'set enum operation constraint'
233
+ end
234
+
235
+ describe Gecode::Constraints::SetEnum::Operation, ' (intersection)' do
236
+ before do
237
+ @model = Gecode::Model.new
238
+ @sets = @model.set_var_array(10, [], 0..20)
239
+ @target = @rhs = @model.set_var([], 0..20)
240
+ @model.branch_on @sets
241
+
242
+ @stub = @sets.intersection
243
+ @operation_type = Gecode::Raw::SOT_INTER
244
+ end
245
+
246
+ it 'should constrain the intersection of the sets' do
247
+ @sets.intersection.must_be.subset_of [1,4,17]
248
+ @sets.intersection.must_be.superset_of [1]
249
+ @model.solve!.should_not be_nil
250
+ intersection = @sets.values.inject(nil) do |intersection, set|
251
+ next set.to_a if intersection.nil?
252
+ intersection &= set.to_a
253
+ end.uniq
254
+ intersection.should include(1)
255
+ (intersection - [1,4,17]).should be_empty
256
+ end
257
+
258
+ it_should_behave_like 'set enum operation constraint'
259
+ end
260
+
261
+ describe Gecode::Constraints::SetEnum::Operation, ' (disjoint union)' do
262
+ before do
263
+ @model = Gecode::Model.new
264
+ @sets = @model.set_var_array(10, [], 0..20)
265
+ @target = @rhs = @model.set_var([], 0..20)
266
+ @model.branch_on @sets
267
+
268
+ @stub = @sets.disjoint_union
269
+ @operation_type = Gecode::Raw::SOT_DUNION
270
+ end
271
+
272
+ it 'should constrain the disjoint union of the sets' do
273
+ @sets.disjoint_union.must_be.subset_of [1,4,17]
274
+ @sets.disjoint_union.must_be.superset_of [1]
275
+ @model.solve!.should_not be_nil
276
+ disjoint_union = @sets.values.inject([]) do |union, set|
277
+ intersection = union & set.to_a
278
+ union += set.to_a - intersection
279
+ end.uniq
280
+ disjoint_union.should include(1)
281
+ (disjoint_union - [1,4,17]).should be_empty
282
+ end
283
+
284
+ it_should_behave_like 'set enum operation constraint'
285
+ end
@@ -103,6 +103,11 @@ describe Gecode::SetEnumMethods do
103
103
  @set_enum.to_set_var_array.should be_kind_of(Gecode::Raw::SetVarArray)
104
104
  end
105
105
  end
106
+
107
+ it 'should compute the smallest upper bound union range' do
108
+ @set_enum.upper_bound_range.should == (0..1)
109
+ (@set_enum << @model.set_var([], -4..4)).upper_bound_range.should == (-4..4)
110
+ end
106
111
  end
107
112
 
108
113
  describe Gecode::FixnumEnumMethods do
data/specs/model.rb CHANGED
@@ -94,6 +94,13 @@ describe Gecode::Model, ' (set creation)' do
94
94
  @lower_card = 1
95
95
  @upper_card = 3
96
96
  end
97
+
98
+ it 'should allow the creation of set variables without specified bounds' do
99
+ var = @model.set_var
100
+ var.lower_bound.size.should == 0
101
+ var.upper_bound.min.should == Gecode::Raw::Limits::Set::INT_MIN
102
+ var.upper_bound.max.should == Gecode::Raw::Limits::Set::INT_MAX
103
+ end
97
104
 
98
105
  it 'should allow the creation of set variables with glb range and lub range' do
99
106
  @model.set_var(@glb_range, @lub_range).should have_bounds(@glb_range,
@@ -0,0 +1,6 @@
1
+
2
+ require 'mkmf'
3
+ find_header("rust_conversions.hh", "./include" )
4
+ eval File.open("out.rb").readlines.to_s
5
+ create_makefile("Gecode")
6
+
@@ -0,0 +1,627 @@
1
+
2
+ require 'rust'
3
+
4
+ Rust::Bindings::create_bindings Rust::Bindings::LangCxx, "Gecode" do |b|
5
+ b.include_header '/home/andreas/conprog/gecode-1.3.1/gecode/int/view.icc', Rust::Bindings::HeaderGlobal
6
+ b.add_namespace "Gecode", "" do |ns|
7
+ ns.add_cxx_class "ViewRanges" do |klass|
8
+ klass.add_constructor
9
+ klass.add_constructor do |method|
10
+ method.add_parameter "View&", "x"
11
+ end
12
+ klass.add_method "init", "void" do |method|
13
+ method.add_parameter "View&", "x"
14
+ end
15
+ klass.add_method "operator", "bool"
16
+ klass.add_method "min", "int"
17
+ klass.add_method "max", "int"
18
+ klass.add_method "width", "int"
19
+ end
20
+ ns.add_cxx_class "ViewValues" do |klass|
21
+ klass.add_constructor
22
+ klass.add_constructor do |method|
23
+ method.add_parameter "View&", "x"
24
+ end
25
+ klass.add_method "init", "void" do |method|
26
+ method.add_parameter "View&", "x"
27
+ end
28
+ end
29
+ ns.add_cxx_class "IntView" do |klass|
30
+ klass.add_constructor
31
+ klass.add_constructor do |method|
32
+ method.add_parameter "IntVar&", "x"
33
+ end
34
+ klass.add_method "min", "int"
35
+ klass.add_method "max", "int"
36
+ klass.add_method "med", "int"
37
+ klass.add_method "val", "int"
38
+ klass.add_method "size", "int"
39
+ klass.add_method "width", "int"
40
+ klass.add_method "regret_min", "int"
41
+ klass.add_method "regret_max", "int"
42
+ klass.add_method "range", "bool"
43
+ klass.add_method "assigned", "bool"
44
+ klass.add_method "in", "bool" do |method|
45
+ method.add_parameter "int", "n"
46
+ end
47
+ klass.add_method "in", "bool" do |method|
48
+ method.add_parameter "double", "n"
49
+ end
50
+ klass.add_method "lq", "ModEvent" do |method|
51
+ method.add_parameter "Space*", "home"
52
+ method.add_parameter "int", "n"
53
+ end
54
+ klass.add_method "lq", "ModEvent" do |method|
55
+ method.add_parameter "Space*", "home"
56
+ method.add_parameter "double", "n"
57
+ end
58
+ klass.add_method "le", "ModEvent" do |method|
59
+ method.add_parameter "Space*", "home"
60
+ method.add_parameter "int", "n"
61
+ end
62
+ klass.add_method "le", "ModEvent" do |method|
63
+ method.add_parameter "Space*", "home"
64
+ method.add_parameter "double", "n"
65
+ end
66
+ klass.add_method "gq", "ModEvent" do |method|
67
+ method.add_parameter "Space*", "home"
68
+ method.add_parameter "int", "n"
69
+ end
70
+ klass.add_method "gq", "ModEvent" do |method|
71
+ method.add_parameter "Space*", "home"
72
+ method.add_parameter "double", "n"
73
+ end
74
+ klass.add_method "gr", "ModEvent" do |method|
75
+ method.add_parameter "Space*", "home"
76
+ method.add_parameter "int", "n"
77
+ end
78
+ klass.add_method "gr", "ModEvent" do |method|
79
+ method.add_parameter "Space*", "home"
80
+ method.add_parameter "double", "n"
81
+ end
82
+ klass.add_method "nq", "ModEvent" do |method|
83
+ method.add_parameter "Space*", "home"
84
+ method.add_parameter "int", "n"
85
+ end
86
+ klass.add_method "nq", "ModEvent" do |method|
87
+ method.add_parameter "Space*", "home"
88
+ method.add_parameter "double", "n"
89
+ end
90
+ klass.add_method "eq", "ModEvent" do |method|
91
+ method.add_parameter "Space*", "home"
92
+ method.add_parameter "int", "n"
93
+ end
94
+ klass.add_method "eq", "ModEvent" do |method|
95
+ method.add_parameter "Space*", "home"
96
+ method.add_parameter "double", "n"
97
+ end
98
+ end
99
+ ns.add_cxx_class "I" do |klass|
100
+ klass.add_method "narrow", "ModEvent" do |method|
101
+ method.add_parameter "Space*", "home"
102
+ method.add_parameter "I&", "i"
103
+ end
104
+ klass.add_method "update", "void" do |method|
105
+ method.add_parameter "Space*", "home"
106
+ method.add_parameter "bool", "share"
107
+ method.add_parameter "IntView&", "x"
108
+ end
109
+ end
110
+ ns.add_cxx_class "MinusView" do |klass|
111
+ klass.add_constructor
112
+ klass.add_constructor do |method|
113
+ method.add_parameter "IntView&", "x"
114
+ end
115
+ klass.add_method "init", "void" do |method|
116
+ method.add_parameter "IntView&", "x"
117
+ end
118
+ klass.add_method "min", "int"
119
+ klass.add_method "max", "int"
120
+ klass.add_method "med", "int"
121
+ klass.add_method "val", "int"
122
+ klass.add_method "size", "int"
123
+ klass.add_method "width", "int"
124
+ klass.add_method "regret_min", "int"
125
+ klass.add_method "regret_max", "int"
126
+ klass.add_method "range", "bool"
127
+ klass.add_method "assigned", "bool"
128
+ klass.add_method "in", "bool" do |method|
129
+ method.add_parameter "int", "n"
130
+ end
131
+ klass.add_method "in", "bool" do |method|
132
+ method.add_parameter "double", "n"
133
+ end
134
+ klass.add_method "lq", "ModEvent" do |method|
135
+ method.add_parameter "Space*", "home"
136
+ method.add_parameter "int", "n"
137
+ end
138
+ klass.add_method "lq", "ModEvent" do |method|
139
+ method.add_parameter "Space*", "home"
140
+ method.add_parameter "double", "n"
141
+ end
142
+ klass.add_method "le", "ModEvent" do |method|
143
+ method.add_parameter "Space*", "home"
144
+ method.add_parameter "int", "n"
145
+ end
146
+ klass.add_method "le", "ModEvent" do |method|
147
+ method.add_parameter "Space*", "home"
148
+ method.add_parameter "double", "n"
149
+ end
150
+ klass.add_method "gq", "ModEvent" do |method|
151
+ method.add_parameter "Space*", "home"
152
+ method.add_parameter "int", "n"
153
+ end
154
+ klass.add_method "gq", "ModEvent" do |method|
155
+ method.add_parameter "Space*", "home"
156
+ method.add_parameter "double", "n"
157
+ end
158
+ klass.add_method "gr", "ModEvent" do |method|
159
+ method.add_parameter "Space*", "home"
160
+ method.add_parameter "int", "n"
161
+ end
162
+ klass.add_method "gr", "ModEvent" do |method|
163
+ method.add_parameter "Space*", "home"
164
+ method.add_parameter "double", "n"
165
+ end
166
+ klass.add_method "nq", "ModEvent" do |method|
167
+ method.add_parameter "Space*", "home"
168
+ method.add_parameter "int", "n"
169
+ end
170
+ klass.add_method "nq", "ModEvent" do |method|
171
+ method.add_parameter "Space*", "home"
172
+ method.add_parameter "double", "n"
173
+ end
174
+ klass.add_method "eq", "ModEvent" do |method|
175
+ method.add_parameter "Space*", "home"
176
+ method.add_parameter "int", "n"
177
+ end
178
+ klass.add_method "eq", "ModEvent" do |method|
179
+ method.add_parameter "Space*", "home"
180
+ method.add_parameter "double", "n"
181
+ end
182
+ end
183
+ ns.add_cxx_class "I" do |klass|
184
+ klass.add_method "narrow", "ModEvent" do |method|
185
+ method.add_parameter "Space*", "home"
186
+ method.add_parameter "I&", "i"
187
+ end
188
+ klass.add_method "pme", "ModEvent" do |method|
189
+ method.add_parameter "Propagator*", "p"
190
+ end
191
+ klass.add_method "pme", "PropModEvent" do |method|
192
+ method.add_parameter "ModEvent", "me"
193
+ end
194
+ klass.add_method "subscribe", "void" do |method|
195
+ method.add_parameter "Space*", "home"
196
+ method.add_parameter "Propagator*", "p"
197
+ method.add_parameter "PropCond", "pc"
198
+ method.add_parameter "bool", "process"
199
+ end
200
+ klass.add_method "cancel", "void" do |method|
201
+ method.add_parameter "Space*", "home"
202
+ method.add_parameter "Propagator*", "p"
203
+ method.add_parameter "PropCond", "pc"
204
+ end
205
+ klass.add_method "update", "void" do |method|
206
+ method.add_parameter "Space*", "home"
207
+ method.add_parameter "bool", "share"
208
+ method.add_parameter "MinusView&", "x"
209
+ end
210
+ klass.add_method "same", "bool" do |method|
211
+ method.add_parameter "Int::MinusViewInt::&", "x"
212
+ method.add_parameter "Int::MinusViewInt::&", "y"
213
+ end
214
+ klass.add_method "before", "bool" do |method|
215
+ method.add_parameter "Int::MinusViewInt::&", "x"
216
+ method.add_parameter "Int::MinusViewInt::&", "y"
217
+ end
218
+ end
219
+ ns.add_cxx_class "OffsetView" do |klass|
220
+ klass.add_constructor
221
+ klass.add_constructor do |method|
222
+ method.add_parameter "IntView&", "x"
223
+ method.add_parameter "int", "c"
224
+ end
225
+ klass.add_method "init", "void" do |method|
226
+ method.add_parameter "IntView&", "x"
227
+ method.add_parameter "int", "c"
228
+ end
229
+ klass.add_method "offset", "int"
230
+ klass.add_method "min", "int"
231
+ klass.add_method "max", "int"
232
+ klass.add_method "med", "int"
233
+ klass.add_method "val", "int"
234
+ klass.add_method "size", "int"
235
+ klass.add_method "width", "int"
236
+ klass.add_method "regret_min", "int"
237
+ klass.add_method "regret_max", "int"
238
+ klass.add_method "range", "bool"
239
+ klass.add_method "assigned", "bool"
240
+ klass.add_method "in", "bool" do |method|
241
+ method.add_parameter "int", "n"
242
+ end
243
+ klass.add_method "in", "bool" do |method|
244
+ method.add_parameter "double", "n"
245
+ end
246
+ klass.add_method "lq", "ModEvent" do |method|
247
+ method.add_parameter "Space*", "home"
248
+ method.add_parameter "int", "n"
249
+ end
250
+ klass.add_method "lq", "ModEvent" do |method|
251
+ method.add_parameter "Space*", "home"
252
+ method.add_parameter "double", "n"
253
+ end
254
+ klass.add_method "le", "ModEvent" do |method|
255
+ method.add_parameter "Space*", "home"
256
+ method.add_parameter "int", "n"
257
+ end
258
+ klass.add_method "le", "ModEvent" do |method|
259
+ method.add_parameter "Space*", "home"
260
+ method.add_parameter "double", "n"
261
+ end
262
+ klass.add_method "gq", "ModEvent" do |method|
263
+ method.add_parameter "Space*", "home"
264
+ method.add_parameter "int", "n"
265
+ end
266
+ klass.add_method "gq", "ModEvent" do |method|
267
+ method.add_parameter "Space*", "home"
268
+ method.add_parameter "double", "n"
269
+ end
270
+ klass.add_method "gr", "ModEvent" do |method|
271
+ method.add_parameter "Space*", "home"
272
+ method.add_parameter "int", "n"
273
+ end
274
+ klass.add_method "gr", "ModEvent" do |method|
275
+ method.add_parameter "Space*", "home"
276
+ method.add_parameter "double", "n"
277
+ end
278
+ klass.add_method "nq", "ModEvent" do |method|
279
+ method.add_parameter "Space*", "home"
280
+ method.add_parameter "int", "n"
281
+ end
282
+ klass.add_method "nq", "ModEvent" do |method|
283
+ method.add_parameter "Space*", "home"
284
+ method.add_parameter "double", "n"
285
+ end
286
+ klass.add_method "eq", "ModEvent" do |method|
287
+ method.add_parameter "Space*", "home"
288
+ method.add_parameter "int", "n"
289
+ end
290
+ klass.add_method "eq", "ModEvent" do |method|
291
+ method.add_parameter "Space*", "home"
292
+ method.add_parameter "double", "n"
293
+ end
294
+ end
295
+ ns.add_cxx_class "I" do |klass|
296
+ klass.add_method "narrow", "ModEvent" do |method|
297
+ method.add_parameter "Space*", "home"
298
+ method.add_parameter "I&", "i"
299
+ end
300
+ klass.add_method "pme", "ModEvent" do |method|
301
+ method.add_parameter "Propagator*", "p"
302
+ end
303
+ klass.add_method "pme", "PropModEvent" do |method|
304
+ method.add_parameter "ModEvent", "me"
305
+ end
306
+ klass.add_method "subscribe", "void" do |method|
307
+ method.add_parameter "Space*", "home"
308
+ method.add_parameter "Propagator*", "p"
309
+ method.add_parameter "PropCond", "pc"
310
+ method.add_parameter "bool", "process"
311
+ end
312
+ klass.add_method "cancel", "void" do |method|
313
+ method.add_parameter "Space*", "home"
314
+ method.add_parameter "Propagator*", "p"
315
+ method.add_parameter "PropCond", "pc"
316
+ end
317
+ klass.add_method "update", "void" do |method|
318
+ method.add_parameter "Space*", "home"
319
+ method.add_parameter "bool", "share"
320
+ method.add_parameter "OffsetView&", "x"
321
+ end
322
+ klass.add_method "same", "bool" do |method|
323
+ method.add_parameter "Int::OffsetViewInt::&", "x"
324
+ method.add_parameter "Int::OffsetViewInt::&", "y"
325
+ end
326
+ klass.add_method "before", "bool" do |method|
327
+ method.add_parameter "Int::OffsetViewInt::&", "x"
328
+ method.add_parameter "Int::OffsetViewInt::&", "y"
329
+ end
330
+ end
331
+ ns.add_cxx_class "ScaleView" do |klass|
332
+ klass.add_constructor
333
+ klass.add_constructor do |method|
334
+ method.add_parameter "int", "b"
335
+ method.add_parameter "IntView&", "y"
336
+ end
337
+ klass.add_method "init", "void" do |method|
338
+ method.add_parameter "int", "b"
339
+ method.add_parameter "IntView&", "y"
340
+ end
341
+ klass.add_method "scale", "int"
342
+ klass.add_method "min", "Val"
343
+ klass.add_method "max", "Val"
344
+ klass.add_method "med", "Val"
345
+ klass.add_method "val", "Val"
346
+ klass.add_method "size", "UnsVal"
347
+ klass.add_method "width", "UnsVal"
348
+ klass.add_method "regret_min", "UnsVal"
349
+ klass.add_method "regret_max", "UnsVal"
350
+ klass.add_method "range", "bool"
351
+ klass.add_method "assigned", "bool"
352
+ klass.add_method "in", "bool" do |method|
353
+ method.add_parameter "Val", "n"
354
+ end
355
+ klass.add_method "lq", "ModEvent" do |method|
356
+ method.add_parameter "Space*", "home"
357
+ method.add_parameter "Val", "n"
358
+ end
359
+ klass.add_method "le", "ModEvent" do |method|
360
+ method.add_parameter "Space*", "home"
361
+ method.add_parameter "Val", "n"
362
+ end
363
+ klass.add_method "gq", "ModEvent" do |method|
364
+ method.add_parameter "Space*", "home"
365
+ method.add_parameter "Val", "n"
366
+ end
367
+ klass.add_method "gr", "ModEvent" do |method|
368
+ method.add_parameter "Space*", "home"
369
+ method.add_parameter "Val", "n"
370
+ end
371
+ klass.add_method "nq", "ModEvent" do |method|
372
+ method.add_parameter "Space*", "home"
373
+ method.add_parameter "Val", "n"
374
+ end
375
+ klass.add_method "eq", "ModEvent" do |method|
376
+ method.add_parameter "Space*", "home"
377
+ method.add_parameter "Val", "n"
378
+ end
379
+ klass.add_method "pme", "ModEvent" do |method|
380
+ method.add_parameter "Propagator*", "p"
381
+ end
382
+ klass.add_method "pme", "PropModEvent" do |method|
383
+ method.add_parameter "ModEvent", "me"
384
+ end
385
+ klass.add_method "subscribe", "void" do |method|
386
+ method.add_parameter "Space*", "home"
387
+ method.add_parameter "Propagator*", "p"
388
+ method.add_parameter "PropCond", "pc"
389
+ method.add_parameter "bool", "process"
390
+ end
391
+ klass.add_method "cancel", "void" do |method|
392
+ method.add_parameter "Space*", "home"
393
+ method.add_parameter "Propagator*", "p"
394
+ method.add_parameter "PropCond", "pc"
395
+ end
396
+ klass.add_method "update", "void" do |method|
397
+ method.add_parameter "Space*", "home"
398
+ method.add_parameter "bool", "share"
399
+ method.add_parameter "Val", "par2"
400
+ method.add_parameter "x", "par3"
401
+ end
402
+ end
403
+ ns.add_cxx_class "ConstIntView" do |klass|
404
+ klass.add_constructor
405
+ klass.add_constructor do |method|
406
+ method.add_parameter "int", "n"
407
+ end
408
+ klass.add_method "init", "void" do |method|
409
+ method.add_parameter "int", "n"
410
+ end
411
+ klass.add_method "min", "int"
412
+ klass.add_method "max", "int"
413
+ klass.add_method "med", "int"
414
+ klass.add_method "val", "int"
415
+ klass.add_method "size", "int"
416
+ klass.add_method "width", "int"
417
+ klass.add_method "regret_min", "int"
418
+ klass.add_method "regret_max", "int"
419
+ klass.add_method "range", "bool"
420
+ klass.add_method "assigned", "bool"
421
+ klass.add_method "in", "bool" do |method|
422
+ method.add_parameter "int", "n"
423
+ end
424
+ klass.add_method "in", "bool" do |method|
425
+ method.add_parameter "double", "n"
426
+ end
427
+ klass.add_method "lq", "ModEvent" do |method|
428
+ method.add_parameter "Space*", "home"
429
+ method.add_parameter "int", "n"
430
+ end
431
+ klass.add_method "lq", "ModEvent" do |method|
432
+ method.add_parameter "Space*", "home"
433
+ method.add_parameter "double", "n"
434
+ end
435
+ klass.add_method "le", "ModEvent" do |method|
436
+ method.add_parameter "Space*", "home"
437
+ method.add_parameter "int", "n"
438
+ end
439
+ klass.add_method "le", "ModEvent" do |method|
440
+ method.add_parameter "Space*", "home"
441
+ method.add_parameter "double", "n"
442
+ end
443
+ klass.add_method "gq", "ModEvent" do |method|
444
+ method.add_parameter "Space*", "home"
445
+ method.add_parameter "int", "n"
446
+ end
447
+ klass.add_method "gq", "ModEvent" do |method|
448
+ method.add_parameter "Space*", "home"
449
+ method.add_parameter "double", "n"
450
+ end
451
+ klass.add_method "gr", "ModEvent" do |method|
452
+ method.add_parameter "Space*", "home"
453
+ method.add_parameter "int", "n"
454
+ end
455
+ klass.add_method "gr", "ModEvent" do |method|
456
+ method.add_parameter "Space*", "home"
457
+ method.add_parameter "double", "n"
458
+ end
459
+ klass.add_method "nq", "ModEvent" do |method|
460
+ method.add_parameter "Space*", "home"
461
+ method.add_parameter "int", "n"
462
+ end
463
+ klass.add_method "nq", "ModEvent" do |method|
464
+ method.add_parameter "Space*", "home"
465
+ method.add_parameter "double", "n"
466
+ end
467
+ klass.add_method "eq", "ModEvent" do |method|
468
+ method.add_parameter "Space*", "home"
469
+ method.add_parameter "int", "n"
470
+ end
471
+ klass.add_method "eq", "ModEvent" do |method|
472
+ method.add_parameter "Space*", "home"
473
+ method.add_parameter "double", "n"
474
+ end
475
+ end
476
+ ns.add_cxx_class "I" do |klass|
477
+ klass.add_method "narrow", "ModEvent" do |method|
478
+ method.add_parameter "Space*", "home"
479
+ method.add_parameter "I&", "i"
480
+ end
481
+ klass.add_method "pme", "ModEvent" do |method|
482
+ method.add_parameter "Propagator*", "p"
483
+ end
484
+ klass.add_method "pme", "PropModEvent" do |method|
485
+ method.add_parameter "ModEvent", "me"
486
+ end
487
+ klass.add_method "subscribe", "void" do |method|
488
+ method.add_parameter "Space*", "home"
489
+ method.add_parameter "Propagator*", "p"
490
+ method.add_parameter "PropCond", "pc"
491
+ method.add_parameter "bool", "process"
492
+ end
493
+ klass.add_method "cancel", "void" do |method|
494
+ method.add_parameter "Space*", "home"
495
+ method.add_parameter "Propagator*", "p"
496
+ method.add_parameter "PropCond", "pc"
497
+ end
498
+ klass.add_method "update", "void" do |method|
499
+ method.add_parameter "Space*", "home"
500
+ method.add_parameter "bool", "share"
501
+ method.add_parameter "ConstIntView&", "x"
502
+ end
503
+ klass.add_method "same", "bool" do |method|
504
+ method.add_parameter "Int::ConstIntViewInt::&", "x"
505
+ method.add_parameter "Int::ConstIntViewInt::&", "y"
506
+ end
507
+ end
508
+ ns.add_cxx_class "View" do |klass|
509
+ klass.add_method "before", "bool" do |method|
510
+ method.add_parameter "Int::ConstIntViewInt::&", "x"
511
+ method.add_parameter "Int::ConstIntViewInt::&", "y"
512
+ end
513
+ end
514
+ ns.add_cxx_class "ViewArray" do |klass|
515
+ klass.add_method "BoolView", "explicit" do |method|
516
+ method.add_parameter "IntView&", "x"
517
+ end
518
+ klass.add_method "zero", "bool"
519
+ klass.add_method "one", "bool"
520
+ klass.add_method "none", "bool"
521
+ klass.add_method "t_one", "ModEvent" do |method|
522
+ method.add_parameter "Space*", "home"
523
+ end
524
+ klass.add_method "t_zero", "ModEvent" do |method|
525
+ method.add_parameter "Space*", "home"
526
+ end
527
+ klass.add_method "t_one_none", "void" do |method|
528
+ method.add_parameter "Space*", "home"
529
+ end
530
+ klass.add_method "t_zero_none", "void" do |method|
531
+ method.add_parameter "Space*", "home"
532
+ end
533
+ klass.add_method "update", "void" do |method|
534
+ method.add_parameter "Space*", "home"
535
+ method.add_parameter "bool", "share"
536
+ method.add_parameter "BoolView&", "x"
537
+ end
538
+ end
539
+ ns.add_cxx_class "NegBoolView" do |klass|
540
+ klass.add_constructor
541
+ klass.add_constructor do |method|
542
+ method.add_parameter "BoolView&", "b"
543
+ end
544
+ klass.add_method "init", "void" do |method|
545
+ method.add_parameter "BoolView&", "b"
546
+ end
547
+ klass.add_method "zero", "bool"
548
+ klass.add_method "one", "bool"
549
+ klass.add_method "none", "bool"
550
+ klass.add_method "t_one", "ModEvent" do |method|
551
+ method.add_parameter "Space*", "home"
552
+ end
553
+ klass.add_method "t_zero", "ModEvent" do |method|
554
+ method.add_parameter "Space*", "home"
555
+ end
556
+ klass.add_method "t_one_none", "void" do |method|
557
+ method.add_parameter "Space*", "home"
558
+ end
559
+ klass.add_method "t_zero_none", "void" do |method|
560
+ method.add_parameter "Space*", "home"
561
+ end
562
+ klass.add_method "min", "int"
563
+ klass.add_method "max", "int"
564
+ klass.add_method "val", "int"
565
+ klass.add_method "assigned", "bool"
566
+ klass.add_method "pme", "ModEvent" do |method|
567
+ method.add_parameter "Propagator*", "p"
568
+ end
569
+ klass.add_method "pme", "PropModEvent" do |method|
570
+ method.add_parameter "ModEvent", "me"
571
+ end
572
+ klass.add_method "subscribe", "void" do |method|
573
+ method.add_parameter "Space*", "home"
574
+ method.add_parameter "Propagator*", "p"
575
+ method.add_parameter "PropCond", "pc"
576
+ method.add_parameter "bool", "process"
577
+ end
578
+ klass.add_method "cancel", "void" do |method|
579
+ method.add_parameter "Space*", "home"
580
+ method.add_parameter "Propagator*", "p"
581
+ method.add_parameter "PropCond", "pc"
582
+ end
583
+ klass.add_method "update", "void" do |method|
584
+ method.add_parameter "Space*", "home"
585
+ method.add_parameter "bool", "share"
586
+ method.add_parameter "NegBoolView&", "x"
587
+ end
588
+ klass.add_method "bool_test", "BoolTest" do |method|
589
+ method.add_parameter "BoolView&", "b0"
590
+ method.add_parameter "BoolView&", "b1"
591
+ end
592
+ klass.add_method "bool_test", "BoolTest" do |method|
593
+ method.add_parameter "BoolView&", "b0"
594
+ method.add_parameter "NegBoolView&", "b1"
595
+ end
596
+ klass.add_method "bool_test", "BoolTest" do |method|
597
+ method.add_parameter "NegBoolView&", "b0"
598
+ method.add_parameter "BoolView&", "b1"
599
+ end
600
+ klass.add_method "bool_test", "BoolTest" do |method|
601
+ method.add_parameter "NegBoolView&", "b0"
602
+ method.add_parameter "NegBoolView&", "b1"
603
+ end
604
+ klass.add_method "same", "bool" do |method|
605
+ method.add_parameter "Int::NegBoolViewInt::&", "x"
606
+ method.add_parameter "Int::NegBoolViewInt::&", "y"
607
+ end
608
+ klass.add_method "before", "bool" do |method|
609
+ method.add_parameter "Int::NegBoolViewInt::&", "x"
610
+ method.add_parameter "Int::NegBoolViewInt::&", "y"
611
+ end
612
+ end
613
+ ns.add_cxx_class "ViewVarTraits" do |klass|
614
+ klass.add_method "vx", "Gecode::Int::IntView" do |method|
615
+ method.add_parameter "x", "par0"
616
+ end
617
+ end
618
+ ns.add_cxx_class "View" do |klass|
619
+ klass.add_method "rtest_eq_bnd", "RelTest" do |method|
620
+ method.add_parameter "View", "x"
621
+ method.add_parameter "View", "y"
622
+ end
623
+ end
624
+
625
+ end
626
+ end
627
+