ConstraintSolver 0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (155) hide show
  1. data/bin/ConstraintSolver +24 -0
  2. data/doc/classes/Array.html +209 -0
  3. data/doc/classes/ConstraintSolver.html +242 -0
  4. data/doc/classes/ConstraintSolver/AbstractConstraint.html +317 -0
  5. data/doc/classes/ConstraintSolver/AllDifferentConstraint.html +451 -0
  6. data/doc/classes/ConstraintSolver/AllDifferentConstraintTest.html +397 -0
  7. data/doc/classes/ConstraintSolver/BinaryConstraint.html +483 -0
  8. data/doc/classes/ConstraintSolver/BinaryConstraintTest.html +367 -0
  9. data/doc/classes/ConstraintSolver/BinaryRelation.html +276 -0
  10. data/doc/classes/ConstraintSolver/BinaryRelationTest.html +194 -0
  11. data/doc/classes/ConstraintSolver/ConstraintList.html +208 -0
  12. data/doc/classes/ConstraintSolver/ConstraintListTest.html +252 -0
  13. data/doc/classes/ConstraintSolver/ConstraintSolver.html +353 -0
  14. data/doc/classes/ConstraintSolver/ConstraintSolverTest.html +403 -0
  15. data/doc/classes/ConstraintSolver/Domain.html +522 -0
  16. data/doc/classes/ConstraintSolver/DomainTest.html +356 -0
  17. data/doc/classes/ConstraintSolver/DomainWipeoutException.html +158 -0
  18. data/doc/classes/ConstraintSolver/Problem.html +239 -0
  19. data/doc/classes/ConstraintSolver/ProblemTest.html +227 -0
  20. data/doc/classes/ConstraintSolver/Solution.html +342 -0
  21. data/doc/classes/ConstraintSolver/SolutionTest.html +250 -0
  22. data/doc/classes/ConstraintSolver/UndoStackEmptyException.html +158 -0
  23. data/doc/classes/ConstraintSolver/Variable.html +418 -0
  24. data/doc/classes/ConstraintSolver/VariableTest.html +284 -0
  25. data/doc/classes/ExtensionsTest.html +233 -0
  26. data/doc/classes/Fixnum.html +153 -0
  27. data/doc/created.rid +1 -0
  28. data/doc/dot/f_0.dot +38 -0
  29. data/doc/dot/f_0.png +0 -0
  30. data/doc/dot/f_1.dot +392 -0
  31. data/doc/dot/f_1.png +0 -0
  32. data/doc/dot/f_10.dot +392 -0
  33. data/doc/dot/f_10.png +0 -0
  34. data/doc/dot/f_11.dot +38 -0
  35. data/doc/dot/f_11.png +0 -0
  36. data/doc/dot/f_12.dot +392 -0
  37. data/doc/dot/f_12.png +0 -0
  38. data/doc/dot/f_13.dot +392 -0
  39. data/doc/dot/f_13.png +0 -0
  40. data/doc/dot/f_14.dot +392 -0
  41. data/doc/dot/f_14.png +0 -0
  42. data/doc/dot/f_15.dot +392 -0
  43. data/doc/dot/f_15.png +0 -0
  44. data/doc/dot/f_16.dot +392 -0
  45. data/doc/dot/f_16.png +0 -0
  46. data/doc/dot/f_17.dot +392 -0
  47. data/doc/dot/f_17.png +0 -0
  48. data/doc/dot/f_18.dot +392 -0
  49. data/doc/dot/f_18.png +0 -0
  50. data/doc/dot/f_19.dot +392 -0
  51. data/doc/dot/f_19.png +0 -0
  52. data/doc/dot/f_2.dot +392 -0
  53. data/doc/dot/f_2.png +0 -0
  54. data/doc/dot/f_3.dot +392 -0
  55. data/doc/dot/f_3.png +0 -0
  56. data/doc/dot/f_4.dot +392 -0
  57. data/doc/dot/f_4.png +0 -0
  58. data/doc/dot/f_5.dot +392 -0
  59. data/doc/dot/f_5.png +0 -0
  60. data/doc/dot/f_6.dot +14 -0
  61. data/doc/dot/f_6.png +0 -0
  62. data/doc/dot/f_7.dot +392 -0
  63. data/doc/dot/f_7.png +0 -0
  64. data/doc/dot/f_8.dot +392 -0
  65. data/doc/dot/f_8.png +0 -0
  66. data/doc/dot/f_9.dot +392 -0
  67. data/doc/dot/f_9.png +0 -0
  68. data/doc/dot/m_10_0.dot +392 -0
  69. data/doc/dot/m_10_0.png +0 -0
  70. data/doc/dot/m_12_0.dot +392 -0
  71. data/doc/dot/m_12_0.png +0 -0
  72. data/doc/dot/m_13_0.dot +392 -0
  73. data/doc/dot/m_13_0.png +0 -0
  74. data/doc/dot/m_14_0.dot +392 -0
  75. data/doc/dot/m_14_0.png +0 -0
  76. data/doc/dot/m_15_0.dot +392 -0
  77. data/doc/dot/m_15_0.png +0 -0
  78. data/doc/dot/m_16_0.dot +392 -0
  79. data/doc/dot/m_16_0.png +0 -0
  80. data/doc/dot/m_17_0.dot +392 -0
  81. data/doc/dot/m_17_0.png +0 -0
  82. data/doc/dot/m_18_0.dot +392 -0
  83. data/doc/dot/m_18_0.png +0 -0
  84. data/doc/dot/m_19_0.dot +392 -0
  85. data/doc/dot/m_19_0.png +0 -0
  86. data/doc/dot/m_1_0.dot +392 -0
  87. data/doc/dot/m_1_0.png +0 -0
  88. data/doc/dot/m_2_0.dot +392 -0
  89. data/doc/dot/m_2_0.png +0 -0
  90. data/doc/dot/m_3_0.dot +392 -0
  91. data/doc/dot/m_3_0.png +0 -0
  92. data/doc/dot/m_4_0.dot +392 -0
  93. data/doc/dot/m_4_0.png +0 -0
  94. data/doc/dot/m_5_0.dot +392 -0
  95. data/doc/dot/m_5_0.png +0 -0
  96. data/doc/dot/m_7_0.dot +392 -0
  97. data/doc/dot/m_7_0.png +0 -0
  98. data/doc/dot/m_8_0.dot +392 -0
  99. data/doc/dot/m_8_0.png +0 -0
  100. data/doc/dot/m_9_0.dot +392 -0
  101. data/doc/dot/m_9_0.png +0 -0
  102. data/doc/files/lib/AbstractConstraint_rb.html +148 -0
  103. data/doc/files/lib/AllDifferentConstraint_rb.html +156 -0
  104. data/doc/files/lib/BinaryConstraint_rb.html +155 -0
  105. data/doc/files/lib/ConstraintList_rb.html +148 -0
  106. data/doc/files/lib/ConstraintSolver_rb.html +162 -0
  107. data/doc/files/lib/Domain_rb.html +155 -0
  108. data/doc/files/lib/Problem_rb.html +148 -0
  109. data/doc/files/lib/Solution_rb.html +148 -0
  110. data/doc/files/lib/Variable_rb.html +148 -0
  111. data/doc/files/lib/extensions_rb.html +108 -0
  112. data/doc/files/test/AllDifferentConstraintTest_rb.html +158 -0
  113. data/doc/files/test/BinaryConstraintTest_rb.html +158 -0
  114. data/doc/files/test/ConstraintListTest_rb.html +160 -0
  115. data/doc/files/test/ConstraintSolverTest_rb.html +164 -0
  116. data/doc/files/test/DomainTest_rb.html +156 -0
  117. data/doc/files/test/ProblemTest_rb.html +160 -0
  118. data/doc/files/test/SolutionTest_rb.html +159 -0
  119. data/doc/files/test/TestSuite_rb.html +113 -0
  120. data/doc/files/test/VariableTest_rb.html +157 -0
  121. data/doc/files/test/extensionsTest_rb.html +118 -0
  122. data/doc/fr_class_index.html +51 -0
  123. data/doc/fr_file_index.html +46 -0
  124. data/doc/fr_method_index.html +133 -0
  125. data/doc/index.html +24 -0
  126. data/examples/example.rb +7 -0
  127. data/examples/queens.rb +13 -0
  128. data/examples/soft.rb +14 -0
  129. data/lib/AbstractConstraint.rb +45 -0
  130. data/lib/AllDifferentConstraint.rb +160 -0
  131. data/lib/BinaryConstraint.rb +187 -0
  132. data/lib/ConstraintList.rb +31 -0
  133. data/lib/ConstraintSolver.rb +213 -0
  134. data/lib/Domain.rb +100 -0
  135. data/lib/GraphUtils.rb +293 -0
  136. data/lib/OneOfEqualsConstraint.rb +81 -0
  137. data/lib/Problem.rb +30 -0
  138. data/lib/Solution.rb +56 -0
  139. data/lib/TupleConstraint.rb +111 -0
  140. data/lib/Variable.rb +74 -0
  141. data/lib/extensions.rb +55 -0
  142. data/test/AllDifferentConstraintTest.rb +140 -0
  143. data/test/BinaryConstraintTest.rb +108 -0
  144. data/test/ConstraintListTest.rb +41 -0
  145. data/test/ConstraintSolverTest.rb +274 -0
  146. data/test/DomainTest.rb +83 -0
  147. data/test/GraphUtilsTest.rb +83 -0
  148. data/test/OneOfEqualsConstraintTest.rb +82 -0
  149. data/test/ProblemTest.rb +35 -0
  150. data/test/SolutionTest.rb +35 -0
  151. data/test/TestSuite.rb +10 -0
  152. data/test/TupleConstraintTest.rb +151 -0
  153. data/test/VariableTest.rb +47 -0
  154. data/test/extensionsTest.rb +57 -0
  155. metadata +212 -0
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/ruby
2
+
3
+ $:.unshift File.join(File.dirname(__FILE__), "..", "lib")
4
+
5
+ require 'test/unit'
6
+ require 'extensions'
7
+ require 'Variable'
8
+ require 'Domain'
9
+
10
+ class ExtensionsTest < Test::Unit::TestCase
11
+ def setup
12
+ @array = Array.new([ 1, 2, 3, 4 ])
13
+ end
14
+
15
+ def testRest
16
+ assert_equal([ 2, 3, 4 ], @array.rest)
17
+ assert_equal([ true, true ], [ true, true, true ].rest)
18
+ end
19
+
20
+ def testFoldLeft
21
+ assert_equal(6, [ 1, 2, 3 ].foldLeft(Proc.new { |a,b| a + b }))
22
+ assert_equal(false, [ false, false, false ].foldLeft(Proc.new { |a,b| a & b }))
23
+ assert_equal(true, [ false, true, false ].foldLeft(Proc.new { |a,b| a | b }))
24
+ end
25
+
26
+ def testEachAfter
27
+ res = Array.new
28
+ @array.eachAfter(2) { |x| res << x }
29
+ assert_equal([ 3, 4 ], res)
30
+ res = Array.new
31
+ @array.eachAfter(4) { |x| res << x }
32
+ assert_equal(true, res.empty?)
33
+ res = Array.new
34
+ @array.eachAfter(5) { |x| res << x }
35
+ assert_equal([ 1, 2, 3, 4 ], res)
36
+ end
37
+
38
+ def testEachStartWith
39
+ res = Array.new
40
+ @array.eachStartWith(2) { |x| res << x }
41
+ assert_equal([ 2, 3, 4 ], res)
42
+ end
43
+
44
+ def testIncludeAny
45
+ set = [ 1, 2, 3 ].to_set
46
+ assert_equal(true, set.include_any?([ 1 ]))
47
+ assert_equal(false, set.include_any?([ 4, 5, 6 ]))
48
+ end
49
+
50
+ def testIncludeHash
51
+ hash = { 1 => 2, 3 => 4, 4 => 5 }
52
+ assert_equal(false, hash.include_hash?({ 2 => 3 }))
53
+ assert_equal(false, hash.include_hash?({ 1 => 2, 2 => 3, 3 => 4, 4 => 5 }))
54
+ assert_equal(true, hash.include_hash?({ 1 => 2 }))
55
+ assert_equal(true, hash.include_hash?({ 4 => 5, 3 => 4, 1 => 2 }))
56
+ end
57
+ end
metadata ADDED
@@ -0,0 +1,212 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.8.11
3
+ specification_version: 1
4
+ name: ConstraintSolver
5
+ version: !ruby/object:Gem::Version
6
+ version: "0.1"
7
+ date: 2007-07-08 00:00:00 +02:00
8
+ summary: A solver for constraint satisfaction and constrained optimisation problems.
9
+ require_paths:
10
+ - lib
11
+ email: mai02dcs@studserv.uni-leipzig.de
12
+ homepage: http://larsko.dyndns.org/
13
+ rubyforge_project:
14
+ description:
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ authors:
29
+ - Lars Kotthoff
30
+ files:
31
+ - lib/BinaryConstraint.rb
32
+ - lib/extensions.rb
33
+ - lib/Problem.rb
34
+ - lib/Variable.rb
35
+ - lib/Domain.rb
36
+ - lib/AllDifferentConstraint.rb
37
+ - lib/Solution.rb
38
+ - lib/AbstractConstraint.rb
39
+ - lib/ConstraintList.rb
40
+ - lib/GraphUtils.rb
41
+ - lib/ConstraintSolver.rb
42
+ - lib/OneOfEqualsConstraint.rb
43
+ - lib/TupleConstraint.rb
44
+ - test/extensionsTest.rb
45
+ - test/ProblemTest.rb
46
+ - test/DomainTest.rb
47
+ - test/VariableTest.rb
48
+ - test/SolutionTest.rb
49
+ - test/TestSuite.rb
50
+ - test/BinaryConstraintTest.rb
51
+ - test/AllDifferentConstraintTest.rb
52
+ - test/ConstraintListTest.rb
53
+ - test/ConstraintSolverTest.rb
54
+ - test/GraphUtilsTest.rb
55
+ - test/TupleConstraintTest.rb
56
+ - test/OneOfEqualsConstraintTest.rb
57
+ - doc/created.rid
58
+ - doc/dot
59
+ - doc/files
60
+ - doc/classes
61
+ - doc/fr_file_index.html
62
+ - doc/fr_class_index.html
63
+ - doc/fr_method_index.html
64
+ - doc/index.html
65
+ - doc/dot/f_0.dot
66
+ - doc/dot/f_0.png
67
+ - doc/dot/f_1.dot
68
+ - doc/dot/f_1.png
69
+ - doc/dot/m_1_0.dot
70
+ - doc/dot/m_1_0.png
71
+ - doc/dot/f_2.dot
72
+ - doc/dot/f_2.png
73
+ - doc/dot/m_2_0.dot
74
+ - doc/dot/m_2_0.png
75
+ - doc/dot/f_3.dot
76
+ - doc/dot/f_3.png
77
+ - doc/dot/m_3_0.dot
78
+ - doc/dot/m_3_0.png
79
+ - doc/dot/f_4.dot
80
+ - doc/dot/f_4.png
81
+ - doc/dot/m_4_0.dot
82
+ - doc/dot/m_4_0.png
83
+ - doc/dot/f_5.dot
84
+ - doc/dot/f_5.png
85
+ - doc/dot/m_5_0.dot
86
+ - doc/dot/m_5_0.png
87
+ - doc/dot/f_6.dot
88
+ - doc/dot/f_6.png
89
+ - doc/dot/f_7.dot
90
+ - doc/dot/f_7.png
91
+ - doc/dot/m_7_0.dot
92
+ - doc/dot/m_7_0.png
93
+ - doc/dot/f_8.dot
94
+ - doc/dot/f_8.png
95
+ - doc/dot/m_8_0.dot
96
+ - doc/dot/m_8_0.png
97
+ - doc/dot/f_9.dot
98
+ - doc/dot/f_9.png
99
+ - doc/dot/m_9_0.dot
100
+ - doc/dot/m_9_0.png
101
+ - doc/dot/f_10.dot
102
+ - doc/dot/f_10.png
103
+ - doc/dot/m_10_0.dot
104
+ - doc/dot/m_10_0.png
105
+ - doc/dot/f_11.dot
106
+ - doc/dot/f_11.png
107
+ - doc/dot/f_12.dot
108
+ - doc/dot/f_12.png
109
+ - doc/dot/m_12_0.dot
110
+ - doc/dot/m_12_0.png
111
+ - doc/dot/f_13.dot
112
+ - doc/dot/f_13.png
113
+ - doc/dot/m_13_0.dot
114
+ - doc/dot/m_13_0.png
115
+ - doc/dot/f_14.dot
116
+ - doc/dot/f_14.png
117
+ - doc/dot/m_14_0.dot
118
+ - doc/dot/m_14_0.png
119
+ - doc/dot/f_15.dot
120
+ - doc/dot/f_15.png
121
+ - doc/dot/m_15_0.dot
122
+ - doc/dot/m_15_0.png
123
+ - doc/dot/f_16.dot
124
+ - doc/dot/f_16.png
125
+ - doc/dot/m_16_0.dot
126
+ - doc/dot/m_16_0.png
127
+ - doc/dot/f_17.dot
128
+ - doc/dot/f_17.png
129
+ - doc/dot/m_17_0.dot
130
+ - doc/dot/m_17_0.png
131
+ - doc/dot/f_18.dot
132
+ - doc/dot/f_18.png
133
+ - doc/dot/m_18_0.dot
134
+ - doc/dot/m_18_0.png
135
+ - doc/dot/f_19.dot
136
+ - doc/dot/f_19.png
137
+ - doc/dot/m_19_0.dot
138
+ - doc/dot/m_19_0.png
139
+ - doc/files/test
140
+ - doc/files/lib
141
+ - doc/files/test/extensionsTest_rb.html
142
+ - doc/files/test/ProblemTest_rb.html
143
+ - doc/files/test/DomainTest_rb.html
144
+ - doc/files/test/VariableTest_rb.html
145
+ - doc/files/test/SolutionTest_rb.html
146
+ - doc/files/test/BinaryConstraintTest_rb.html
147
+ - doc/files/test/TestSuite_rb.html
148
+ - doc/files/test/AllDifferentConstraintTest_rb.html
149
+ - doc/files/test/ConstraintListTest_rb.html
150
+ - doc/files/test/ConstraintSolverTest_rb.html
151
+ - doc/files/lib/BinaryConstraint_rb.html
152
+ - doc/files/lib/extensions_rb.html
153
+ - doc/files/lib/Problem_rb.html
154
+ - doc/files/lib/Variable_rb.html
155
+ - doc/files/lib/Domain_rb.html
156
+ - doc/files/lib/Solution_rb.html
157
+ - doc/files/lib/AbstractConstraint_rb.html
158
+ - doc/files/lib/ConstraintList_rb.html
159
+ - doc/files/lib/AllDifferentConstraint_rb.html
160
+ - doc/files/lib/ConstraintSolver_rb.html
161
+ - doc/classes/Array.html
162
+ - doc/classes/ExtensionsTest.html
163
+ - doc/classes/Fixnum.html
164
+ - doc/classes/ConstraintSolver.html
165
+ - doc/classes/ConstraintSolver
166
+ - doc/classes/ConstraintSolver/BinaryRelation.html
167
+ - doc/classes/ConstraintSolver/AllDifferentConstraintTest.html
168
+ - doc/classes/ConstraintSolver/SolutionTest.html
169
+ - doc/classes/ConstraintSolver/DomainWipeoutException.html
170
+ - doc/classes/ConstraintSolver/AbstractConstraint.html
171
+ - doc/classes/ConstraintSolver/ConstraintSolverTest.html
172
+ - doc/classes/ConstraintSolver/ConstraintListTest.html
173
+ - doc/classes/ConstraintSolver/Solution.html
174
+ - doc/classes/ConstraintSolver/VariableTest.html
175
+ - doc/classes/ConstraintSolver/Domain.html
176
+ - doc/classes/ConstraintSolver/DomainTest.html
177
+ - doc/classes/ConstraintSolver/ConstraintSolver.html
178
+ - doc/classes/ConstraintSolver/BinaryConstraintTest.html
179
+ - doc/classes/ConstraintSolver/Variable.html
180
+ - doc/classes/ConstraintSolver/ProblemTest.html
181
+ - doc/classes/ConstraintSolver/BinaryConstraint.html
182
+ - doc/classes/ConstraintSolver/BinaryRelationTest.html
183
+ - doc/classes/ConstraintSolver/ConstraintList.html
184
+ - doc/classes/ConstraintSolver/Problem.html
185
+ - doc/classes/ConstraintSolver/AllDifferentConstraint.html
186
+ - doc/classes/ConstraintSolver/UndoStackEmptyException.html
187
+ - bin/ConstraintSolver
188
+ - examples/example.rb
189
+ - examples/queens.rb
190
+ - examples/soft.rb
191
+ test_files:
192
+ - test/TestSuite.rb
193
+ rdoc_options: []
194
+
195
+ extra_rdoc_files: []
196
+
197
+ executables:
198
+ - ConstraintSolver
199
+ extensions: []
200
+
201
+ requirements: []
202
+
203
+ dependencies:
204
+ - !ruby/object:Gem::Dependency
205
+ name: log4r
206
+ version_requirement:
207
+ version_requirements: !ruby/object:Gem::Version::Requirement
208
+ requirements:
209
+ - - ">"
210
+ - !ruby/object:Gem::Version
211
+ version: 0.0.0
212
+ version: