gecoder-with-gecode 0.8.2-mswin32 → 0.8.3-mswin32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES +14 -0
- data/lib/gecode.dll +0 -0
- data/lib/gecoder/bindings/bindings.rb +104 -46
- data/lib/gecoder/interface/binding_changes.rb +1 -301
- data/lib/gecoder/interface/branch.rb +15 -11
- data/lib/gecoder/interface/constraints.rb +38 -0
- data/lib/gecoder/interface/constraints/bool/boolean.rb +56 -52
- data/lib/gecoder/interface/constraints/bool/channel.rb +1 -16
- data/lib/gecoder/interface/constraints/bool_enum/channel.rb +13 -8
- data/lib/gecoder/interface/constraints/bool_enum/extensional.rb +48 -0
- data/lib/gecoder/interface/constraints/extensional_regexp.rb +101 -0
- data/lib/gecoder/interface/constraints/int/channel.rb +1 -13
- data/lib/gecoder/interface/constraints/int_enum/channel.rb +15 -35
- data/lib/gecoder/interface/constraints/int_enum/extensional.rb +130 -0
- data/lib/gecoder/interface/constraints/set/channel.rb +54 -0
- data/lib/gecoder/interface/constraints/set_enum/channel.rb +37 -6
- data/lib/gecoder/interface/constraints/set_var_constraints.rb +1 -0
- data/lib/gecoder/interface/model.rb +110 -85
- data/lib/gecoder/interface/variables.rb +3 -21
- data/lib/gecoder/version.rb +1 -1
- data/specs/branch.rb +16 -1
- data/specs/constraints/bool_enum_relation.rb +6 -6
- data/specs/constraints/boolean.rb +31 -25
- data/specs/constraints/channel.rb +102 -4
- data/specs/constraints/extensional.rb +185 -2
- data/specs/constraints/reification_sugar.rb +2 -46
- data/specs/model.rb +85 -7
- data/tasks/dependencies.txt +1 -0
- data/vendor/rust/rust/class.rb +33 -35
- data/vendor/rust/rust/templates/ClassDeclarations.rusttpl +1 -1
- data/vendor/rust/rust/templates/CxxClassDefinitions.rusttpl +10 -1
- metadata +186 -185
- data/example/raw_bindings.rb +0 -44
- data/specs/binding_changes.rb +0 -76
data/example/raw_bindings.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/example_helper'
|
2
|
-
|
3
|
-
# An example of using the raw bindings. Solves the send+more=money problem.
|
4
|
-
|
5
|
-
# Variables
|
6
|
-
space = Gecode::Raw::Space.new
|
7
|
-
letters = Gecode::Raw::IntVarArray.new(space, 8, 0, 9)
|
8
|
-
space.own(letters, 'letters')
|
9
|
-
s, e, n, d, m, o, r, y = (0..7).to_a.map{ |i| letters.at(i) }
|
10
|
-
|
11
|
-
# Constraints
|
12
|
-
Gecode::Raw::post(space, (s * 1000 + e * 100 + n * 10 + d +
|
13
|
-
m * 1000 + o * 100 + r * 10 + e).
|
14
|
-
equal(m * 10000 + o * 1000 + n * 100 + e * 10 + y ),
|
15
|
-
Gecode::Raw::ICL_DEF, Gecode::Raw::PK_DEF)
|
16
|
-
Gecode::Raw::rel(space, s, Gecode::Raw::IRT_NQ, 0, Gecode::Raw::ICL_DEF,
|
17
|
-
Gecode::Raw::PK_DEF)
|
18
|
-
Gecode::Raw::rel(space, m, Gecode::Raw::IRT_NQ, 0, Gecode::Raw::ICL_DEF,
|
19
|
-
Gecode::Raw::PK_DEF)
|
20
|
-
Gecode::Raw::distinct(space, letters, Gecode::Raw::ICL_DEF, Gecode::Raw::PK_DEF)
|
21
|
-
|
22
|
-
# Branching.
|
23
|
-
Gecode::Raw::branch(space, letters,
|
24
|
-
Gecode::Raw::INT_VAR_SIZE_MIN, Gecode::Raw::INT_VAL_MIN)
|
25
|
-
|
26
|
-
# Search
|
27
|
-
COPY_DIST = 16
|
28
|
-
ADAPTATION_DIST = 4
|
29
|
-
dfs = Gecode::Raw::DFS.new(space, COPY_DIST, ADAPTATION_DIST,
|
30
|
-
Gecode::Raw::Search::Stop.new)
|
31
|
-
|
32
|
-
space = dfs.next
|
33
|
-
if space.nil?
|
34
|
-
puts 'Failed'
|
35
|
-
else
|
36
|
-
puts 'Solution:'
|
37
|
-
correct_letters = space.intVarArray('letters')
|
38
|
-
arr = []
|
39
|
-
correct_letters.size.times do |i|
|
40
|
-
arr << correct_letters.at(i).val
|
41
|
-
end
|
42
|
-
puts arr.join(' ')
|
43
|
-
end
|
44
|
-
|
data/specs/binding_changes.rb
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
-
|
3
|
-
describe 'Space', :shared => true do
|
4
|
-
it 'should give different indices when creating int variables' do
|
5
|
-
@space.new_int_vars([0, 17]).should_not equal(@space.new_int_vars([0, 17]))
|
6
|
-
end
|
7
|
-
|
8
|
-
it 'should give different indices when creating bool variables' do
|
9
|
-
@space.new_bool_vars().should_not equal(@space.new_bool_vars())
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'should give different indices when creating multiple int variables' do
|
13
|
-
@space.new_int_vars([0, 17], 17).uniq.size.should equal(17)
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'should give different indices when creating multiple bool variables' do
|
17
|
-
@space.new_bool_vars(17).uniq.size.should equal(17)
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'should not return nil for created int variables' do
|
21
|
-
@space.new_int_vars([0, 17], 4).each do |i|
|
22
|
-
@space.int_var(i).should_not be_nil
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'should not return nil for created int variables' do
|
27
|
-
@space.new_bool_vars(4).each do |i|
|
28
|
-
@space.bool_var(i).should_not be_nil
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'should return nil when requesting int variables with negative indices' do
|
33
|
-
@space.int_var(-1).should be_nil
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'should return nil when requesting bool variables with negative indices' do
|
37
|
-
@space.bool_var(-1).should be_nil
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'should raise an error if given a domain of incorrect type' do
|
41
|
-
lambda{ @space.new_int_vars(17) }.should raise_error(TypeError)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
describe Gecode::Raw::Space, ' (new)' do
|
46
|
-
before do
|
47
|
-
@space = Gecode::Raw::Space.new
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'should return nil when requesting int variables' do
|
51
|
-
@space.int_var(0).should be_nil
|
52
|
-
end
|
53
|
-
|
54
|
-
it 'should return nil when requesting bool variables' do
|
55
|
-
@space.bool_var(0).should be_nil
|
56
|
-
end
|
57
|
-
|
58
|
-
it_should_behave_like 'Space'
|
59
|
-
end
|
60
|
-
|
61
|
-
describe Gecode::Raw::Space, ' (with items)' do
|
62
|
-
before do
|
63
|
-
@space = Gecode::Raw::Space.new
|
64
|
-
@first = @space.new_int_vars([1, 4]).first
|
65
|
-
@second = @space.new_int_vars([-5, 5]).first
|
66
|
-
end
|
67
|
-
|
68
|
-
it_should_behave_like 'Space'
|
69
|
-
|
70
|
-
it 'should give int variables with the correct domains' do
|
71
|
-
@space.int_var(@first).min.should equal(1)
|
72
|
-
@space.int_var(@first).max.should equal(4)
|
73
|
-
@space.int_var(@second).min.should equal(-5)
|
74
|
-
@space.int_var(@second).max.should equal(5)
|
75
|
-
end
|
76
|
-
end
|