File tree 4 files changed +39
-3
lines changed
4 files changed +39
-3
lines changed Original file line number Diff line number Diff line change
1
+
2
+ # ensure line endings are preserved for the mps test files
3
+ t /data /simple-problem.mps text eol =lf
4
+ t /data /simple-problem-crlf.mps text eol =crlf
Original file line number Diff line number Diff line change @@ -167,9 +167,9 @@ boundaries are supported."
167
167
(:raw
168
168
raw)))))
169
169
170
- (iter (for line = (read-line stream ))
170
+ (iter (for line = (string-right-trim ' ( #\Space #\Return ) ( read-line stream ) ))
171
171
(if-let (header-card (unless (char= #\space (aref line 0 ))
172
- (string-downcase (string-right-trim " " ( substring line 0 15 ) ))))
172
+ (string-downcase (substring line 0 15 ))))
173
173
(cond
174
174
; ; do nothing on comments
175
175
((char= (aref header-card 0 ) #\* ))
Original file line number Diff line number Diff line change
1
+ *This is a simple MPS problem to test the MPS reader
2
+ NAME simple
3
+ ROWS
4
+ N obj
5
+ L row1
6
+ L row2
7
+ COLUMNS
8
+ X obj 1 row1 3
9
+ Y obj 4 row1 1
10
+ Y row2 1
11
+ Z obj 8 row2 2
12
+ RHS
13
+ rhs1 row1 8 row2 7
14
+ ENDATA
Original file line number Diff line number Diff line change 224
224
(is (set-equal ' ((z . (0 . 4 )) (|w| . (0 . 1 )) (x . (nil . nil )))
225
225
(problem-var-bounds problem)))
226
226
(is (simple-linear-constraint-set-equal ' ((<= ((x . 3 ) (y . 1 )) 8 ) (<= ((y . 1 ) (z . 2 )) 10 ) (<= ((|w| . -1 ) (x . -2 ) (z . 1 )) 1 ))
227
- (problem-constraints problem))))))
227
+ (problem-constraints problem))
228
228
229
+ (with-open-file (stream (merge-pathnames " t/data/simple-problem-crlf.mps"
230
+ (asdf :system-source-directory :linear-programming-test ))
231
+ :direction :input
232
+ :external-format :utf-8 )
233
+ (let ((problem (read-mps stream ' max)))
234
+ (is (typep problem ' problem))
235
+ (is (eq ' max (problem-type problem)))
236
+ (is-true (null (symbol-package (problem-objective-var problem))))
237
+ (is (set-equal ' (x y z)
238
+ (map ' list #' identity (problem-vars problem))))
239
+ (is (set-equal ' ((x . 1 ) (y . 4 ) (z . 8 ))
240
+ (problem-objective-func problem)))
241
+ (is (set-equal ' ()
242
+ (problem-integer-vars problem)))
243
+ (is (set-equal ' ()
244
+ (problem-var-bounds problem)))
245
+ (is (simple-linear-constraint-set-equal ' ((<= ((x . 3 ) (y . 1 )) 8 ) (<= ((y . 1 ) (z . 2 )) 7 ))
246
+ (problem-constraints problem)))))))))
229
247
230
248
(test write-standard-format
231
249
(let* ((problem (make-linear-problem (max (+ x y)) (<= (+ (* 2 x) y) 5 )))
You can’t perform that action at this time.
0 commit comments