|
245 | 245 | (is (set-equal '((z . (0 . 4)) (|w| . (0 . 1)) (x . (nil . nil)))
|
246 | 246 | (problem-var-bounds problem)))
|
247 | 247 | (is (simple-linear-constraint-set-equal '((<= ((x . 3) (y . 1)) 8) (<= ((y . 1) (z . 2)) 10) (<= ((|w| . -1) (x . -2) (z . 1)) 1))
|
248 |
| - (problem-constraints problem)) |
| 248 | + (problem-constraints problem))))) |
249 | 249 |
|
250 |
| - (with-open-file (stream (merge-pathnames "t/data/simple-problem-crlf.mps" |
251 |
| - (asdf:system-source-directory :linear-programming-test)) |
252 |
| - :direction :input |
253 |
| - :external-format :utf-8) |
254 |
| - (let ((problem (read-mps stream 'max))) |
255 |
| - (is (typep problem 'problem)) |
256 |
| - (is (eq 'max (problem-type problem))) |
257 |
| - (is-true (null (symbol-package (problem-objective-var problem)))) |
258 |
| - (is (set-equal '(x y z) |
259 |
| - (map 'list #'identity (problem-vars problem)))) |
260 |
| - (is (set-equal '((x . 1) (y . 4) (z . 8)) |
261 |
| - (problem-objective-func problem))) |
262 |
| - (is (set-equal '() |
263 |
| - (problem-integer-vars problem))) |
264 |
| - (is (set-equal '() |
265 |
| - (problem-var-bounds problem))) |
266 |
| - (is (simple-linear-constraint-set-equal '((<= ((x . 3) (y . 1)) 8) (<= ((y . 1) (z . 2)) 7)) |
267 |
| - (problem-constraints problem))))))))) |
| 250 | + ; Test input modes |
| 251 | + (with-open-file (stream (merge-pathnames "t/data/advanced-problem.mps" |
| 252 | + (asdf:system-source-directory :linear-programming-test)) |
| 253 | + :direction :input |
| 254 | + :external-format :utf-8) |
| 255 | + (let ((problem (read-mps stream nil :read-case :upcase :rhs-id "rhs1"))) |
| 256 | + (is (set-equal '(|W| |X| |Y| |Z|) |
| 257 | + (map 'list #'identity (problem-vars problem)))))) |
| 258 | + (with-open-file (stream (merge-pathnames "t/data/advanced-problem.mps" |
| 259 | + (asdf:system-source-directory :linear-programming-test)) |
| 260 | + :direction :input |
| 261 | + :external-format :utf-8) |
| 262 | + (let ((problem (read-mps stream nil :read-case :downcase :rhs-id "rhs1"))) |
| 263 | + (is (set-equal '(|w| |x| |y| |z|) |
| 264 | + (map 'list #'identity (problem-vars problem)))))) |
| 265 | + (with-open-file (stream (merge-pathnames "t/data/advanced-problem.mps" |
| 266 | + (asdf:system-source-directory :linear-programming-test)) |
| 267 | + :direction :input |
| 268 | + :external-format :utf-8) |
| 269 | + (let ((problem (read-mps stream nil :read-case :invert :rhs-id "rhs1"))) |
| 270 | + (is (set-equal '(|W| |x| |y| |z|) |
| 271 | + (map 'list #'identity (problem-vars problem)))))) |
| 272 | + |
| 273 | + ; Test windows line endings |
| 274 | + (with-open-file (stream (merge-pathnames "t/data/simple-problem-crlf.mps" |
| 275 | + (asdf:system-source-directory :linear-programming-test)) |
| 276 | + :direction :input |
| 277 | + :external-format :utf-8) |
| 278 | + (let ((problem (read-mps stream 'max))) |
| 279 | + (is (typep problem 'problem)) |
| 280 | + (is (eq 'max (problem-type problem))) |
| 281 | + (is-true (null (symbol-package (problem-objective-var problem)))) |
| 282 | + (is (set-equal '(x y z) |
| 283 | + (map 'list #'identity (problem-vars problem)))) |
| 284 | + (is (set-equal '((x . 1) (y . 4) (z . 8)) |
| 285 | + (problem-objective-func problem))) |
| 286 | + (is (set-equal '() |
| 287 | + (problem-integer-vars problem))) |
| 288 | + (is (set-equal '() |
| 289 | + (problem-var-bounds problem))) |
| 290 | + (is (simple-linear-constraint-set-equal '((<= ((x . 3) (y . 1)) 8) (<= ((y . 1) (z . 2)) 7)) |
| 291 | + (problem-constraints problem)))))) |
268 | 292 |
|
269 | 293 | (test write-standard-format
|
270 | 294 | (let* ((problem (make-linear-problem (max (+ x y)) (<= (+ (* 2 x) y) 5)))
|
|
0 commit comments