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.
- data/bin/ConstraintSolver +24 -0
- data/doc/classes/Array.html +209 -0
- data/doc/classes/ConstraintSolver.html +242 -0
- data/doc/classes/ConstraintSolver/AbstractConstraint.html +317 -0
- data/doc/classes/ConstraintSolver/AllDifferentConstraint.html +451 -0
- data/doc/classes/ConstraintSolver/AllDifferentConstraintTest.html +397 -0
- data/doc/classes/ConstraintSolver/BinaryConstraint.html +483 -0
- data/doc/classes/ConstraintSolver/BinaryConstraintTest.html +367 -0
- data/doc/classes/ConstraintSolver/BinaryRelation.html +276 -0
- data/doc/classes/ConstraintSolver/BinaryRelationTest.html +194 -0
- data/doc/classes/ConstraintSolver/ConstraintList.html +208 -0
- data/doc/classes/ConstraintSolver/ConstraintListTest.html +252 -0
- data/doc/classes/ConstraintSolver/ConstraintSolver.html +353 -0
- data/doc/classes/ConstraintSolver/ConstraintSolverTest.html +403 -0
- data/doc/classes/ConstraintSolver/Domain.html +522 -0
- data/doc/classes/ConstraintSolver/DomainTest.html +356 -0
- data/doc/classes/ConstraintSolver/DomainWipeoutException.html +158 -0
- data/doc/classes/ConstraintSolver/Problem.html +239 -0
- data/doc/classes/ConstraintSolver/ProblemTest.html +227 -0
- data/doc/classes/ConstraintSolver/Solution.html +342 -0
- data/doc/classes/ConstraintSolver/SolutionTest.html +250 -0
- data/doc/classes/ConstraintSolver/UndoStackEmptyException.html +158 -0
- data/doc/classes/ConstraintSolver/Variable.html +418 -0
- data/doc/classes/ConstraintSolver/VariableTest.html +284 -0
- data/doc/classes/ExtensionsTest.html +233 -0
- data/doc/classes/Fixnum.html +153 -0
- data/doc/created.rid +1 -0
- data/doc/dot/f_0.dot +38 -0
- data/doc/dot/f_0.png +0 -0
- data/doc/dot/f_1.dot +392 -0
- data/doc/dot/f_1.png +0 -0
- data/doc/dot/f_10.dot +392 -0
- data/doc/dot/f_10.png +0 -0
- data/doc/dot/f_11.dot +38 -0
- data/doc/dot/f_11.png +0 -0
- data/doc/dot/f_12.dot +392 -0
- data/doc/dot/f_12.png +0 -0
- data/doc/dot/f_13.dot +392 -0
- data/doc/dot/f_13.png +0 -0
- data/doc/dot/f_14.dot +392 -0
- data/doc/dot/f_14.png +0 -0
- data/doc/dot/f_15.dot +392 -0
- data/doc/dot/f_15.png +0 -0
- data/doc/dot/f_16.dot +392 -0
- data/doc/dot/f_16.png +0 -0
- data/doc/dot/f_17.dot +392 -0
- data/doc/dot/f_17.png +0 -0
- data/doc/dot/f_18.dot +392 -0
- data/doc/dot/f_18.png +0 -0
- data/doc/dot/f_19.dot +392 -0
- data/doc/dot/f_19.png +0 -0
- data/doc/dot/f_2.dot +392 -0
- data/doc/dot/f_2.png +0 -0
- data/doc/dot/f_3.dot +392 -0
- data/doc/dot/f_3.png +0 -0
- data/doc/dot/f_4.dot +392 -0
- data/doc/dot/f_4.png +0 -0
- data/doc/dot/f_5.dot +392 -0
- data/doc/dot/f_5.png +0 -0
- data/doc/dot/f_6.dot +14 -0
- data/doc/dot/f_6.png +0 -0
- data/doc/dot/f_7.dot +392 -0
- data/doc/dot/f_7.png +0 -0
- data/doc/dot/f_8.dot +392 -0
- data/doc/dot/f_8.png +0 -0
- data/doc/dot/f_9.dot +392 -0
- data/doc/dot/f_9.png +0 -0
- data/doc/dot/m_10_0.dot +392 -0
- data/doc/dot/m_10_0.png +0 -0
- data/doc/dot/m_12_0.dot +392 -0
- data/doc/dot/m_12_0.png +0 -0
- data/doc/dot/m_13_0.dot +392 -0
- data/doc/dot/m_13_0.png +0 -0
- data/doc/dot/m_14_0.dot +392 -0
- data/doc/dot/m_14_0.png +0 -0
- data/doc/dot/m_15_0.dot +392 -0
- data/doc/dot/m_15_0.png +0 -0
- data/doc/dot/m_16_0.dot +392 -0
- data/doc/dot/m_16_0.png +0 -0
- data/doc/dot/m_17_0.dot +392 -0
- data/doc/dot/m_17_0.png +0 -0
- data/doc/dot/m_18_0.dot +392 -0
- data/doc/dot/m_18_0.png +0 -0
- data/doc/dot/m_19_0.dot +392 -0
- data/doc/dot/m_19_0.png +0 -0
- data/doc/dot/m_1_0.dot +392 -0
- data/doc/dot/m_1_0.png +0 -0
- data/doc/dot/m_2_0.dot +392 -0
- data/doc/dot/m_2_0.png +0 -0
- data/doc/dot/m_3_0.dot +392 -0
- data/doc/dot/m_3_0.png +0 -0
- data/doc/dot/m_4_0.dot +392 -0
- data/doc/dot/m_4_0.png +0 -0
- data/doc/dot/m_5_0.dot +392 -0
- data/doc/dot/m_5_0.png +0 -0
- data/doc/dot/m_7_0.dot +392 -0
- data/doc/dot/m_7_0.png +0 -0
- data/doc/dot/m_8_0.dot +392 -0
- data/doc/dot/m_8_0.png +0 -0
- data/doc/dot/m_9_0.dot +392 -0
- data/doc/dot/m_9_0.png +0 -0
- data/doc/files/lib/AbstractConstraint_rb.html +148 -0
- data/doc/files/lib/AllDifferentConstraint_rb.html +156 -0
- data/doc/files/lib/BinaryConstraint_rb.html +155 -0
- data/doc/files/lib/ConstraintList_rb.html +148 -0
- data/doc/files/lib/ConstraintSolver_rb.html +162 -0
- data/doc/files/lib/Domain_rb.html +155 -0
- data/doc/files/lib/Problem_rb.html +148 -0
- data/doc/files/lib/Solution_rb.html +148 -0
- data/doc/files/lib/Variable_rb.html +148 -0
- data/doc/files/lib/extensions_rb.html +108 -0
- data/doc/files/test/AllDifferentConstraintTest_rb.html +158 -0
- data/doc/files/test/BinaryConstraintTest_rb.html +158 -0
- data/doc/files/test/ConstraintListTest_rb.html +160 -0
- data/doc/files/test/ConstraintSolverTest_rb.html +164 -0
- data/doc/files/test/DomainTest_rb.html +156 -0
- data/doc/files/test/ProblemTest_rb.html +160 -0
- data/doc/files/test/SolutionTest_rb.html +159 -0
- data/doc/files/test/TestSuite_rb.html +113 -0
- data/doc/files/test/VariableTest_rb.html +157 -0
- data/doc/files/test/extensionsTest_rb.html +118 -0
- data/doc/fr_class_index.html +51 -0
- data/doc/fr_file_index.html +46 -0
- data/doc/fr_method_index.html +133 -0
- data/doc/index.html +24 -0
- data/examples/example.rb +7 -0
- data/examples/queens.rb +13 -0
- data/examples/soft.rb +14 -0
- data/lib/AbstractConstraint.rb +45 -0
- data/lib/AllDifferentConstraint.rb +160 -0
- data/lib/BinaryConstraint.rb +187 -0
- data/lib/ConstraintList.rb +31 -0
- data/lib/ConstraintSolver.rb +213 -0
- data/lib/Domain.rb +100 -0
- data/lib/GraphUtils.rb +293 -0
- data/lib/OneOfEqualsConstraint.rb +81 -0
- data/lib/Problem.rb +30 -0
- data/lib/Solution.rb +56 -0
- data/lib/TupleConstraint.rb +111 -0
- data/lib/Variable.rb +74 -0
- data/lib/extensions.rb +55 -0
- data/test/AllDifferentConstraintTest.rb +140 -0
- data/test/BinaryConstraintTest.rb +108 -0
- data/test/ConstraintListTest.rb +41 -0
- data/test/ConstraintSolverTest.rb +274 -0
- data/test/DomainTest.rb +83 -0
- data/test/GraphUtilsTest.rb +83 -0
- data/test/OneOfEqualsConstraintTest.rb +82 -0
- data/test/ProblemTest.rb +35 -0
- data/test/SolutionTest.rb +35 -0
- data/test/TestSuite.rb +10 -0
- data/test/TupleConstraintTest.rb +151 -0
- data/test/VariableTest.rb +47 -0
- data/test/extensionsTest.rb +57 -0
- metadata +212 -0
|
@@ -0,0 +1,342 @@
|
|
|
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::Solution</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::Solution</td>
|
|
54
|
+
</tr>
|
|
55
|
+
<tr class="top-aligned-row">
|
|
56
|
+
<td><strong>In:</strong></td>
|
|
57
|
+
<td>
|
|
58
|
+
<a href="../../files/lib/Solution_rb.html">
|
|
59
|
+
lib/Solution.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
|
+
Object
|
|
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
|
+
<div id="description">
|
|
129
|
+
<p>
|
|
130
|
+
This class represents a solution to a constraint satisfaction problem.
|
|
131
|
+
</p>
|
|
132
|
+
|
|
133
|
+
</div>
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
</div>
|
|
137
|
+
|
|
138
|
+
<div id="method-list">
|
|
139
|
+
<h3 class="section-bar">Methods</h3>
|
|
140
|
+
|
|
141
|
+
<div class="name-list">
|
|
142
|
+
<a href="#M000041"><=></a>
|
|
143
|
+
<a href="#M000042">==</a>
|
|
144
|
+
<a href="#M000040">each</a>
|
|
145
|
+
<a href="#M000039">new</a>
|
|
146
|
+
<a href="#M000043">to_s</a>
|
|
147
|
+
</div>
|
|
148
|
+
</div>
|
|
149
|
+
|
|
150
|
+
</div>
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
<!-- if includes -->
|
|
154
|
+
|
|
155
|
+
<div id="section">
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
<div id="attribute-list">
|
|
162
|
+
<h3 class="section-bar">Attributes</h3>
|
|
163
|
+
|
|
164
|
+
<div class="name-list">
|
|
165
|
+
<table>
|
|
166
|
+
<tr class="top-aligned-row context-row">
|
|
167
|
+
<td class="context-item-name">merit</td>
|
|
168
|
+
<td class="context-item-value"> [R] </td>
|
|
169
|
+
<td class="context-item-desc"></td>
|
|
170
|
+
</tr>
|
|
171
|
+
<tr class="top-aligned-row context-row">
|
|
172
|
+
<td class="context-item-name">variables</td>
|
|
173
|
+
<td class="context-item-value"> [R] </td>
|
|
174
|
+
<td class="context-item-desc"></td>
|
|
175
|
+
</tr>
|
|
176
|
+
</table>
|
|
177
|
+
</div>
|
|
178
|
+
</div>
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
<!-- if method_list -->
|
|
183
|
+
<div id="methods">
|
|
184
|
+
<h3 class="section-bar">Public Class methods</h3>
|
|
185
|
+
|
|
186
|
+
<div id="method-M000039" class="method-detail">
|
|
187
|
+
<a name="M000039"></a>
|
|
188
|
+
|
|
189
|
+
<div class="method-heading">
|
|
190
|
+
<a href="#M000039" class="method-signature">
|
|
191
|
+
<span class="method-name">new</span><span class="method-args">(variables, meritMap={})</span>
|
|
192
|
+
</a>
|
|
193
|
+
</div>
|
|
194
|
+
|
|
195
|
+
<div class="method-description">
|
|
196
|
+
<p>
|
|
197
|
+
Initialises a <a href="Solution.html#M000039">new</a> solution with a list
|
|
198
|
+
of variables. The variables must all have values assigned to them.
|
|
199
|
+
Optionally, a map to map domain values of variables to their merit can be
|
|
200
|
+
spcified.
|
|
201
|
+
</p>
|
|
202
|
+
<p><a class="source-toggle" href="#"
|
|
203
|
+
onclick="toggleCode('M000039-source');return false;">[Source]</a></p>
|
|
204
|
+
<div class="method-source-code" id="M000039-source">
|
|
205
|
+
<pre>
|
|
206
|
+
<span class="ruby-comment cmt"># File lib/Solution.rb, line 11</span>
|
|
207
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">variables</span>, <span class="ruby-identifier">meritMap</span>={})
|
|
208
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">variables</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Array</span>)
|
|
209
|
+
<span class="ruby-identifier">variables</span> = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>([ <span class="ruby-identifier">variables</span> ])
|
|
210
|
+
<span class="ruby-keyword kw">end</span>
|
|
211
|
+
<span class="ruby-keyword kw">if</span> ((<span class="ruby-identifier">variables</span>.<span class="ruby-identifier">collect</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> }).<span class="ruby-identifier">foldLeft</span>(<span class="ruby-constant">Proc</span>.<span class="ruby-identifier">new</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">a</span>,<span class="ruby-identifier">b</span><span class="ruby-operator">|</span> <span class="ruby-identifier">a</span> <span class="ruby-operator">&</span> <span class="ruby-identifier">b</span> }))
|
|
212
|
+
<span class="ruby-ivar">@variables</span> = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>
|
|
213
|
+
<span class="ruby-identifier">variables</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">variable</span><span class="ruby-operator">|</span>
|
|
214
|
+
<span class="ruby-ivar">@variables</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">variable</span>.<span class="ruby-identifier">dup</span>
|
|
215
|
+
}
|
|
216
|
+
<span class="ruby-keyword kw">else</span>
|
|
217
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">"All variables must have values assigned to them!"</span>
|
|
218
|
+
<span class="ruby-keyword kw">end</span>
|
|
219
|
+
<span class="ruby-ivar">@merit</span> = <span class="ruby-value">0</span>
|
|
220
|
+
<span class="ruby-ivar">@variables</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">var</span><span class="ruby-operator">|</span>
|
|
221
|
+
<span class="ruby-ivar">@merit</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">meritMap</span>[<span class="ruby-identifier">var</span>.<span class="ruby-identifier">value</span>] <span class="ruby-operator">?</span> <span class="ruby-identifier">var</span>.<span class="ruby-identifier">merit</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">meritMap</span>[<span class="ruby-identifier">var</span>.<span class="ruby-identifier">value</span>] <span class="ruby-operator">:</span> <span class="ruby-identifier">var</span>.<span class="ruby-identifier">merit</span>
|
|
222
|
+
}
|
|
223
|
+
<span class="ruby-keyword kw">end</span>
|
|
224
|
+
</pre>
|
|
225
|
+
</div>
|
|
226
|
+
</div>
|
|
227
|
+
</div>
|
|
228
|
+
|
|
229
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
|
230
|
+
|
|
231
|
+
<div id="method-M000041" class="method-detail">
|
|
232
|
+
<a name="M000041"></a>
|
|
233
|
+
|
|
234
|
+
<div class="method-heading">
|
|
235
|
+
<a href="#M000041" class="method-signature">
|
|
236
|
+
<span class="method-name"><=></span><span class="method-args">(solution)</span>
|
|
237
|
+
</a>
|
|
238
|
+
</div>
|
|
239
|
+
|
|
240
|
+
<div class="method-description">
|
|
241
|
+
<p><a class="source-toggle" href="#"
|
|
242
|
+
onclick="toggleCode('M000041-source');return false;">[Source]</a></p>
|
|
243
|
+
<div class="method-source-code" id="M000041-source">
|
|
244
|
+
<pre>
|
|
245
|
+
<span class="ruby-comment cmt"># File lib/Solution.rb, line 35</span>
|
|
246
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-operator"><=></span>(<span class="ruby-identifier">solution</span>)
|
|
247
|
+
<span class="ruby-ivar">@value</span> <span class="ruby-operator"><=></span> <span class="ruby-identifier">solution</span>.<span class="ruby-identifier">value</span>
|
|
248
|
+
<span class="ruby-keyword kw">end</span>
|
|
249
|
+
</pre>
|
|
250
|
+
</div>
|
|
251
|
+
</div>
|
|
252
|
+
</div>
|
|
253
|
+
|
|
254
|
+
<div id="method-M000042" class="method-detail">
|
|
255
|
+
<a name="M000042"></a>
|
|
256
|
+
|
|
257
|
+
<div class="method-heading">
|
|
258
|
+
<a href="#M000042" class="method-signature">
|
|
259
|
+
<span class="method-name">==</span><span class="method-args">(solution)</span>
|
|
260
|
+
</a>
|
|
261
|
+
</div>
|
|
262
|
+
|
|
263
|
+
<div class="method-description">
|
|
264
|
+
<p><a class="source-toggle" href="#"
|
|
265
|
+
onclick="toggleCode('M000042-source');return false;">[Source]</a></p>
|
|
266
|
+
<div class="method-source-code" id="M000042-source">
|
|
267
|
+
<pre>
|
|
268
|
+
<span class="ruby-comment cmt"># File lib/Solution.rb, line 39</span>
|
|
269
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-operator">==</span>(<span class="ruby-identifier">solution</span>)
|
|
270
|
+
<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">solution</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Solution</span>)
|
|
271
|
+
<span class="ruby-ivar">@variables</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">solution</span>.<span class="ruby-identifier">variables</span> <span class="ruby-keyword kw">and</span> <span class="ruby-ivar">@merit</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">solution</span>.<span class="ruby-identifier">merit</span>
|
|
272
|
+
<span class="ruby-keyword kw">end</span>
|
|
273
|
+
</pre>
|
|
274
|
+
</div>
|
|
275
|
+
</div>
|
|
276
|
+
</div>
|
|
277
|
+
|
|
278
|
+
<div id="method-M000040" class="method-detail">
|
|
279
|
+
<a name="M000040"></a>
|
|
280
|
+
|
|
281
|
+
<div class="method-heading">
|
|
282
|
+
<a href="#M000040" class="method-signature">
|
|
283
|
+
<span class="method-name">each</span><span class="method-args">() {|variable| ...}</span>
|
|
284
|
+
</a>
|
|
285
|
+
</div>
|
|
286
|
+
|
|
287
|
+
<div class="method-description">
|
|
288
|
+
<p><a class="source-toggle" href="#"
|
|
289
|
+
onclick="toggleCode('M000040-source');return false;">[Source]</a></p>
|
|
290
|
+
<div class="method-source-code" id="M000040-source">
|
|
291
|
+
<pre>
|
|
292
|
+
<span class="ruby-comment cmt"># File lib/Solution.rb, line 29</span>
|
|
293
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">each</span>
|
|
294
|
+
<span class="ruby-ivar">@variables</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">variable</span><span class="ruby-operator">|</span>
|
|
295
|
+
<span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">variable</span>
|
|
296
|
+
}
|
|
297
|
+
<span class="ruby-keyword kw">end</span>
|
|
298
|
+
</pre>
|
|
299
|
+
</div>
|
|
300
|
+
</div>
|
|
301
|
+
</div>
|
|
302
|
+
|
|
303
|
+
<div id="method-M000043" class="method-detail">
|
|
304
|
+
<a name="M000043"></a>
|
|
305
|
+
|
|
306
|
+
<div class="method-heading">
|
|
307
|
+
<a href="#M000043" class="method-signature">
|
|
308
|
+
<span class="method-name">to_s</span><span class="method-args">()</span>
|
|
309
|
+
</a>
|
|
310
|
+
</div>
|
|
311
|
+
|
|
312
|
+
<div class="method-description">
|
|
313
|
+
<p><a class="source-toggle" href="#"
|
|
314
|
+
onclick="toggleCode('M000043-source');return false;">[Source]</a></p>
|
|
315
|
+
<div class="method-source-code" id="M000043-source">
|
|
316
|
+
<pre>
|
|
317
|
+
<span class="ruby-comment cmt"># File lib/Solution.rb, line 44</span>
|
|
318
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_s</span>
|
|
319
|
+
<span class="ruby-identifier">s</span> = (<span class="ruby-ivar">@variables</span>.<span class="ruby-identifier">collect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">variable</span><span class="ruby-operator">|</span>
|
|
320
|
+
<span class="ruby-identifier">variable</span>.<span class="ruby-identifier">to_s</span>
|
|
321
|
+
}).<span class="ruby-identifier">join</span>(<span class="ruby-value str">", "</span>)
|
|
322
|
+
<span class="ruby-identifier">s</span> <span class="ruby-operator">+=</span> <span class="ruby-value str">", merit "</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">merit</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">merit</span>.<span class="ruby-identifier">nil?</span>
|
|
323
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">s</span>
|
|
324
|
+
<span class="ruby-keyword kw">end</span>
|
|
325
|
+
</pre>
|
|
326
|
+
</div>
|
|
327
|
+
</div>
|
|
328
|
+
</div>
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
</div>
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
</div>
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
<div id="validator-badges">
|
|
338
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
|
339
|
+
</div>
|
|
340
|
+
|
|
341
|
+
</body>
|
|
342
|
+
</html>
|
|
@@ -0,0 +1,250 @@
|
|
|
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::SolutionTest</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::SolutionTest</td>
|
|
54
|
+
</tr>
|
|
55
|
+
<tr class="top-aligned-row">
|
|
56
|
+
<td><strong>In:</strong></td>
|
|
57
|
+
<td>
|
|
58
|
+
<a href="../../files/test/SolutionTest_rb.html">
|
|
59
|
+
test/SolutionTest.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="#M000021">setup</a>
|
|
137
|
+
<a href="#M000022">testConstructor</a>
|
|
138
|
+
<a href="#M000023">testValues</a>
|
|
139
|
+
</div>
|
|
140
|
+
</div>
|
|
141
|
+
|
|
142
|
+
</div>
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
<!-- if includes -->
|
|
146
|
+
|
|
147
|
+
<div id="section">
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
<!-- if method_list -->
|
|
157
|
+
<div id="methods">
|
|
158
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
|
159
|
+
|
|
160
|
+
<div id="method-M000021" class="method-detail">
|
|
161
|
+
<a name="M000021"></a>
|
|
162
|
+
|
|
163
|
+
<div class="method-heading">
|
|
164
|
+
<a href="#M000021" class="method-signature">
|
|
165
|
+
<span class="method-name">setup</span><span class="method-args">()</span>
|
|
166
|
+
</a>
|
|
167
|
+
</div>
|
|
168
|
+
|
|
169
|
+
<div class="method-description">
|
|
170
|
+
<p><a class="source-toggle" href="#"
|
|
171
|
+
onclick="toggleCode('M000021-source');return false;">[Source]</a></p>
|
|
172
|
+
<div class="method-source-code" id="M000021-source">
|
|
173
|
+
<pre>
|
|
174
|
+
<span class="ruby-comment cmt"># File test/SolutionTest.rb, line 13</span>
|
|
175
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">setup</span>
|
|
176
|
+
<span class="ruby-ivar">@var</span> = <span class="ruby-constant">Variable</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">"test"</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>), <span class="ruby-keyword kw">nil</span>, <span class="ruby-value">2</span>)
|
|
177
|
+
<span class="ruby-keyword kw">end</span>
|
|
178
|
+
</pre>
|
|
179
|
+
</div>
|
|
180
|
+
</div>
|
|
181
|
+
</div>
|
|
182
|
+
|
|
183
|
+
<div id="method-M000022" class="method-detail">
|
|
184
|
+
<a name="M000022"></a>
|
|
185
|
+
|
|
186
|
+
<div class="method-heading">
|
|
187
|
+
<a href="#M000022" class="method-signature">
|
|
188
|
+
<span class="method-name">testConstructor</span><span class="method-args">()</span>
|
|
189
|
+
</a>
|
|
190
|
+
</div>
|
|
191
|
+
|
|
192
|
+
<div class="method-description">
|
|
193
|
+
<p><a class="source-toggle" href="#"
|
|
194
|
+
onclick="toggleCode('M000022-source');return false;">[Source]</a></p>
|
|
195
|
+
<div class="method-source-code" id="M000022-source">
|
|
196
|
+
<pre>
|
|
197
|
+
<span class="ruby-comment cmt"># File test/SolutionTest.rb, line 17</span>
|
|
198
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">testConstructor</span>
|
|
199
|
+
<span class="ruby-identifier">assert_raise</span>(<span class="ruby-constant">ArgumentError</span>) { <span class="ruby-constant">Solution</span>.<span class="ruby-identifier">new</span> }
|
|
200
|
+
<span class="ruby-identifier">assert_raise</span>(<span class="ruby-constant">ArgumentError</span>) { <span class="ruby-constant">Solution</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@var</span>) }
|
|
201
|
+
<span class="ruby-ivar">@var</span>.<span class="ruby-identifier">value</span> = <span class="ruby-value">1</span>
|
|
202
|
+
<span class="ruby-identifier">assert_nothing_raised</span> { <span class="ruby-constant">Solution</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@var</span>) }
|
|
203
|
+
<span class="ruby-identifier">assert_nothing_raised</span> { <span class="ruby-constant">Solution</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@var</span>, {}) }
|
|
204
|
+
<span class="ruby-ivar">@var</span>.<span class="ruby-identifier">reset</span>
|
|
205
|
+
<span class="ruby-keyword kw">end</span>
|
|
206
|
+
</pre>
|
|
207
|
+
</div>
|
|
208
|
+
</div>
|
|
209
|
+
</div>
|
|
210
|
+
|
|
211
|
+
<div id="method-M000023" class="method-detail">
|
|
212
|
+
<a name="M000023"></a>
|
|
213
|
+
|
|
214
|
+
<div class="method-heading">
|
|
215
|
+
<a href="#M000023" class="method-signature">
|
|
216
|
+
<span class="method-name">testValues</span><span class="method-args">()</span>
|
|
217
|
+
</a>
|
|
218
|
+
</div>
|
|
219
|
+
|
|
220
|
+
<div class="method-description">
|
|
221
|
+
<p><a class="source-toggle" href="#"
|
|
222
|
+
onclick="toggleCode('M000023-source');return false;">[Source]</a></p>
|
|
223
|
+
<div class="method-source-code" id="M000023-source">
|
|
224
|
+
<pre>
|
|
225
|
+
<span class="ruby-comment cmt"># File test/SolutionTest.rb, line 26</span>
|
|
226
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">testValues</span>
|
|
227
|
+
<span class="ruby-ivar">@var</span>.<span class="ruby-identifier">value</span> = <span class="ruby-value">1</span>
|
|
228
|
+
<span class="ruby-identifier">solution</span> = <span class="ruby-constant">Solution</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@var</span>, { <span class="ruby-value">1</span> =<span class="ruby-operator">></span> <span class="ruby-value">2</span> })
|
|
229
|
+
<span class="ruby-identifier">assert_equal</span>(<span class="ruby-value">4</span>, <span class="ruby-identifier">solution</span>.<span class="ruby-identifier">merit</span>)
|
|
230
|
+
<span class="ruby-identifier">assert_equal</span>(<span class="ruby-value">1</span>, <span class="ruby-identifier">solution</span>.<span class="ruby-identifier">variables</span>.<span class="ruby-identifier">size</span>)
|
|
231
|
+
<span class="ruby-identifier">assert_equal</span>(<span class="ruby-value">1</span>, <span class="ruby-identifier">solution</span>.<span class="ruby-identifier">variables</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">value</span>)
|
|
232
|
+
<span class="ruby-keyword kw">end</span>
|
|
233
|
+
</pre>
|
|
234
|
+
</div>
|
|
235
|
+
</div>
|
|
236
|
+
</div>
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
</div>
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
</div>
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
<div id="validator-badges">
|
|
246
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
|
247
|
+
</div>
|
|
248
|
+
|
|
249
|
+
</body>
|
|
250
|
+
</html>
|