line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------- |
2
|
|
|
|
|
|
|
| Copyright (c) 2013-2017, Nucleic Development Team. |
3
|
|
|
|
|
|
|
| |
4
|
|
|
|
|
|
|
| Distributed under the terms of the Modified BSD License. |
5
|
|
|
|
|
|
|
| |
6
|
|
|
|
|
|
|
| The full license is in the file LICENSE, distributed with this software. |
7
|
|
|
|
|
|
|
|----------------------------------------------------------------------------*/ |
8
|
|
|
|
|
|
|
#pragma once |
9
|
|
|
|
|
|
|
#include <vector> |
10
|
|
|
|
|
|
|
#include "constraint.h" |
11
|
|
|
|
|
|
|
#include "expression.h" |
12
|
|
|
|
|
|
|
#include "term.h" |
13
|
|
|
|
|
|
|
#include "variable.h" |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
namespace kiwi |
17
|
|
|
|
|
|
|
{ |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
// Variable multiply, divide, and unary invert |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
inline |
22
|
160
|
|
|
|
|
|
Term operator*( const Variable& variable, double coefficient ) |
23
|
|
|
|
|
|
|
{ |
24
|
160
|
|
|
|
|
|
return Term( variable, coefficient ); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
inline |
29
|
11
|
|
|
|
|
|
Term operator/( const Variable& variable, double denominator ) |
30
|
|
|
|
|
|
|
{ |
31
|
11
|
|
|
|
|
|
return variable * ( 1.0 / denominator ); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
inline |
36
|
123
|
|
|
|
|
|
Term operator-( const Variable& variable ) |
37
|
|
|
|
|
|
|
{ |
38
|
123
|
|
|
|
|
|
return variable * -1.0; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
// Term multiply, divide, and unary invert |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
inline |
45
|
2123
|
|
|
|
|
|
Term operator*( const Term& term, double coefficient ) |
46
|
|
|
|
|
|
|
{ |
47
|
2123
|
|
|
|
|
|
return Term( term.variable(), term.coefficient() * coefficient ); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
inline |
52
|
1
|
|
|
|
|
|
Term operator/( const Term& term, double denominator ) |
53
|
|
|
|
|
|
|
{ |
54
|
1
|
|
|
|
|
|
return term * ( 1.0 / denominator ); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
inline |
59
|
3
|
|
|
|
|
|
Term operator-( const Term& term ) |
60
|
|
|
|
|
|
|
{ |
61
|
3
|
|
|
|
|
|
return term * -1.0; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
// Expression multiply, divide, and unary invert |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
inline |
68
|
2567
|
|
|
|
|
|
Expression operator*( const Expression& expression, double coefficient ) |
69
|
|
|
|
|
|
|
{ |
70
|
5134
|
|
|
|
|
|
std::vector<Term> terms; |
71
|
2567
|
50
|
|
|
|
|
terms.reserve( expression.terms().size() ); |
72
|
|
|
|
|
|
|
|
73
|
4686
|
100
|
|
|
|
|
for (const Term &term : expression.terms()) |
74
|
2119
|
50
|
|
|
|
|
terms.push_back(term * coefficient); |
|
|
50
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
5134
|
|
|
|
|
|
return Expression( std::move(terms), expression.constant() * coefficient ); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
inline |
81
|
65
|
|
|
|
|
|
Expression operator/( const Expression& expression, double denominator ) |
82
|
|
|
|
|
|
|
{ |
83
|
65
|
|
|
|
|
|
return expression * ( 1.0 / denominator ); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
inline |
88
|
2502
|
|
|
|
|
|
Expression operator-( const Expression& expression ) |
89
|
|
|
|
|
|
|
{ |
90
|
2502
|
|
|
|
|
|
return expression * -1.0; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
// Double multiply |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
inline |
97
|
0
|
|
|
|
|
|
Expression operator*( double coefficient, const Expression& expression ) |
98
|
|
|
|
|
|
|
{ |
99
|
0
|
|
|
|
|
|
return expression * coefficient; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
inline |
104
|
0
|
|
|
|
|
|
Term operator*( double coefficient, const Term& term ) |
105
|
|
|
|
|
|
|
{ |
106
|
0
|
|
|
|
|
|
return term * coefficient; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
inline |
111
|
25
|
|
|
|
|
|
Term operator*( double coefficient, const Variable& variable ) |
112
|
|
|
|
|
|
|
{ |
113
|
25
|
|
|
|
|
|
return variable * coefficient; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
// Expression add and subtract |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
inline |
120
|
2501
|
|
|
|
|
|
Expression operator+( const Expression& first, const Expression& second ) |
121
|
|
|
|
|
|
|
{ |
122
|
5002
|
|
|
|
|
|
std::vector<Term> terms; |
123
|
2501
|
50
|
|
|
|
|
terms.reserve( first.terms().size() + second.terms().size() ); |
124
|
2501
|
50
|
|
|
|
|
terms.insert( terms.begin(), first.terms().begin(), first.terms().end() ); |
125
|
2501
|
50
|
|
|
|
|
terms.insert( terms.end(), second.terms().begin(), second.terms().end() ); |
126
|
5002
|
|
|
|
|
|
return Expression( std::move(terms), first.constant() + second.constant() ); |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
inline |
131
|
2
|
|
|
|
|
|
Expression operator+( const Expression& first, const Term& second ) |
132
|
|
|
|
|
|
|
{ |
133
|
4
|
|
|
|
|
|
std::vector<Term> terms; |
134
|
2
|
50
|
|
|
|
|
terms.reserve( first.terms().size() + 1 ); |
135
|
2
|
50
|
|
|
|
|
terms.insert( terms.begin(), first.terms().begin(), first.terms().end() ); |
136
|
2
|
50
|
|
|
|
|
terms.push_back( second ); |
137
|
4
|
|
|
|
|
|
return Expression( std::move(terms), first.constant() ); |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
inline |
142
|
1
|
|
|
|
|
|
Expression operator+( const Expression& expression, const Variable& variable ) |
143
|
|
|
|
|
|
|
{ |
144
|
1
|
50
|
|
|
|
|
return expression + Term( variable ); |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
inline |
149
|
0
|
|
|
|
|
|
Expression operator+( const Expression& expression, double constant ) |
150
|
|
|
|
|
|
|
{ |
151
|
0
|
|
|
|
|
|
return Expression( expression.terms(), expression.constant() + constant ); |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
inline |
156
|
2501
|
|
|
|
|
|
Expression operator-( const Expression& first, const Expression& second ) |
157
|
|
|
|
|
|
|
{ |
158
|
2501
|
50
|
|
|
|
|
return first + -second; |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
inline |
163
|
0
|
|
|
|
|
|
Expression operator-( const Expression& expression, const Term& term ) |
164
|
|
|
|
|
|
|
{ |
165
|
0
|
0
|
|
|
|
|
return expression + -term; |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
inline |
170
|
0
|
|
|
|
|
|
Expression operator-( const Expression& expression, const Variable& variable ) |
171
|
|
|
|
|
|
|
{ |
172
|
0
|
0
|
|
|
|
|
return expression + -variable; |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
inline |
177
|
0
|
|
|
|
|
|
Expression operator-( const Expression& expression, double constant ) |
178
|
|
|
|
|
|
|
{ |
179
|
0
|
|
|
|
|
|
return expression + -constant; |
180
|
|
|
|
|
|
|
} |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
// Term add and subtract |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
inline |
186
|
1
|
|
|
|
|
|
Expression operator+( const Term& term, const Expression& expression ) |
187
|
|
|
|
|
|
|
{ |
188
|
1
|
|
|
|
|
|
return expression + term; |
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
inline |
193
|
934
|
|
|
|
|
|
Expression operator+( const Term& first, const Term& second ) |
194
|
|
|
|
|
|
|
{ |
195
|
2802
|
50
|
|
|
|
|
return Expression( { first, second } ); |
|
|
100
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
196
|
|
|
|
|
|
|
} |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
inline |
200
|
924
|
|
|
|
|
|
Expression operator+( const Term& term, const Variable& variable ) |
201
|
|
|
|
|
|
|
{ |
202
|
924
|
50
|
|
|
|
|
return term + Term( variable ); |
203
|
|
|
|
|
|
|
} |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
inline |
207
|
10
|
|
|
|
|
|
Expression operator+( const Term& term, double constant ) |
208
|
|
|
|
|
|
|
{ |
209
|
10
|
|
|
|
|
|
return Expression( term, constant ); |
210
|
|
|
|
|
|
|
} |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
inline |
214
|
0
|
|
|
|
|
|
Expression operator-( const Term& term, const Expression& expression ) |
215
|
|
|
|
|
|
|
{ |
216
|
0
|
0
|
|
|
|
|
return -expression + term; |
217
|
|
|
|
|
|
|
} |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
inline |
221
|
1
|
|
|
|
|
|
Expression operator-( const Term& first, const Term& second ) |
222
|
|
|
|
|
|
|
{ |
223
|
1
|
50
|
|
|
|
|
return first + -second; |
224
|
|
|
|
|
|
|
} |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
inline |
228
|
0
|
|
|
|
|
|
Expression operator-( const Term& term, const Variable& variable ) |
229
|
|
|
|
|
|
|
{ |
230
|
0
|
0
|
|
|
|
|
return term + -variable; |
231
|
|
|
|
|
|
|
} |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
inline |
235
|
1
|
|
|
|
|
|
Expression operator-( const Term& term, double constant ) |
236
|
|
|
|
|
|
|
{ |
237
|
1
|
|
|
|
|
|
return term + -constant; |
238
|
|
|
|
|
|
|
} |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
// Variable add and subtract |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
inline |
244
|
1
|
|
|
|
|
|
Expression operator+( const Variable& variable, const Expression& expression ) |
245
|
|
|
|
|
|
|
{ |
246
|
1
|
|
|
|
|
|
return expression + variable; |
247
|
|
|
|
|
|
|
} |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
inline |
251
|
121
|
|
|
|
|
|
Expression operator+( const Variable& variable, const Term& term ) |
252
|
|
|
|
|
|
|
{ |
253
|
121
|
|
|
|
|
|
return term + variable; |
254
|
|
|
|
|
|
|
} |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
inline |
258
|
803
|
|
|
|
|
|
Expression operator+( const Variable& first, const Variable& second ) |
259
|
|
|
|
|
|
|
{ |
260
|
803
|
50
|
|
|
|
|
return Term( first ) + second; |
261
|
|
|
|
|
|
|
} |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
inline |
265
|
4
|
|
|
|
|
|
Expression operator+( const Variable& variable, double constant ) |
266
|
|
|
|
|
|
|
{ |
267
|
4
|
50
|
|
|
|
|
return Term( variable ) + constant; |
268
|
|
|
|
|
|
|
} |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
inline |
272
|
0
|
|
|
|
|
|
Expression operator-( const Variable& variable, const Expression& expression ) |
273
|
|
|
|
|
|
|
{ |
274
|
0
|
0
|
|
|
|
|
return variable + -expression; |
275
|
|
|
|
|
|
|
} |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
inline |
279
|
0
|
|
|
|
|
|
Expression operator-( const Variable& variable, const Term& term ) |
280
|
|
|
|
|
|
|
{ |
281
|
0
|
0
|
|
|
|
|
return variable + -term; |
282
|
|
|
|
|
|
|
} |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
inline |
286
|
121
|
|
|
|
|
|
Expression operator-( const Variable& first, const Variable& second ) |
287
|
|
|
|
|
|
|
{ |
288
|
121
|
50
|
|
|
|
|
return first + -second; |
289
|
|
|
|
|
|
|
} |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
inline |
293
|
1
|
|
|
|
|
|
Expression operator-( const Variable& variable, double constant ) |
294
|
|
|
|
|
|
|
{ |
295
|
1
|
|
|
|
|
|
return variable + -constant; |
296
|
|
|
|
|
|
|
} |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
// Double add and subtract |
300
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
inline |
302
|
0
|
|
|
|
|
|
Expression operator+( double constant, const Expression& expression ) |
303
|
|
|
|
|
|
|
{ |
304
|
0
|
|
|
|
|
|
return expression + constant; |
305
|
|
|
|
|
|
|
} |
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
inline |
309
|
1
|
|
|
|
|
|
Expression operator+( double constant, const Term& term ) |
310
|
|
|
|
|
|
|
{ |
311
|
1
|
|
|
|
|
|
return term + constant; |
312
|
|
|
|
|
|
|
} |
313
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
inline |
316
|
1
|
|
|
|
|
|
Expression operator+( double constant, const Variable& variable ) |
317
|
|
|
|
|
|
|
{ |
318
|
1
|
|
|
|
|
|
return variable + constant; |
319
|
|
|
|
|
|
|
} |
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
inline |
323
|
0
|
|
|
|
|
|
Expression operator-( double constant, const Expression& expression ) |
324
|
|
|
|
|
|
|
{ |
325
|
0
|
0
|
|
|
|
|
return -expression + constant; |
326
|
|
|
|
|
|
|
} |
327
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
inline |
330
|
1
|
|
|
|
|
|
Expression operator-( double constant, const Term& term ) |
331
|
|
|
|
|
|
|
{ |
332
|
1
|
50
|
|
|
|
|
return -term + constant; |
333
|
|
|
|
|
|
|
} |
334
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
inline |
337
|
1
|
|
|
|
|
|
Expression operator-( double constant, const Variable& variable ) |
338
|
|
|
|
|
|
|
{ |
339
|
1
|
50
|
|
|
|
|
return -variable + constant; |
340
|
|
|
|
|
|
|
} |
341
|
|
|
|
|
|
|
|
342
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
// Expression relations |
344
|
|
|
|
|
|
|
|
345
|
|
|
|
|
|
|
inline |
346
|
1742
|
|
|
|
|
|
Constraint operator==( const Expression& first, const Expression& second ) |
347
|
|
|
|
|
|
|
{ |
348
|
1742
|
50
|
|
|
|
|
return Constraint( first - second, OP_EQ ); |
349
|
|
|
|
|
|
|
} |
350
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
|
352
|
|
|
|
|
|
|
inline |
353
|
1740
|
|
|
|
|
|
Constraint operator==( const Expression& expression, const Term& term ) |
354
|
|
|
|
|
|
|
{ |
355
|
1740
|
50
|
|
|
|
|
return expression == Expression( term ); |
356
|
|
|
|
|
|
|
} |
357
|
|
|
|
|
|
|
|
358
|
|
|
|
|
|
|
|
359
|
|
|
|
|
|
|
inline |
360
|
1738
|
|
|
|
|
|
Constraint operator==( const Expression& expression, const Variable& variable ) |
361
|
|
|
|
|
|
|
{ |
362
|
1738
|
50
|
|
|
|
|
return expression == Term( variable ); |
363
|
|
|
|
|
|
|
} |
364
|
|
|
|
|
|
|
|
365
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
inline |
367
|
2
|
|
|
|
|
|
Constraint operator==( const Expression& expression, double constant ) |
368
|
|
|
|
|
|
|
{ |
369
|
2
|
50
|
|
|
|
|
return expression == Expression( constant ); |
370
|
|
|
|
|
|
|
} |
371
|
|
|
|
|
|
|
|
372
|
|
|
|
|
|
|
|
373
|
|
|
|
|
|
|
inline |
374
|
382
|
|
|
|
|
|
Constraint operator<=( const Expression& first, const Expression& second ) |
375
|
|
|
|
|
|
|
{ |
376
|
382
|
50
|
|
|
|
|
return Constraint( first - second, OP_LE ); |
377
|
|
|
|
|
|
|
} |
378
|
|
|
|
|
|
|
|
379
|
|
|
|
|
|
|
|
380
|
|
|
|
|
|
|
inline |
381
|
127
|
|
|
|
|
|
Constraint operator<=( const Expression& expression, const Term& term ) |
382
|
|
|
|
|
|
|
{ |
383
|
127
|
50
|
|
|
|
|
return expression <= Expression( term ); |
384
|
|
|
|
|
|
|
} |
385
|
|
|
|
|
|
|
|
386
|
|
|
|
|
|
|
|
387
|
|
|
|
|
|
|
inline |
388
|
127
|
|
|
|
|
|
Constraint operator<=( const Expression& expression, const Variable& variable ) |
389
|
|
|
|
|
|
|
{ |
390
|
127
|
50
|
|
|
|
|
return expression <= Term( variable ); |
391
|
|
|
|
|
|
|
} |
392
|
|
|
|
|
|
|
|
393
|
|
|
|
|
|
|
|
394
|
|
|
|
|
|
|
inline |
395
|
255
|
|
|
|
|
|
Constraint operator<=( const Expression& expression, double constant ) |
396
|
|
|
|
|
|
|
{ |
397
|
255
|
50
|
|
|
|
|
return expression <= Expression( constant ); |
398
|
|
|
|
|
|
|
} |
399
|
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
|
401
|
|
|
|
|
|
|
inline |
402
|
377
|
|
|
|
|
|
Constraint operator>=( const Expression& first, const Expression& second ) |
403
|
|
|
|
|
|
|
{ |
404
|
377
|
50
|
|
|
|
|
return Constraint( first - second, OP_GE ); |
405
|
|
|
|
|
|
|
} |
406
|
|
|
|
|
|
|
|
407
|
|
|
|
|
|
|
|
408
|
|
|
|
|
|
|
inline |
409
|
120
|
|
|
|
|
|
Constraint operator>=( const Expression& expression, const Term& term ) |
410
|
|
|
|
|
|
|
{ |
411
|
120
|
50
|
|
|
|
|
return expression >= Expression( term ); |
412
|
|
|
|
|
|
|
} |
413
|
|
|
|
|
|
|
|
414
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
inline |
416
|
120
|
|
|
|
|
|
Constraint operator>=( const Expression& expression, const Variable& variable ) |
417
|
|
|
|
|
|
|
{ |
418
|
120
|
50
|
|
|
|
|
return expression >= Term( variable ); |
419
|
|
|
|
|
|
|
} |
420
|
|
|
|
|
|
|
|
421
|
|
|
|
|
|
|
|
422
|
|
|
|
|
|
|
inline |
423
|
257
|
|
|
|
|
|
Constraint operator>=( const Expression& expression, double constant ) |
424
|
|
|
|
|
|
|
{ |
425
|
257
|
50
|
|
|
|
|
return expression >= Expression( constant ); |
426
|
|
|
|
|
|
|
} |
427
|
|
|
|
|
|
|
|
428
|
|
|
|
|
|
|
|
429
|
|
|
|
|
|
|
// Term relations |
430
|
|
|
|
|
|
|
|
431
|
|
|
|
|
|
|
inline |
432
|
2
|
|
|
|
|
|
Constraint operator==( const Term& term, const Expression& expression ) |
433
|
|
|
|
|
|
|
{ |
434
|
2
|
|
|
|
|
|
return expression == term; |
435
|
|
|
|
|
|
|
} |
436
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
|
438
|
|
|
|
|
|
|
inline |
439
|
0
|
|
|
|
|
|
Constraint operator==( const Term& first, const Term& second ) |
440
|
|
|
|
|
|
|
{ |
441
|
0
|
0
|
|
|
|
|
return Expression( first ) == second; |
442
|
|
|
|
|
|
|
} |
443
|
|
|
|
|
|
|
|
444
|
|
|
|
|
|
|
|
445
|
|
|
|
|
|
|
inline |
446
|
1062
|
|
|
|
|
|
Constraint operator==( const Term& term, const Variable& variable ) |
447
|
|
|
|
|
|
|
{ |
448
|
1062
|
50
|
|
|
|
|
return Expression( term ) == variable; |
449
|
|
|
|
|
|
|
} |
450
|
|
|
|
|
|
|
|
451
|
|
|
|
|
|
|
|
452
|
|
|
|
|
|
|
inline |
453
|
1
|
|
|
|
|
|
Constraint operator==( const Term& term, double constant ) |
454
|
|
|
|
|
|
|
{ |
455
|
1
|
50
|
|
|
|
|
return Expression( term ) == constant; |
456
|
|
|
|
|
|
|
} |
457
|
|
|
|
|
|
|
|
458
|
|
|
|
|
|
|
|
459
|
|
|
|
|
|
|
inline |
460
|
0
|
|
|
|
|
|
Constraint operator<=( const Term& term, const Expression& expression ) |
461
|
|
|
|
|
|
|
{ |
462
|
0
|
|
|
|
|
|
return expression >= term; |
463
|
|
|
|
|
|
|
} |
464
|
|
|
|
|
|
|
|
465
|
|
|
|
|
|
|
|
466
|
|
|
|
|
|
|
inline |
467
|
0
|
|
|
|
|
|
Constraint operator<=( const Term& first, const Term& second ) |
468
|
|
|
|
|
|
|
{ |
469
|
0
|
0
|
|
|
|
|
return Expression( first ) <= second; |
470
|
|
|
|
|
|
|
} |
471
|
|
|
|
|
|
|
|
472
|
|
|
|
|
|
|
|
473
|
|
|
|
|
|
|
inline |
474
|
0
|
|
|
|
|
|
Constraint operator<=( const Term& term, const Variable& variable ) |
475
|
|
|
|
|
|
|
{ |
476
|
0
|
0
|
|
|
|
|
return Expression( term ) <= variable; |
477
|
|
|
|
|
|
|
} |
478
|
|
|
|
|
|
|
|
479
|
|
|
|
|
|
|
|
480
|
|
|
|
|
|
|
inline |
481
|
255
|
|
|
|
|
|
Constraint operator<=( const Term& term, double constant ) |
482
|
|
|
|
|
|
|
{ |
483
|
255
|
50
|
|
|
|
|
return Expression( term ) <= constant; |
484
|
|
|
|
|
|
|
} |
485
|
|
|
|
|
|
|
|
486
|
|
|
|
|
|
|
|
487
|
|
|
|
|
|
|
inline |
488
|
0
|
|
|
|
|
|
Constraint operator>=( const Term& term, const Expression& expression ) |
489
|
|
|
|
|
|
|
{ |
490
|
0
|
|
|
|
|
|
return expression <= term; |
491
|
|
|
|
|
|
|
} |
492
|
|
|
|
|
|
|
|
493
|
|
|
|
|
|
|
|
494
|
|
|
|
|
|
|
inline |
495
|
0
|
|
|
|
|
|
Constraint operator>=( const Term& first, const Term& second ) |
496
|
|
|
|
|
|
|
{ |
497
|
0
|
0
|
|
|
|
|
return Expression( first ) >= second; |
498
|
|
|
|
|
|
|
} |
499
|
|
|
|
|
|
|
|
500
|
|
|
|
|
|
|
|
501
|
|
|
|
|
|
|
inline |
502
|
0
|
|
|
|
|
|
Constraint operator>=( const Term& term, const Variable& variable ) |
503
|
|
|
|
|
|
|
{ |
504
|
0
|
0
|
|
|
|
|
return Expression( term ) >= variable; |
505
|
|
|
|
|
|
|
} |
506
|
|
|
|
|
|
|
|
507
|
|
|
|
|
|
|
|
508
|
|
|
|
|
|
|
inline |
509
|
257
|
|
|
|
|
|
Constraint operator>=( const Term& term, double constant ) |
510
|
|
|
|
|
|
|
{ |
511
|
257
|
50
|
|
|
|
|
return Expression( term ) >= constant; |
512
|
|
|
|
|
|
|
} |
513
|
|
|
|
|
|
|
|
514
|
|
|
|
|
|
|
|
515
|
|
|
|
|
|
|
// Variable relations |
516
|
|
|
|
|
|
|
inline |
517
|
676
|
|
|
|
|
|
Constraint operator==( const Variable& variable, const Expression& expression ) |
518
|
|
|
|
|
|
|
{ |
519
|
676
|
|
|
|
|
|
return expression == variable; |
520
|
|
|
|
|
|
|
} |
521
|
|
|
|
|
|
|
|
522
|
|
|
|
|
|
|
|
523
|
|
|
|
|
|
|
inline |
524
|
0
|
|
|
|
|
|
Constraint operator==( const Variable& variable, const Term& term ) |
525
|
|
|
|
|
|
|
{ |
526
|
0
|
|
|
|
|
|
return term == variable; |
527
|
|
|
|
|
|
|
} |
528
|
|
|
|
|
|
|
|
529
|
|
|
|
|
|
|
|
530
|
|
|
|
|
|
|
inline |
531
|
1062
|
|
|
|
|
|
Constraint operator==( const Variable& first, const Variable& second ) |
532
|
|
|
|
|
|
|
{ |
533
|
1062
|
50
|
|
|
|
|
return Term( first ) == second; |
534
|
|
|
|
|
|
|
} |
535
|
|
|
|
|
|
|
|
536
|
|
|
|
|
|
|
|
537
|
|
|
|
|
|
|
inline |
538
|
1
|
|
|
|
|
|
Constraint operator==( const Variable& variable, double constant ) |
539
|
|
|
|
|
|
|
{ |
540
|
1
|
50
|
|
|
|
|
return Term( variable ) == constant; |
541
|
|
|
|
|
|
|
} |
542
|
|
|
|
|
|
|
|
543
|
|
|
|
|
|
|
|
544
|
|
|
|
|
|
|
inline |
545
|
120
|
|
|
|
|
|
Constraint operator<=( const Variable& variable, const Expression& expression ) |
546
|
|
|
|
|
|
|
{ |
547
|
120
|
|
|
|
|
|
return expression >= variable; |
548
|
|
|
|
|
|
|
} |
549
|
|
|
|
|
|
|
|
550
|
|
|
|
|
|
|
|
551
|
|
|
|
|
|
|
inline |
552
|
0
|
|
|
|
|
|
Constraint operator<=( const Variable& variable, const Term& term ) |
553
|
|
|
|
|
|
|
{ |
554
|
0
|
|
|
|
|
|
return term >= variable; |
555
|
|
|
|
|
|
|
} |
556
|
|
|
|
|
|
|
|
557
|
|
|
|
|
|
|
|
558
|
|
|
|
|
|
|
inline |
559
|
0
|
|
|
|
|
|
Constraint operator<=( const Variable& first, const Variable& second ) |
560
|
|
|
|
|
|
|
{ |
561
|
0
|
0
|
|
|
|
|
return Term( first ) <= second; |
562
|
|
|
|
|
|
|
} |
563
|
|
|
|
|
|
|
|
564
|
|
|
|
|
|
|
|
565
|
|
|
|
|
|
|
inline |
566
|
255
|
|
|
|
|
|
Constraint operator<=( const Variable& variable, double constant ) |
567
|
|
|
|
|
|
|
{ |
568
|
255
|
50
|
|
|
|
|
return Term( variable ) <= constant; |
569
|
|
|
|
|
|
|
} |
570
|
|
|
|
|
|
|
|
571
|
|
|
|
|
|
|
|
572
|
|
|
|
|
|
|
inline |
573
|
127
|
|
|
|
|
|
Constraint operator>=( const Variable& variable, const Expression& expression ) |
574
|
|
|
|
|
|
|
{ |
575
|
127
|
|
|
|
|
|
return expression <= variable; |
576
|
|
|
|
|
|
|
} |
577
|
|
|
|
|
|
|
|
578
|
|
|
|
|
|
|
|
579
|
|
|
|
|
|
|
inline |
580
|
0
|
|
|
|
|
|
Constraint operator>=( const Variable& variable, const Term& term ) |
581
|
|
|
|
|
|
|
{ |
582
|
0
|
|
|
|
|
|
return term <= variable; |
583
|
|
|
|
|
|
|
} |
584
|
|
|
|
|
|
|
|
585
|
|
|
|
|
|
|
|
586
|
|
|
|
|
|
|
inline |
587
|
0
|
|
|
|
|
|
Constraint operator>=( const Variable& first, const Variable& second ) |
588
|
|
|
|
|
|
|
{ |
589
|
0
|
0
|
|
|
|
|
return Term( first ) >= second; |
590
|
|
|
|
|
|
|
} |
591
|
|
|
|
|
|
|
|
592
|
|
|
|
|
|
|
|
593
|
|
|
|
|
|
|
inline |
594
|
257
|
|
|
|
|
|
Constraint operator>=( const Variable& variable, double constant ) |
595
|
|
|
|
|
|
|
{ |
596
|
257
|
50
|
|
|
|
|
return Term( variable ) >= constant; |
597
|
|
|
|
|
|
|
} |
598
|
|
|
|
|
|
|
|
599
|
|
|
|
|
|
|
|
600
|
|
|
|
|
|
|
// Double relations |
601
|
|
|
|
|
|
|
|
602
|
|
|
|
|
|
|
inline |
603
|
1
|
|
|
|
|
|
Constraint operator==( double constant, const Expression& expression ) |
604
|
|
|
|
|
|
|
{ |
605
|
1
|
|
|
|
|
|
return expression == constant; |
606
|
|
|
|
|
|
|
} |
607
|
|
|
|
|
|
|
|
608
|
|
|
|
|
|
|
|
609
|
|
|
|
|
|
|
inline |
610
|
0
|
|
|
|
|
|
Constraint operator==( double constant, const Term& term ) |
611
|
|
|
|
|
|
|
{ |
612
|
0
|
|
|
|
|
|
return term == constant; |
613
|
|
|
|
|
|
|
} |
614
|
|
|
|
|
|
|
|
615
|
|
|
|
|
|
|
|
616
|
|
|
|
|
|
|
inline |
617
|
0
|
|
|
|
|
|
Constraint operator==( double constant, const Variable& variable ) |
618
|
|
|
|
|
|
|
{ |
619
|
0
|
|
|
|
|
|
return variable == constant; |
620
|
|
|
|
|
|
|
} |
621
|
|
|
|
|
|
|
|
622
|
|
|
|
|
|
|
|
623
|
|
|
|
|
|
|
inline |
624
|
0
|
|
|
|
|
|
Constraint operator<=( double constant, const Expression& expression ) |
625
|
|
|
|
|
|
|
{ |
626
|
0
|
|
|
|
|
|
return expression >= constant; |
627
|
|
|
|
|
|
|
} |
628
|
|
|
|
|
|
|
|
629
|
|
|
|
|
|
|
|
630
|
|
|
|
|
|
|
inline |
631
|
0
|
|
|
|
|
|
Constraint operator<=( double constant, const Term& term ) |
632
|
|
|
|
|
|
|
{ |
633
|
0
|
|
|
|
|
|
return term >= constant; |
634
|
|
|
|
|
|
|
} |
635
|
|
|
|
|
|
|
|
636
|
|
|
|
|
|
|
|
637
|
|
|
|
|
|
|
inline |
638
|
0
|
|
|
|
|
|
Constraint operator<=( double constant, const Variable& variable ) |
639
|
|
|
|
|
|
|
{ |
640
|
0
|
|
|
|
|
|
return variable >= constant; |
641
|
|
|
|
|
|
|
} |
642
|
|
|
|
|
|
|
|
643
|
|
|
|
|
|
|
|
644
|
|
|
|
|
|
|
inline |
645
|
0
|
|
|
|
|
|
Constraint operator>=( double constant, const Expression& expression ) |
646
|
|
|
|
|
|
|
{ |
647
|
0
|
|
|
|
|
|
return expression <= constant; |
648
|
|
|
|
|
|
|
} |
649
|
|
|
|
|
|
|
|
650
|
|
|
|
|
|
|
|
651
|
|
|
|
|
|
|
inline |
652
|
0
|
|
|
|
|
|
Constraint operator>=( double constant, const Term& term ) |
653
|
|
|
|
|
|
|
{ |
654
|
0
|
|
|
|
|
|
return term <= constant; |
655
|
|
|
|
|
|
|
} |
656
|
|
|
|
|
|
|
|
657
|
|
|
|
|
|
|
|
658
|
|
|
|
|
|
|
inline |
659
|
0
|
|
|
|
|
|
Constraint operator>=( double constant, const Variable& variable ) |
660
|
|
|
|
|
|
|
{ |
661
|
0
|
|
|
|
|
|
return variable <= constant; |
662
|
|
|
|
|
|
|
} |
663
|
|
|
|
|
|
|
|
664
|
|
|
|
|
|
|
|
665
|
|
|
|
|
|
|
// Constraint strength modifier |
666
|
|
|
|
|
|
|
|
667
|
|
|
|
|
|
|
inline |
668
|
1100
|
|
|
|
|
|
Constraint operator|( const Constraint& constraint, double strength ) |
669
|
|
|
|
|
|
|
{ |
670
|
1100
|
|
|
|
|
|
return Constraint( constraint, strength ); |
671
|
|
|
|
|
|
|
} |
672
|
|
|
|
|
|
|
|
673
|
|
|
|
|
|
|
|
674
|
|
|
|
|
|
|
inline |
675
|
0
|
|
|
|
|
|
Constraint operator|( double strength, const Constraint& constraint ) |
676
|
|
|
|
|
|
|
{ |
677
|
0
|
|
|
|
|
|
return constraint | strength; |
678
|
|
|
|
|
|
|
} |
679
|
|
|
|
|
|
|
|
680
|
|
|
|
|
|
|
} // namespace kiwi |