ConstraintSolver 0.1

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.
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,397 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Class: ConstraintSolver::AllDifferentConstraintTest</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Class</strong></td>
53
+ <td class="class-name-in-header">ConstraintSolver::AllDifferentConstraintTest</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../files/test/AllDifferentConstraintTest_rb.html">
59
+ test/AllDifferentConstraintTest.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ <tr class="top-aligned-row">
66
+ <td><strong>Parent:</strong></td>
67
+ <td>
68
+ Test::Unit::TestCase
69
+ </td>
70
+ </tr>
71
+ </table>
72
+ </div>
73
+ <!-- banner header -->
74
+
75
+ <div id="bodyContent">
76
+
77
+
78
+
79
+ <div id="contextContent">
80
+ <div id="diagram">
81
+ <map id="map" name="map">
82
+ <area shape="rect" coords="1537,5,1665,53" href="../Test/Unit/TestCase.html" alt="Test::Unit::TestCase" />
83
+ <area shape="rect" coords="937,133,1089,181" href="AllDifferentConstraintTest.html" alt="AllDifferentConstraintTest" />
84
+ <area shape="rect" coords="2305,133,2396,181" href="SolutionTest.html" alt="SolutionTest" />
85
+ <area shape="rect" coords="204,133,335,181" href="ConstraintSolverTest.html" alt="ConstraintSolverTest" />
86
+ <area shape="rect" coords="1923,133,2040,181" href="ConstraintListTest.html" alt="ConstraintListTest" />
87
+ <area shape="rect" coords="1123,133,1213,181" href="VariableTest.html" alt="VariableTest" />
88
+ <area shape="rect" coords="2429,133,2517,181" href="DomainTest.html" alt="DomainTest" />
89
+ <area shape="rect" coords="1387,133,1517,181" href="BinaryConstraintTest.html" alt="BinaryConstraintTest" />
90
+ <area shape="rect" coords="1797,133,1888,181" href="ProblemTest.html" alt="ProblemTest" />
91
+ <area shape="rect" coords="1541,133,1661,181" href="BinaryRelationTest.html" alt="BinaryRelationTest" />
92
+ <area shape="rect" coords="589,5,667,53" href="../Exception.html" alt="Exception" />
93
+ <area shape="rect" coords="463,133,615,181" href="DomainWipeoutException.html" alt="DomainWipeoutException" />
94
+ <area shape="rect" coords="639,133,799,181" href="UndoStackEmptyException.html" alt="UndoStackEmptyException" />
95
+ <area shape="rect" coords="53,133,171,181" href="AbstractConstraint.html" alt="AbstractConstraint" />
96
+ <area shape="rect" coords="160,237,269,285" href="BinaryConstraint.html" alt="BinaryConstraint" />
97
+ <area shape="rect" coords="301,237,432,285" href="AllDifferentConstraint.html" alt="AllDifferentConstraint" />
98
+ <area shape="rect" coords="2085,5,2157,53" href="../Array.html" alt="Array" />
99
+ <area shape="rect" coords="2073,133,2169,181" href="ConstraintList.html" alt="ConstraintList" />
100
+ <area shape="rect" coords="37,237,136,285" href="BinaryRelation.html" alt="BinaryRelation" />
101
+ <area shape="rect" coords="2201,133,2273,181" href="Variable.html" alt="Variable" />
102
+ <area shape="rect" coords="1693,133,1765,181" href="Solution.html" alt="Solution" />
103
+ <area shape="rect" coords="1245,133,1355,181" href="ConstraintSolver.html" alt="ConstraintSolver" />
104
+ <area shape="rect" coords="831,133,903,181" href="Problem.html" alt="Problem" />
105
+ <area shape="rect" coords="367,133,439,181" href="Domain.html" alt="Domain" />
106
+ <area shape="rect" coords="2419,99,2531,192" href="../ConstraintSolver.html" alt="test/DomainTest.rb" />
107
+ <area shape="rect" coords="2295,99,2408,192" href="../ConstraintSolver.html" alt="test/SolutionTest.rb" />
108
+ <area shape="rect" coords="27,203,280,296" href="../ConstraintSolver.html" alt="lib/BinaryConstraint.rb" />
109
+ <area shape="rect" coords="2191,99,2284,192" href="../ConstraintSolver.html" alt="lib/Variable.rb" />
110
+ <area shape="rect" coords="1912,99,2052,192" href="../ConstraintSolver.html" alt="test/ConstraintListTest.rb" />
111
+ <area shape="rect" coords="2063,99,2180,192" href="../ConstraintSolver.html" alt="lib/ConstraintList.rb" />
112
+ <area shape="rect" coords="1787,99,1901,192" href="../ConstraintSolver.html" alt="test/ProblemTest.rb" />
113
+ <area shape="rect" coords="1683,99,1776,192" href="../ConstraintSolver.html" alt="lib/Solution.rb" />
114
+ <area shape="rect" coords="1376,99,1672,192" href="../ConstraintSolver.html" alt="test/BinaryConstraintTest.rb" />
115
+ <area shape="rect" coords="1235,99,1365,192" href="../ConstraintSolver.html" alt="lib/ConstraintSolver.rb" />
116
+ <area shape="rect" coords="1111,99,1224,192" href="../ConstraintSolver.html" alt="test/VariableTest.rb" />
117
+ <area shape="rect" coords="924,99,1100,192" href="../ConstraintSolver.html" alt="test/AllDifferentConstraintTest.rb" />
118
+ <area shape="rect" coords="291,203,443,296" href="../ConstraintSolver.html" alt="lib/AllDifferentConstraint.rb" />
119
+ <area shape="rect" coords="820,99,913,192" href="../ConstraintSolver.html" alt="lib/Problem.rb" />
120
+ <area shape="rect" coords="192,99,345,192" href="../ConstraintSolver.html" alt="test/ConstraintSolverTest.rb" />
121
+ <area shape="rect" coords="356,99,809,192" href="../ConstraintSolver.html" alt="lib/Domain.rb" />
122
+ <area shape="rect" coords="43,99,181,192" href="../ConstraintSolver.html" alt="lib/AbstractConstraint.rb" />
123
+ <area shape="rect" coords="16,64,2541,307" href="../ConstraintSolver.html" alt="ConstraintSolver" />
124
+ </map>
125
+ <img src="../../dot/m_19_0.png" usemap="#map" border="0" alt="dot/m_19_0.png">
126
+ </div>
127
+
128
+
129
+
130
+ </div>
131
+
132
+ <div id="method-list">
133
+ <h3 class="section-bar">Methods</h3>
134
+
135
+ <div class="name-list">
136
+ <a href="#M000013">setup</a>&nbsp;&nbsp;
137
+ <a href="#M000015">testAssigned</a>&nbsp;&nbsp;
138
+ <a href="#M000014">testConstructor</a>&nbsp;&nbsp;
139
+ <a href="#M000020">testDomainWipeout</a>&nbsp;&nbsp;
140
+ <a href="#M000017">testEquals</a>&nbsp;&nbsp;
141
+ <a href="#M000018">testHolds</a>&nbsp;&nbsp;
142
+ <a href="#M000016">testInclude</a>&nbsp;&nbsp;
143
+ <a href="#M000019">testRevise</a>&nbsp;&nbsp;
144
+ </div>
145
+ </div>
146
+
147
+ </div>
148
+
149
+
150
+ <!-- if includes -->
151
+
152
+ <div id="section">
153
+
154
+
155
+
156
+
157
+
158
+
159
+
160
+
161
+ <!-- if method_list -->
162
+ <div id="methods">
163
+ <h3 class="section-bar">Public Instance methods</h3>
164
+
165
+ <div id="method-M000013" class="method-detail">
166
+ <a name="M000013"></a>
167
+
168
+ <div class="method-heading">
169
+ <a href="#M000013" class="method-signature">
170
+ <span class="method-name">setup</span><span class="method-args">()</span>
171
+ </a>
172
+ </div>
173
+
174
+ <div class="method-description">
175
+ <p><a class="source-toggle" href="#"
176
+ onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
177
+ <div class="method-source-code" id="M000013-source">
178
+ <pre>
179
+ <span class="ruby-comment cmt"># File test/AllDifferentConstraintTest.rb, line 12</span>
180
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">setup</span>
181
+ <span class="ruby-identifier">domain</span> = <span class="ruby-constant">Domain</span>.<span class="ruby-identifier">new</span>([ <span class="ruby-value">1</span>, <span class="ruby-value">2</span>, <span class="ruby-value">3</span> ].<span class="ruby-identifier">to_set</span>)
182
+ <span class="ruby-ivar">@x</span> = <span class="ruby-constant">Variable</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">&quot;x&quot;</span>, <span class="ruby-identifier">domain</span>)
183
+ <span class="ruby-ivar">@y</span> = <span class="ruby-constant">Variable</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">&quot;y&quot;</span>, <span class="ruby-identifier">domain</span>.<span class="ruby-identifier">clone</span>)
184
+ <span class="ruby-ivar">@z</span> = <span class="ruby-constant">Variable</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">&quot;z&quot;</span>, <span class="ruby-identifier">domain</span>.<span class="ruby-identifier">clone</span>)
185
+ <span class="ruby-ivar">@constraint</span> = <span class="ruby-constant">AllDifferentConstraint</span>.<span class="ruby-identifier">new</span>([ <span class="ruby-ivar">@x</span>, <span class="ruby-ivar">@y</span>, <span class="ruby-ivar">@z</span> ])
186
+ <span class="ruby-keyword kw">end</span>
187
+ </pre>
188
+ </div>
189
+ </div>
190
+ </div>
191
+
192
+ <div id="method-M000015" class="method-detail">
193
+ <a name="M000015"></a>
194
+
195
+ <div class="method-heading">
196
+ <a href="#M000015" class="method-signature">
197
+ <span class="method-name">testAssigned</span><span class="method-args">()</span>
198
+ </a>
199
+ </div>
200
+
201
+ <div class="method-description">
202
+ <p><a class="source-toggle" href="#"
203
+ onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
204
+ <div class="method-source-code" id="M000015-source">
205
+ <pre>
206
+ <span class="ruby-comment cmt"># File test/AllDifferentConstraintTest.rb, line 27</span>
207
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">testAssigned</span>
208
+ <span class="ruby-identifier">assert_equal</span>(<span class="ruby-keyword kw">false</span>, <span class="ruby-ivar">@constraint</span>.<span class="ruby-identifier">allAssigned?</span>)
209
+ <span class="ruby-ivar">@y</span>.<span class="ruby-identifier">value</span> = <span class="ruby-value">1</span>
210
+ <span class="ruby-ivar">@z</span>.<span class="ruby-identifier">value</span> = <span class="ruby-value">1</span>
211
+ <span class="ruby-identifier">assert_equal</span>(<span class="ruby-keyword kw">false</span>, <span class="ruby-ivar">@constraint</span>.<span class="ruby-identifier">allAssigned?</span>)
212
+ <span class="ruby-ivar">@x</span>.<span class="ruby-identifier">value</span> = <span class="ruby-value">1</span>
213
+ <span class="ruby-identifier">assert_equal</span>(<span class="ruby-keyword kw">true</span>, <span class="ruby-ivar">@constraint</span>.<span class="ruby-identifier">allAssigned?</span>)
214
+ <span class="ruby-ivar">@x</span>.<span class="ruby-identifier">reset</span>
215
+ <span class="ruby-ivar">@y</span>.<span class="ruby-identifier">reset</span>
216
+ <span class="ruby-ivar">@z</span>.<span class="ruby-identifier">reset</span>
217
+ <span class="ruby-keyword kw">end</span>
218
+ </pre>
219
+ </div>
220
+ </div>
221
+ </div>
222
+
223
+ <div id="method-M000014" class="method-detail">
224
+ <a name="M000014"></a>
225
+
226
+ <div class="method-heading">
227
+ <a href="#M000014" class="method-signature">
228
+ <span class="method-name">testConstructor</span><span class="method-args">()</span>
229
+ </a>
230
+ </div>
231
+
232
+ <div class="method-description">
233
+ <p><a class="source-toggle" href="#"
234
+ onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
235
+ <div class="method-source-code" id="M000014-source">
236
+ <pre>
237
+ <span class="ruby-comment cmt"># File test/AllDifferentConstraintTest.rb, line 20</span>
238
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">testConstructor</span>
239
+ <span class="ruby-identifier">assert_raise</span>(<span class="ruby-constant">ArgumentError</span>) { <span class="ruby-constant">AllDifferentConstraint</span>.<span class="ruby-identifier">new</span> }
240
+ <span class="ruby-identifier">assert_raise</span>(<span class="ruby-constant">ArgumentError</span>) { <span class="ruby-constant">AllDifferentConstraint</span>.<span class="ruby-identifier">new</span>([]) }
241
+ <span class="ruby-identifier">assert_raise</span>(<span class="ruby-constant">ArgumentError</span>) { <span class="ruby-constant">AllDifferentConstraint</span>.<span class="ruby-identifier">new</span>([ <span class="ruby-ivar">@x</span> ]) }
242
+ <span class="ruby-identifier">assert_nothing_raised</span> { <span class="ruby-constant">AllDifferentConstraint</span>.<span class="ruby-identifier">new</span>([ <span class="ruby-ivar">@x</span>, <span class="ruby-ivar">@y</span>, <span class="ruby-ivar">@z</span> ]) }
243
+ <span class="ruby-keyword kw">end</span>
244
+ </pre>
245
+ </div>
246
+ </div>
247
+ </div>
248
+
249
+ <div id="method-M000020" class="method-detail">
250
+ <a name="M000020"></a>
251
+
252
+ <div class="method-heading">
253
+ <a href="#M000020" class="method-signature">
254
+ <span class="method-name">testDomainWipeout</span><span class="method-args">()</span>
255
+ </a>
256
+ </div>
257
+
258
+ <div class="method-description">
259
+ <p><a class="source-toggle" href="#"
260
+ onclick="toggleCode('M000020-source');return false;">[Source]</a></p>
261
+ <div class="method-source-code" id="M000020-source">
262
+ <pre>
263
+ <span class="ruby-comment cmt"># File test/AllDifferentConstraintTest.rb, line 71</span>
264
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">testDomainWipeout</span>
265
+ <span class="ruby-identifier">domain</span> = <span class="ruby-constant">Domain</span>.<span class="ruby-identifier">new</span>([ <span class="ruby-value">1</span> ].<span class="ruby-identifier">to_set</span>)
266
+ <span class="ruby-identifier">x</span> = <span class="ruby-constant">Variable</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">&quot;x&quot;</span>, <span class="ruby-identifier">domain</span>)
267
+ <span class="ruby-identifier">y</span> = <span class="ruby-constant">Variable</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">&quot;y&quot;</span>, <span class="ruby-identifier">domain</span>.<span class="ruby-identifier">clone</span>)
268
+ <span class="ruby-identifier">z</span> = <span class="ruby-constant">Variable</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">&quot;z&quot;</span>, <span class="ruby-identifier">domain</span>.<span class="ruby-identifier">clone</span>)
269
+ <span class="ruby-identifier">constraint</span> = <span class="ruby-constant">AllDifferentConstraint</span>.<span class="ruby-identifier">new</span>([ <span class="ruby-identifier">x</span>, <span class="ruby-identifier">y</span>, <span class="ruby-identifier">z</span> ])
270
+ <span class="ruby-identifier">assert_raise</span>(<span class="ruby-constant">DomainWipeoutException</span>) { <span class="ruby-identifier">constraint</span>.<span class="ruby-identifier">revise</span> }
271
+ <span class="ruby-keyword kw">end</span>
272
+ </pre>
273
+ </div>
274
+ </div>
275
+ </div>
276
+
277
+ <div id="method-M000017" class="method-detail">
278
+ <a name="M000017"></a>
279
+
280
+ <div class="method-heading">
281
+ <a href="#M000017" class="method-signature">
282
+ <span class="method-name">testEquals</span><span class="method-args">()</span>
283
+ </a>
284
+ </div>
285
+
286
+ <div class="method-description">
287
+ <p><a class="source-toggle" href="#"
288
+ onclick="toggleCode('M000017-source');return false;">[Source]</a></p>
289
+ <div class="method-source-code" id="M000017-source">
290
+ <pre>
291
+ <span class="ruby-comment cmt"># File test/AllDifferentConstraintTest.rb, line 46</span>
292
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">testEquals</span>
293
+ <span class="ruby-identifier">assert_not_equal</span>(<span class="ruby-constant">AllDifferentConstraint</span>.<span class="ruby-identifier">new</span>([ <span class="ruby-ivar">@x</span>, <span class="ruby-ivar">@y</span> ]), <span class="ruby-ivar">@constraint</span>)
294
+ <span class="ruby-identifier">assert_equal</span>(<span class="ruby-constant">AllDifferentConstraint</span>.<span class="ruby-identifier">new</span>([ <span class="ruby-ivar">@x</span>, <span class="ruby-ivar">@y</span>, <span class="ruby-ivar">@z</span> ]), <span class="ruby-ivar">@constraint</span>)
295
+ <span class="ruby-keyword kw">end</span>
296
+ </pre>
297
+ </div>
298
+ </div>
299
+ </div>
300
+
301
+ <div id="method-M000018" class="method-detail">
302
+ <a name="M000018"></a>
303
+
304
+ <div class="method-heading">
305
+ <a href="#M000018" class="method-signature">
306
+ <span class="method-name">testHolds</span><span class="method-args">()</span>
307
+ </a>
308
+ </div>
309
+
310
+ <div class="method-description">
311
+ <p><a class="source-toggle" href="#"
312
+ onclick="toggleCode('M000018-source');return false;">[Source]</a></p>
313
+ <div class="method-source-code" id="M000018-source">
314
+ <pre>
315
+ <span class="ruby-comment cmt"># File test/AllDifferentConstraintTest.rb, line 51</span>
316
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">testHolds</span>
317
+ <span class="ruby-identifier">assert_raise</span>(<span class="ruby-constant">RuntimeError</span>) { <span class="ruby-ivar">@constraint</span>.<span class="ruby-identifier">holds?</span> }
318
+ <span class="ruby-ivar">@x</span>.<span class="ruby-identifier">value</span> = <span class="ruby-value">1</span>
319
+ <span class="ruby-ivar">@y</span>.<span class="ruby-identifier">value</span> = <span class="ruby-value">2</span>
320
+ <span class="ruby-ivar">@z</span>.<span class="ruby-identifier">value</span> = <span class="ruby-value">2</span>
321
+ <span class="ruby-identifier">assert_equal</span>(<span class="ruby-keyword kw">false</span>, <span class="ruby-ivar">@constraint</span>.<span class="ruby-identifier">holds?</span>)
322
+ <span class="ruby-ivar">@z</span>.<span class="ruby-identifier">value</span> = <span class="ruby-value">3</span>
323
+ <span class="ruby-identifier">assert_equal</span>(<span class="ruby-keyword kw">true</span>, <span class="ruby-ivar">@constraint</span>.<span class="ruby-identifier">holds?</span>)
324
+ <span class="ruby-ivar">@constraint</span>.<span class="ruby-identifier">variables</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">var</span><span class="ruby-operator">|</span> <span class="ruby-identifier">var</span>.<span class="ruby-identifier">reset</span> }
325
+ <span class="ruby-keyword kw">end</span>
326
+ </pre>
327
+ </div>
328
+ </div>
329
+ </div>
330
+
331
+ <div id="method-M000016" class="method-detail">
332
+ <a name="M000016"></a>
333
+
334
+ <div class="method-heading">
335
+ <a href="#M000016" class="method-signature">
336
+ <span class="method-name">testInclude</span><span class="method-args">()</span>
337
+ </a>
338
+ </div>
339
+
340
+ <div class="method-description">
341
+ <p><a class="source-toggle" href="#"
342
+ onclick="toggleCode('M000016-source');return false;">[Source]</a></p>
343
+ <div class="method-source-code" id="M000016-source">
344
+ <pre>
345
+ <span class="ruby-comment cmt"># File test/AllDifferentConstraintTest.rb, line 39</span>
346
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">testInclude</span>
347
+ <span class="ruby-identifier">assert_equal</span>(<span class="ruby-keyword kw">true</span>, <span class="ruby-ivar">@constraint</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-ivar">@x</span>))
348
+ <span class="ruby-identifier">assert_equal</span>(<span class="ruby-keyword kw">true</span>, <span class="ruby-ivar">@constraint</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-ivar">@y</span>))
349
+ <span class="ruby-identifier">assert_equal</span>(<span class="ruby-keyword kw">true</span>, <span class="ruby-ivar">@constraint</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-ivar">@z</span>))
350
+ <span class="ruby-identifier">assert_equal</span>(<span class="ruby-keyword kw">false</span>, <span class="ruby-ivar">@constraint</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-constant">Variable</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">&quot;foobar&quot;</span>, <span class="ruby-value">1</span>)))
351
+ <span class="ruby-keyword kw">end</span>
352
+ </pre>
353
+ </div>
354
+ </div>
355
+ </div>
356
+
357
+ <div id="method-M000019" class="method-detail">
358
+ <a name="M000019"></a>
359
+
360
+ <div class="method-heading">
361
+ <a href="#M000019" class="method-signature">
362
+ <span class="method-name">testRevise</span><span class="method-args">()</span>
363
+ </a>
364
+ </div>
365
+
366
+ <div class="method-description">
367
+ <p><a class="source-toggle" href="#"
368
+ onclick="toggleCode('M000019-source');return false;">[Source]</a></p>
369
+ <div class="method-source-code" id="M000019-source">
370
+ <pre>
371
+ <span class="ruby-comment cmt"># File test/AllDifferentConstraintTest.rb, line 62</span>
372
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">testRevise</span>
373
+ <span class="ruby-identifier">assert_equal</span>([ [], <span class="ruby-value">0</span> ], <span class="ruby-ivar">@constraint</span>.<span class="ruby-identifier">revise</span>)
374
+ <span class="ruby-ivar">@x</span>.<span class="ruby-identifier">value</span> = <span class="ruby-value">1</span>
375
+ <span class="ruby-identifier">assert_equal</span>([ [ <span class="ruby-ivar">@y</span>, <span class="ruby-ivar">@z</span> ], <span class="ruby-value">0</span> ], <span class="ruby-ivar">@constraint</span>.<span class="ruby-identifier">revise</span>)
376
+ <span class="ruby-identifier">assert_equal</span>([ <span class="ruby-value">2</span>, <span class="ruby-value">3</span> ].<span class="ruby-identifier">to_set</span>, <span class="ruby-ivar">@y</span>.<span class="ruby-identifier">values</span>)
377
+ <span class="ruby-identifier">assert_equal</span>([ <span class="ruby-value">2</span>, <span class="ruby-value">3</span> ].<span class="ruby-identifier">to_set</span>, <span class="ruby-ivar">@z</span>.<span class="ruby-identifier">values</span>)
378
+ <span class="ruby-ivar">@x</span>.<span class="ruby-identifier">reset</span>
379
+ <span class="ruby-keyword kw">end</span>
380
+ </pre>
381
+ </div>
382
+ </div>
383
+ </div>
384
+
385
+
386
+ </div>
387
+
388
+
389
+ </div>
390
+
391
+
392
+ <div id="validator-badges">
393
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
394
+ </div>
395
+
396
+ </body>
397
+ </html>
@@ -0,0 +1,483 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Class: ConstraintSolver::BinaryConstraint</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Class</strong></td>
53
+ <td class="class-name-in-header">ConstraintSolver::BinaryConstraint</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../files/lib/BinaryConstraint_rb.html">
59
+ lib/BinaryConstraint.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ <tr class="top-aligned-row">
66
+ <td><strong>Parent:</strong></td>
67
+ <td>
68
+ <a href="AbstractConstraint.html">
69
+ AbstractConstraint
70
+ </a>
71
+ </td>
72
+ </tr>
73
+ </table>
74
+ </div>
75
+ <!-- banner header -->
76
+
77
+ <div id="bodyContent">
78
+
79
+
80
+
81
+ <div id="contextContent">
82
+ <div id="diagram">
83
+ <map id="map" name="map">
84
+ <area shape="rect" coords="1537,5,1665,53" href="../Test/Unit/TestCase.html" alt="Test::Unit::TestCase" />
85
+ <area shape="rect" coords="937,133,1089,181" href="AllDifferentConstraintTest.html" alt="AllDifferentConstraintTest" />
86
+ <area shape="rect" coords="2305,133,2396,181" href="SolutionTest.html" alt="SolutionTest" />
87
+ <area shape="rect" coords="204,133,335,181" href="ConstraintSolverTest.html" alt="ConstraintSolverTest" />
88
+ <area shape="rect" coords="1923,133,2040,181" href="ConstraintListTest.html" alt="ConstraintListTest" />
89
+ <area shape="rect" coords="1123,133,1213,181" href="VariableTest.html" alt="VariableTest" />
90
+ <area shape="rect" coords="2429,133,2517,181" href="DomainTest.html" alt="DomainTest" />
91
+ <area shape="rect" coords="1387,133,1517,181" href="BinaryConstraintTest.html" alt="BinaryConstraintTest" />
92
+ <area shape="rect" coords="1797,133,1888,181" href="ProblemTest.html" alt="ProblemTest" />
93
+ <area shape="rect" coords="1541,133,1661,181" href="BinaryRelationTest.html" alt="BinaryRelationTest" />
94
+ <area shape="rect" coords="589,5,667,53" href="../Exception.html" alt="Exception" />
95
+ <area shape="rect" coords="463,133,615,181" href="DomainWipeoutException.html" alt="DomainWipeoutException" />
96
+ <area shape="rect" coords="639,133,799,181" href="UndoStackEmptyException.html" alt="UndoStackEmptyException" />
97
+ <area shape="rect" coords="53,133,171,181" href="AbstractConstraint.html" alt="AbstractConstraint" />
98
+ <area shape="rect" coords="160,237,269,285" href="BinaryConstraint.html" alt="BinaryConstraint" />
99
+ <area shape="rect" coords="301,237,432,285" href="AllDifferentConstraint.html" alt="AllDifferentConstraint" />
100
+ <area shape="rect" coords="2085,5,2157,53" href="../Array.html" alt="Array" />
101
+ <area shape="rect" coords="2073,133,2169,181" href="ConstraintList.html" alt="ConstraintList" />
102
+ <area shape="rect" coords="37,237,136,285" href="BinaryRelation.html" alt="BinaryRelation" />
103
+ <area shape="rect" coords="2201,133,2273,181" href="Variable.html" alt="Variable" />
104
+ <area shape="rect" coords="1693,133,1765,181" href="Solution.html" alt="Solution" />
105
+ <area shape="rect" coords="1245,133,1355,181" href="ConstraintSolver.html" alt="ConstraintSolver" />
106
+ <area shape="rect" coords="831,133,903,181" href="Problem.html" alt="Problem" />
107
+ <area shape="rect" coords="367,133,439,181" href="Domain.html" alt="Domain" />
108
+ <area shape="rect" coords="2419,99,2531,192" href="../ConstraintSolver.html" alt="test/DomainTest.rb" />
109
+ <area shape="rect" coords="2295,99,2408,192" href="../ConstraintSolver.html" alt="test/SolutionTest.rb" />
110
+ <area shape="rect" coords="27,203,280,296" href="../ConstraintSolver.html" alt="lib/BinaryConstraint.rb" />
111
+ <area shape="rect" coords="2191,99,2284,192" href="../ConstraintSolver.html" alt="lib/Variable.rb" />
112
+ <area shape="rect" coords="1912,99,2052,192" href="../ConstraintSolver.html" alt="test/ConstraintListTest.rb" />
113
+ <area shape="rect" coords="2063,99,2180,192" href="../ConstraintSolver.html" alt="lib/ConstraintList.rb" />
114
+ <area shape="rect" coords="1787,99,1901,192" href="../ConstraintSolver.html" alt="test/ProblemTest.rb" />
115
+ <area shape="rect" coords="1683,99,1776,192" href="../ConstraintSolver.html" alt="lib/Solution.rb" />
116
+ <area shape="rect" coords="1376,99,1672,192" href="../ConstraintSolver.html" alt="test/BinaryConstraintTest.rb" />
117
+ <area shape="rect" coords="1235,99,1365,192" href="../ConstraintSolver.html" alt="lib/ConstraintSolver.rb" />
118
+ <area shape="rect" coords="1111,99,1224,192" href="../ConstraintSolver.html" alt="test/VariableTest.rb" />
119
+ <area shape="rect" coords="924,99,1100,192" href="../ConstraintSolver.html" alt="test/AllDifferentConstraintTest.rb" />
120
+ <area shape="rect" coords="291,203,443,296" href="../ConstraintSolver.html" alt="lib/AllDifferentConstraint.rb" />
121
+ <area shape="rect" coords="820,99,913,192" href="../ConstraintSolver.html" alt="lib/Problem.rb" />
122
+ <area shape="rect" coords="192,99,345,192" href="../ConstraintSolver.html" alt="test/ConstraintSolverTest.rb" />
123
+ <area shape="rect" coords="356,99,809,192" href="../ConstraintSolver.html" alt="lib/Domain.rb" />
124
+ <area shape="rect" coords="43,99,181,192" href="../ConstraintSolver.html" alt="lib/AbstractConstraint.rb" />
125
+ <area shape="rect" coords="16,64,2541,307" href="../ConstraintSolver.html" alt="ConstraintSolver" />
126
+ </map>
127
+ <img src="../../dot/m_19_0.png" usemap="#map" border="0" alt="dot/m_19_0.png">
128
+ </div>
129
+
130
+ <div id="description">
131
+ <p>
132
+ Represents a binary constraint.
133
+ </p>
134
+
135
+ </div>
136
+
137
+
138
+ </div>
139
+
140
+ <div id="method-list">
141
+ <h3 class="section-bar">Methods</h3>
142
+
143
+ <div class="name-list">
144
+ <a href="#M000093">==</a>&nbsp;&nbsp;
145
+ <a href="#M000089">allAssigned?</a>&nbsp;&nbsp;
146
+ <a href="#M000094">each</a>&nbsp;&nbsp;
147
+ <a href="#M000088">holds?</a>&nbsp;&nbsp;
148
+ <a href="#M000090">include?</a>&nbsp;&nbsp;
149
+ <a href="#M000087">new</a>&nbsp;&nbsp;
150
+ <a href="#M000095">revise</a>&nbsp;&nbsp;
151
+ <a href="#M000091">to_s</a>&nbsp;&nbsp;
152
+ <a href="#M000092">to_s_full</a>&nbsp;&nbsp;
153
+ </div>
154
+ </div>
155
+
156
+ </div>
157
+
158
+
159
+ <!-- if includes -->
160
+
161
+ <div id="section">
162
+
163
+
164
+
165
+
166
+
167
+ <div id="attribute-list">
168
+ <h3 class="section-bar">Attributes</h3>
169
+
170
+ <div class="name-list">
171
+ <table>
172
+ <tr class="top-aligned-row context-row">
173
+ <td class="context-item-name">lhs</td>
174
+ <td class="context-item-value">&nbsp;[R]&nbsp;</td>
175
+ <td class="context-item-desc"></td>
176
+ </tr>
177
+ <tr class="top-aligned-row context-row">
178
+ <td class="context-item-name">relation</td>
179
+ <td class="context-item-value">&nbsp;[R]&nbsp;</td>
180
+ <td class="context-item-desc"></td>
181
+ </tr>
182
+ <tr class="top-aligned-row context-row">
183
+ <td class="context-item-name">rhs</td>
184
+ <td class="context-item-value">&nbsp;[R]&nbsp;</td>
185
+ <td class="context-item-desc"></td>
186
+ </tr>
187
+ </table>
188
+ </div>
189
+ </div>
190
+
191
+
192
+
193
+ <!-- if method_list -->
194
+ <div id="methods">
195
+ <h3 class="section-bar">Public Class methods</h3>
196
+
197
+ <div id="method-M000087" class="method-detail">
198
+ <a name="M000087"></a>
199
+
200
+ <div class="method-heading">
201
+ <a href="#M000087" class="method-signature">
202
+ <span class="method-name">new</span><span class="method-args">(lhs, rhs, relation)</span>
203
+ </a>
204
+ </div>
205
+
206
+ <div class="method-description">
207
+ <p>
208
+ Initialises a <a href="BinaryConstraint.html#M000087">new</a> binary
209
+ constraint. The arguments are the variable at the left hand side of the
210
+ relation, the variable at the right hand side of the relation and the
211
+ relation itself.
212
+ </p>
213
+ <p><a class="source-toggle" href="#"
214
+ onclick="toggleCode('M000087-source');return false;">[Source]</a></p>
215
+ <div class="method-source-code" id="M000087-source">
216
+ <pre>
217
+ <span class="ruby-comment cmt"># File lib/BinaryConstraint.rb, line 13</span>
218
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">lhs</span>, <span class="ruby-identifier">rhs</span>, <span class="ruby-identifier">relation</span>)
219
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">relation</span>.<span class="ruby-identifier">arity</span> <span class="ruby-operator">!=</span> <span class="ruby-value">2</span>
220
+ <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">&quot;The relation given must take two arguments!&quot;</span>
221
+ <span class="ruby-keyword kw">end</span>
222
+ <span class="ruby-ivar">@lhs</span> = <span class="ruby-identifier">lhs</span>
223
+ <span class="ruby-ivar">@rhs</span> = <span class="ruby-identifier">rhs</span>
224
+ <span class="ruby-ivar">@relation</span> = <span class="ruby-identifier">relation</span>
225
+ <span class="ruby-keyword kw">end</span>
226
+ </pre>
227
+ </div>
228
+ </div>
229
+ </div>
230
+
231
+ <h3 class="section-bar">Public Instance methods</h3>
232
+
233
+ <div id="method-M000093" class="method-detail">
234
+ <a name="M000093"></a>
235
+
236
+ <div class="method-heading">
237
+ <a href="#M000093" class="method-signature">
238
+ <span class="method-name">==</span><span class="method-args">(constraint)</span>
239
+ </a>
240
+ </div>
241
+
242
+ <div class="method-description">
243
+ <p><a class="source-toggle" href="#"
244
+ onclick="toggleCode('M000093-source');return false;">[Source]</a></p>
245
+ <div class="method-source-code" id="M000093-source">
246
+ <pre>
247
+ <span class="ruby-comment cmt"># File lib/BinaryConstraint.rb, line 49</span>
248
+ <span class="ruby-keyword kw">def</span> <span class="ruby-operator">==</span>(<span class="ruby-identifier">constraint</span>)
249
+ <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">constraint</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">BinaryConstraint</span>)
250
+ (<span class="ruby-ivar">@lhs</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">constraint</span>.<span class="ruby-identifier">lhs</span>) <span class="ruby-keyword kw">and</span> (<span class="ruby-ivar">@rhs</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">constraint</span>.<span class="ruby-identifier">rhs</span>) <span class="ruby-keyword kw">and</span> (<span class="ruby-ivar">@relation</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">constraint</span>.<span class="ruby-identifier">relation</span>)
251
+ <span class="ruby-keyword kw">end</span>
252
+ </pre>
253
+ </div>
254
+ </div>
255
+ </div>
256
+
257
+ <div id="method-M000089" class="method-detail">
258
+ <a name="M000089"></a>
259
+
260
+ <div class="method-heading">
261
+ <a href="#M000089" class="method-signature">
262
+ <span class="method-name">allAssigned?</span><span class="method-args">()</span>
263
+ </a>
264
+ </div>
265
+
266
+ <div class="method-description">
267
+ <p><a class="source-toggle" href="#"
268
+ onclick="toggleCode('M000089-source');return false;">[Source]</a></p>
269
+ <div class="method-source-code" id="M000089-source">
270
+ <pre>
271
+ <span class="ruby-comment cmt"># File lib/BinaryConstraint.rb, line 33</span>
272
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">allAssigned?</span>
273
+ <span class="ruby-ivar">@lhs</span>.<span class="ruby-identifier">assigned?</span> <span class="ruby-keyword kw">and</span> <span class="ruby-ivar">@rhs</span>.<span class="ruby-identifier">assigned?</span>
274
+ <span class="ruby-keyword kw">end</span>
275
+ </pre>
276
+ </div>
277
+ </div>
278
+ </div>
279
+
280
+ <div id="method-M000094" class="method-detail">
281
+ <a name="M000094"></a>
282
+
283
+ <div class="method-heading">
284
+ <a href="#M000094" class="method-signature">
285
+ <span class="method-name">each</span><span class="method-args">() {|variable| ...}</span>
286
+ </a>
287
+ </div>
288
+
289
+ <div class="method-description">
290
+ <p><a class="source-toggle" href="#"
291
+ onclick="toggleCode('M000094-source');return false;">[Source]</a></p>
292
+ <div class="method-source-code" id="M000094-source">
293
+ <pre>
294
+ <span class="ruby-comment cmt"># File lib/BinaryConstraint.rb, line 54</span>
295
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">each</span>
296
+ [ <span class="ruby-ivar">@lhs</span>, <span class="ruby-ivar">@rhs</span> ].<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">variable</span><span class="ruby-operator">|</span>
297
+ <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">variable</span>
298
+ }
299
+ <span class="ruby-keyword kw">end</span>
300
+ </pre>
301
+ </div>
302
+ </div>
303
+ </div>
304
+
305
+ <div id="method-M000088" class="method-detail">
306
+ <a name="M000088"></a>
307
+
308
+ <div class="method-heading">
309
+ <a href="#M000088" class="method-signature">
310
+ <span class="method-name">holds?</span><span class="method-args">()</span>
311
+ </a>
312
+ </div>
313
+
314
+ <div class="method-description">
315
+ <p>
316
+ Checks whether the relation returns true when called with the values
317
+ assigned to left hand side and right hand side.
318
+ </p>
319
+ <p><a class="source-toggle" href="#"
320
+ onclick="toggleCode('M000088-source');return false;">[Source]</a></p>
321
+ <div class="method-source-code" id="M000088-source">
322
+ <pre>
323
+ <span class="ruby-comment cmt"># File lib/BinaryConstraint.rb, line 24</span>
324
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">holds?</span>
325
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">allAssigned?</span>
326
+ <span class="ruby-ivar">@relation</span>.<span class="ruby-identifier">call</span>(<span class="ruby-ivar">@lhs</span>.<span class="ruby-identifier">value</span>, <span class="ruby-ivar">@rhs</span>.<span class="ruby-identifier">value</span>)
327
+ <span class="ruby-keyword kw">else</span>
328
+ <span class="ruby-identifier">raise</span> <span class="ruby-constant">RuntimeError</span>, <span class="ruby-value str">&quot;Cannot check whether &quot;</span> <span class="ruby-operator">+</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">+</span>
329
+ <span class="ruby-value str">&quot; holds because not all variables have been assigned values!&quot;</span>
330
+ <span class="ruby-keyword kw">end</span>
331
+ <span class="ruby-keyword kw">end</span>
332
+ </pre>
333
+ </div>
334
+ </div>
335
+ </div>
336
+
337
+ <div id="method-M000090" class="method-detail">
338
+ <a name="M000090"></a>
339
+
340
+ <div class="method-heading">
341
+ <a href="#M000090" class="method-signature">
342
+ <span class="method-name">include?</span><span class="method-args">(variable)</span>
343
+ </a>
344
+ </div>
345
+
346
+ <div class="method-description">
347
+ <p><a class="source-toggle" href="#"
348
+ onclick="toggleCode('M000090-source');return false;">[Source]</a></p>
349
+ <div class="method-source-code" id="M000090-source">
350
+ <pre>
351
+ <span class="ruby-comment cmt"># File lib/BinaryConstraint.rb, line 37</span>
352
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">include?</span>(<span class="ruby-identifier">variable</span>)
353
+ (<span class="ruby-ivar">@lhs</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">variable</span>) <span class="ruby-keyword kw">or</span> (<span class="ruby-ivar">@rhs</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">variable</span>)
354
+ <span class="ruby-keyword kw">end</span>
355
+ </pre>
356
+ </div>
357
+ </div>
358
+ </div>
359
+
360
+ <div id="method-M000095" class="method-detail">
361
+ <a name="M000095"></a>
362
+
363
+ <div class="method-heading">
364
+ <a href="#M000095" class="method-signature">
365
+ <span class="method-name">revise</span><span class="method-args">()</span>
366
+ </a>
367
+ </div>
368
+
369
+ <div class="method-description">
370
+ <p><a class="source-toggle" href="#"
371
+ onclick="toggleCode('M000095-source');return false;">[Source]</a></p>
372
+ <div class="method-source-code" id="M000095-source">
373
+ <pre>
374
+ <span class="ruby-comment cmt"># File lib/BinaryConstraint.rb, line 60</span>
375
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">revise</span>
376
+ <span class="ruby-comment cmt"># TODO: check bounds consistency rather than everything explicitly</span>
377
+ <span class="ruby-identifier">checks</span> = <span class="ruby-value">0</span>
378
+ <span class="ruby-identifier">revisedVariables</span> = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>
379
+ <span class="ruby-identifier">pruneList</span> = <span class="ruby-constant">Set</span>.<span class="ruby-identifier">new</span>
380
+ <span class="ruby-identifier">assigned</span> = [ <span class="ruby-ivar">@lhs</span>, <span class="ruby-ivar">@rhs</span> ].<span class="ruby-identifier">find</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">var</span><span class="ruby-operator">|</span> <span class="ruby-identifier">var</span>.<span class="ruby-identifier">assigned?</span> }
381
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">assigned</span>.<span class="ruby-identifier">nil?</span>
382
+ <span class="ruby-identifier">pruneList</span> = <span class="ruby-ivar">@lhs</span>.<span class="ruby-identifier">values</span>.<span class="ruby-identifier">clone</span>
383
+ <span class="ruby-identifier">pruneListRight</span> = <span class="ruby-ivar">@rhs</span>.<span class="ruby-identifier">values</span>.<span class="ruby-identifier">clone</span>
384
+ <span class="ruby-ivar">@lhs</span>.<span class="ruby-identifier">domain</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">lvalue</span><span class="ruby-operator">|</span>
385
+ <span class="ruby-ivar">@lhs</span>.<span class="ruby-identifier">value</span> = <span class="ruby-identifier">lvalue</span>
386
+ <span class="ruby-ivar">@rhs</span>.<span class="ruby-identifier">domain</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">rvalue</span><span class="ruby-operator">|</span>
387
+ <span class="ruby-ivar">@rhs</span>.<span class="ruby-identifier">value</span> = <span class="ruby-identifier">rvalue</span>
388
+ <span class="ruby-identifier">checks</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
389
+ <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">holds?</span>
390
+ <span class="ruby-identifier">pruneList</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">lvalue</span>)
391
+ <span class="ruby-identifier">pruneListRight</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">rvalue</span>)
392
+ <span class="ruby-keyword kw">end</span>
393
+ }
394
+ <span class="ruby-ivar">@rhs</span>.<span class="ruby-identifier">reset</span>
395
+ }
396
+ <span class="ruby-ivar">@lhs</span>.<span class="ruby-identifier">reset</span>
397
+ <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">pruneList</span>.<span class="ruby-identifier">empty?</span>
398
+ <span class="ruby-ivar">@lhs</span>.<span class="ruby-identifier">domain</span>.<span class="ruby-identifier">prune</span>(<span class="ruby-identifier">pruneList</span>)
399
+ <span class="ruby-identifier">revisedVariables</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-ivar">@lhs</span>
400
+ <span class="ruby-keyword kw">end</span>
401
+ <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">pruneListRight</span>.<span class="ruby-identifier">empty?</span>
402
+ <span class="ruby-ivar">@rhs</span>.<span class="ruby-identifier">domain</span>.<span class="ruby-identifier">prune</span>(<span class="ruby-identifier">pruneListRight</span>)
403
+ <span class="ruby-identifier">revisedVariables</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-ivar">@rhs</span>
404
+ <span class="ruby-keyword kw">end</span>
405
+ <span class="ruby-keyword kw">else</span>
406
+ <span class="ruby-identifier">unassigned</span> = ([ <span class="ruby-ivar">@lhs</span>, <span class="ruby-ivar">@rhs</span> ] <span class="ruby-operator">-</span> [ <span class="ruby-identifier">assigned</span> ]).<span class="ruby-identifier">first</span>
407
+ <span class="ruby-identifier">unassigned</span>.<span class="ruby-identifier">domain</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
408
+ <span class="ruby-identifier">unassigned</span>.<span class="ruby-identifier">value</span> = <span class="ruby-identifier">value</span>
409
+ <span class="ruby-identifier">checks</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
410
+ <span class="ruby-identifier">pruneList</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">value</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">holds?</span>
411
+ }
412
+ <span class="ruby-identifier">unassigned</span>.<span class="ruby-identifier">reset</span>
413
+ <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">pruneList</span>.<span class="ruby-identifier">empty?</span>
414
+ <span class="ruby-identifier">unassigned</span>.<span class="ruby-identifier">domain</span>.<span class="ruby-identifier">prune</span>(<span class="ruby-identifier">pruneList</span>)
415
+ <span class="ruby-identifier">revisedVariables</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">unassigned</span>
416
+ <span class="ruby-keyword kw">end</span>
417
+ <span class="ruby-keyword kw">end</span>
418
+ <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">revisedVariables</span>, <span class="ruby-identifier">checks</span>
419
+ <span class="ruby-keyword kw">end</span>
420
+ </pre>
421
+ </div>
422
+ </div>
423
+ </div>
424
+
425
+ <div id="method-M000091" class="method-detail">
426
+ <a name="M000091"></a>
427
+
428
+ <div class="method-heading">
429
+ <a href="#M000091" class="method-signature">
430
+ <span class="method-name">to_s</span><span class="method-args">()</span>
431
+ </a>
432
+ </div>
433
+
434
+ <div class="method-description">
435
+ <p><a class="source-toggle" href="#"
436
+ onclick="toggleCode('M000091-source');return false;">[Source]</a></p>
437
+ <div class="method-source-code" id="M000091-source">
438
+ <pre>
439
+ <span class="ruby-comment cmt"># File lib/BinaryConstraint.rb, line 41</span>
440
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_s</span>
441
+ <span class="ruby-ivar">@lhs</span>.<span class="ruby-identifier">name</span> <span class="ruby-operator">+</span> <span class="ruby-value str">&quot; &quot;</span> <span class="ruby-operator">+</span> <span class="ruby-ivar">@relation</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">+</span> <span class="ruby-value str">&quot; &quot;</span> <span class="ruby-operator">+</span> <span class="ruby-ivar">@rhs</span>.<span class="ruby-identifier">name</span>
442
+ <span class="ruby-keyword kw">end</span>
443
+ </pre>
444
+ </div>
445
+ </div>
446
+ </div>
447
+
448
+ <div id="method-M000092" class="method-detail">
449
+ <a name="M000092"></a>
450
+
451
+ <div class="method-heading">
452
+ <a href="#M000092" class="method-signature">
453
+ <span class="method-name">to_s_full</span><span class="method-args">()</span>
454
+ </a>
455
+ </div>
456
+
457
+ <div class="method-description">
458
+ <p><a class="source-toggle" href="#"
459
+ onclick="toggleCode('M000092-source');return false;">[Source]</a></p>
460
+ <div class="method-source-code" id="M000092-source">
461
+ <pre>
462
+ <span class="ruby-comment cmt"># File lib/BinaryConstraint.rb, line 45</span>
463
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_s_full</span>
464
+ <span class="ruby-ivar">@lhs</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">+</span> <span class="ruby-value str">&quot; &quot;</span> <span class="ruby-operator">+</span> <span class="ruby-ivar">@relation</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">+</span> <span class="ruby-value str">&quot; &quot;</span> <span class="ruby-operator">+</span> <span class="ruby-ivar">@rhs</span>.<span class="ruby-identifier">to_s</span>
465
+ <span class="ruby-keyword kw">end</span>
466
+ </pre>
467
+ </div>
468
+ </div>
469
+ </div>
470
+
471
+
472
+ </div>
473
+
474
+
475
+ </div>
476
+
477
+
478
+ <div id="validator-badges">
479
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
480
+ </div>
481
+
482
+ </body>
483
+ </html>