Mercurial > jwe > octave
comparison scripts/optimization/glpk.m @ 21130:9d7619605e5e
* glpk.m: Make tests conditional on HAVE_GLPK.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 21 Jan 2016 18:12:34 -0500 |
parents | e204d44f5069 |
children | ecce63c99c3f |
comparison
equal
deleted
inserted
replaced
21129:228b65504557 | 21130:9d7619605e5e |
---|---|
597 __glpk__ (c, A, b, lb, ub, ctype, vartype, sense, param); | 597 __glpk__ (c, A, b, lb, ub, ctype, vartype, sense, param); |
598 | 598 |
599 endfunction | 599 endfunction |
600 | 600 |
601 | 601 |
602 %!test | 602 %!testif HAVE_GLPK |
603 %! sense = -1; | 603 %! sense = -1; |
604 %! c = [10, 6, 4]'; | 604 %! c = [10, 6, 4]'; |
605 %! A = [1, 1, 1; 10, 4, 5; 2, 2, 6]; | 605 %! A = [1, 1, 1; 10, 4, 5; 2, 2, 6]; |
606 %! b = [100, 600, 300]'; | 606 %! b = [100, 600, 300]'; |
607 %! ctype = ['U', 'U', 'U']'; | 607 %! ctype = ['U', 'U', 'U']'; |
615 %! assert (fmin, c' * xmin) | 615 %! assert (fmin, c' * xmin) |
616 %! for i = 1:3 | 616 %! for i = 1:3 |
617 %! assert (A(i,:) * xmin <= b(i)) | 617 %! assert (A(i,:) * xmin <= b(i)) |
618 %! endfor | 618 %! endfor |
619 | 619 |
620 %!test | 620 %!testif HAVE_GLPK |
621 %! sense = 1; | 621 %! sense = 1; |
622 %! c = [-1, -1]'; | 622 %! c = [-1, -1]'; |
623 %! A = [-2, 5; 2, -2]; | 623 %! A = [-2, 5; 2, -2]; |
624 %! b = [5, 1]'; | 624 %! b = [5, 1]'; |
625 %! ctype = ['U', 'U']'; | 625 %! ctype = ['U', 'U']'; |
633 %! for i = 1:2 | 633 %! for i = 1:2 |
634 %! assert (A(i,:) * xmin <= b(i)) | 634 %! assert (A(i,:) * xmin <= b(i)) |
635 %! endfor | 635 %! endfor |
636 | 636 |
637 | 637 |
638 %!test | 638 %!testif HAVE_GLPK |
639 %! sense = 1; | 639 %! sense = 1; |
640 %! c = [0, 0, 0, -1, -1]'; | 640 %! c = [0, 0, 0, -1, -1]'; |
641 %! A = [-2, 0, 0, 1, 0; 0, 1, 0, 0, 2; 0, 0, 1, 3, 2]; | 641 %! A = [-2, 0, 0, 1, 0; 0, 1, 0, 0, 2; 0, 0, 1, 3, 2]; |
642 %! b = [4, 12, 18]'; | 642 %! b = [4, 12, 18]'; |
643 %! ctype = ['S', 'S', 'S']'; | 643 %! ctype = ['S', 'S', 'S']'; |