diff options
101 files changed, 3398 insertions, 145 deletions
diff --git a/demos/README.rst b/demos/README.rst new file mode 100644 index 0000000..5a4e36d --- /dev/null +++ b/demos/README.rst @@ -0,0 +1,5 @@ +DEMOS Files +=========== + +Demo files for the qpipopt and qpipoptmat which are used for Quadratic Programming. And also for symphony and symphonymat which are used for Mixed integer linear programming. + diff --git a/demos/qpipopt.dem.sce b/demos/qpipopt.dem.sce index 3b36ff1..d929a5c 100644 --- a/demos/qpipopt.dem.sce +++ b/demos/qpipopt.dem.sce @@ -17,7 +17,9 @@ ub=[10000; 100; 1.5; 100; 100; 1000]; p=[1; 2; 3; 4; 5; 6]; Q=eye(6,6); nbVar = 6; nbCon = 5; -[xopt,fopt,exitflag,output,lambda]=qpipopt(nbVar,nbCon,Q,p,lb,ub,conMatrix,conLB,conUB) +x0 = repmat(0,nbVar,1); +param = list("MaxIter", 300, "CpuTime", 100); +[xopt,fopt,exitflag,output,lambda]=qpipopt(nbVar,nbCon,Q,p,lb,ub,conMatrix,conLB,conUB,x0,param) halt() // Press return to continue //Find the value of x that minimize following function diff --git a/demos/qpipoptmat.dem.sce b/demos/qpipoptmat.dem.sce new file mode 100644 index 0000000..61263a8 --- /dev/null +++ b/demos/qpipoptmat.dem.sce @@ -0,0 +1,42 @@ +mode(1) +// +// Demo of qpipoptmat.sci +// + +//Find x in R^6 such that: +halt() // Press return to continue + +Aeq= [1,-1,1,0,3,1; +-1,0,-3,-4,5,6; +2,5,3,0,1,0]; +beq=[1; 2; 3]; +A= [0,1,0,1,2,-1; +-1,0,2,1,1,0]; +b = [-1; 2.5]; +lb=[-1000; -10000; 0; -1000; -1000; -1000]; +ub=[10000; 100; 1.5; 100; 100; 1000]; +x0 = repmat(0,6,1); +param = list("MaxIter", 300, "CpuTime", 100); +//and minimize 0.5*x'*Q*x + p'*x with +f=[1; 2; 3; 4; 5; 6]; H=eye(6,6); +[xopt,fopt,exitflag,output,lambda]=qpipoptmat(H,f,A,b,Aeq,beq,lb,ub,[],param) +clear H f A b Aeq beq lb ub; +halt() // Press return to continue + +//Find the value of x that minimize following function +// f(x) = 0.5*x1^2 + x2^2 - x1*x2 - 2*x1 - 6*x2 +// Subject to: +// x1 + x2 ≤ 2 +// –x1 + 2x2 ≤ 2 +// 2x1 + x2 ≤ 3 +// 0 ≤ x1, 0 ≤ x2. +H = [1 -1; -1 2]; +f = [-2; -6]; +A = [1 1; -1 2; 2 1]; +b = [2; 2; 3]; +lb = [0; 0]; +ub = [%inf; %inf]; +[xopt,fopt,exitflag,output,lambda] = qpipoptmat(H,f,A,b,[],[],lb,ub) +halt() // Press return to continue + +//========= E N D === O F === D E M O =========// diff --git a/demos/qpipoptmat.dem.sce~ b/demos/qpipoptmat.dem.sce~ new file mode 100644 index 0000000..79628a7 --- /dev/null +++ b/demos/qpipoptmat.dem.sce~ @@ -0,0 +1,42 @@ +mode(1) +// +// Demo of qpipoptmat.sci +// + +//Find x in R^6 such that: +halt() // Press return to continue + +Aeq= [1,-1,1,0,3,1; +-1,0,-3,-4,5,6; +2,5,3,0,1,0]; +beq=[1; 2; 3]; +A= [0,1,0,1,2,-1; +-1,0,2,1,1,0]; +b = [-1; 2.5]; +lb=[-1000; -10000; 0; -1000; -1000; -1000]; +ub=[10000; 100; 1.5; 100; 100; 1000]; +x0 = repmat(0,6,1); +param = list("MaxIter", 300, "CpuTime", 100); +//and minimize 0.5*x'*Q*x + p'*x with +f=[1; 2; 3; 4; 5; 6]; H=eye(6,6); +[xopt,fopt,exitflag,output,lambda]=qpipoptmat(H,f,A,b,Aeq,beq,lb,ub,[],param); +clear H f A b Aeq beq lb ub; +halt() // Press return to continue + +//Find the value of x that minimize following function +// f(x) = 0.5*x1^2 + x2^2 - x1*x2 - 2*x1 - 6*x2 +// Subject to: +// x1 + x2 ≤ 2 +// –x1 + 2x2 ≤ 2 +// 2x1 + x2 ≤ 3 +// 0 ≤ x1, 0 ≤ x2. +H = [1 -1; -1 2]; +f = [-2; -6]; +A = [1 1; -1 2; 2 1]; +b = [2; 2; 3]; +lb = [0; 0]; +ub = [%inf; %inf]; +[xopt,fopt,exitflag,output,lambda] = qpipoptmat(H,f,A,b,[],[],lb,ub) +halt() // Press return to continue + +//========= E N D === O F === D E M O =========// diff --git a/demos/sci_symphony.dem.gateway.sce b/demos/sci_symphony.dem.gateway.sce index 9256ca2..b3c52f4 100644 --- a/demos/sci_symphony.dem.gateway.sce +++ b/demos/sci_symphony.dem.gateway.sce @@ -11,6 +11,6 @@ demopath = get_absolute_file_path("sci_symphony.dem.gateway.sce"); -subdemolist = ["Symphony for knapsack", "symphony_knapsack.sce"]; +subdemolist = ["Symphony", "symphony.dem.sce"; "SymphonyMat", "symphonymat.dem.sce"; "Qpipopt", "qpipopt.dem.sce"; "QpipoptMat", "qpipoptmat.dem.sce";]; subdemolist(:,2) = demopath + subdemolist(:,2); diff --git a/demos/sci_symphony.dem.gateway.sce~ b/demos/sci_symphony.dem.gateway.sce~ new file mode 100644 index 0000000..9256ca2 --- /dev/null +++ b/demos/sci_symphony.dem.gateway.sce~ @@ -0,0 +1,16 @@ +// Copyright (C) 2015 - IIT Bombay - FOSSEE +// +// Author: Harpreet Singh +// Organization: FOSSEE, IIT Bombay +// Email: harpreet.mertia@gmail.com +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + +demopath = get_absolute_file_path("sci_symphony.dem.gateway.sce"); + +subdemolist = ["Symphony for knapsack", "symphony_knapsack.sce"]; + +subdemolist(:,2) = demopath + subdemolist(:,2); diff --git a/demos/symphony.dem.sce b/demos/symphony.dem.sce new file mode 100644 index 0000000..627c857 --- /dev/null +++ b/demos/symphony.dem.sce @@ -0,0 +1,113 @@ +mode(1) +// +// Demo of symphony.sci +// + +//A basic case : +// Objective function +c = [350*5,330*3,310*4,280*6,500,450,400,100] +// Lower Bound of variable +lb = repmat(0,1,8); +// Upper Bound of variables +ub = [repmat(1,1,4) repmat(%inf,1,4)]; +// Constraint Matrix +conMatrix = [5,3,4,6,1,1,1,1; +5*0.05,3*0.04,4*0.05,6*0.03,0.08,0.07,0.06,0.03; +5*0.03,3*0.03,4*0.04,6*0.04,0.06,0.07,0.08,0.09;] +// Lower Bound of constrains +conlb = [ 25; 1.25; 1.25] +// Upper Bound of constrains +conub = [ 25; 1.25; 1.25] +// Row Matrix for telling symphony that the is integer or not +isInt = [repmat(%t,1,4) repmat(%f,1,4)]; +xopt = [1 1 0 1 7.25 0 0.25 3.5] +fopt = [8495] +// Calling Symphony +[x,f,status,output] = symphony(8,3,c,isInt,lb,ub,conMatrix,conlb,conub,1) +halt() // Press return to continue + +// An advanced case where we set some options in symphony +// This problem is taken from +// P.C.Chu and J.E.Beasley +// "A genetic algorithm for the multidimensional knapsack problem", +// Journal of Heuristics, vol. 4, 1998, pp63-86. +// The problem to be solved is: +// Max sum{j=1,...,n} p(j)x(j) +// st sum{j=1,...,n} r(i,j)x(j) <= b(i) i=1,...,m +// x(j)=0 or 1 +// The function to be maximize i.e. P(j) +p = [ 504 803 667 1103 834 585 811 856 690 832 846 813 868 793 .. +825 1002 860 615 540 797 616 660 707 866 647 746 1006 608 .. +877 900 573 788 484 853 942 630 591 630 640 1169 932 1034 .. +957 798 669 625 467 1051 552 717 654 388 559 555 1104 783 .. +959 668 507 855 986 831 821 825 868 852 832 828 799 686 .. +510 671 575 740 510 675 996 636 826 1022 1140 654 909 799 .. +1162 653 814 625 599 476 767 954 906 904 649 873 565 853 1008 632] +//Constraint Matrix +conMatrix = [ +//Constraint 1 +42 41 523 215 819 551 69 193 582 375 367 478 162 898 .. +550 553 298 577 493 183 260 224 852 394 958 282 402 604 .. +164 308 218 61 273 772 191 117 276 877 415 873 902 465 .. +320 870 244 781 86 622 665 155 680 101 665 227 597 354 .. +597 79 162 998 849 136 112 751 735 884 71 449 266 420 .. +797 945 746 46 44 545 882 72 383 714 987 183 731 301 .. +718 91 109 567 708 507 983 808 766 615 554 282 995 946 651 298; +//Constraint 2 +509 883 229 569 706 639 114 727 491 481 681 948 687 941 .. +350 253 573 40 124 384 660 951 739 329 146 593 658 816 .. +638 717 779 289 430 851 937 289 159 260 930 248 656 833 .. +892 60 278 741 297 967 86 249 354 614 836 290 893 857 .. +158 869 206 504 799 758 431 580 780 788 583 641 32 653 .. +252 709 129 368 440 314 287 854 460 594 512 239 719 751 .. +708 670 269 832 137 356 960 651 398 893 407 477 552 805 881 850; +//Constraint 3 +806 361 199 781 596 669 957 358 259 888 319 751 275 177 .. +883 749 229 265 282 694 819 77 190 551 140 442 867 283 .. +137 359 445 58 440 192 485 744 844 969 50 833 57 877 .. +482 732 968 113 486 710 439 747 174 260 877 474 841 422 .. +280 684 330 910 791 322 404 403 519 148 948 414 894 147 .. +73 297 97 651 380 67 582 973 143 732 624 518 847 113 .. +382 97 905 398 859 4 142 110 11 213 398 173 106 331 254 447 ; +//Constraint 4 +404 197 817 1000 44 307 39 659 46 334 448 599 931 776 .. +263 980 807 378 278 841 700 210 542 636 388 129 203 110 .. +817 502 657 804 662 989 585 645 113 436 610 948 919 115 .. +967 13 445 449 740 592 327 167 368 335 179 909 825 614 .. +987 350 179 415 821 525 774 283 427 275 659 392 73 896 .. +68 982 697 421 246 672 649 731 191 514 983 886 95 846 .. +689 206 417 14 735 267 822 977 302 687 118 990 323 993 525 322; +//Constrain 5 +475 36 287 577 45 700 803 654 196 844 657 387 518 143 .. +515 335 942 701 332 803 265 922 908 139 995 845 487 100 .. +447 653 649 738 424 475 425 926 795 47 136 801 904 740 .. +768 460 76 660 500 915 897 25 716 557 72 696 653 933 .. +420 582 810 861 758 647 237 631 271 91 75 756 409 440 .. +483 336 765 637 981 980 202 35 594 689 602 76 767 693 .. +893 160 785 311 417 748 375 362 617 553 474 915 457 261 350 635 ; +]; +nbCon = size(conMatrix,1) +nbVar = size(conMatrix,2) +// Lower Bound of variables +lb = repmat(0,1,nbVar) +// Upper Bound of variables +ub = repmat(1,1,nbVar) +// Row Matrix for telling symphony that the is integer or not +isInt = repmat(%t,1,nbVar) +// Lower Bound of constrains +conLB=repmat(0,nbCon,1); +// Upper Bound of constraints +conUB=[11927 13727 11551 13056 13460 ]'; +options = list("time_limit", 25); +// The expected solution : +// Output variables +xopt = [0 1 1 0 0 1 0 1 0 1 0 0 0 0 0 0 0 1 0 0 0 0 1 0 1 1 0 1 1 0 1 .. +0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 1 1 0 0 1 0 .. +0 1 0 1 0 0 1 0 0 1 0 1 0 0 0 0 0 1 1 0 0 0 0 0 1 1 0 0 1 0 0 1 0] +// Optimal value +fopt = [ 24381 ] +// Calling Symphony +[x,f,status,output] = symphony(nbVar,nbCon,p,isInt,lb,ub,conMatrix,conLB,conUB,-1,options) +halt() // Press return to continue + +//========= E N D === O F === D E M O =========// diff --git a/demos/symphonymat.dem.sce b/demos/symphonymat.dem.sce new file mode 100644 index 0000000..441eb51 --- /dev/null +++ b/demos/symphonymat.dem.sce @@ -0,0 +1,104 @@ +mode(1) +// +// Demo of symphonymat.sci +// + +// Objective function +c = [350*5,330*3,310*4,280*6,500,450,400,100] +// Lower Bound of variable +lb = repmat(0,1,8); +// Upper Bound of variables +ub = [repmat(1,1,4) repmat(%inf,1,4)]; +// Constraint Matrix +Aeq = [5,3,4,6,1,1,1,1; +5*0.05,3*0.04,4*0.05,6*0.03,0.08,0.07,0.06,0.03; +5*0.03,3*0.03,4*0.04,6*0.04,0.06,0.07,0.08,0.09;] +beq = [ 25, 1.25, 1.25] +intcon = [1 2 3 4]; +// Calling Symphony +[x,f,status,output] = symphonymat(c,intcon,[],[],Aeq,beq,lb,ub) +halt() // Press return to continue + +// An advanced case where we set some options in symphony +// This problem is taken from +// P.C.Chu and J.E.Beasley +// "A genetic algorithm for the multidimensional knapsack problem", +// Journal of Heuristics, vol. 4, 1998, pp63-86. +// The problem to be solved is: +// Max sum{j=1,...,n} p(j)x(j) +// st sum{j=1,...,n} r(i,j)x(j) <= b(i) i=1,...,m +// x(j)=0 or 1 +// The function to be maximize i.e. P(j) +objCoef = -1*[ 504 803 667 1103 834 585 811 856 690 832 846 813 868 793 .. +825 1002 860 615 540 797 616 660 707 866 647 746 1006 608 .. +877 900 573 788 484 853 942 630 591 630 640 1169 932 1034 .. +957 798 669 625 467 1051 552 717 654 388 559 555 1104 783 .. +959 668 507 855 986 831 821 825 868 852 832 828 799 686 .. +510 671 575 740 510 675 996 636 826 1022 1140 654 909 799 .. +1162 653 814 625 599 476 767 954 906 904 649 873 565 853 1008 632] +//Constraint Matrix +conMatrix = [ //Constraint 1 +42 41 523 215 819 551 69 193 582 375 367 478 162 898 .. +550 553 298 577 493 183 260 224 852 394 958 282 402 604 .. +164 308 218 61 273 772 191 117 276 877 415 873 902 465 .. +320 870 244 781 86 622 665 155 680 101 665 227 597 354 .. +597 79 162 998 849 136 112 751 735 884 71 449 266 420 .. +797 945 746 46 44 545 882 72 383 714 987 183 731 301 .. +718 91 109 567 708 507 983 808 766 615 554 282 995 946 651 298; +//Constraint 2 +509 883 229 569 706 639 114 727 491 481 681 948 687 941 .. +350 253 573 40 124 384 660 951 739 329 146 593 658 816 .. +638 717 779 289 430 851 937 289 159 260 930 248 656 833 .. +892 60 278 741 297 967 86 249 354 614 836 290 893 857 .. +158 869 206 504 799 758 431 580 780 788 583 641 32 653 .. +252 709 129 368 440 314 287 854 460 594 512 239 719 751 .. +708 670 269 832 137 356 960 651 398 893 407 477 552 805 881 850; +//Constraint 3 +806 361 199 781 596 669 957 358 259 888 319 751 275 177 .. +883 749 229 265 282 694 819 77 190 551 140 442 867 283 .. +137 359 445 58 440 192 485 744 844 969 50 833 57 877 .. +482 732 968 113 486 710 439 747 174 260 877 474 841 422 .. +280 684 330 910 791 322 404 403 519 148 948 414 894 147 .. +73 297 97 651 380 67 582 973 143 732 624 518 847 113 .. +382 97 905 398 859 4 142 110 11 213 398 173 106 331 254 447 ; +//Constraint 4 +404 197 817 1000 44 307 39 659 46 334 448 599 931 776 .. +263 980 807 378 278 841 700 210 542 636 388 129 203 110 .. +817 502 657 804 662 989 585 645 113 436 610 948 919 115 .. +967 13 445 449 740 592 327 167 368 335 179 909 825 614 .. +987 350 179 415 821 525 774 283 427 275 659 392 73 896 .. +68 982 697 421 246 672 649 731 191 514 983 886 95 846 .. +689 206 417 14 735 267 822 977 302 687 118 990 323 993 525 322; +//Constrain 5 +475 36 287 577 45 700 803 654 196 844 657 387 518 143 .. +515 335 942 701 332 803 265 922 908 139 995 845 487 100 .. +447 653 649 738 424 475 425 926 795 47 136 801 904 740 .. +768 460 76 660 500 915 897 25 716 557 72 696 653 933 .. +420 582 810 861 758 647 237 631 271 91 75 756 409 440 .. +483 336 765 637 981 980 202 35 594 689 602 76 767 693 .. +893 160 785 311 417 748 375 362 617 553 474 915 457 261 350 635 ; +]; +nbVar = size(objCoef,2) +conUB=[11927 13727 11551 13056 13460 ]; +// Lower Bound of variables +lb = repmat(0,1,nbVar) +// Upper Bound of variables +ub = repmat(1,1,nbVar) +// Lower Bound of constrains +intcon = [] +for i = 1:nbVar +intcon = [intcon i]; +end +options = list("time_limit", 25); +// The expected solution : +// Output variables +xopt = [0 1 1 0 0 1 0 1 0 1 0 0 0 0 0 0 0 1 0 0 0 0 1 0 1 1 0 1 1 0 1 .. +0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 1 1 .. +0 0 1 0 0 1 0 1 0 0 1 0 0 1 0 1 0 0 0 0 0 1 1 0 0 0 0 0 1 1 0 0 1 0 0 1 0] +// Optimal value +fopt = [ 24381 ] +// Calling Symphony +[x,f,status,output] = symphonymat(objCoef,intcon,conMatrix,conUB,[],[],lb,ub,options); +halt() // Press return to continue + +//========= E N D === O F === D E M O =========// diff --git a/demos/symphonymat.dem.sce~ b/demos/symphonymat.dem.sce~ new file mode 100644 index 0000000..ef4d7cc --- /dev/null +++ b/demos/symphonymat.dem.sce~ @@ -0,0 +1,104 @@ +mode(1) +// +// Demo of symphonymat.sci +// + +// Objective function +c = [350*5,330*3,310*4,280*6,500,450,400,100] +// Lower Bound of variable +lb = repmat(0,1,8); +// Upper Bound of variables +ub = [repmat(1,1,4) repmat(%inf,1,4)]; +// Constraint Matrix +Aeq = [5,3,4,6,1,1,1,1; +5*0.05,3*0.04,4*0.05,6*0.03,0.08,0.07,0.06,0.03; +5*0.03,3*0.03,4*0.04,6*0.04,0.06,0.07,0.08,0.09;] +beq = [ 25, 1.25, 1.25] +intcon = [1 2 3 4]; +// Calling Symphony +[x,f,status,output] = symphonymat(c,intcon,[],[],Aeq,beq,lb,ub) +halt() // Press return to continue + +// An advanced case where we set some options in symphony +// This problem is taken from +// P.C.Chu and J.E.Beasley +// "A genetic algorithm for the multidimensional knapsack problem", +// Journal of Heuristics, vol. 4, 1998, pp63-86. +// The problem to be solved is: +// Max sum{j=1,...,n} p(j)x(j) +// st sum{j=1,...,n} r(i,j)x(j) <= b(i) i=1,...,m +// x(j)=0 or 1 +// The function to be maximize i.e. P(j) +objCoef = -1*[ 504 803 667 1103 834 585 811 856 690 832 846 813 868 793 .. +825 1002 860 615 540 797 616 660 707 866 647 746 1006 608 .. +877 900 573 788 484 853 942 630 591 630 640 1169 932 1034 .. +957 798 669 625 467 1051 552 717 654 388 559 555 1104 783 .. +959 668 507 855 986 831 821 825 868 852 832 828 799 686 .. +510 671 575 740 510 675 996 636 826 1022 1140 654 909 799 .. +1162 653 814 625 599 476 767 954 906 904 649 873 565 853 1008 632] +//Constraint Matrix +conMatrix = [ //Constraint 1 +42 41 523 215 819 551 69 193 582 375 367 478 162 898 .. +550 553 298 577 493 183 260 224 852 394 958 282 402 604 .. +164 308 218 61 273 772 191 117 276 877 415 873 902 465 .. +320 870 244 781 86 622 665 155 680 101 665 227 597 354 .. +597 79 162 998 849 136 112 751 735 884 71 449 266 420 .. +797 945 746 46 44 545 882 72 383 714 987 183 731 301 .. +718 91 109 567 708 507 983 808 766 615 554 282 995 946 651 298; +//Constraint 2 +509 883 229 569 706 639 114 727 491 481 681 948 687 941 .. +350 253 573 40 124 384 660 951 739 329 146 593 658 816 .. +638 717 779 289 430 851 937 289 159 260 930 248 656 833 .. +892 60 278 741 297 967 86 249 354 614 836 290 893 857 .. +158 869 206 504 799 758 431 580 780 788 583 641 32 653 .. +252 709 129 368 440 314 287 854 460 594 512 239 719 751 .. +708 670 269 832 137 356 960 651 398 893 407 477 552 805 881 850; +//Constraint 3 +806 361 199 781 596 669 957 358 259 888 319 751 275 177 .. +883 749 229 265 282 694 819 77 190 551 140 442 867 283 .. +137 359 445 58 440 192 485 744 844 969 50 833 57 877 .. +482 732 968 113 486 710 439 747 174 260 877 474 841 422 .. +280 684 330 910 791 322 404 403 519 148 948 414 894 147 .. +73 297 97 651 380 67 582 973 143 732 624 518 847 113 .. +382 97 905 398 859 4 142 110 11 213 398 173 106 331 254 447 ; +//Constraint 4 +404 197 817 1000 44 307 39 659 46 334 448 599 931 776 .. +263 980 807 378 278 841 700 210 542 636 388 129 203 110 .. +817 502 657 804 662 989 585 645 113 436 610 948 919 115 .. +967 13 445 449 740 592 327 167 368 335 179 909 825 614 .. +987 350 179 415 821 525 774 283 427 275 659 392 73 896 .. +68 982 697 421 246 672 649 731 191 514 983 886 95 846 .. +689 206 417 14 735 267 822 977 302 687 118 990 323 993 525 322; +//Constrain 5 +475 36 287 577 45 700 803 654 196 844 657 387 518 143 .. +515 335 942 701 332 803 265 922 908 139 995 845 487 100 .. +447 653 649 738 424 475 425 926 795 47 136 801 904 740 .. +768 460 76 660 500 915 897 25 716 557 72 696 653 933 .. +420 582 810 861 758 647 237 631 271 91 75 756 409 440 .. +483 336 765 637 981 980 202 35 594 689 602 76 767 693 .. +893 160 785 311 417 748 375 362 617 553 474 915 457 261 350 635 ; +]; +nbVar = size(objCoef,2) +conUB=[11927 13727 11551 13056 13460 ]; +// Lower Bound of variables +lb = repmat(0,1,nbVar) +// Upper Bound of variables +ub = repmat(1,1,nbVar) +// Lower Bound of constrains +intcon = [] +for i = 1:nbVar +intcon = [intcon i]; +end +options = list("time_limit", 25); +// The expected solution : +// Output variables +xopt = [0 1 1 0 0 1 0 1 0 1 0 0 0 0 0 0 0 1 0 0 0 0 1 0 1 1 0 1 1 0 1 .. +0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 1 1 .. +0 0 1 0 0 1 0 1 0 0 1 0 0 1 0 1 0 0 0 0 0 1 1 0 0 0 0 0 1 1 0 0 1 0 0 1 0] +// Optimal value +fopt = [ 24381 ] +// Calling Symphony +[x,f,status,output] = symphonymat(objCoef,intcon,conMatrix,conUB,[],[],lb,ub); +halt() // Press return to continue + +//========= E N D === O F === D E M O =========// diff --git a/etc/README.rst b/etc/README.rst new file mode 100644 index 0000000..2ffc09f --- /dev/null +++ b/etc/README.rst @@ -0,0 +1,14 @@ +DEMOS Files +=========== + +Start and exit files of the toolbox. + +.start +------- + +It will run a script when loader.sce is run from root toolbox directory. It will run loader files in all of the directories and link to important library. + +.quit +------- + +It will run a script when unloader.sce is run from root toolbox directory. It will unlink all of the important library. diff --git a/etc/README.rst~ b/etc/README.rst~ new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/etc/README.rst~ diff --git a/etc/Symphony.quit b/etc/Symphony.quit index 13883fb..1eabef8 100644 --- a/etc/Symphony.quit +++ b/etc/Symphony.quit @@ -10,3 +10,27 @@ // http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt +function quitModule() + + etc_tlbx = get_absolute_file_path("Symphony.quit"); + etc_tlbx = getshortpathname(etc_tlbx); + root_tlbx = strncpy( etc_tlbx, length(etc_tlbx)-length("\etc\") ); + + //unlink libraries + [bOK, ilib] = c_link('FAMOS'); + if bOK then + ulink(ilib); + end + + // Remove Preferences GUI + // ============================================================================= + if getscilabmode() == "STD" then + removeModulePreferences(root_tlbx); + end + +endfunction + + +quitModule(); +clear quitModule; + diff --git a/help/en_US/README.rst b/help/en_US/README.rst new file mode 100644 index 0000000..95f8ace --- /dev/null +++ b/help/en_US/README.rst @@ -0,0 +1,6 @@ +Help XML +======== + +This directory contains all of help files in XML. These files are automatically generated by help_from_sci function by the help of comments in Macro. + +By the help of this we can generate html and jar files. diff --git a/help/en_US/README.rst~ b/help/en_US/README.rst~ new file mode 100644 index 0000000..8e9edd5 --- /dev/null +++ b/help/en_US/README.rst~ @@ -0,0 +1,5 @@ +Help XML +======== + +This directory contains all of help files in XML. These files are automatically generated by help_from_sci function by the help of comments in Macro. + diff --git a/help/en_US/master_help.xml b/help/en_US/master_help.xml index 791d3d0..67338f2 100644 --- a/help/en_US/master_help.xml +++ b/help/en_US/master_help.xml @@ -2,9 +2,9 @@ <!DOCTYPE book [ <!--Begin Entities--> <!ENTITY a6b85f6e0c98751f20b68663a23cb4cd2 SYSTEM "/home/harpreet/symphony_work/symphony/help/en_US/qpipopt.xml"> -<!ENTITY a44928acec52adf395379e18fcff06730 SYSTEM "/home/harpreet/symphony_work/symphony/help/en_US/qpipopt_mat.xml"> +<!ENTITY a8549a3935858ed104f4749ca2243456a SYSTEM "/home/harpreet/symphony_work/symphony/help/en_US/qpipoptmat.xml"> <!ENTITY aca972f273143ecb39f56b42e4723ac67 SYSTEM "/home/harpreet/symphony_work/symphony/help/en_US/symphony.xml"> -<!ENTITY a9953e61e8dd264a86df73772d3055e7f SYSTEM "/home/harpreet/symphony_work/symphony/help/en_US/symphony_mat.xml"> +<!ENTITY a9910ada35b57b0581e8a77d145abac4a SYSTEM "/home/harpreet/symphony_work/symphony/help/en_US/symphonymat.xml"> <!ENTITY acc223314e8a8bc290a13618df33a6237 SYSTEM "/home/harpreet/symphony_work/symphony/help/en_US/Symphony Native Function/sym_addConstr.xml"> <!ENTITY a5e032b3334f53385f0ce250f0d5c18f2 SYSTEM "/home/harpreet/symphony_work/symphony/help/en_US/Symphony Native Function/sym_addVar.xml"> <!ENTITY a11ac5af5f92741f96e56398fe6113c1a SYSTEM "/home/harpreet/symphony_work/symphony/help/en_US/Symphony Native Function/sym_close.xml"> @@ -80,9 +80,9 @@ <part xml:id='section_19f4f1e5726c01d683e8b82be0a7e910'> <title>Symphony Toolbox</title> &a6b85f6e0c98751f20b68663a23cb4cd2; -&a44928acec52adf395379e18fcff06730; +&a8549a3935858ed104f4749ca2243456a; &aca972f273143ecb39f56b42e4723ac67; -&a9953e61e8dd264a86df73772d3055e7f; +&a9910ada35b57b0581e8a77d145abac4a; <chapter xml:id='section_508f0b211d17ea6769714cc144e6b731'> <title>Symphony Native Functions</title> &acc223314e8a8bc290a13618df33a6237; diff --git a/help/en_US/qpipopt.xml b/help/en_US/qpipopt.xml index 144fe18..aecbe40 100644 --- a/help/en_US/qpipopt.xml +++ b/help/en_US/qpipopt.xml @@ -25,6 +25,8 @@ <title>Calling Sequence</title> <synopsis> xopt = qpipopt(nbVar,nbCon,Q,p,LB,UB,conMatrix,conLB,conUB) + xopt = qpipopt(nbVar,nbCon,Q,p,LB,UB,conMatrix,conLB,conUB,x0) + xopt = qpipopt(nbVar,nbCon,Q,p,LB,UB,conMatrix,conLB,conUB,x0,param) [xopt,fopt,exitflag,output,lamda] = qpipopt( ... ) </synopsis> @@ -40,17 +42,21 @@ <varlistentry><term>Q :</term> <listitem><para> a n x n symmetric matrix of doubles, where n is number of variables, represents coefficients of quadratic in the quadratic problem.</para></listitem></varlistentry> <varlistentry><term>p :</term> - <listitem><para> a 1 x n matrix of doubles, where n is number of variables, represents coefficients of linear in the quadratic problem</para></listitem></varlistentry> + <listitem><para> a n x 1 matrix of doubles, where n is number of variables, represents coefficients of linear in the quadratic problem</para></listitem></varlistentry> <varlistentry><term>LB :</term> - <listitem><para> a 1 x n matrix of doubles, where n is number of variables, contains lower bounds of the variables.</para></listitem></varlistentry> + <listitem><para> a n x 1 matrix of doubles, where n is number of variables, contains lower bounds of the variables.</para></listitem></varlistentry> <varlistentry><term>UB :</term> - <listitem><para> a 1 x n matrix of doubles, where n is number of variables, contains upper bounds of the variables.</para></listitem></varlistentry> + <listitem><para> a n x 1 matrix of doubles, where n is number of variables, contains upper bounds of the variables.</para></listitem></varlistentry> <varlistentry><term>conMatrix :</term> <listitem><para> a m x n matrix of doubles, where n is number of variables and m is number of constraints, contains matrix representing the constraint matrix</para></listitem></varlistentry> <varlistentry><term>conLB :</term> <listitem><para> a m x 1 matrix of doubles, where m is number of constraints, contains lower bounds of the constraints.</para></listitem></varlistentry> <varlistentry><term>conUB :</term> <listitem><para> a m x 1 matrix of doubles, where m is number of constraints, contains upper bounds of the constraints.</para></listitem></varlistentry> + <varlistentry><term>x0 :</term> + <listitem><para> a m x 1 matrix of doubles, where m is number of constraints, contains initial guess of variables.</para></listitem></varlistentry> + <varlistentry><term>param :</term> + <listitem><para> a list containing the the parameters to be set.</para></listitem></varlistentry> <varlistentry><term>xopt :</term> <listitem><para> a 1xn matrix of doubles, the computed solution of the optimization problem.</para></listitem></varlistentry> <varlistentry><term>fopt :</term> @@ -104,7 +110,9 @@ ub=[10000; 100; 1.5; 100; 100; 1000]; p=[1; 2; 3; 4; 5; 6]; Q=eye(6,6); nbVar = 6; nbCon = 5; -[xopt,fopt,exitflag,output,lambda]=qpipopt(nbVar,nbCon,Q,p,lb,ub,conMatrix,conLB,conUB) +x0 = repmat(0,nbVar,1); +param = list("MaxIter", 300, "CpuTime", 100); +[xopt,fopt,exitflag,output,lambda]=qpipopt(nbVar,nbCon,Q,p,lb,ub,conMatrix,conLB,conUB,x0,param) ]]></programlisting> </refsection> diff --git a/help/en_US/qpipoptmat.xml b/help/en_US/qpipoptmat.xml new file mode 100644 index 0000000..eb8e737 --- /dev/null +++ b/help/en_US/qpipoptmat.xml @@ -0,0 +1,149 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + * + * This help file was generated from qpipoptmat.sci using help_from_sci(). + * + --> + +<refentry version="5.0-subset Scilab" xml:id="qpipoptmat" xml:lang="en" + xmlns="http://docbook.org/ns/docbook" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns:ns3="http://www.w3.org/1999/xhtml" + xmlns:mml="http://www.w3.org/1998/Math/MathML" + xmlns:scilab="http://www.scilab.org" + xmlns:db="http://docbook.org/ns/docbook"> + + <refnamediv> + <refname>qpipoptmat</refname> + <refpurpose>Solves a linear quadratic problem.</refpurpose> + </refnamediv> + + +<refsynopsisdiv> + <title>Calling Sequence</title> + <synopsis> + x = qpipoptmat(H,f) + x = qpipoptmat(H,f,A,b) + x = qpipoptmat(H,f,A,b,Aeq,beq) + x = qpipoptmat(H,f,A,b,Aeq,beq,lb,ub) + x = qpipoptmat(H,f,A,b,Aeq,beq,lb,ub,x0) + x = qpipoptmat(H,f,A,b,Aeq,beq,lb,ub,x0,param) + [xopt,fopt,exitflag,output,lamda] = qpipoptmat( ... ) + + </synopsis> +</refsynopsisdiv> + +<refsection> + <title>Parameters</title> + <variablelist> + <varlistentry><term>H :</term> + <listitem><para> a n x n matrix of doubles, where n is number of variables, represents coefficients of quadratic in the quadratic problem.</para></listitem></varlistentry> + <varlistentry><term>f :</term> + <listitem><para> a n x 1 matrix of doubles, where n is number of variables, represents coefficients of linear in the quadratic problem</para></listitem></varlistentry> + <varlistentry><term>A :</term> + <listitem><para> a m x n matrix of doubles, represents the linear coefficients in the inequality constraints</para></listitem></varlistentry> + <varlistentry><term>b :</term> + <listitem><para> a column vector of doubles, represents the linear coefficients in the inequality constraints</para></listitem></varlistentry> + <varlistentry><term>Aeq :</term> + <listitem><para> a meq x n matrix of doubles, represents the linear coefficients in the equality constraints</para></listitem></varlistentry> + <varlistentry><term>beq :</term> + <listitem><para> a vector of doubles, represents the linear coefficients in the equality constraints</para></listitem></varlistentry> + <varlistentry><term>LB :</term> + <listitem><para> a n x 1 matrix of doubles, where n is number of variables, contains lower bounds of the variables.</para></listitem></varlistentry> + <varlistentry><term>UB :</term> + <listitem><para> a n x 1 matrix of doubles, where n is number of variables, contains upper bounds of the variables.</para></listitem></varlistentry> + <varlistentry><term>x0 :</term> + <listitem><para> a m x 1 matrix of doubles, where m is number of constraints, contains initial guess of variables.</para></listitem></varlistentry> + <varlistentry><term>param :</term> + <listitem><para> a list containing the the parameters to be set.</para></listitem></varlistentry> + <varlistentry><term>xopt :</term> + <listitem><para> a nx1 matrix of doubles, the computed solution of the optimization problem.</para></listitem></varlistentry> + <varlistentry><term>fopt :</term> + <listitem><para> a 1x1 matrix of doubles, the function value at x.</para></listitem></varlistentry> + <varlistentry><term>exitflag :</term> + <listitem><para> Integer identifying the reason the algorithm terminated.</para></listitem></varlistentry> + <varlistentry><term>output :</term> + <listitem><para> Structure containing information about the optimization.</para></listitem></varlistentry> + <varlistentry><term>lambda :</term> + <listitem><para> Structure containing the Lagrange multipliers at the solution x (separated by constraint type).</para></listitem></varlistentry> + </variablelist> +</refsection> + +<refsection> + <title>Description</title> + <para> +Search the minimum of a constrained linear quadratic optimization problem specified by : +find the minimum of f(x) such that + </para> + <para> +<latex> +\begin{eqnarray} +&\mbox{min}_{x} +& 1/2*x'*H*x + f'*x \\ +& \text{subject to} & A.x \leq b \\ +& & Aeq.x \leq beq \\ +& & lb \leq x \leq ub \\ +\end{eqnarray} +</latex> + </para> + <para> +We are calling IPOpt for solving the quadratic problem, IPOpt is a library written in C++. The code has been written by Andreas Wächter and Carl Laird. + </para> + <para> +</para> +</refsection> + +<refsection> + <title>Examples</title> + <programlisting role="example"><![CDATA[ +//Find x in R^6 such that: + +Aeq= [1,-1,1,0,3,1; +-1,0,-3,-4,5,6; +2,5,3,0,1,0]; +beq=[1; 2; 3]; +A= [0,1,0,1,2,-1; +-1,0,2,1,1,0]; +b = [-1; 2.5]; +lb=[-1000; -10000; 0; -1000; -1000; -1000]; +ub=[10000; 100; 1.5; 100; 100; 1000]; +x0 = repmat(0,6,1); +param = list("MaxIter", 300, "CpuTime", 100); +//and minimize 0.5*x'*Q*x + p'*x with +f=[1; 2; 3; 4; 5; 6]; H=eye(6,6); +[xopt,fopt,exitflag,output,lambda]=qpipoptmat(H,f,A,b,Aeq,beq,lb,ub,[],param); +clear H f A b Aeq beq lb ub; + + ]]></programlisting> +</refsection> + +<refsection> + <title>Examples</title> + <programlisting role="example"><![CDATA[ +//Find the value of x that minimize following function +// f(x) = 0.5*x1^2 + x2^2 - x1*x2 - 2*x1 - 6*x2 +// Subject to: +// x1 + x2 ≤ 2 +// –x1 + 2x2 ≤ 2 +// 2x1 + x2 ≤ 3 +// 0 ≤ x1, 0 ≤ x2. +H = [1 -1; -1 2]; +f = [-2; -6]; +A = [1 1; -1 2; 2 1]; +b = [2; 2; 3]; +lb = [0; 0]; +ub = [%inf; %inf]; +[xopt,fopt,exitflag,output,lambda] = qpipoptmat(H,f,A,b,[],[],lb,ub) + + ]]></programlisting> +</refsection> + +<refsection> + <title>Authors</title> + <simplelist type="vert"> + <member>Keyur Joshi, Saikiran, Iswarya, Harpreet Singh</member> + </simplelist> +</refsection> +</refentry> diff --git a/help/en_US/scilab_en_US_help/JavaHelpSearch/DOCS b/help/en_US/scilab_en_US_help/JavaHelpSearch/DOCS Binary files differindex 1b55b83..bf90ce2 100644 --- a/help/en_US/scilab_en_US_help/JavaHelpSearch/DOCS +++ b/help/en_US/scilab_en_US_help/JavaHelpSearch/DOCS diff --git a/help/en_US/scilab_en_US_help/JavaHelpSearch/DOCS.TAB b/help/en_US/scilab_en_US_help/JavaHelpSearch/DOCS.TAB index 3b7b18b..1b174ab 100644 --- a/help/en_US/scilab_en_US_help/JavaHelpSearch/DOCS.TAB +++ b/help/en_US/scilab_en_US_help/JavaHelpSearch/DOCS.TAB @@ -1,6 +1,2 @@ -e__y_u'\''uEIuSI0'@
[ -CP6N4*=h'
-rq\tX5 -C04 ҃bBG
҃_ -*]*紆X7 aH#J(0 Xtl4 -8PhU}h`TtW(hbEh2QUWe d몙w_Juj_zf_!#qC&"((!|dX(O00ٽ(ȿ5F,質F,ήX,:0/40θ+,22:~̪2ҋ,.0`
\ No newline at end of file +e__y_u'\ _4_hT_e4s
_ +C`7FF$
6(q\tX6±P$
tؠ`6
|*V@XR
AX{0lHJ(3\/ P$2YGGr $V(&QoZ(0Ou8?_)[j_z&eکY;7|T0!,B(*2 Ur&(O00мٱF6/tг]~m*`QӦBj///9Y.,d꪿e7erd̫t00˨,
\ No newline at end of file diff --git a/help/en_US/scilab_en_US_help/JavaHelpSearch/OFFSETS b/help/en_US/scilab_en_US_help/JavaHelpSearch/OFFSETS Binary files differindex e290f81..ac2dfed 100644 --- a/help/en_US/scilab_en_US_help/JavaHelpSearch/OFFSETS +++ b/help/en_US/scilab_en_US_help/JavaHelpSearch/OFFSETS diff --git a/help/en_US/scilab_en_US_help/JavaHelpSearch/POSITIONS b/help/en_US/scilab_en_US_help/JavaHelpSearch/POSITIONS Binary files differindex 7fd9ab2..8be86f0 100644 --- a/help/en_US/scilab_en_US_help/JavaHelpSearch/POSITIONS +++ b/help/en_US/scilab_en_US_help/JavaHelpSearch/POSITIONS diff --git a/help/en_US/scilab_en_US_help/JavaHelpSearch/SCHEMA b/help/en_US/scilab_en_US_help/JavaHelpSearch/SCHEMA index 59337ab..c0f76d2 100644 --- a/help/en_US/scilab_en_US_help/JavaHelpSearch/SCHEMA +++ b/help/en_US/scilab_en_US_help/JavaHelpSearch/SCHEMA @@ -1,2 +1,2 @@ JavaSearch 1.0 -TMAP bs=2048 rt=1 fl=-1 id1=1347 id2=1 +TMAP bs=2048 rt=1 fl=-1 id1=1355 id2=1 diff --git a/help/en_US/scilab_en_US_help/JavaHelpSearch/TMAP b/help/en_US/scilab_en_US_help/JavaHelpSearch/TMAP Binary files differindex 0f25c4d..28f8966 100644 --- a/help/en_US/scilab_en_US_help/JavaHelpSearch/TMAP +++ b/help/en_US/scilab_en_US_help/JavaHelpSearch/TMAP diff --git a/help/en_US/scilab_en_US_help/_LaTeX_qpipoptmat.xml_1.png b/help/en_US/scilab_en_US_help/_LaTeX_qpipoptmat.xml_1.png Binary files differnew file mode 100644 index 0000000..b6e2743 --- /dev/null +++ b/help/en_US/scilab_en_US_help/_LaTeX_qpipoptmat.xml_1.png diff --git a/help/en_US/scilab_en_US_help/_LaTeX_symphonymat.xml_1.png b/help/en_US/scilab_en_US_help/_LaTeX_symphonymat.xml_1.png Binary files differnew file mode 100644 index 0000000..07dafd6 --- /dev/null +++ b/help/en_US/scilab_en_US_help/_LaTeX_symphonymat.xml_1.png diff --git a/help/en_US/scilab_en_US_help/index.html b/help/en_US/scilab_en_US_help/index.html index 2b1442a..12fb83c 100644 --- a/help/en_US/scilab_en_US_help/index.html +++ b/help/en_US/scilab_en_US_help/index.html @@ -38,7 +38,7 @@ -<li><a href="qpipopt_mat.html" class="refentry">qpipopt_mat</a> — <span class="refentry-description">Solves a linear quadratic problem.</span></li> +<li><a href="qpipoptmat.html" class="refentry">qpipoptmat</a> — <span class="refentry-description">Solves a linear quadratic problem.</span></li> @@ -50,7 +50,7 @@ -<li><a href="symphony_mat.html" class="refentry">symphony_mat</a> — <span class="refentry-description">Solves a mixed integer linear programming constrained optimization problem in intlinprog format.</span></li> +<li><a href="symphonymat.html" class="refentry">symphonymat</a> — <span class="refentry-description">Solves a mixed integer linear programming constrained optimization problem in intlinprog format.</span></li> <li><a href="section_508f0b211d17ea6769714cc144e6b731.html" class="chapter">Symphony Native Functions</a> <ul class="list-refentry"><li><a href="sym_addConstr.html" class="refentry">sym_addConstr</a> — <span class="refentry-description">Add a new constraint</span></li> diff --git a/help/en_US/scilab_en_US_help/jhelpmap.jhm b/help/en_US/scilab_en_US_help/jhelpmap.jhm index 1601f23..9dfdea5 100644 --- a/help/en_US/scilab_en_US_help/jhelpmap.jhm +++ b/help/en_US/scilab_en_US_help/jhelpmap.jhm @@ -4,9 +4,9 @@ <mapID target="index" url="index.html"/> <mapID target="section_19f4f1e5726c01d683e8b82be0a7e910" url="section_19f4f1e5726c01d683e8b82be0a7e910.html"/> <mapID target="qpipopt" url="qpipopt.html"/> -<mapID target="qpipopt_mat" url="qpipopt_mat.html"/> +<mapID target="qpipoptmat" url="qpipoptmat.html"/> <mapID target="symphony" url="symphony.html"/> -<mapID target="symphony_mat" url="symphony_mat.html"/> +<mapID target="symphonymat" url="symphonymat.html"/> <mapID target="section_508f0b211d17ea6769714cc144e6b731" url="section_508f0b211d17ea6769714cc144e6b731.html"/> <mapID target="sym_addConstr" url="sym_addConstr.html"/> <mapID target="sym_addVar" url="sym_addVar.html"/> diff --git a/help/en_US/scilab_en_US_help/jhelptoc.xml b/help/en_US/scilab_en_US_help/jhelptoc.xml index 463b86d..84c6d37 100644 --- a/help/en_US/scilab_en_US_help/jhelptoc.xml +++ b/help/en_US/scilab_en_US_help/jhelptoc.xml @@ -4,9 +4,9 @@ <tocitem target="index" text="Symphony Toolbox"> <tocitem target="section_19f4f1e5726c01d683e8b82be0a7e910" text="Symphony Toolbox"> <tocitem target="qpipopt" text="qpipopt"/> -<tocitem target="qpipopt_mat" text="qpipopt_mat"/> +<tocitem target="qpipoptmat" text="qpipoptmat"/> <tocitem target="symphony" text="symphony"/> -<tocitem target="symphony_mat" text="symphony_mat"/> +<tocitem target="symphonymat" text="symphonymat"/> <tocitem target="section_508f0b211d17ea6769714cc144e6b731" text="Symphony Native Functions"> <tocitem target="sym_addConstr" text="sym_addConstr"/> <tocitem target="sym_addVar" text="sym_addVar"/> diff --git a/help/en_US/scilab_en_US_help/qpipopt.html b/help/en_US/scilab_en_US_help/qpipopt.html index fba4521..6659f44 100644 --- a/help/en_US/scilab_en_US_help/qpipopt.html +++ b/help/en_US/scilab_en_US_help/qpipopt.html @@ -20,7 +20,7 @@ </td> <td width="30%" class="next"> - <span class="next"><a href="qpipopt_mat.html">qpipopt_mat >></a></span> + <span class="next"><a href="qpipoptmat.html">qpipoptmat >></a></span> </td> </tr></table> @@ -38,6 +38,8 @@ <div class="refsynopsisdiv"><h3 class="title">Calling Sequence</h3> <div class="synopsis"><pre><span class="default">xopt</span><span class="default"> = </span><span class="functionid">qpipopt</span><span class="default">(</span><span class="default">nbVar</span><span class="default">,</span><span class="default">nbCon</span><span class="default">,</span><span class="default">Q</span><span class="default">,</span><span class="default">p</span><span class="default">,</span><span class="default">LB</span><span class="default">,</span><span class="default">UB</span><span class="default">,</span><span class="default">conMatrix</span><span class="default">,</span><span class="default">conLB</span><span class="default">,</span><span class="default">conUB</span><span class="default">)</span> +<span class="default">xopt</span><span class="default"> = </span><span class="functionid">qpipopt</span><span class="default">(</span><span class="default">nbVar</span><span class="default">,</span><span class="default">nbCon</span><span class="default">,</span><span class="default">Q</span><span class="default">,</span><span class="default">p</span><span class="default">,</span><span class="default">LB</span><span class="default">,</span><span class="default">UB</span><span class="default">,</span><span class="default">conMatrix</span><span class="default">,</span><span class="default">conLB</span><span class="default">,</span><span class="default">conUB</span><span class="default">,</span><span class="default">x0</span><span class="default">)</span> +<span class="default">xopt</span><span class="default"> = </span><span class="functionid">qpipopt</span><span class="default">(</span><span class="default">nbVar</span><span class="default">,</span><span class="default">nbCon</span><span class="default">,</span><span class="default">Q</span><span class="default">,</span><span class="default">p</span><span class="default">,</span><span class="default">LB</span><span class="default">,</span><span class="default">UB</span><span class="default">,</span><span class="default">conMatrix</span><span class="default">,</span><span class="default">conLB</span><span class="default">,</span><span class="default">conUB</span><span class="default">,</span><span class="default">x0</span><span class="default">,</span><span class="default">param</span><span class="default">)</span> <span class="default">[</span><span class="default">xopt</span><span class="default">,</span><span class="default">fopt</span><span class="default">,</span><span class="default">exitflag</span><span class="default">,</span><span class="default">output</span><span class="default">,</span><span class="default">lamda</span><span class="default">] = </span><span class="functionid">qpipopt</span><span class="default">( ... )</span></pre></div></div> <div class="refsection"><h3 class="title">Parameters</h3> @@ -48,17 +50,21 @@ <dt><span class="term">Q :</span> <dd><p class="para">a n x n symmetric matrix of doubles, where n is number of variables, represents coefficients of quadratic in the quadratic problem.</p></dd></dt> <dt><span class="term">p :</span> - <dd><p class="para">a 1 x n matrix of doubles, where n is number of variables, represents coefficients of linear in the quadratic problem</p></dd></dt> + <dd><p class="para">a n x 1 matrix of doubles, where n is number of variables, represents coefficients of linear in the quadratic problem</p></dd></dt> <dt><span class="term">LB :</span> - <dd><p class="para">a 1 x n matrix of doubles, where n is number of variables, contains lower bounds of the variables.</p></dd></dt> + <dd><p class="para">a n x 1 matrix of doubles, where n is number of variables, contains lower bounds of the variables.</p></dd></dt> <dt><span class="term">UB :</span> - <dd><p class="para">a 1 x n matrix of doubles, where n is number of variables, contains upper bounds of the variables.</p></dd></dt> + <dd><p class="para">a n x 1 matrix of doubles, where n is number of variables, contains upper bounds of the variables.</p></dd></dt> <dt><span class="term">conMatrix :</span> <dd><p class="para">a m x n matrix of doubles, where n is number of variables and m is number of constraints, contains matrix representing the constraint matrix</p></dd></dt> <dt><span class="term">conLB :</span> <dd><p class="para">a m x 1 matrix of doubles, where m is number of constraints, contains lower bounds of the constraints.</p></dd></dt> <dt><span class="term">conUB :</span> <dd><p class="para">a m x 1 matrix of doubles, where m is number of constraints, contains upper bounds of the constraints.</p></dd></dt> + <dt><span class="term">x0 :</span> + <dd><p class="para">a m x 1 matrix of doubles, where m is number of constraints, contains initial guess of variables.</p></dd></dt> + <dt><span class="term">param :</span> + <dd><p class="para">a list containing the the parameters to be set.</p></dd></dt> <dt><span class="term">xopt :</span> <dd><p class="para">a 1xn matrix of doubles, the computed solution of the optimization problem.</p></dd></dt> <dt><span class="term">fopt :</span> @@ -92,7 +98,9 @@ find the minimum of f(x) such that</p> <span class="scilabid">p</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabnumber">1</span><span class="scilabdefault">;</span> <span class="scilabnumber">2</span><span class="scilabdefault">;</span> <span class="scilabnumber">3</span><span class="scilabdefault">;</span> <span class="scilabnumber">4</span><span class="scilabdefault">;</span> <span class="scilabnumber">5</span><span class="scilabdefault">;</span> <span class="scilabnumber">6</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> <span class="scilabid">Q</span><span class="scilaboperator">=</span><a class="scilabcommand" href="scilab://eye">eye</a><span class="scilabopenclose">(</span><span class="scilabnumber">6</span><span class="scilabdefault">,</span><span class="scilabnumber">6</span><span class="scilabopenclose">)</span><span class="scilabdefault">;</span> <span class="scilabid">nbVar</span> <span class="scilaboperator">=</span> <span class="scilabnumber">6</span><span class="scilabdefault">;</span> <span class="scilabid">nbCon</span> <span class="scilaboperator">=</span> <span class="scilabnumber">5</span><span class="scilabdefault">;</span> -<span class="scilabopenclose">[</span><span class="scilabid">xopt</span><span class="scilabdefault">,</span><span class="scilabid">fopt</span><span class="scilabdefault">,</span><span class="scilabid">exitflag</span><span class="scilabdefault">,</span><span class="scilabid">output</span><span class="scilabdefault">,</span><span class="scilabid">lambda</span><span class="scilabopenclose">]</span><span class="scilaboperator">=</span><span class="scilabid">qpipopt</span><span class="scilabopenclose">(</span><span class="scilabid">nbVar</span><span class="scilabdefault">,</span><span class="scilabid">nbCon</span><span class="scilabdefault">,</span><span class="scilabid">Q</span><span class="scilabdefault">,</span><span class="scilabid">p</span><span class="scilabdefault">,</span><span class="scilabid">lb</span><span class="scilabdefault">,</span><span class="scilabid">ub</span><span class="scilabdefault">,</span><span class="scilabid">conMatrix</span><span class="scilabdefault">,</span><span class="scilabid">conLB</span><span class="scilabdefault">,</span><span class="scilabid">conUB</span><span class="scilabopenclose">)</span></pre></td><td valign="top"><a href="scilab://scilab.execexample/"><img src="ScilabExecute.png" border="0"/></a></td><td valign="top"><a href="scilab://scilab.editexample/"><img src="ScilabEdit.png" border="0"/></a></td><td></td></tr></table></div></div> +<span class="scilabid">x0</span> <span class="scilaboperator">=</span> <a class="scilabmacro" href="scilab://repmat">repmat</a><span class="scilabopenclose">(</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabid">nbVar</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabopenclose">)</span><span class="scilabdefault">;</span> +<span class="scilabid">param</span> <span class="scilaboperator">=</span> <a class="scilabcommand" href="scilab://list">list</a><span class="scilabopenclose">(</span><span class="scilabstring">"</span><span class="scilabstring">MaxIter</span><span class="scilabstring">"</span><span class="scilabdefault">,</span> <span class="scilabnumber">300</span><span class="scilabdefault">,</span> <span class="scilabstring">"</span><span class="scilabstring">CpuTime</span><span class="scilabstring">"</span><span class="scilabdefault">,</span> <span class="scilabnumber">100</span><span class="scilabopenclose">)</span><span class="scilabdefault">;</span> +<span class="scilabopenclose">[</span><span class="scilabid">xopt</span><span class="scilabdefault">,</span><span class="scilabid">fopt</span><span class="scilabdefault">,</span><span class="scilabid">exitflag</span><span class="scilabdefault">,</span><span class="scilabid">output</span><span class="scilabdefault">,</span><span class="scilabid">lambda</span><span class="scilabopenclose">]</span><span class="scilaboperator">=</span><span class="scilabid">qpipopt</span><span class="scilabopenclose">(</span><span class="scilabid">nbVar</span><span class="scilabdefault">,</span><span class="scilabid">nbCon</span><span class="scilabdefault">,</span><span class="scilabid">Q</span><span class="scilabdefault">,</span><span class="scilabid">p</span><span class="scilabdefault">,</span><span class="scilabid">lb</span><span class="scilabdefault">,</span><span class="scilabid">ub</span><span class="scilabdefault">,</span><span class="scilabid">conMatrix</span><span class="scilabdefault">,</span><span class="scilabid">conLB</span><span class="scilabdefault">,</span><span class="scilabid">conUB</span><span class="scilabdefault">,</span><span class="scilabid">x0</span><span class="scilabdefault">,</span><span class="scilabid">param</span><span class="scilabopenclose">)</span></pre></td><td valign="top"><a href="scilab://scilab.execexample/"><img src="ScilabExecute.png" border="0"/></a></td><td valign="top"><a href="scilab://scilab.editexample/"><img src="ScilabEdit.png" border="0"/></a></td><td></td></tr></table></div></div> <div class="refsection"><h3 class="title">Examples</h3> <div class="programlisting"><table border="0" width="100%"><tr><td width="98%"><pre class="scilabcode"><span class="scilabcomment">//Find the value of x that minimize following function</span> @@ -130,7 +138,7 @@ find the minimum of f(x) such that</p> </td> <td width="30%" class="next"> - <span class="next"><a href="qpipopt_mat.html">qpipopt_mat >></a></span> + <span class="next"><a href="qpipoptmat.html">qpipoptmat >></a></span> </td> </tr></table> diff --git a/help/en_US/scilab_en_US_help/qpipoptmat.html b/help/en_US/scilab_en_US_help/qpipoptmat.html new file mode 100644 index 0000000..5e7518e --- /dev/null +++ b/help/en_US/scilab_en_US_help/qpipoptmat.html @@ -0,0 +1,146 @@ +<html><head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> + <title>qpipoptmat</title> + <style type="text/css" media="all"> + @import url("scilab_code.css"); + @import url("xml_code.css"); + @import url("c_code.css"); + @import url("style.css"); + </style> + </head> + <body> + <div class="manualnavbar"> + <table width="100%"><tr> + <td width="30%"> + <span class="previous"><a href="qpipopt.html"><< qpipopt</a></span> + + </td> + <td width="40%" class="center"> + <span class="top"><a href="section_19f4f1e5726c01d683e8b82be0a7e910.html">Symphony Toolbox</a></span> + + </td> + <td width="30%" class="next"> + <span class="next"><a href="symphony.html">symphony >></a></span> + + </td> + </tr></table> + <hr /> + </div> + + + + <span class="path"><a href="index.html">Symphony Toolbox</a> >> <a href="section_19f4f1e5726c01d683e8b82be0a7e910.html">Symphony Toolbox</a> > qpipoptmat</span> + + <br /><br /> + <div class="refnamediv"><h1 class="refname">qpipoptmat</h1> + <p class="refpurpose">Solves a linear quadratic problem.</p></div> + + +<div class="refsynopsisdiv"><h3 class="title">Calling Sequence</h3> + <div class="synopsis"><pre><span class="default">x</span><span class="default"> = </span><span class="functionid">qpipoptmat</span><span class="default">(</span><span class="default">H</span><span class="default">,</span><span class="default">f</span><span class="default">)</span> +<span class="default">x</span><span class="default"> = </span><span class="functionid">qpipoptmat</span><span class="default">(</span><span class="default">H</span><span class="default">,</span><span class="default">f</span><span class="default">,</span><span class="default">A</span><span class="default">,</span><span class="default">b</span><span class="default">)</span> +<span class="default">x</span><span class="default"> = </span><span class="functionid">qpipoptmat</span><span class="default">(</span><span class="default">H</span><span class="default">,</span><span class="default">f</span><span class="default">,</span><span class="default">A</span><span class="default">,</span><span class="default">b</span><span class="default">,</span><span class="default">Aeq</span><span class="default">,</span><span class="default">beq</span><span class="default">)</span> +<span class="default">x</span><span class="default"> = </span><span class="functionid">qpipoptmat</span><span class="default">(</span><span class="default">H</span><span class="default">,</span><span class="default">f</span><span class="default">,</span><span class="default">A</span><span class="default">,</span><span class="default">b</span><span class="default">,</span><span class="default">Aeq</span><span class="default">,</span><span class="default">beq</span><span class="default">,</span><span class="default">lb</span><span class="default">,</span><span class="default">ub</span><span class="default">)</span> +<span class="default">x</span><span class="default"> = </span><span class="functionid">qpipoptmat</span><span class="default">(</span><span class="default">H</span><span class="default">,</span><span class="default">f</span><span class="default">,</span><span class="default">A</span><span class="default">,</span><span class="default">b</span><span class="default">,</span><span class="default">Aeq</span><span class="default">,</span><span class="default">beq</span><span class="default">,</span><span class="default">lb</span><span class="default">,</span><span class="default">ub</span><span class="default">,</span><span class="default">x0</span><span class="default">)</span> +<span class="default">x</span><span class="default"> = </span><span class="functionid">qpipoptmat</span><span class="default">(</span><span class="default">H</span><span class="default">,</span><span class="default">f</span><span class="default">,</span><span class="default">A</span><span class="default">,</span><span class="default">b</span><span class="default">,</span><span class="default">Aeq</span><span class="default">,</span><span class="default">beq</span><span class="default">,</span><span class="default">lb</span><span class="default">,</span><span class="default">ub</span><span class="default">,</span><span class="default">x0</span><span class="default">,</span><span class="default">param</span><span class="default">)</span> +<span class="default">[</span><span class="default">xopt</span><span class="default">,</span><span class="default">fopt</span><span class="default">,</span><span class="default">exitflag</span><span class="default">,</span><span class="default">output</span><span class="default">,</span><span class="default">lamda</span><span class="default">] = </span><span class="functionid">qpipoptmat</span><span class="default">( ... )</span></pre></div></div> + +<div class="refsection"><h3 class="title">Parameters</h3> + <dl><dt><span class="term">H :</span> + <dd><p class="para">a n x n matrix of doubles, where n is number of variables, represents coefficients of quadratic in the quadratic problem.</p></dd></dt> + <dt><span class="term">f :</span> + <dd><p class="para">a n x 1 matrix of doubles, where n is number of variables, represents coefficients of linear in the quadratic problem</p></dd></dt> + <dt><span class="term">A :</span> + <dd><p class="para">a m x n matrix of doubles, represents the linear coefficients in the inequality constraints</p></dd></dt> + <dt><span class="term">b :</span> + <dd><p class="para">a column vector of doubles, represents the linear coefficients in the inequality constraints</p></dd></dt> + <dt><span class="term">Aeq :</span> + <dd><p class="para">a meq x n matrix of doubles, represents the linear coefficients in the equality constraints</p></dd></dt> + <dt><span class="term">beq :</span> + <dd><p class="para">a vector of doubles, represents the linear coefficients in the equality constraints</p></dd></dt> + <dt><span class="term">LB :</span> + <dd><p class="para">a n x 1 matrix of doubles, where n is number of variables, contains lower bounds of the variables.</p></dd></dt> + <dt><span class="term">UB :</span> + <dd><p class="para">a n x 1 matrix of doubles, where n is number of variables, contains upper bounds of the variables.</p></dd></dt> + <dt><span class="term">x0 :</span> + <dd><p class="para">a m x 1 matrix of doubles, where m is number of constraints, contains initial guess of variables.</p></dd></dt> + <dt><span class="term">param :</span> + <dd><p class="para">a list containing the the parameters to be set.</p></dd></dt> + <dt><span class="term">xopt :</span> + <dd><p class="para">a nx1 matrix of doubles, the computed solution of the optimization problem.</p></dd></dt> + <dt><span class="term">fopt :</span> + <dd><p class="para">a 1x1 matrix of doubles, the function value at x.</p></dd></dt> + <dt><span class="term">exitflag :</span> + <dd><p class="para">Integer identifying the reason the algorithm terminated.</p></dd></dt> + <dt><span class="term">output :</span> + <dd><p class="para">Structure containing information about the optimization.</p></dd></dt> + <dt><span class="term">lambda :</span> + <dd><p class="para">Structure containing the Lagrange multipliers at the solution x (separated by constraint type).</p></dd></dt></dl></div> + +<div class="refsection"><h3 class="title">Description</h3> + <p class="para">Search the minimum of a constrained linear quadratic optimization problem specified by : +find the minimum of f(x) such that</p> + <p class="para"><span><img src='./_LaTeX_qpipoptmat.xml_1.png' style='position:relative;top:40px;width:284px;height:88px'/></span></p> + <p class="para">We are calling IPOpt for solving the quadratic problem, IPOpt is a library written in C++. The code has been written by Andreas Wächter and Carl Laird.</p> + <p class="para"></p></div> + +<div class="refsection"><h3 class="title">Examples</h3> + <div class="programlisting"><table border="0" width="100%"><tr><td width="98%"><pre class="scilabcode"><span class="scilabcomment">//Find x in R^6 such that:</span> + +<span class="scilabid">Aeq</span><span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">3</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabdefault">;</span> +<span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabnumber">3</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabnumber">4</span><span class="scilabdefault">,</span><span class="scilabnumber">5</span><span class="scilabdefault">,</span><span class="scilabnumber">6</span><span class="scilabdefault">;</span> +<span class="scilabnumber">2</span><span class="scilabdefault">,</span><span class="scilabnumber">5</span><span class="scilabdefault">,</span><span class="scilabnumber">3</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> +<span class="scilabid">beq</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabnumber">1</span><span class="scilabdefault">;</span> <span class="scilabnumber">2</span><span class="scilabdefault">;</span> <span class="scilabnumber">3</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> +<span class="scilabid">A</span><span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">2</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">;</span> +<span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">2</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> +<span class="scilabid">b</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">;</span> <span class="scilabnumber">2.5</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> +<span class="scilabid">lb</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilaboperator">-</span><span class="scilabnumber">1000</span><span class="scilabdefault">;</span> <span class="scilaboperator">-</span><span class="scilabnumber">10000</span><span class="scilabdefault">;</span> <span class="scilabnumber">0</span><span class="scilabdefault">;</span> <span class="scilaboperator">-</span><span class="scilabnumber">1000</span><span class="scilabdefault">;</span> <span class="scilaboperator">-</span><span class="scilabnumber">1000</span><span class="scilabdefault">;</span> <span class="scilaboperator">-</span><span class="scilabnumber">1000</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> +<span class="scilabid">ub</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabnumber">10000</span><span class="scilabdefault">;</span> <span class="scilabnumber">100</span><span class="scilabdefault">;</span> <span class="scilabnumber">1.5</span><span class="scilabdefault">;</span> <span class="scilabnumber">100</span><span class="scilabdefault">;</span> <span class="scilabnumber">100</span><span class="scilabdefault">;</span> <span class="scilabnumber">1000</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> +<span class="scilabid">x0</span> <span class="scilaboperator">=</span> <a class="scilabmacro" href="scilab://repmat">repmat</a><span class="scilabopenclose">(</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">6</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabopenclose">)</span><span class="scilabdefault">;</span> +<span class="scilabid">param</span> <span class="scilaboperator">=</span> <a class="scilabcommand" href="scilab://list">list</a><span class="scilabopenclose">(</span><span class="scilabstring">"</span><span class="scilabstring">MaxIter</span><span class="scilabstring">"</span><span class="scilabdefault">,</span> <span class="scilabnumber">300</span><span class="scilabdefault">,</span> <span class="scilabstring">"</span><span class="scilabstring">CpuTime</span><span class="scilabstring">"</span><span class="scilabdefault">,</span> <span class="scilabnumber">100</span><span class="scilabopenclose">)</span><span class="scilabdefault">;</span> +<span class="scilabcomment">//and minimize 0.5*x</span><span class="scilabcomment">'</span><span class="scilabcomment">*Q*x + p</span><span class="scilabcomment">'</span><span class="scilabcomment">*x with</span> +<span class="scilabid">f</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabnumber">1</span><span class="scilabdefault">;</span> <span class="scilabnumber">2</span><span class="scilabdefault">;</span> <span class="scilabnumber">3</span><span class="scilabdefault">;</span> <span class="scilabnumber">4</span><span class="scilabdefault">;</span> <span class="scilabnumber">5</span><span class="scilabdefault">;</span> <span class="scilabnumber">6</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> <span class="scilabid">H</span><span class="scilaboperator">=</span><a class="scilabcommand" href="scilab://eye">eye</a><span class="scilabopenclose">(</span><span class="scilabnumber">6</span><span class="scilabdefault">,</span><span class="scilabnumber">6</span><span class="scilabopenclose">)</span><span class="scilabdefault">;</span> +<span class="scilabopenclose">[</span><span class="scilabid">xopt</span><span class="scilabdefault">,</span><span class="scilabid">fopt</span><span class="scilabdefault">,</span><span class="scilabid">exitflag</span><span class="scilabdefault">,</span><span class="scilabid">output</span><span class="scilabdefault">,</span><span class="scilabid">lambda</span><span class="scilabopenclose">]</span><span class="scilaboperator">=</span><span class="scilabid">qpipoptmat</span><span class="scilabopenclose">(</span><span class="scilabid">H</span><span class="scilabdefault">,</span><span class="scilabid">f</span><span class="scilabdefault">,</span><span class="scilabid">A</span><span class="scilabdefault">,</span><span class="scilabid">b</span><span class="scilabdefault">,</span><span class="scilabid">Aeq</span><span class="scilabdefault">,</span><span class="scilabid">beq</span><span class="scilabdefault">,</span><span class="scilabid">lb</span><span class="scilabdefault">,</span><span class="scilabid">ub</span><span class="scilabdefault">,</span><span class="scilabopenclose">[</span><span class="scilabopenclose">]</span><span class="scilabdefault">,</span><span class="scilabid">param</span><span class="scilabopenclose">)</span><span class="scilabdefault">;</span> +<span class="scilabid">clear</span> <span class="scilabid">H</span> <span class="scilabid">f</span> <span class="scilabid">A</span> <span class="scilabid">b</span> <span class="scilabid">Aeq</span> <span class="scilabid">beq</span> <span class="scilabid">lb</span> <span class="scilabid">ub</span><span class="scilabdefault">;</span></pre></td><td valign="top"><a href="scilab://scilab.execexample/"><img src="ScilabExecute.png" border="0"/></a></td><td valign="top"><a href="scilab://scilab.editexample/"><img src="ScilabEdit.png" border="0"/></a></td><td></td></tr></table></div></div> + +<div class="refsection"><h3 class="title">Examples</h3> + <div class="programlisting"><table border="0" width="100%"><tr><td width="98%"><pre class="scilabcode"><span class="scilabcomment">//Find the value of x that minimize following function</span> +<span class="scilabcomment">// f(x) = 0.5*x1^2 + x2^2 - x1*x2 - 2*x1 - 6*x2</span> +<span class="scilabcomment">// Subject to:</span> +<span class="scilabcomment">// x1 + x2 ≤ 2</span> +<span class="scilabcomment">// –x1 + 2x2 ≤ 2</span> +<span class="scilabcomment">// 2x1 + x2 ≤ 3</span> +<span class="scilabcomment">// 0 ≤ x1, 0 ≤ x2.</span> +<span class="scilabid">H</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilabnumber">1</span> <span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">;</span> <span class="scilaboperator">-</span><span class="scilabnumber">1</span> <span class="scilabnumber">2</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> +<span class="scilabid">f</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilaboperator">-</span><span class="scilabnumber">2</span><span class="scilabdefault">;</span> <span class="scilaboperator">-</span><span class="scilabnumber">6</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> +<span class="scilabid">A</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilabnumber">1</span> <span class="scilabnumber">1</span><span class="scilabdefault">;</span> <span class="scilaboperator">-</span><span class="scilabnumber">1</span> <span class="scilabnumber">2</span><span class="scilabdefault">;</span> <span class="scilabnumber">2</span> <span class="scilabnumber">1</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> +<span class="scilabid">b</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilabnumber">2</span><span class="scilabdefault">;</span> <span class="scilabnumber">2</span><span class="scilabdefault">;</span> <span class="scilabnumber">3</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> +<span class="scilabid">lb</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilabnumber">0</span><span class="scilabdefault">;</span> <span class="scilabnumber">0</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> +<span class="scilabid">ub</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilabconstants">%inf</span><span class="scilabdefault">;</span> <span class="scilabconstants">%inf</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> +<span class="scilabopenclose">[</span><span class="scilabid">xopt</span><span class="scilabdefault">,</span><span class="scilabid">fopt</span><span class="scilabdefault">,</span><span class="scilabid">exitflag</span><span class="scilabdefault">,</span><span class="scilabid">output</span><span class="scilabdefault">,</span><span class="scilabid">lambda</span><span class="scilabopenclose">]</span> <span class="scilaboperator">=</span> <span class="scilabid">qpipoptmat</span><span class="scilabopenclose">(</span><span class="scilabid">H</span><span class="scilabdefault">,</span><span class="scilabid">f</span><span class="scilabdefault">,</span><span class="scilabid">A</span><span class="scilabdefault">,</span><span class="scilabid">b</span><span class="scilabdefault">,</span><span class="scilabopenclose">[</span><span class="scilabopenclose">]</span><span class="scilabdefault">,</span><span class="scilabopenclose">[</span><span class="scilabopenclose">]</span><span class="scilabdefault">,</span><span class="scilabid">lb</span><span class="scilabdefault">,</span><span class="scilabid">ub</span><span class="scilabopenclose">)</span></pre></td><td valign="top"><a href="scilab://scilab.execexample/"><img src="ScilabExecute.png" border="0"/></a></td><td valign="top"><a href="scilab://scilab.editexample/"><img src="ScilabEdit.png" border="0"/></a></td><td></td></tr></table></div></div> + +<div class="refsection"><h3 class="title">Authors</h3> + <ul class="itemizedlist"><li class="member">Keyur Joshi, Saikiran, Iswarya, Harpreet Singh</li></ul></div> + <br /> + + <div class="manualnavbar"> + <table width="100%"> + <tr><td colspan="3" class="next"><a href="http://bugzilla.scilab.org/enter_bug.cgi?product=Scilab%20software&component=Documentation%20pages" class="ulink">Report an issue</a></td></tr> +<tr> + <td width="30%"> + <span class="previous"><a href="qpipopt.html"><< qpipopt</a></span> + + </td> + <td width="40%" class="center"> + <span class="top"><a href="section_19f4f1e5726c01d683e8b82be0a7e910.html">Symphony Toolbox</a></span> + + </td> + <td width="30%" class="next"> + <span class="next"><a href="symphony.html">symphony >></a></span> + + </td> + </tr></table> + <hr /> + </div> + </body> +</html> diff --git a/help/en_US/scilab_en_US_help/section_19f4f1e5726c01d683e8b82be0a7e910.html b/help/en_US/scilab_en_US_help/section_19f4f1e5726c01d683e8b82be0a7e910.html index ed07ab6..1e5e538 100644 --- a/help/en_US/scilab_en_US_help/section_19f4f1e5726c01d683e8b82be0a7e910.html +++ b/help/en_US/scilab_en_US_help/section_19f4f1e5726c01d683e8b82be0a7e910.html @@ -37,7 +37,7 @@ -<li><a href="qpipopt_mat.html" class="refentry">qpipopt_mat</a> — <span class="refentry-description">Solves a linear quadratic problem.</span></li> +<li><a href="qpipoptmat.html" class="refentry">qpipoptmat</a> — <span class="refentry-description">Solves a linear quadratic problem.</span></li> @@ -49,7 +49,7 @@ -<li><a href="symphony_mat.html" class="refentry">symphony_mat</a> — <span class="refentry-description">Solves a mixed integer linear programming constrained optimization problem in intlinprog format.</span></li> +<li><a href="symphonymat.html" class="refentry">symphonymat</a> — <span class="refentry-description">Solves a mixed integer linear programming constrained optimization problem in intlinprog format.</span></li> <li><a href="section_508f0b211d17ea6769714cc144e6b731.html" class="chapter">Symphony Native Functions</a> <ul class="list-refentry"><li><a href="sym_addConstr.html" class="refentry">sym_addConstr</a> — <span class="refentry-description">Add a new constraint</span></li> diff --git a/help/en_US/scilab_en_US_help/section_508f0b211d17ea6769714cc144e6b731.html b/help/en_US/scilab_en_US_help/section_508f0b211d17ea6769714cc144e6b731.html index 1d1b6d9..cf8c746 100644 --- a/help/en_US/scilab_en_US_help/section_508f0b211d17ea6769714cc144e6b731.html +++ b/help/en_US/scilab_en_US_help/section_508f0b211d17ea6769714cc144e6b731.html @@ -12,7 +12,7 @@ <div class="manualnavbar"> <table width="100%"><tr> <td width="30%"> - <span class="previous"><a href="symphony_mat.html"><< symphony_mat</a></span> + <span class="previous"><a href="symphonymat.html"><< symphonymat</a></span> </td> <td width="40%" class="center"> @@ -268,7 +268,7 @@ <tr><td colspan="3" class="next"><a href="http://bugzilla.scilab.org/enter_bug.cgi?product=Scilab%20software&component=Documentation%20pages" class="ulink">Report an issue</a></td></tr> <tr> <td width="30%"> - <span class="previous"><a href="symphony_mat.html"><< symphony_mat</a></span> + <span class="previous"><a href="symphonymat.html"><< symphonymat</a></span> </td> <td width="40%" class="center"> diff --git a/help/en_US/scilab_en_US_help/symphony.html b/help/en_US/scilab_en_US_help/symphony.html index 0af9d1b..a1e3eea 100644 --- a/help/en_US/scilab_en_US_help/symphony.html +++ b/help/en_US/scilab_en_US_help/symphony.html @@ -12,7 +12,7 @@ <div class="manualnavbar"> <table width="100%"><tr> <td width="30%"> - <span class="previous"><a href="qpipopt_mat.html"><< qpipopt_mat</a></span> + <span class="previous"><a href="qpipoptmat.html"><< qpipoptmat</a></span> </td> <td width="40%" class="center"> @@ -20,7 +20,7 @@ </td> <td width="30%" class="next"> - <span class="next"><a href="symphony_mat.html">symphony_mat >></a></span> + <span class="next"><a href="symphonymat.html">symphonymat >></a></span> </td> </tr></table> @@ -102,7 +102,7 @@ find the minimum or maximum of f(x) such that</p> <span class="scilabid">xopt</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilabnumber">1</span> <span class="scilabnumber">1</span> <span class="scilabnumber">0</span> <span class="scilabnumber">1</span> <span class="scilabnumber">7.25</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0.25</span> <span class="scilabnumber">3.5</span><span class="scilabopenclose">]</span> <span class="scilabid">fopt</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilabnumber">8495</span><span class="scilabopenclose">]</span> <span class="scilabcomment">// Calling Symphony</span> -<span class="scilabopenclose">[</span><span class="scilabid">x</span><span class="scilabdefault">,</span><span class="scilabid">f</span><span class="scilabdefault">,</span><span class="scilabid">iter</span><span class="scilabopenclose">]</span> <span class="scilaboperator">=</span> <span class="scilabid">symphony</span><span class="scilabopenclose">(</span><span class="scilabnumber">8</span><span class="scilabdefault">,</span><span class="scilabnumber">3</span><span class="scilabdefault">,</span><span class="scilabid">c</span><span class="scilabdefault">,</span><span class="scilabid">isInt</span><span class="scilabdefault">,</span><span class="scilabid">lb</span><span class="scilabdefault">,</span><span class="scilabid">ub</span><span class="scilabdefault">,</span><span class="scilabid">conMatrix</span><span class="scilabdefault">,</span><span class="scilabid">conlb</span><span class="scilabdefault">,</span><span class="scilabid">conub</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabopenclose">)</span><span class="scilabdefault">;</span></pre></td><td valign="top"><a href="scilab://scilab.execexample/"><img src="ScilabExecute.png" border="0"/></a></td><td valign="top"><a href="scilab://scilab.editexample/"><img src="ScilabEdit.png" border="0"/></a></td><td></td></tr></table></div></div> +<span class="scilabopenclose">[</span><span class="scilabid">x</span><span class="scilabdefault">,</span><span class="scilabid">f</span><span class="scilabdefault">,</span><span class="scilabid">status</span><span class="scilabdefault">,</span><span class="scilabid">output</span><span class="scilabopenclose">]</span> <span class="scilaboperator">=</span> <span class="scilabid">symphony</span><span class="scilabopenclose">(</span><span class="scilabnumber">8</span><span class="scilabdefault">,</span><span class="scilabnumber">3</span><span class="scilabdefault">,</span><span class="scilabid">c</span><span class="scilabdefault">,</span><span class="scilabid">isInt</span><span class="scilabdefault">,</span><span class="scilabid">lb</span><span class="scilabdefault">,</span><span class="scilabid">ub</span><span class="scilabdefault">,</span><span class="scilabid">conMatrix</span><span class="scilabdefault">,</span><span class="scilabid">conlb</span><span class="scilabdefault">,</span><span class="scilabid">conub</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabopenclose">)</span></pre></td><td valign="top"><a href="scilab://scilab.execexample/"><img src="ScilabExecute.png" border="0"/></a></td><td valign="top"><a href="scilab://scilab.editexample/"><img src="ScilabEdit.png" border="0"/></a></td><td></td></tr></table></div></div> <div class="refsection"><h3 class="title">Examples</h3> <div class="programlisting"><table border="0" width="100%"><tr><td width="98%"><pre class="scilabcode"><span class="scilabcomment">// An advanced case where we set some options in symphony</span> @@ -177,7 +177,7 @@ find the minimum or maximum of f(x) such that</p> <span class="scilabid">conLB</span><span class="scilaboperator">=</span><a class="scilabmacro" href="scilab://repmat">repmat</a><span class="scilabopenclose">(</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabid">nbCon</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabopenclose">)</span><span class="scilabdefault">;</span> <span class="scilabcomment">// Upper Bound of constraints</span> <span class="scilabid">conUB</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabnumber">11927</span> <span class="scilabnumber">13727</span> <span class="scilabnumber">11551</span> <span class="scilabnumber">13056</span> <span class="scilabnumber">13460</span> <span class="scilabopenclose">]</span><span class="scilaboperator">'</span><span class="scilabdefault">;</span> -<span class="scilabid">options</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilabstring">"</span><span class="scilabstring">time_limit</span><span class="scilabstring">"</span> <span class="scilabstring">"</span><span class="scilabstring">25</span><span class="scilabstring">"</span><span class="scilabopenclose">]</span> +<span class="scilabid">options</span> <span class="scilaboperator">=</span> <a class="scilabcommand" href="scilab://list">list</a><span class="scilabopenclose">(</span><span class="scilabstring">"</span><span class="scilabstring">time_limit</span><span class="scilabstring">"</span><span class="scilabdefault">,</span> <span class="scilabnumber">25</span><span class="scilabopenclose">)</span><span class="scilabdefault">;</span> <span class="scilabcomment">// The expected solution :</span> <span class="scilabcomment">// Output variables</span> <span class="scilabid">xopt</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilabnumber">0</span> <span class="scilabnumber">1</span> <span class="scilabnumber">1</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">1</span> <span class="scilabnumber">0</span> <span class="scilabnumber">1</span> <span class="scilabnumber">0</span> <span class="scilabnumber">1</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">1</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">1</span> <span class="scilabnumber">0</span> <span class="scilabnumber">1</span> <span class="scilabnumber">1</span> <span class="scilabnumber">0</span> <span class="scilabnumber">1</span> <span class="scilabnumber">1</span> <span class="scilabnumber">0</span> <span class="scilabnumber">1</span> <span class="scilabspecial">..</span> @@ -186,7 +186,7 @@ find the minimum or maximum of f(x) such that</p> <span class="scilabcomment">// Optimal value</span> <span class="scilabid">fopt</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span> <span class="scilabnumber">24381</span> <span class="scilabopenclose">]</span> <span class="scilabcomment">// Calling Symphony</span> -<span class="scilabopenclose">[</span><span class="scilabid">x</span><span class="scilabdefault">,</span><span class="scilabid">f</span><span class="scilabdefault">,</span><span class="scilabid">iter</span><span class="scilabopenclose">]</span><span class="scilaboperator">=</span> <span class="scilabid">symphony</span><span class="scilabopenclose">(</span><span class="scilabid">nbVar</span><span class="scilabdefault">,</span><span class="scilabid">nbCon</span><span class="scilabdefault">,</span><span class="scilabid">p</span><span class="scilabdefault">,</span><span class="scilabid">isInt</span><span class="scilabdefault">,</span><span class="scilabid">lb</span><span class="scilabdefault">,</span><span class="scilabid">ub</span><span class="scilabdefault">,</span><span class="scilabid">conMatrix</span><span class="scilabdefault">,</span><span class="scilabid">conLB</span><span class="scilabdefault">,</span><span class="scilabid">conUB</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabid">options</span><span class="scilabopenclose">)</span></pre></td><td valign="top"><a href="scilab://scilab.execexample/"><img src="ScilabExecute.png" border="0"/></a></td><td valign="top"><a href="scilab://scilab.editexample/"><img src="ScilabEdit.png" border="0"/></a></td><td></td></tr></table></div></div> +<span class="scilabopenclose">[</span><span class="scilabid">x</span><span class="scilabdefault">,</span><span class="scilabid">f</span><span class="scilabdefault">,</span><span class="scilabid">status</span><span class="scilabdefault">,</span><span class="scilabid">output</span><span class="scilabopenclose">]</span> <span class="scilaboperator">=</span> <span class="scilabid">symphony</span><span class="scilabopenclose">(</span><span class="scilabid">nbVar</span><span class="scilabdefault">,</span><span class="scilabid">nbCon</span><span class="scilabdefault">,</span><span class="scilabid">p</span><span class="scilabdefault">,</span><span class="scilabid">isInt</span><span class="scilabdefault">,</span><span class="scilabid">lb</span><span class="scilabdefault">,</span><span class="scilabid">ub</span><span class="scilabdefault">,</span><span class="scilabid">conMatrix</span><span class="scilabdefault">,</span><span class="scilabid">conLB</span><span class="scilabdefault">,</span><span class="scilabid">conUB</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabid">options</span><span class="scilabopenclose">)</span></pre></td><td valign="top"><a href="scilab://scilab.execexample/"><img src="ScilabExecute.png" border="0"/></a></td><td valign="top"><a href="scilab://scilab.editexample/"><img src="ScilabEdit.png" border="0"/></a></td><td></td></tr></table></div></div> <div class="refsection"><h3 class="title">Authors</h3> <ul class="itemizedlist"><li class="member">Keyur Joshi, Saikiran, Iswarya, Harpreet Singh</li></ul></div> @@ -197,7 +197,7 @@ find the minimum or maximum of f(x) such that</p> <tr><td colspan="3" class="next"><a href="http://bugzilla.scilab.org/enter_bug.cgi?product=Scilab%20software&component=Documentation%20pages" class="ulink">Report an issue</a></td></tr> <tr> <td width="30%"> - <span class="previous"><a href="qpipopt_mat.html"><< qpipopt_mat</a></span> + <span class="previous"><a href="qpipoptmat.html"><< qpipoptmat</a></span> </td> <td width="40%" class="center"> @@ -205,7 +205,7 @@ find the minimum or maximum of f(x) such that</p> </td> <td width="30%" class="next"> - <span class="next"><a href="symphony_mat.html">symphony_mat >></a></span> + <span class="next"><a href="symphonymat.html">symphonymat >></a></span> </td> </tr></table> diff --git a/help/en_US/scilab_en_US_help/symphonymat.html b/help/en_US/scilab_en_US_help/symphonymat.html new file mode 100644 index 0000000..23ff2c6 --- /dev/null +++ b/help/en_US/scilab_en_US_help/symphonymat.html @@ -0,0 +1,201 @@ +<html><head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> + <title>symphonymat</title> + <style type="text/css" media="all"> + @import url("scilab_code.css"); + @import url("xml_code.css"); + @import url("c_code.css"); + @import url("style.css"); + </style> + </head> + <body> + <div class="manualnavbar"> + <table width="100%"><tr> + <td width="30%"> + <span class="previous"><a href="symphony.html"><< symphony</a></span> + + </td> + <td width="40%" class="center"> + <span class="top"><a href="section_19f4f1e5726c01d683e8b82be0a7e910.html">Symphony Toolbox</a></span> + + </td> + <td width="30%" class="next"> + <span class="next"><a href="section_508f0b211d17ea6769714cc144e6b731.html">Symphony Native Functions >></a></span> + + </td> + </tr></table> + <hr /> + </div> + + + + <span class="path"><a href="index.html">Symphony Toolbox</a> >> <a href="section_19f4f1e5726c01d683e8b82be0a7e910.html">Symphony Toolbox</a> > symphonymat</span> + + <br /><br /> + <div class="refnamediv"><h1 class="refname">symphonymat</h1> + <p class="refpurpose">Solves a mixed integer linear programming constrained optimization problem in intlinprog format.</p></div> + + +<div class="refsynopsisdiv"><h3 class="title">Calling Sequence</h3> + <div class="synopsis"><pre><span class="default">xopt</span><span class="default"> = </span><span class="functionid">symphonymat</span><span class="default">(</span><span class="default">f</span><span class="default">,</span><span class="default">intcon</span><span class="default">,</span><span class="default">A</span><span class="default">,</span><span class="default">b</span><span class="default">)</span> +<span class="default">xopt</span><span class="default"> = </span><span class="functionid">symphonymat</span><span class="default">(</span><span class="default">f</span><span class="default">,</span><span class="default">intcon</span><span class="default">,</span><span class="default">A</span><span class="default">,</span><span class="default">b</span><span class="default">,</span><span class="default">Aeq</span><span class="default">,</span><span class="default">beq</span><span class="default">)</span> +<span class="default">xopt</span><span class="default"> = </span><span class="functionid">symphonymat</span><span class="default">(</span><span class="default">f</span><span class="default">,</span><span class="default">intcon</span><span class="default">,</span><span class="default">A</span><span class="default">,</span><span class="default">b</span><span class="default">,</span><span class="default">Aeq</span><span class="default">,</span><span class="default">beq</span><span class="default">,</span><span class="default">lb</span><span class="default">,</span><span class="default">ub</span><span class="default">)</span> +<span class="default">xopt</span><span class="default"> = </span><span class="functionid">symphonymat</span><span class="default">(</span><span class="default">f</span><span class="default">,</span><span class="default">intcon</span><span class="default">,</span><span class="default">A</span><span class="default">,</span><span class="default">b</span><span class="default">,</span><span class="default">Aeq</span><span class="default">,</span><span class="default">beq</span><span class="default">,</span><span class="default">lb</span><span class="default">,</span><span class="default">ub</span><span class="default">,</span><span class="default">options</span><span class="default">)</span> +<span class="default">[</span><span class="default">xopt</span><span class="default">,</span><span class="default">fopt</span><span class="default">,</span><span class="default">status</span><span class="default">,</span><span class="default">output</span><span class="default">] = </span><span class="functionid">symphonymat</span><span class="default">( ... )</span></pre></div></div> + +<div class="refsection"><h3 class="title">Parameters</h3> + <dl><dt><span class="term">f :</span> + <dd><p class="para">a 1xn matrix of doubles, where n is number of variables, contains coefficients of the variables in the objective</p></dd></dt> + <dt><span class="term">intcon :</span> + <dd><p class="para">Vector of integer constraints, specified as a vector of positive integers. The values in intcon indicate the components of the decision variable x that are integer-valued. intcon has values from 1 through number of variable</p></dd></dt> + <dt><span class="term">A :</span> + <dd><p class="para">Linear inequality constraint matrix, specified as a matrix of doubles. A represents the linear coefficients in the constraints A*x ≤ b. A has size M-by-N, where M is the number of constraints and N is number of variables</p></dd></dt> + <dt><span class="term">b :</span> + <dd><p class="para">Linear inequality constraint vector, specified as a vector of doubles. b represents the constant vector in the constraints A*x ≤ b. b has length M, where A is M-by-N</p></dd></dt> + <dt><span class="term">Aeq :</span> + <dd><p class="para">Linear equality constraint matrix, specified as a matrix of doubles. Aeq represents the linear coefficients in the constraints Aeq*x = beq. Aeq has size Meq-by-N, where Meq is the number of constraints and N is number of variables</p></dd></dt> + <dt><span class="term">beq :</span> + <dd><p class="para">Linear equality constraint vector, specified as a vector of doubles. beq represents the constant vector in the constraints Aeq*x = beq. beq has length Meq, where Aeq is Meq-by-N.</p></dd></dt> + <dt><span class="term">lb :</span> + <dd><p class="para">Lower bounds, specified as a vector or array of doubles. lb represents the lower bounds elementwise in lb ≤ x ≤ ub.</p></dd></dt> + <dt><span class="term">ub :</span> + <dd><p class="para">Upper bounds, specified as a vector or array of doubles. ub represents the upper bounds elementwise in lb ≤ x ≤ ub.</p></dd></dt> + <dt><span class="term">options :</span> + <dd><p class="para">a list containing the the parameters to be set.</p></dd></dt> + <dt><span class="term">xopt :</span> + <dd><p class="para">a 1xn matrix of doubles, the computed solution of the optimization problem</p></dd></dt> + <dt><span class="term">fopt :</span> + <dd><p class="para">a 1x1 matrix of doubles, the function value at x</p></dd></dt> + <dt><span class="term">output :</span> + <dd><p class="para">The output data structure contains detailed informations about the optimization process.</p></dd></dt></dl></div> + +<div class="refsection"><h3 class="title">Description</h3> + <p class="para">Search the minimum or maximum of a constrained mixed integer linear programming optimization problem specified by : +find the minimum or maximum of f(x) such that</p> + <p class="para"><span><img src='./_LaTeX_symphonymat.xml_1.png' style='position:relative;top:31px;width:293px;height:70px'/></span></p> + <p class="para">We are calling SYMPHONY written in C by gateway files for the actual computation. SYMPHONY was originally written by Ted Ralphs, Menal Guzelsoy and Ashutosh Mahajan.</p> + <p class="para"></p></div> + +<div class="refsection"><h3 class="title">Examples</h3> + <div class="programlisting"><table border="0" width="100%"><tr><td width="98%"><pre class="scilabcode"><span class="scilabcomment">// Objective function</span> +<span class="scilabid">c</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilabnumber">350</span><span class="scilaboperator">*</span><span class="scilabnumber">5</span><span class="scilabdefault">,</span><span class="scilabnumber">330</span><span class="scilaboperator">*</span><span class="scilabnumber">3</span><span class="scilabdefault">,</span><span class="scilabnumber">310</span><span class="scilaboperator">*</span><span class="scilabnumber">4</span><span class="scilabdefault">,</span><span class="scilabnumber">280</span><span class="scilaboperator">*</span><span class="scilabnumber">6</span><span class="scilabdefault">,</span><span class="scilabnumber">500</span><span class="scilabdefault">,</span><span class="scilabnumber">450</span><span class="scilabdefault">,</span><span class="scilabnumber">400</span><span class="scilabdefault">,</span><span class="scilabnumber">100</span><span class="scilabopenclose">]</span> +<span class="scilabcomment">// Lower Bound of variable</span> +<span class="scilabid">lb</span> <span class="scilaboperator">=</span> <a class="scilabmacro" href="scilab://repmat">repmat</a><span class="scilabopenclose">(</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">8</span><span class="scilabopenclose">)</span><span class="scilabdefault">;</span> +<span class="scilabcomment">// Upper Bound of variables</span> +<span class="scilabid">ub</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><a class="scilabmacro" href="scilab://repmat">repmat</a><span class="scilabopenclose">(</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">4</span><span class="scilabopenclose">)</span> <a class="scilabmacro" href="scilab://repmat">repmat</a><span class="scilabopenclose">(</span><span class="scilabconstants">%inf</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">4</span><span class="scilabopenclose">)</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> +<span class="scilabcomment">// Constraint Matrix</span> +<span class="scilabid">Aeq</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilabnumber">5</span><span class="scilabdefault">,</span><span class="scilabnumber">3</span><span class="scilabdefault">,</span><span class="scilabnumber">4</span><span class="scilabdefault">,</span><span class="scilabnumber">6</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabdefault">;</span> +<span class="scilabnumber">5</span><span class="scilaboperator">*</span><span class="scilabnumber">0.05</span><span class="scilabdefault">,</span><span class="scilabnumber">3</span><span class="scilaboperator">*</span><span class="scilabnumber">0.04</span><span class="scilabdefault">,</span><span class="scilabnumber">4</span><span class="scilaboperator">*</span><span class="scilabnumber">0.05</span><span class="scilabdefault">,</span><span class="scilabnumber">6</span><span class="scilaboperator">*</span><span class="scilabnumber">0.03</span><span class="scilabdefault">,</span><span class="scilabnumber">0.08</span><span class="scilabdefault">,</span><span class="scilabnumber">0.07</span><span class="scilabdefault">,</span><span class="scilabnumber">0.06</span><span class="scilabdefault">,</span><span class="scilabnumber">0.03</span><span class="scilabdefault">;</span> +<span class="scilabnumber">5</span><span class="scilaboperator">*</span><span class="scilabnumber">0.03</span><span class="scilabdefault">,</span><span class="scilabnumber">3</span><span class="scilaboperator">*</span><span class="scilabnumber">0.03</span><span class="scilabdefault">,</span><span class="scilabnumber">4</span><span class="scilaboperator">*</span><span class="scilabnumber">0.04</span><span class="scilabdefault">,</span><span class="scilabnumber">6</span><span class="scilaboperator">*</span><span class="scilabnumber">0.04</span><span class="scilabdefault">,</span><span class="scilabnumber">0.06</span><span class="scilabdefault">,</span><span class="scilabnumber">0.07</span><span class="scilabdefault">,</span><span class="scilabnumber">0.08</span><span class="scilabdefault">,</span><span class="scilabnumber">0.09</span><span class="scilabdefault">;</span><span class="scilabopenclose">]</span> +<span class="scilabid">beq</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span> <span class="scilabnumber">25</span><span class="scilabdefault">,</span> <span class="scilabnumber">1.25</span><span class="scilabdefault">,</span> <span class="scilabnumber">1.25</span><span class="scilabopenclose">]</span> +<span class="scilabid">intcon</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilabnumber">1</span> <span class="scilabnumber">2</span> <span class="scilabnumber">3</span> <span class="scilabnumber">4</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> +<span class="scilabcomment">// Calling Symphony</span> +<span class="scilabopenclose">[</span><span class="scilabid">x</span><span class="scilabdefault">,</span><span class="scilabid">f</span><span class="scilabdefault">,</span><span class="scilabid">status</span><span class="scilabdefault">,</span><span class="scilabid">output</span><span class="scilabopenclose">]</span> <span class="scilaboperator">=</span> <span class="scilabid">symphonymat</span><span class="scilabopenclose">(</span><span class="scilabid">c</span><span class="scilabdefault">,</span><span class="scilabid">intcon</span><span class="scilabdefault">,</span><span class="scilabopenclose">[</span><span class="scilabopenclose">]</span><span class="scilabdefault">,</span><span class="scilabopenclose">[</span><span class="scilabopenclose">]</span><span class="scilabdefault">,</span><span class="scilabid">Aeq</span><span class="scilabdefault">,</span><span class="scilabid">beq</span><span class="scilabdefault">,</span><span class="scilabid">lb</span><span class="scilabdefault">,</span><span class="scilabid">ub</span><span class="scilabopenclose">)</span></pre></td><td valign="top"><a href="scilab://scilab.execexample/"><img src="ScilabExecute.png" border="0"/></a></td><td valign="top"><a href="scilab://scilab.editexample/"><img src="ScilabEdit.png" border="0"/></a></td><td></td></tr></table></div></div> + +<div class="refsection"><h3 class="title">Examples</h3> + <div class="programlisting"><table border="0" width="100%"><tr><td width="98%"><pre class="scilabcode"><span class="scilabcomment">// An advanced case where we set some options in symphony</span> +<span class="scilabcomment">// This problem is taken from</span> +<span class="scilabcomment">// P.C.Chu and J.E.Beasley</span> +<span class="scilabcomment">// </span><span class="scilabcomment">"</span><span class="scilabcomment">A genetic algorithm for the multidimensional knapsack problem</span><span class="scilabcomment">"</span><span class="scilabcomment">,</span> +<span class="scilabcomment">// Journal of Heuristics, vol. 4, 1998, pp63-86.</span> +<span class="scilabcomment">// The problem to be solved is:</span> +<span class="scilabcomment">// Max sum{j=1,...,n} p(j)x(j)</span> +<span class="scilabcomment">// st sum{j=1,...,n} r(i,j)x(j) </span><span class="scilabcomment"><</span><span class="scilabcomment">= b(i) i=1,...,m</span> +<span class="scilabcomment">// x(j)=0 or 1</span> +<span class="scilabcomment">// The function to be maximize i.e. P(j)</span> +<span class="scilabid">objCoef</span> <span class="scilaboperator">=</span> <span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilaboperator">*</span><span class="scilabopenclose">[</span> <span class="scilabnumber">504</span> <span class="scilabnumber">803</span> <span class="scilabnumber">667</span> <span class="scilabnumber">1103</span> <span class="scilabnumber">834</span> <span class="scilabnumber">585</span> <span class="scilabnumber">811</span> <span class="scilabnumber">856</span> <span class="scilabnumber">690</span> <span class="scilabnumber">832</span> <span class="scilabnumber">846</span> <span class="scilabnumber">813</span> <span class="scilabnumber">868</span> <span class="scilabnumber">793</span> <span class="scilabspecial">..</span> +<span class="scilabnumber">825</span> <span class="scilabnumber">1002</span> <span class="scilabnumber">860</span> <span class="scilabnumber">615</span> <span class="scilabnumber">540</span> <span class="scilabnumber">797</span> <span class="scilabnumber">616</span> <span class="scilabnumber">660</span> <span class="scilabnumber">707</span> <span class="scilabnumber">866</span> <span class="scilabnumber">647</span> <span class="scilabnumber">746</span> <span class="scilabnumber">1006</span> <span class="scilabnumber">608</span> <span class="scilabspecial">..</span> +<span class="scilabnumber">877</span> <span class="scilabnumber">900</span> <span class="scilabnumber">573</span> <span class="scilabnumber">788</span> <span class="scilabnumber">484</span> <span class="scilabnumber">853</span> <span class="scilabnumber">942</span> <span class="scilabnumber">630</span> <span class="scilabnumber">591</span> <span class="scilabnumber">630</span> <span class="scilabnumber">640</span> <span class="scilabnumber">1169</span> <span class="scilabnumber">932</span> <span class="scilabnumber">1034</span> <span class="scilabspecial">..</span> +<span class="scilabnumber">957</span> <span class="scilabnumber">798</span> <span class="scilabnumber">669</span> <span class="scilabnumber">625</span> <span class="scilabnumber">467</span> <span class="scilabnumber">1051</span> <span class="scilabnumber">552</span> <span class="scilabnumber">717</span> <span class="scilabnumber">654</span> <span class="scilabnumber">388</span> <span class="scilabnumber">559</span> <span class="scilabnumber">555</span> <span class="scilabnumber">1104</span> <span class="scilabnumber">783</span> <span class="scilabspecial">..</span> +<span class="scilabnumber">959</span> <span class="scilabnumber">668</span> <span class="scilabnumber">507</span> <span class="scilabnumber">855</span> <span class="scilabnumber">986</span> <span class="scilabnumber">831</span> <span class="scilabnumber">821</span> <span class="scilabnumber">825</span> <span class="scilabnumber">868</span> <span class="scilabnumber">852</span> <span class="scilabnumber">832</span> <span class="scilabnumber">828</span> <span class="scilabnumber">799</span> <span class="scilabnumber">686</span> <span class="scilabspecial">..</span> +<span class="scilabnumber">510</span> <span class="scilabnumber">671</span> <span class="scilabnumber">575</span> <span class="scilabnumber">740</span> <span class="scilabnumber">510</span> <span class="scilabnumber">675</span> <span class="scilabnumber">996</span> <span class="scilabnumber">636</span> <span class="scilabnumber">826</span> <span class="scilabnumber">1022</span> <span class="scilabnumber">1140</span> <span class="scilabnumber">654</span> <span class="scilabnumber">909</span> <span class="scilabnumber">799</span> <span class="scilabspecial">..</span> +<span class="scilabnumber">1162</span> <span class="scilabnumber">653</span> <span class="scilabnumber">814</span> <span class="scilabnumber">625</span> <span class="scilabnumber">599</span> <span class="scilabnumber">476</span> <span class="scilabnumber">767</span> <span class="scilabnumber">954</span> <span class="scilabnumber">906</span> <span class="scilabnumber">904</span> <span class="scilabnumber">649</span> <span class="scilabnumber">873</span> <span class="scilabnumber">565</span> <span class="scilabnumber">853</span> <span class="scilabnumber">1008</span> <span class="scilabnumber">632</span><span class="scilabopenclose">]</span> +<span class="scilabcomment">//Constraint Matrix</span> +<span class="scilabid">conMatrix</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span> <span class="scilabcomment">//Constraint 1</span> +<span class="scilabnumber">42</span> <span class="scilabnumber">41</span> <span class="scilabnumber">523</span> <span class="scilabnumber">215</span> <span class="scilabnumber">819</span> <span class="scilabnumber">551</span> <span class="scilabnumber">69</span> <span class="scilabnumber">193</span> <span class="scilabnumber">582</span> <span class="scilabnumber">375</span> <span class="scilabnumber">367</span> <span class="scilabnumber">478</span> <span class="scilabnumber">162</span> <span class="scilabnumber">898</span> <span class="scilabspecial">..</span> +<span class="scilabnumber">550</span> <span class="scilabnumber">553</span> <span class="scilabnumber">298</span> <span class="scilabnumber">577</span> <span class="scilabnumber">493</span> <span class="scilabnumber">183</span> <span class="scilabnumber">260</span> <span class="scilabnumber">224</span> <span class="scilabnumber">852</span> <span class="scilabnumber">394</span> <span class="scilabnumber">958</span> <span class="scilabnumber">282</span> <span class="scilabnumber">402</span> <span class="scilabnumber">604</span> <span class="scilabspecial">..</span> +<span class="scilabnumber">164</span> <span class="scilabnumber">308</span> <span class="scilabnumber">218</span> <span class="scilabnumber">61</span> <span class="scilabnumber">273</span> <span class="scilabnumber">772</span> <span class="scilabnumber">191</span> <span class="scilabnumber">117</span> <span class="scilabnumber">276</span> <span class="scilabnumber">877</span> <span class="scilabnumber">415</span> <span class="scilabnumber">873</span> <span class="scilabnumber">902</span> <span class="scilabnumber">465</span> <span class="scilabspecial">..</span> +<span class="scilabnumber">320</span> <span class="scilabnumber">870</span> <span class="scilabnumber">244</span> <span class="scilabnumber">781</span> <span class="scilabnumber">86</span> <span class="scilabnumber">622</span> <span class="scilabnumber">665</span> <span class="scilabnumber">155</span> <span class="scilabnumber">680</span> <span class="scilabnumber">101</span> <span class="scilabnumber">665</span> <span class="scilabnumber">227</span> <span class="scilabnumber">597</span> <span class="scilabnumber">354</span> <span class="scilabspecial">..</span> +<span class="scilabnumber">597</span> <span class="scilabnumber">79</span> <span class="scilabnumber">162</span> <span class="scilabnumber">998</span> <span class="scilabnumber">849</span> <span class="scilabnumber">136</span> <span class="scilabnumber">112</span> <span class="scilabnumber">751</span> <span class="scilabnumber">735</span> <span class="scilabnumber">884</span> <span class="scilabnumber">71</span> <span class="scilabnumber">449</span> <span class="scilabnumber">266</span> <span class="scilabnumber">420</span> <span class="scilabspecial">..</span> +<span class="scilabnumber">797</span> <span class="scilabnumber">945</span> <span class="scilabnumber">746</span> <span class="scilabnumber">46</span> <span class="scilabnumber">44</span> <span class="scilabnumber">545</span> <span class="scilabnumber">882</span> <span class="scilabnumber">72</span> <span class="scilabnumber">383</span> <span class="scilabnumber">714</span> <span class="scilabnumber">987</span> <span class="scilabnumber">183</span> <span class="scilabnumber">731</span> <span class="scilabnumber">301</span> <span class="scilabspecial">..</span> +<span class="scilabnumber">718</span> <span class="scilabnumber">91</span> <span class="scilabnumber">109</span> <span class="scilabnumber">567</span> <span class="scilabnumber">708</span> <span class="scilabnumber">507</span> <span class="scilabnumber">983</span> <span class="scilabnumber">808</span> <span class="scilabnumber">766</span> <span class="scilabnumber">615</span> <span class="scilabnumber">554</span> <span class="scilabnumber">282</span> <span class="scilabnumber">995</span> <span class="scilabnumber">946</span> <span class="scilabnumber">651</span> <span class="scilabnumber">298</span><span class="scilabdefault">;</span> +<span class="scilabcomment">//Constraint 2</span> +<span class="scilabnumber">509</span> <span class="scilabnumber">883</span> <span class="scilabnumber">229</span> <span class="scilabnumber">569</span> <span class="scilabnumber">706</span> <span class="scilabnumber">639</span> <span class="scilabnumber">114</span> <span class="scilabnumber">727</span> <span class="scilabnumber">491</span> <span class="scilabnumber">481</span> <span class="scilabnumber">681</span> <span class="scilabnumber">948</span> <span class="scilabnumber">687</span> <span class="scilabnumber">941</span> <span class="scilabspecial">..</span> +<span class="scilabnumber">350</span> <span class="scilabnumber">253</span> <span class="scilabnumber">573</span> <span class="scilabnumber">40</span> <span class="scilabnumber">124</span> <span class="scilabnumber">384</span> <span class="scilabnumber">660</span> <span class="scilabnumber">951</span> <span class="scilabnumber">739</span> <span class="scilabnumber">329</span> <span class="scilabnumber">146</span> <span class="scilabnumber">593</span> <span class="scilabnumber">658</span> <span class="scilabnumber">816</span> <span class="scilabspecial">..</span> +<span class="scilabnumber">638</span> <span class="scilabnumber">717</span> <span class="scilabnumber">779</span> <span class="scilabnumber">289</span> <span class="scilabnumber">430</span> <span class="scilabnumber">851</span> <span class="scilabnumber">937</span> <span class="scilabnumber">289</span> <span class="scilabnumber">159</span> <span class="scilabnumber">260</span> <span class="scilabnumber">930</span> <span class="scilabnumber">248</span> <span class="scilabnumber">656</span> <span class="scilabnumber">833</span> <span class="scilabspecial">..</span> +<span class="scilabnumber">892</span> <span class="scilabnumber">60</span> <span class="scilabnumber">278</span> <span class="scilabnumber">741</span> <span class="scilabnumber">297</span> <span class="scilabnumber">967</span> <span class="scilabnumber">86</span> <span class="scilabnumber">249</span> <span class="scilabnumber">354</span> <span class="scilabnumber">614</span> <span class="scilabnumber">836</span> <span class="scilabnumber">290</span> <span class="scilabnumber">893</span> <span class="scilabnumber">857</span> <span class="scilabspecial">..</span> +<span class="scilabnumber">158</span> <span class="scilabnumber">869</span> <span class="scilabnumber">206</span> <span class="scilabnumber">504</span> <span class="scilabnumber">799</span> <span class="scilabnumber">758</span> <span class="scilabnumber">431</span> <span class="scilabnumber">580</span> <span class="scilabnumber">780</span> <span class="scilabnumber">788</span> <span class="scilabnumber">583</span> <span class="scilabnumber">641</span> <span class="scilabnumber">32</span> <span class="scilabnumber">653</span> <span class="scilabspecial">..</span> +<span class="scilabnumber">252</span> <span class="scilabnumber">709</span> <span class="scilabnumber">129</span> <span class="scilabnumber">368</span> <span class="scilabnumber">440</span> <span class="scilabnumber">314</span> <span class="scilabnumber">287</span> <span class="scilabnumber">854</span> <span class="scilabnumber">460</span> <span class="scilabnumber">594</span> <span class="scilabnumber">512</span> <span class="scilabnumber">239</span> <span class="scilabnumber">719</span> <span class="scilabnumber">751</span> <span class="scilabspecial">..</span> +<span class="scilabnumber">708</span> <span class="scilabnumber">670</span> <span class="scilabnumber">269</span> <span class="scilabnumber">832</span> <span class="scilabnumber">137</span> <span class="scilabnumber">356</span> <span class="scilabnumber">960</span> <span class="scilabnumber">651</span> <span class="scilabnumber">398</span> <span class="scilabnumber">893</span> <span class="scilabnumber">407</span> <span class="scilabnumber">477</span> <span class="scilabnumber">552</span> <span class="scilabnumber">805</span> <span class="scilabnumber">881</span> <span class="scilabnumber">850</span><span class="scilabdefault">;</span> +<span class="scilabcomment">//Constraint 3</span> +<span class="scilabnumber">806</span> <span class="scilabnumber">361</span> <span class="scilabnumber">199</span> <span class="scilabnumber">781</span> <span class="scilabnumber">596</span> <span class="scilabnumber">669</span> <span class="scilabnumber">957</span> <span class="scilabnumber">358</span> <span class="scilabnumber">259</span> <span class="scilabnumber">888</span> <span class="scilabnumber">319</span> <span class="scilabnumber">751</span> <span class="scilabnumber">275</span> <span class="scilabnumber">177</span> <span class="scilabspecial">..</span> +<span class="scilabnumber">883</span> <span class="scilabnumber">749</span> <span class="scilabnumber">229</span> <span class="scilabnumber">265</span> <span class="scilabnumber">282</span> <span class="scilabnumber">694</span> <span class="scilabnumber">819</span> <span class="scilabnumber">77</span> <span class="scilabnumber">190</span> <span class="scilabnumber">551</span> <span class="scilabnumber">140</span> <span class="scilabnumber">442</span> <span class="scilabnumber">867</span> <span class="scilabnumber">283</span> <span class="scilabspecial">..</span> +<span class="scilabnumber">137</span> <span class="scilabnumber">359</span> <span class="scilabnumber">445</span> <span class="scilabnumber">58</span> <span class="scilabnumber">440</span> <span class="scilabnumber">192</span> <span class="scilabnumber">485</span> <span class="scilabnumber">744</span> <span class="scilabnumber">844</span> <span class="scilabnumber">969</span> <span class="scilabnumber">50</span> <span class="scilabnumber">833</span> <span class="scilabnumber">57</span> <span class="scilabnumber">877</span> <span class="scilabspecial">..</span> +<span class="scilabnumber">482</span> <span class="scilabnumber">732</span> <span class="scilabnumber">968</span> <span class="scilabnumber">113</span> <span class="scilabnumber">486</span> <span class="scilabnumber">710</span> <span class="scilabnumber">439</span> <span class="scilabnumber">747</span> <span class="scilabnumber">174</span> <span class="scilabnumber">260</span> <span class="scilabnumber">877</span> <span class="scilabnumber">474</span> <span class="scilabnumber">841</span> <span class="scilabnumber">422</span> <span class="scilabspecial">..</span> +<span class="scilabnumber">280</span> <span class="scilabnumber">684</span> <span class="scilabnumber">330</span> <span class="scilabnumber">910</span> <span class="scilabnumber">791</span> <span class="scilabnumber">322</span> <span class="scilabnumber">404</span> <span class="scilabnumber">403</span> <span class="scilabnumber">519</span> <span class="scilabnumber">148</span> <span class="scilabnumber">948</span> <span class="scilabnumber">414</span> <span class="scilabnumber">894</span> <span class="scilabnumber">147</span> <span class="scilabspecial">..</span> +<span class="scilabnumber">73</span> <span class="scilabnumber">297</span> <span class="scilabnumber">97</span> <span class="scilabnumber">651</span> <span class="scilabnumber">380</span> <span class="scilabnumber">67</span> <span class="scilabnumber">582</span> <span class="scilabnumber">973</span> <span class="scilabnumber">143</span> <span class="scilabnumber">732</span> <span class="scilabnumber">624</span> <span class="scilabnumber">518</span> <span class="scilabnumber">847</span> <span class="scilabnumber">113</span> <span class="scilabspecial">..</span> +<span class="scilabnumber">382</span> <span class="scilabnumber">97</span> <span class="scilabnumber">905</span> <span class="scilabnumber">398</span> <span class="scilabnumber">859</span> <span class="scilabnumber">4</span> <span class="scilabnumber">142</span> <span class="scilabnumber">110</span> <span class="scilabnumber">11</span> <span class="scilabnumber">213</span> <span class="scilabnumber">398</span> <span class="scilabnumber">173</span> <span class="scilabnumber">106</span> <span class="scilabnumber">331</span> <span class="scilabnumber">254</span> <span class="scilabnumber">447</span> <span class="scilabdefault">;</span> +<span class="scilabcomment">//Constraint 4</span> +<span class="scilabnumber">404</span> <span class="scilabnumber">197</span> <span class="scilabnumber">817</span> <span class="scilabnumber">1000</span> <span class="scilabnumber">44</span> <span class="scilabnumber">307</span> <span class="scilabnumber">39</span> <span class="scilabnumber">659</span> <span class="scilabnumber">46</span> <span class="scilabnumber">334</span> <span class="scilabnumber">448</span> <span class="scilabnumber">599</span> <span class="scilabnumber">931</span> <span class="scilabnumber">776</span> <span class="scilabspecial">..</span> +<span class="scilabnumber">263</span> <span class="scilabnumber">980</span> <span class="scilabnumber">807</span> <span class="scilabnumber">378</span> <span class="scilabnumber">278</span> <span class="scilabnumber">841</span> <span class="scilabnumber">700</span> <span class="scilabnumber">210</span> <span class="scilabnumber">542</span> <span class="scilabnumber">636</span> <span class="scilabnumber">388</span> <span class="scilabnumber">129</span> <span class="scilabnumber">203</span> <span class="scilabnumber">110</span> <span class="scilabspecial">..</span> +<span class="scilabnumber">817</span> <span class="scilabnumber">502</span> <span class="scilabnumber">657</span> <span class="scilabnumber">804</span> <span class="scilabnumber">662</span> <span class="scilabnumber">989</span> <span class="scilabnumber">585</span> <span class="scilabnumber">645</span> <span class="scilabnumber">113</span> <span class="scilabnumber">436</span> <span class="scilabnumber">610</span> <span class="scilabnumber">948</span> <span class="scilabnumber">919</span> <span class="scilabnumber">115</span> <span class="scilabspecial">..</span> +<span class="scilabnumber">967</span> <span class="scilabnumber">13</span> <span class="scilabnumber">445</span> <span class="scilabnumber">449</span> <span class="scilabnumber">740</span> <span class="scilabnumber">592</span> <span class="scilabnumber">327</span> <span class="scilabnumber">167</span> <span class="scilabnumber">368</span> <span class="scilabnumber">335</span> <span class="scilabnumber">179</span> <span class="scilabnumber">909</span> <span class="scilabnumber">825</span> <span class="scilabnumber">614</span> <span class="scilabspecial">..</span> +<span class="scilabnumber">987</span> <span class="scilabnumber">350</span> <span class="scilabnumber">179</span> <span class="scilabnumber">415</span> <span class="scilabnumber">821</span> <span class="scilabnumber">525</span> <span class="scilabnumber">774</span> <span class="scilabnumber">283</span> <span class="scilabnumber">427</span> <span class="scilabnumber">275</span> <span class="scilabnumber">659</span> <span class="scilabnumber">392</span> <span class="scilabnumber">73</span> <span class="scilabnumber">896</span> <span class="scilabspecial">..</span> +<span class="scilabnumber">68</span> <span class="scilabnumber">982</span> <span class="scilabnumber">697</span> <span class="scilabnumber">421</span> <span class="scilabnumber">246</span> <span class="scilabnumber">672</span> <span class="scilabnumber">649</span> <span class="scilabnumber">731</span> <span class="scilabnumber">191</span> <span class="scilabnumber">514</span> <span class="scilabnumber">983</span> <span class="scilabnumber">886</span> <span class="scilabnumber">95</span> <span class="scilabnumber">846</span> <span class="scilabspecial">..</span> +<span class="scilabnumber">689</span> <span class="scilabnumber">206</span> <span class="scilabnumber">417</span> <span class="scilabnumber">14</span> <span class="scilabnumber">735</span> <span class="scilabnumber">267</span> <span class="scilabnumber">822</span> <span class="scilabnumber">977</span> <span class="scilabnumber">302</span> <span class="scilabnumber">687</span> <span class="scilabnumber">118</span> <span class="scilabnumber">990</span> <span class="scilabnumber">323</span> <span class="scilabnumber">993</span> <span class="scilabnumber">525</span> <span class="scilabnumber">322</span><span class="scilabdefault">;</span> +<span class="scilabcomment">//Constrain 5</span> +<span class="scilabnumber">475</span> <span class="scilabnumber">36</span> <span class="scilabnumber">287</span> <span class="scilabnumber">577</span> <span class="scilabnumber">45</span> <span class="scilabnumber">700</span> <span class="scilabnumber">803</span> <span class="scilabnumber">654</span> <span class="scilabnumber">196</span> <span class="scilabnumber">844</span> <span class="scilabnumber">657</span> <span class="scilabnumber">387</span> <span class="scilabnumber">518</span> <span class="scilabnumber">143</span> <span class="scilabspecial">..</span> +<span class="scilabnumber">515</span> <span class="scilabnumber">335</span> <span class="scilabnumber">942</span> <span class="scilabnumber">701</span> <span class="scilabnumber">332</span> <span class="scilabnumber">803</span> <span class="scilabnumber">265</span> <span class="scilabnumber">922</span> <span class="scilabnumber">908</span> <span class="scilabnumber">139</span> <span class="scilabnumber">995</span> <span class="scilabnumber">845</span> <span class="scilabnumber">487</span> <span class="scilabnumber">100</span> <span class="scilabspecial">..</span> +<span class="scilabnumber">447</span> <span class="scilabnumber">653</span> <span class="scilabnumber">649</span> <span class="scilabnumber">738</span> <span class="scilabnumber">424</span> <span class="scilabnumber">475</span> <span class="scilabnumber">425</span> <span class="scilabnumber">926</span> <span class="scilabnumber">795</span> <span class="scilabnumber">47</span> <span class="scilabnumber">136</span> <span class="scilabnumber">801</span> <span class="scilabnumber">904</span> <span class="scilabnumber">740</span> <span class="scilabspecial">..</span> +<span class="scilabnumber">768</span> <span class="scilabnumber">460</span> <span class="scilabnumber">76</span> <span class="scilabnumber">660</span> <span class="scilabnumber">500</span> <span class="scilabnumber">915</span> <span class="scilabnumber">897</span> <span class="scilabnumber">25</span> <span class="scilabnumber">716</span> <span class="scilabnumber">557</span> <span class="scilabnumber">72</span> <span class="scilabnumber">696</span> <span class="scilabnumber">653</span> <span class="scilabnumber">933</span> <span class="scilabspecial">..</span> +<span class="scilabnumber">420</span> <span class="scilabnumber">582</span> <span class="scilabnumber">810</span> <span class="scilabnumber">861</span> <span class="scilabnumber">758</span> <span class="scilabnumber">647</span> <span class="scilabnumber">237</span> <span class="scilabnumber">631</span> <span class="scilabnumber">271</span> <span class="scilabnumber">91</span> <span class="scilabnumber">75</span> <span class="scilabnumber">756</span> <span class="scilabnumber">409</span> <span class="scilabnumber">440</span> <span class="scilabspecial">..</span> +<span class="scilabnumber">483</span> <span class="scilabnumber">336</span> <span class="scilabnumber">765</span> <span class="scilabnumber">637</span> <span class="scilabnumber">981</span> <span class="scilabnumber">980</span> <span class="scilabnumber">202</span> <span class="scilabnumber">35</span> <span class="scilabnumber">594</span> <span class="scilabnumber">689</span> <span class="scilabnumber">602</span> <span class="scilabnumber">76</span> <span class="scilabnumber">767</span> <span class="scilabnumber">693</span> <span class="scilabspecial">..</span> +<span class="scilabnumber">893</span> <span class="scilabnumber">160</span> <span class="scilabnumber">785</span> <span class="scilabnumber">311</span> <span class="scilabnumber">417</span> <span class="scilabnumber">748</span> <span class="scilabnumber">375</span> <span class="scilabnumber">362</span> <span class="scilabnumber">617</span> <span class="scilabnumber">553</span> <span class="scilabnumber">474</span> <span class="scilabnumber">915</span> <span class="scilabnumber">457</span> <span class="scilabnumber">261</span> <span class="scilabnumber">350</span> <span class="scilabnumber">635</span> <span class="scilabdefault">;</span> +<span class="scilabopenclose">]</span><span class="scilabdefault">;</span> +<span class="scilabid">nbVar</span> <span class="scilaboperator">=</span> <a class="scilabcommand" href="scilab://size">size</a><span class="scilabopenclose">(</span><span class="scilabid">objCoef</span><span class="scilabdefault">,</span><span class="scilabnumber">2</span><span class="scilabopenclose">)</span> +<span class="scilabid">conUB</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabnumber">11927</span> <span class="scilabnumber">13727</span> <span class="scilabnumber">11551</span> <span class="scilabnumber">13056</span> <span class="scilabnumber">13460</span> <span class="scilabopenclose">]</span><span class="scilabdefault">;</span> +<span class="scilabcomment">// Lower Bound of variables</span> +<span class="scilabid">lb</span> <span class="scilaboperator">=</span> <a class="scilabmacro" href="scilab://repmat">repmat</a><span class="scilabopenclose">(</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabid">nbVar</span><span class="scilabopenclose">)</span> +<span class="scilabcomment">// Upper Bound of variables</span> +<span class="scilabid">ub</span> <span class="scilaboperator">=</span> <a class="scilabmacro" href="scilab://repmat">repmat</a><span class="scilabopenclose">(</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabid">nbVar</span><span class="scilabopenclose">)</span> +<span class="scilabcomment">// Lower Bound of constrains</span> +<span class="scilabid">intcon</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilabopenclose">]</span> +<span class="scilabskeyword">for</span> <span class="scilabid">i</span> <span class="scilaboperator">=</span> <span class="scilabnumber">1</span><span class="scilabspecial">:</span><span class="scilabid">nbVar</span> +<span class="scilabid">intcon</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilabid">intcon</span> <span class="scilabid">i</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> +<span class="scilabskeyword">end</span> +<span class="scilabid">options</span> <span class="scilaboperator">=</span> <a class="scilabcommand" href="scilab://list">list</a><span class="scilabopenclose">(</span><span class="scilabstring">"</span><span class="scilabstring">time_limit</span><span class="scilabstring">"</span><span class="scilabdefault">,</span> <span class="scilabnumber">25</span><span class="scilabopenclose">)</span><span class="scilabdefault">;</span> +<span class="scilabcomment">// The expected solution :</span> +<span class="scilabcomment">// Output variables</span> +<span class="scilabid">xopt</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilabnumber">0</span> <span class="scilabnumber">1</span> <span class="scilabnumber">1</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">1</span> <span class="scilabnumber">0</span> <span class="scilabnumber">1</span> <span class="scilabnumber">0</span> <span class="scilabnumber">1</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">1</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">1</span> <span class="scilabnumber">0</span> <span class="scilabnumber">1</span> <span class="scilabnumber">1</span> <span class="scilabnumber">0</span> <span class="scilabnumber">1</span> <span class="scilabnumber">1</span> <span class="scilabnumber">0</span> <span class="scilabnumber">1</span> <span class="scilabspecial">..</span> +<span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">1</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">1</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">1</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">1</span> <span class="scilabnumber">1</span> <span class="scilabspecial">..</span> +<span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">1</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">1</span> <span class="scilabnumber">0</span> <span class="scilabnumber">1</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">1</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">1</span> <span class="scilabnumber">0</span> <span class="scilabnumber">1</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">1</span> <span class="scilabnumber">1</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">1</span> <span class="scilabnumber">1</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">1</span> <span class="scilabnumber">0</span> <span class="scilabnumber">0</span> <span class="scilabnumber">1</span> <span class="scilabnumber">0</span><span class="scilabopenclose">]</span> +<span class="scilabcomment">// Optimal value</span> +<span class="scilabid">fopt</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span> <span class="scilabnumber">24381</span> <span class="scilabopenclose">]</span> +<span class="scilabcomment">// Calling Symphony</span> +<span class="scilabopenclose">[</span><span class="scilabid">x</span><span class="scilabdefault">,</span><span class="scilabid">f</span><span class="scilabdefault">,</span><span class="scilabid">status</span><span class="scilabdefault">,</span><span class="scilabid">output</span><span class="scilabopenclose">]</span> <span class="scilaboperator">=</span> <span class="scilabid">symphonymat</span><span class="scilabopenclose">(</span><span class="scilabid">objCoef</span><span class="scilabdefault">,</span><span class="scilabid">intcon</span><span class="scilabdefault">,</span><span class="scilabid">conMatrix</span><span class="scilabdefault">,</span><span class="scilabid">conUB</span><span class="scilabdefault">,</span><span class="scilabopenclose">[</span><span class="scilabopenclose">]</span><span class="scilabdefault">,</span><span class="scilabopenclose">[</span><span class="scilabopenclose">]</span><span class="scilabdefault">,</span><span class="scilabid">lb</span><span class="scilabdefault">,</span><span class="scilabid">ub</span><span class="scilabdefault">,</span><span class="scilabid">options</span><span class="scilabopenclose">)</span><span class="scilabdefault">;</span></pre></td><td valign="top"><a href="scilab://scilab.execexample/"><img src="ScilabExecute.png" border="0"/></a></td><td valign="top"><a href="scilab://scilab.editexample/"><img src="ScilabEdit.png" border="0"/></a></td><td></td></tr></table></div></div> + +<div class="refsection"><h3 class="title">Authors</h3> + <ul class="itemizedlist"><li class="member">Keyur Joshi, Saikiran, Iswarya, Harpreet Singh</li></ul></div> + <br /> + + <div class="manualnavbar"> + <table width="100%"> + <tr><td colspan="3" class="next"><a href="http://bugzilla.scilab.org/enter_bug.cgi?product=Scilab%20software&component=Documentation%20pages" class="ulink">Report an issue</a></td></tr> +<tr> + <td width="30%"> + <span class="previous"><a href="symphony.html"><< symphony</a></span> + + </td> + <td width="40%" class="center"> + <span class="top"><a href="section_19f4f1e5726c01d683e8b82be0a7e910.html">Symphony Toolbox</a></span> + + </td> + <td width="30%" class="next"> + <span class="next"><a href="section_508f0b211d17ea6769714cc144e6b731.html">Symphony Native Functions >></a></span> + + </td> + </tr></table> + <hr /> + </div> + </body> +</html> diff --git a/help/en_US/symphony.xml b/help/en_US/symphony.xml index 86ad4b7..c33b95c 100644 --- a/help/en_US/symphony.xml +++ b/help/en_US/symphony.xml @@ -114,7 +114,8 @@ isInt = [repmat(%t,1,4) repmat(%f,1,4)]; xopt = [1 1 0 1 7.25 0 0.25 3.5] fopt = [8495] // Calling Symphony -[x,f,iter] = symphony(8,3,c,isInt,lb,ub,conMatrix,conlb,conub,1); +[x,f,status,output] = symphony(8,3,c,isInt,lb,ub,conMatrix,conlb,conub,1) + ]]></programlisting> </refsection> @@ -193,7 +194,7 @@ isInt = repmat(%t,1,nbVar) conLB=repmat(0,nbCon,1); // Upper Bound of constraints conUB=[11927 13727 11551 13056 13460 ]'; -options = ["time_limit" "25"] +options = list("time_limit", 25); // The expected solution : // Output variables xopt = [0 1 1 0 0 1 0 1 0 1 0 0 0 0 0 0 0 1 0 0 0 0 1 0 1 1 0 1 1 0 1 .. @@ -202,7 +203,7 @@ xopt = [0 1 1 0 0 1 0 1 0 1 0 0 0 0 0 0 0 1 0 0 0 0 1 0 1 1 0 1 1 0 1 .. // Optimal value fopt = [ 24381 ] // Calling Symphony -[x,f,iter]= symphony(nbVar,nbCon,p,isInt,lb,ub,conMatrix,conLB,conUB,-1,options) +[x,f,status,output] = symphony(nbVar,nbCon,p,isInt,lb,ub,conMatrix,conLB,conUB,-1,options) ]]></programlisting> </refsection> diff --git a/help/en_US/symphonymat.xml b/help/en_US/symphonymat.xml new file mode 100644 index 0000000..ca56363 --- /dev/null +++ b/help/en_US/symphonymat.xml @@ -0,0 +1,203 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + * + * This help file was generated from symphonymat.sci using help_from_sci(). + * + --> + +<refentry version="5.0-subset Scilab" xml:id="symphonymat" xml:lang="en" + xmlns="http://docbook.org/ns/docbook" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns:ns3="http://www.w3.org/1999/xhtml" + xmlns:mml="http://www.w3.org/1998/Math/MathML" + xmlns:scilab="http://www.scilab.org" + xmlns:db="http://docbook.org/ns/docbook"> + + <refnamediv> + <refname>symphonymat</refname> + <refpurpose>Solves a mixed integer linear programming constrained optimization problem in intlinprog format.</refpurpose> + </refnamediv> + + +<refsynopsisdiv> + <title>Calling Sequence</title> + <synopsis> + xopt = symphonymat(f,intcon,A,b) + xopt = symphonymat(f,intcon,A,b,Aeq,beq) + xopt = symphonymat(f,intcon,A,b,Aeq,beq,lb,ub) + xopt = symphonymat(f,intcon,A,b,Aeq,beq,lb,ub,options) + [xopt,fopt,status,output] = symphonymat( ... ) + + </synopsis> +</refsynopsisdiv> + +<refsection> + <title>Parameters</title> + <variablelist> + <varlistentry><term>f :</term> + <listitem><para> a 1xn matrix of doubles, where n is number of variables, contains coefficients of the variables in the objective</para></listitem></varlistentry> + <varlistentry><term>intcon :</term> + <listitem><para> Vector of integer constraints, specified as a vector of positive integers. The values in intcon indicate the components of the decision variable x that are integer-valued. intcon has values from 1 through number of variable</para></listitem></varlistentry> + <varlistentry><term>A :</term> + <listitem><para> Linear inequality constraint matrix, specified as a matrix of doubles. A represents the linear coefficients in the constraints A*x ≤ b. A has size M-by-N, where M is the number of constraints and N is number of variables</para></listitem></varlistentry> + <varlistentry><term>b :</term> + <listitem><para> Linear inequality constraint vector, specified as a vector of doubles. b represents the constant vector in the constraints A*x ≤ b. b has length M, where A is M-by-N</para></listitem></varlistentry> + <varlistentry><term>Aeq :</term> + <listitem><para> Linear equality constraint matrix, specified as a matrix of doubles. Aeq represents the linear coefficients in the constraints Aeq*x = beq. Aeq has size Meq-by-N, where Meq is the number of constraints and N is number of variables</para></listitem></varlistentry> + <varlistentry><term>beq :</term> + <listitem><para> Linear equality constraint vector, specified as a vector of doubles. beq represents the constant vector in the constraints Aeq*x = beq. beq has length Meq, where Aeq is Meq-by-N.</para></listitem></varlistentry> + <varlistentry><term>lb :</term> + <listitem><para> Lower bounds, specified as a vector or array of doubles. lb represents the lower bounds elementwise in lb ≤ x ≤ ub.</para></listitem></varlistentry> + <varlistentry><term>ub :</term> + <listitem><para> Upper bounds, specified as a vector or array of doubles. ub represents the upper bounds elementwise in lb ≤ x ≤ ub.</para></listitem></varlistentry> + <varlistentry><term>options :</term> + <listitem><para> a list containing the the parameters to be set.</para></listitem></varlistentry> + <varlistentry><term>xopt :</term> + <listitem><para> a 1xn matrix of doubles, the computed solution of the optimization problem</para></listitem></varlistentry> + <varlistentry><term>fopt :</term> + <listitem><para> a 1x1 matrix of doubles, the function value at x</para></listitem></varlistentry> + <varlistentry><term>output :</term> + <listitem><para> The output data structure contains detailed informations about the optimization process.</para></listitem></varlistentry> + </variablelist> +</refsection> + +<refsection> + <title>Description</title> + <para> +Search the minimum or maximum of a constrained mixed integer linear programming optimization problem specified by : +find the minimum or maximum of f(x) such that + </para> + <para> +<latex> +\begin{eqnarray} +&\mbox{min}_{x} +& f(x) \\ +& \text{subject to} & conLB \leq C(x) \leq conUB \\ +& & lb \leq x \leq ub \\ +\end{eqnarray} +</latex> + </para> + <para> +We are calling SYMPHONY written in C by gateway files for the actual computation. SYMPHONY was originally written by Ted Ralphs, Menal Guzelsoy and Ashutosh Mahajan. + </para> + <para> +</para> +</refsection> + +<refsection> + <title>Examples</title> + <programlisting role="example"><![CDATA[ +// Objective function +c = [350*5,330*3,310*4,280*6,500,450,400,100] +// Lower Bound of variable +lb = repmat(0,1,8); +// Upper Bound of variables +ub = [repmat(1,1,4) repmat(%inf,1,4)]; +// Constraint Matrix +Aeq = [5,3,4,6,1,1,1,1; +5*0.05,3*0.04,4*0.05,6*0.03,0.08,0.07,0.06,0.03; +5*0.03,3*0.03,4*0.04,6*0.04,0.06,0.07,0.08,0.09;] +beq = [ 25, 1.25, 1.25] +intcon = [1 2 3 4]; +// Calling Symphony +[x,f,status,output] = symphonymat(c,intcon,[],[],Aeq,beq,lb,ub) + + ]]></programlisting> +</refsection> + +<refsection> + <title>Examples</title> + <programlisting role="example"><![CDATA[ +// An advanced case where we set some options in symphony +// This problem is taken from +// P.C.Chu and J.E.Beasley +// "A genetic algorithm for the multidimensional knapsack problem", +// Journal of Heuristics, vol. 4, 1998, pp63-86. +// The problem to be solved is: +// Max sum{j=1,...,n} p(j)x(j) +// st sum{j=1,...,n} r(i,j)x(j) <= b(i) i=1,...,m +// x(j)=0 or 1 +// The function to be maximize i.e. P(j) +objCoef = -1*[ 504 803 667 1103 834 585 811 856 690 832 846 813 868 793 .. +825 1002 860 615 540 797 616 660 707 866 647 746 1006 608 .. +877 900 573 788 484 853 942 630 591 630 640 1169 932 1034 .. +957 798 669 625 467 1051 552 717 654 388 559 555 1104 783 .. +959 668 507 855 986 831 821 825 868 852 832 828 799 686 .. +510 671 575 740 510 675 996 636 826 1022 1140 654 909 799 .. +1162 653 814 625 599 476 767 954 906 904 649 873 565 853 1008 632] +//Constraint Matrix +conMatrix = [ //Constraint 1 +42 41 523 215 819 551 69 193 582 375 367 478 162 898 .. +550 553 298 577 493 183 260 224 852 394 958 282 402 604 .. +164 308 218 61 273 772 191 117 276 877 415 873 902 465 .. +320 870 244 781 86 622 665 155 680 101 665 227 597 354 .. +597 79 162 998 849 136 112 751 735 884 71 449 266 420 .. +797 945 746 46 44 545 882 72 383 714 987 183 731 301 .. +718 91 109 567 708 507 983 808 766 615 554 282 995 946 651 298; +//Constraint 2 +509 883 229 569 706 639 114 727 491 481 681 948 687 941 .. +350 253 573 40 124 384 660 951 739 329 146 593 658 816 .. +638 717 779 289 430 851 937 289 159 260 930 248 656 833 .. +892 60 278 741 297 967 86 249 354 614 836 290 893 857 .. +158 869 206 504 799 758 431 580 780 788 583 641 32 653 .. +252 709 129 368 440 314 287 854 460 594 512 239 719 751 .. +708 670 269 832 137 356 960 651 398 893 407 477 552 805 881 850; +//Constraint 3 +806 361 199 781 596 669 957 358 259 888 319 751 275 177 .. +883 749 229 265 282 694 819 77 190 551 140 442 867 283 .. +137 359 445 58 440 192 485 744 844 969 50 833 57 877 .. +482 732 968 113 486 710 439 747 174 260 877 474 841 422 .. +280 684 330 910 791 322 404 403 519 148 948 414 894 147 .. +73 297 97 651 380 67 582 973 143 732 624 518 847 113 .. +382 97 905 398 859 4 142 110 11 213 398 173 106 331 254 447 ; +//Constraint 4 +404 197 817 1000 44 307 39 659 46 334 448 599 931 776 .. +263 980 807 378 278 841 700 210 542 636 388 129 203 110 .. +817 502 657 804 662 989 585 645 113 436 610 948 919 115 .. +967 13 445 449 740 592 327 167 368 335 179 909 825 614 .. +987 350 179 415 821 525 774 283 427 275 659 392 73 896 .. +68 982 697 421 246 672 649 731 191 514 983 886 95 846 .. +689 206 417 14 735 267 822 977 302 687 118 990 323 993 525 322; +//Constrain 5 +475 36 287 577 45 700 803 654 196 844 657 387 518 143 .. +515 335 942 701 332 803 265 922 908 139 995 845 487 100 .. +447 653 649 738 424 475 425 926 795 47 136 801 904 740 .. +768 460 76 660 500 915 897 25 716 557 72 696 653 933 .. +420 582 810 861 758 647 237 631 271 91 75 756 409 440 .. +483 336 765 637 981 980 202 35 594 689 602 76 767 693 .. +893 160 785 311 417 748 375 362 617 553 474 915 457 261 350 635 ; +]; +nbVar = size(objCoef,2) +conUB=[11927 13727 11551 13056 13460 ]; +// Lower Bound of variables +lb = repmat(0,1,nbVar) +// Upper Bound of variables +ub = repmat(1,1,nbVar) +// Lower Bound of constrains +intcon = [] +for i = 1:nbVar +intcon = [intcon i]; +end +options = list("time_limit", 25); +// The expected solution : +// Output variables +xopt = [0 1 1 0 0 1 0 1 0 1 0 0 0 0 0 0 0 1 0 0 0 0 1 0 1 1 0 1 1 0 1 .. +0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 1 1 .. +0 0 1 0 0 1 0 1 0 0 1 0 0 1 0 1 0 0 0 0 0 1 1 0 0 0 0 0 1 1 0 0 1 0 0 1 0] +// Optimal value +fopt = [ 24381 ] +// Calling Symphony +[x,f,status,output] = symphonymat(objCoef,intcon,conMatrix,conUB,[],[],lb,ub,options); + + ]]></programlisting> +</refsection> + +<refsection> + <title>Authors</title> + <simplelist type="vert"> + <member>Keyur Joshi, Saikiran, Iswarya, Harpreet Singh</member> + </simplelist> +</refsection> +</refentry> diff --git a/jar/README.rst b/jar/README.rst new file mode 100644 index 0000000..ba5bc56 --- /dev/null +++ b/jar/README.rst @@ -0,0 +1,5 @@ +Help JAR +======== + +This is automatically generated file by the xml files. + diff --git a/jar/README.rst~ b/jar/README.rst~ new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/jar/README.rst~ diff --git a/jar/scilab_en_US_help.jar b/jar/scilab_en_US_help.jar Binary files differindex 82b1a76..2f1f947 100644 --- a/jar/scilab_en_US_help.jar +++ b/jar/scilab_en_US_help.jar diff --git a/macros/README.rst b/macros/README.rst new file mode 100644 index 0000000..5a07f63 --- /dev/null +++ b/macros/README.rst @@ -0,0 +1,36 @@ +MACROS +====== + +These files mainly consist of functions for checking the input and calling the gateway functions + +symphony +-------- + +It takes the input in symphony style and checks the input. After all the checks call the symphony_call function. + +symphonymat +----------- + +It takes the input in symphony style and checks the input. After all the checks call the symphony_call function. + +symphony_call +------------- + +It calls the gateway functions to initialize, set options and to solve it. After that it will call the functions to get the solution for the problem. + +setOptions +---------- + +It will set the options in the symphony. + +qpipopt +------- + +It synatize the input and call solveqp in the ipopt style. + +qpipopt +------- + +It synatize the input and call solveqp in the quadprog style. + + diff --git a/macros/README.rst~ b/macros/README.rst~ new file mode 100644 index 0000000..5a07f63 --- /dev/null +++ b/macros/README.rst~ @@ -0,0 +1,36 @@ +MACROS +====== + +These files mainly consist of functions for checking the input and calling the gateway functions + +symphony +-------- + +It takes the input in symphony style and checks the input. After all the checks call the symphony_call function. + +symphonymat +----------- + +It takes the input in symphony style and checks the input. After all the checks call the symphony_call function. + +symphony_call +------------- + +It calls the gateway functions to initialize, set options and to solve it. After that it will call the functions to get the solution for the problem. + +setOptions +---------- + +It will set the options in the symphony. + +qpipopt +------- + +It synatize the input and call solveqp in the ipopt style. + +qpipopt +------- + +It synatize the input and call solveqp in the quadprog style. + + Binary files differdiff --git a/macros/names b/macros/names index 40e5934..e068c5a 100644 --- a/macros/names +++ b/macros/names @@ -3,4 +3,4 @@ qpipoptmat setOptions symphony symphony_call -symphony_mat +symphonymat diff --git a/macros/qpipopt.bin b/macros/qpipopt.bin Binary files differindex 0cdc0d9..07db2ad 100644 --- a/macros/qpipopt.bin +++ b/macros/qpipopt.bin diff --git a/macros/qpipopt.sci b/macros/qpipopt.sci index efcca01..8f3945e 100644 --- a/macros/qpipopt.sci +++ b/macros/qpipopt.sci @@ -16,16 +16,13 @@ function [xopt,fopt,exitflag,output,lambda] = qpipopt (varargin) // Calling Sequence // xopt = qpipopt(nbVar,nbCon,Q,p,LB,UB,conMatrix,conLB,conUB) // xopt = qpipopt(nbVar,nbCon,Q,p,LB,UB,conMatrix,conLB,conUB,x0) + // xopt = qpipopt(nbVar,nbCon,Q,p,LB,UB,conMatrix,conLB,conUB,x0,param) // [xopt,fopt,exitflag,output,lamda] = qpipopt( ... ) // // Parameters // nbVar : a 1 x 1 matrix of doubles, number of variables // nbCon : a 1 x 1 matrix of doubles, number of constraints -<<<<<<< HEAD // Q : a n x n symmetric matrix of doubles, where n is number of variables, represents coefficients of quadratic in the quadratic problem. -======= - // Q : a n x n matrix of doubles, where n is number of variables, represents coefficients of quadratic in the quadratic problem. ->>>>>>> c2679735a3443017e003ca095d0476bae2dd8e40 // p : a n x 1 matrix of doubles, where n is number of variables, represents coefficients of linear in the quadratic problem // LB : a n x 1 matrix of doubles, where n is number of variables, contains lower bounds of the variables. // UB : a n x 1 matrix of doubles, where n is number of variables, contains upper bounds of the variables. @@ -33,6 +30,7 @@ function [xopt,fopt,exitflag,output,lambda] = qpipopt (varargin) // conLB : a m x 1 matrix of doubles, where m is number of constraints, contains lower bounds of the constraints. // conUB : a m x 1 matrix of doubles, where m is number of constraints, contains upper bounds of the constraints. // x0 : a m x 1 matrix of doubles, where m is number of constraints, contains initial guess of variables. + // param : a list containing the the parameters to be set. // xopt : a 1xn matrix of doubles, the computed solution of the optimization problem. // fopt : a 1x1 matrix of doubles, the function value at x. // exitflag : Integer identifying the reason the algorithm terminated. @@ -69,7 +67,9 @@ function [xopt,fopt,exitflag,output,lambda] = qpipopt (varargin) // p=[1; 2; 3; 4; 5; 6]; Q=eye(6,6); // nbVar = 6; // nbCon = 5; - // [xopt,fopt,exitflag,output,lambda]=qpipopt(nbVar,nbCon,Q,p,lb,ub,conMatrix,conLB,conUB) + // x0 = repmat(0,nbVar,1); + // param = list("MaxIter", 300, "CpuTime", 100); + // [xopt,fopt,exitflag,output,lambda]=qpipopt(nbVar,nbCon,Q,p,lb,ub,conMatrix,conLB,conUB,x0,param) // // Examples // //Find the value of x that minimize following function @@ -98,8 +98,8 @@ function [xopt,fopt,exitflag,output,lambda] = qpipopt (varargin) [lhs , rhs] = argn(); //To check the number of argument given by user - if ( rhs < 9 | rhs > 10 ) then - errmsg = msprintf(gettext("%s: Unexpected number of input arguments : %d provided while should be 9 or 10"), "qpipopt", rhs); + if ( rhs < 9 | rhs > 11 ) then + errmsg = msprintf(gettext("%s: Unexpected number of input arguments : %d provided while should be 9, 10 or 11"), "qpipopt", rhs); error(errmsg) end @@ -113,22 +113,53 @@ function [xopt,fopt,exitflag,output,lambda] = qpipopt (varargin) conMatrix = varargin(7); conLB = varargin(8); conUB = varargin(9); + - if ( rhs<10 ) then - x0 = repmat(0,1,nbVar) + if ( rhs<10 | size(varargin(10)) ==0 ) then + x0 = repmat(0,nbVar,1); else x0 = varargin(10); end + if ( rhs<11 ) then + param = list(); + else + param =varargin(11); + end + + if (modulo(size(param),2)) then + errmsg = msprintf(gettext("%s: Size of parameters should be even"), "qpipopt"); + error(errmsg); + end + + + options = list(.. + "MaxIter" , [3000], ... + "CpuTime" , [600] ... + ); + + for i = 1:(size(param))/2 + select param(2*i-1) + case "MaxIter" then + options(2*i) = param(2*i); + case "CpuTime" then + options(2*i) = param(2*i); + else + errmsg = msprintf(gettext("%s: Unrecognized parameter name ''%s''."), "qpipopt", param(2*i-1)); + error(errmsg) + end + end + //IPOpt wants it in row matrix form p = p'; LB = LB'; UB = UB'; conLB = conLB'; conUB = conUB'; + x0 = x0'; //Checking the Q matrix which needs to be a symmetric matrix - if ( Q~=Q') then + if ( ~isequal(Q,Q') ) then errmsg = msprintf(gettext("%s: Q is not a symmetric matrix"), "qpipopt"); error(errmsg); end @@ -182,7 +213,8 @@ function [xopt,fopt,exitflag,output,lambda] = qpipopt (varargin) error(errmsg); end - [xopt,fopt,status,iter,Zl,Zu,lmbda] = solveqp(nbVar,nbCon,Q,p,conMatrix,conLB,conUB,LB,UB,x0); + + [xopt,fopt,status,iter,Zl,Zu,lmbda] = solveqp(nbVar,nbCon,Q,p,conMatrix,conLB,conUB,LB,UB,x0,options); xopt = xopt'; exitflag = status; diff --git a/macros/qpipopt.sci~ b/macros/qpipopt.sci~ new file mode 100644 index 0000000..35e604b --- /dev/null +++ b/macros/qpipopt.sci~ @@ -0,0 +1,233 @@ +// Copyright (C) 2015 - IIT Bombay - FOSSEE +// +// Author: Harpreet Singh +// Organization: FOSSEE, IIT Bombay +// Email: harpreet.mertia@gmail.com +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + + +function [xopt,fopt,exitflag,output,lambda] = qpipopt (varargin) + // Solves a linear quadratic problem. + // + // Calling Sequence + // xopt = qpipopt(nbVar,nbCon,Q,p,LB,UB,conMatrix,conLB,conUB) + // xopt = qpipopt(nbVar,nbCon,Q,p,LB,UB,conMatrix,conLB,conUB,x0) + // xopt = qpipopt(nbVar,nbCon,Q,p,LB,UB,conMatrix,conLB,conUB,x0,param) + // [xopt,fopt,exitflag,output,lamda] = qpipopt( ... ) + // + // Parameters + // nbVar : a 1 x 1 matrix of doubles, number of variables + // nbCon : a 1 x 1 matrix of doubles, number of constraints + // Q : a n x n symmetric matrix of doubles, where n is number of variables, represents coefficients of quadratic in the quadratic problem. + // p : a n x 1 matrix of doubles, where n is number of variables, represents coefficients of linear in the quadratic problem + // LB : a n x 1 matrix of doubles, where n is number of variables, contains lower bounds of the variables. + // UB : a n x 1 matrix of doubles, where n is number of variables, contains upper bounds of the variables. + // conMatrix : a m x n matrix of doubles, where n is number of variables and m is number of constraints, contains matrix representing the constraint matrix + // conLB : a m x 1 matrix of doubles, where m is number of constraints, contains lower bounds of the constraints. + // conUB : a m x 1 matrix of doubles, where m is number of constraints, contains upper bounds of the constraints. + // x0 : a m x 1 matrix of doubles, where m is number of constraints, contains initial guess of variables. + // param : a list containing the the parameters to be set. + // xopt : a 1xn matrix of doubles, the computed solution of the optimization problem. + // fopt : a 1x1 matrix of doubles, the function value at x. + // exitflag : Integer identifying the reason the algorithm terminated. + // output : Structure containing information about the optimization. + // lambda : Structure containing the Lagrange multipliers at the solution x (separated by constraint type). + // + // Description + // Search the minimum of a constrained linear quadratic optimization problem specified by : + // find the minimum of f(x) such that + // + // <latex> + // \begin{eqnarray} + // &\mbox{min}_{x} + // & 1/2*x'*Q*x + p'*x \\ + // & \text{subject to} & conLB \leq C(x) \leq conUB \\ + // & & lb \leq x \leq ub \\ + // \end{eqnarray} + // </latex> + // + // We are calling IPOpt for solving the quadratic problem, IPOpt is a library written in C++. The code has been written by Andreas Wächter and Carl Laird. + // + // Examples + // //Find x in R^6 such that: + // conMatrix= [1,-1,1,0,3,1; + // -1,0,-3,-4,5,6; + // 2,5,3,0,1,0 + // 0,1,0,1,2,-1; + // -1,0,2,1,1,0]; + // conLB=[1;2;3;-%inf;-%inf]; + // conUB = [1;2;3;-1;2.5]; + // lb=[-1000;-10000; 0; -1000; -1000; -1000]; + // ub=[10000; 100; 1.5; 100; 100; 1000]; + // //and minimize 0.5*x'*Q*x + p'*x with + // p=[1; 2; 3; 4; 5; 6]; Q=eye(6,6); + // nbVar = 6; + // nbCon = 5; + // x0 = repmat(0,nbVar,1); + // param = list("MaxIter", 300, "CpuTime", 100); + // [xopt,fopt,exitflag,output,lambda]=qpipopt(nbVar,nbCon,Q,p,lb,ub,conMatrix,conLB,conUB,x0,param) + // + // Examples + // //Find the value of x that minimize following function + // // f(x) = 0.5*x1^2 + x2^2 - x1*x2 - 2*x1 - 6*x2 + // // Subject to: + // // x1 + x2 ≤ 2 + // // –x1 + 2x2 ≤ 2 + // // 2x1 + x2 ≤ 3 + // // 0 ≤ x1, 0 ≤ x2. + // Q = [1 -1; -1 2]; + // p = [-2; -6]; + // conMatrix = [1 1; -1 2; 2 1]; + // conUB = [2; 2; 3]; + // conLB = [-%inf; -%inf; -%inf]; + // lb = [0; 0]; + // ub = [%inf; %inf]; + // nbVar = 2; + // nbCon = 3; + // [xopt,fopt,exitflag,output,lambda] = qpipopt(nbVar,nbCon,Q,p,lb,ub,conMatrix,conLB,conUB) + // + // Authors + // Keyur Joshi, Saikiran, Iswarya, Harpreet Singh + + +//To check the number of input and output argument + [lhs , rhs] = argn(); + +//To check the number of argument given by user + if ( rhs < 9 | rhs > 11 ) then + errmsg = msprintf(gettext("%s: Unexpected number of input arguments : %d provided while should be 9, 10 or 11"), "qpipopt", rhs); + error(errmsg) + end + + + nbVar = varargin(1); + nbCon = varargin(2); + Q = varargin(3); + p = varargin(4); + LB = varargin(5); + UB = varargin(6); + conMatrix = varargin(7); + conLB = varargin(8); + conUB = varargin(9); + + + if ( rhs<10 | size(varargin(10)) ==0 ) then + x0 = repmat(0,nbVar,1); + else + x0 = varargin(10); + end + + if ( rhs<11 ) then + param = []; + else + param =varargin(11); + end + + if (modulo(size(param),2)) then + errmsg = msprintf(gettext("%s: Size of parameters should be even"), "qpipopt"); + error(errmsg); + end + + + options = list(.. + "MaxIter" , [3000], ... + "CpuTime" , [600] ... + ); + + for i = 1:(size(param))/2 + + select param(2*i-1) + case "MaxIter" then + options(1) = param(2*i); + case "CpuTime" then + options(3) = param(2*i); + else + errmsg = msprintf(gettext("%s: Unrecognized parameter name ''%s''."), "qpipopt", param(2*i-1)); + error(errmsg) + end + end + + //IPOpt wants it in row matrix form + p = p'; + LB = LB'; + UB = UB'; + conLB = conLB'; + conUB = conUB'; + x0 = x0'; + + //Checking the Q matrix which needs to be a symmetric matrix + if ( ~isequal(Q,Q') ) then + errmsg = msprintf(gettext("%s: Q is not a symmetric matrix"), "qpipopt"); + error(errmsg); + end + + //Check the size of Q which should equal to the number of variable + if ( size(Q) ~= [nbVar nbVar]) then + errmsg = msprintf(gettext("%s: The Size of Q is not equal to the number of variables"), "qpipopt"); + error(errmsg); + end + + //Check the size of p which should equal to the number of variable + if ( size(p,2) ~= [nbVar]) then + errmsg = msprintf(gettext("%s: The Size of p is not equal to the number of variables"), "qpipopt"); + error(errmsg); + end + + + //Check the size of constraint which should equal to the number of variables + if ( size(conMatrix,2) ~= nbVar) then + errmsg = msprintf(gettext("%s: The size of constraints is not equal to the number of variables"), "qpipopt"); + error(errmsg); + end + + //Check the size of Lower Bound which should equal to the number of variables + if ( size(LB,2) ~= nbVar) then + errmsg = msprintf(gettext("%s: The Lower Bound is not equal to the number of variables"), "qpipopt"); + error(errmsg); + end + + //Check the size of Upper Bound which should equal to the number of variables + if ( size(UB,2) ~= nbVar) then + errmsg = msprintf(gettext("%s: The Upper Bound is not equal to the number of variables"), "qpipopt"); + error(errmsg); + end + + //Check the size of constraints of Lower Bound which should equal to the number of constraints + if ( size(conLB,2) ~= nbCon) then + errmsg = msprintf(gettext("%s: The Lower Bound of constraints is not equal to the number of constraints"), "qpipopt"); + error(errmsg); + end + + //Check the size of constraints of Upper Bound which should equal to the number of constraints + if ( size(conUB,2) ~= nbCon) then + errmsg = msprintf(gettext("%s: The Upper Bound of constraints is not equal to the number of constraints"), "qpipopt"); + error(errmsg); + end + + //Check the size of initial of variables which should equal to the number of variables + if ( size(x0,2) ~= nbVar) then + errmsg = msprintf(gettext("%s: The initial guess of variables is not equal to the number of variables"), "qpipopt"); + error(errmsg); + end + + + [xopt,fopt,status,iter,Zl,Zu,lmbda] = solveqp(nbVar,nbCon,Q,p,conMatrix,conLB,conUB,LB,UB,x0,options); + + xopt = xopt'; + exitflag = status; + output = struct("Iterations" , []); + output.Iterations = iter; + lambda = struct("lower" , [], .. + "upper" , [], .. + "constraint" , []); + + lambda.lower = Zl; + lambda.upper = Zu; + lambda.constraint = lmbda; + + +endfunction diff --git a/macros/qpipoptmat.bin b/macros/qpipoptmat.bin Binary files differindex 68c3988..668402c 100644 --- a/macros/qpipoptmat.bin +++ b/macros/qpipoptmat.bin diff --git a/macros/qpipoptmat.sci b/macros/qpipoptmat.sci index 2f3e911..6ae20c0 100644 --- a/macros/qpipoptmat.sci +++ b/macros/qpipoptmat.sci @@ -14,11 +14,12 @@ function [xopt,fopt,exitflag,output,lambda] = qpipoptmat (varargin) // Solves a linear quadratic problem. // // Calling Sequence - // xopt = qpipoptmat(nbVar,nbCon,Q,p,LB,UB,conMatrix,conLB,conUB) // x = qpipoptmat(H,f) // x = qpipoptmat(H,f,A,b) // x = qpipoptmat(H,f,A,b,Aeq,beq) // x = qpipoptmat(H,f,A,b,Aeq,beq,lb,ub) + // x = qpipoptmat(H,f,A,b,Aeq,beq,lb,ub,x0) + // x = qpipoptmat(H,f,A,b,Aeq,beq,lb,ub,x0,param) // [xopt,fopt,exitflag,output,lamda] = qpipoptmat( ... ) // // Parameters @@ -30,6 +31,8 @@ function [xopt,fopt,exitflag,output,lambda] = qpipoptmat (varargin) // beq : a vector of doubles, represents the linear coefficients in the equality constraints // LB : a n x 1 matrix of doubles, where n is number of variables, contains lower bounds of the variables. // UB : a n x 1 matrix of doubles, where n is number of variables, contains upper bounds of the variables. + // x0 : a m x 1 matrix of doubles, where m is number of constraints, contains initial guess of variables. + // param : a list containing the the parameters to be set. // xopt : a nx1 matrix of doubles, the computed solution of the optimization problem. // fopt : a 1x1 matrix of doubles, the function value at x. // exitflag : Integer identifying the reason the algorithm terminated. @@ -64,9 +67,11 @@ function [xopt,fopt,exitflag,output,lambda] = qpipoptmat (varargin) // b = [-1; 2.5]; // lb=[-1000; -10000; 0; -1000; -1000; -1000]; // ub=[10000; 100; 1.5; 100; 100; 1000]; + // x0 = repmat(0,6,1); + // param = list("MaxIter", 300, "CpuTime", 100); // //and minimize 0.5*x'*Q*x + p'*x with // f=[1; 2; 3; 4; 5; 6]; H=eye(6,6); - // [xopt,fopt,exitflag,output,lambda]=qpipoptmat(H,f,A,b,Aeq,beq,lb,ub) + // [xopt,fopt,exitflag,output,lambda]=qpipoptmat(H,f,A,b,Aeq,beq,lb,ub,[],param) // clear H f A b Aeq beq lb ub; // // Examples @@ -93,8 +98,8 @@ function [xopt,fopt,exitflag,output,lambda] = qpipoptmat (varargin) [lhs , rhs] = argn(); //To check the number of argument given by user - if ( rhs < 2 | rhs == 3 | rhs == 5 | rhs == 7 | rhs > 8 ) then - errmsg = msprintf(gettext("%s: Unexpected number of input arguments : %d provided while should be in the set of [2 4 6 8]"), "qpipopt", rhs); + if ( rhs < 2 | rhs == 3 | rhs == 5 | rhs == 7 | rhs > 10 ) then + errmsg = msprintf(gettext("%s: Unexpected number of input arguments : %d provided while should be in the set of [2 4 6 8 9 10]"), "qpipoptmat", rhs); error(errmsg) end @@ -126,7 +131,50 @@ function [xopt,fopt,exitflag,output,lambda] = qpipoptmat (varargin) LB = varargin(7); UB = varargin(8); end - + + + if ( rhs<9 | size(varargin(9)) ==0 ) then + x0 = repmat(0,nbVar,1) + else + x0 = varargin(9); + end + + if ( rhs<10 ) then + param = list(); + else + param =varargin(10); + end + + + if (modulo(size(param),2)) then + errmsg = msprintf(gettext("%s: Size of parameters should be even"), "qpipoptmat"); + error(errmsg); + end + + if (modulo(size(param),2)) then + errmsg = msprintf(gettext("%s: Size of parameters should be even"), "qpipoptmat"); + error(errmsg); + end + + + options = list(.. + "MaxIter" , [3000], ... + "CpuTime" , [600] ... + ); + + for i = 1:(size(param))/2 + + select param(2*i-1) + case "MaxIter" then + options(2*i-1) = param(2*i); + case "CpuTime" then + options(2*i-1) = param(2*i); + else + errmsg = msprintf(gettext("%s: Unrecognized parameter name ''%s''."), "qpipoptmat", param(2*i-1)); + error(errmsg) + end + end + nbConInEq = size(A,1); nbConEq = size(Aeq,1); @@ -168,33 +216,41 @@ function [xopt,fopt,exitflag,output,lambda] = qpipoptmat (varargin) error(errmsg); end -//Check the size of Upper Bound which should equal to the number of variables + //Check the size of Upper Bound which should equal to the number of variables if ( size(UB,1) ~= nbVar) then errmsg = msprintf(gettext("%s: The Upper Bound is not equal to the number of variables"), "qpipoptmat"); error(errmsg); end -//Check the size of constraints of Lower Bound which should equal to the number of constraints + //Check the size of constraints of Lower Bound which should equal to the number of constraints if ( size(b,1) ~= nbConInEq & size(b,1) ~= 0) then errmsg = msprintf(gettext("%s: The Lower Bound of inequality constraints is not equal to the number of constraints"), "qpipoptmat"); error(errmsg); end -//Check the size of constraints of Upper Bound which should equal to the number of constraints + //Check the size of constraints of Upper Bound which should equal to the number of constraints if ( size(beq,1) ~= nbConEq & size(beq,1) ~= 0) then errmsg = msprintf(gettext("%s: The Upper Bound of equality constraints is not equal to the number of constraints"), "qpipoptmat"); error(errmsg); end + + //Check the size of initial of variables which should equal to the number of variables + if ( size(x0,1) ~= nbVar) then + errmsg = msprintf(gettext("%s: The initial guess of variables is not equal to the number of variables"), "qpipoptmat"); + error(errmsg); + end + //Converting it into ipopt format f = f'; LB = LB'; UB = UB'; + x0 = x0'; conMatrix = [Aeq;A]; nbCon = size(conMatrix,1); conLB = [beq; repmat(-%inf,nbConInEq,1)]'; conUB = [beq;b]' ; - [xopt,fopt,status,iter,Zl,Zu,lmbda] = solveqp(nbVar,nbCon,H,f,conMatrix,conLB,conUB,LB,UB); + [xopt,fopt,status,iter,Zl,Zu,lmbda] = solveqp(nbVar,nbCon,H,f,conMatrix,conLB,conUB,LB,UB,x0,options); xopt = xopt'; exitflag = status; diff --git a/macros/qpipoptmat.sci~ b/macros/qpipoptmat.sci~ index 4c72216..e29da8f 100644 --- a/macros/qpipoptmat.sci~ +++ b/macros/qpipoptmat.sci~ @@ -10,16 +10,17 @@ // http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt -function [xopt,fopt,exitflag,output,lambda] = qpipopt_mat (varargin) +function [xopt,fopt,exitflag,output,lambda] = qpipoptmat (varargin) // Solves a linear quadratic problem. // // Calling Sequence - // xopt = qpipopt_mat(nbVar,nbCon,Q,p,LB,UB,conMatrix,conLB,conUB) - // x = qpipopt_mat(H,f) - // x = qpipopt_mat(H,f,A,b) - // x = qpipopt_mat(H,f,A,b,Aeq,beq) - // x = qpipopt_mat(H,f,A,b,Aeq,beq,lb,ub) - // [xopt,fopt,exitflag,output,lamda] = qpipopt_mat( ... ) + // x = qpipoptmat(H,f) + // x = qpipoptmat(H,f,A,b) + // x = qpipoptmat(H,f,A,b,Aeq,beq) + // x = qpipoptmat(H,f,A,b,Aeq,beq,lb,ub) + // x = qpipoptmat(H,f,A,b,Aeq,beq,lb,ub,x0) + // x = qpipoptmat(H,f,A,b,Aeq,beq,lb,ub,x0,param) + // [xopt,fopt,exitflag,output,lamda] = qpipoptmat( ... ) // // Parameters // H : a n x n matrix of doubles, where n is number of variables, represents coefficients of quadratic in the quadratic problem. @@ -30,6 +31,8 @@ function [xopt,fopt,exitflag,output,lambda] = qpipopt_mat (varargin) // beq : a vector of doubles, represents the linear coefficients in the equality constraints // LB : a n x 1 matrix of doubles, where n is number of variables, contains lower bounds of the variables. // UB : a n x 1 matrix of doubles, where n is number of variables, contains upper bounds of the variables. + // x0 : a m x 1 matrix of doubles, where m is number of constraints, contains initial guess of variables. + // param : a list containing the the parameters to be set. // xopt : a nx1 matrix of doubles, the computed solution of the optimization problem. // fopt : a 1x1 matrix of doubles, the function value at x. // exitflag : Integer identifying the reason the algorithm terminated. @@ -64,9 +67,11 @@ function [xopt,fopt,exitflag,output,lambda] = qpipopt_mat (varargin) // b = [-1; 2.5]; // lb=[-1000; -10000; 0; -1000; -1000; -1000]; // ub=[10000; 100; 1.5; 100; 100; 1000]; + // x0 = repmat(0,6,1); + // param = list("MaxIter", 300, "CpuTime", 100); // //and minimize 0.5*x'*Q*x + p'*x with // f=[1; 2; 3; 4; 5; 6]; H=eye(6,6); - // [xopt,fopt,exitflag,output,lambda]=qpipopt_mat(H,f,A,b,Aeq,beq,lb,ub) + // [xopt,fopt,exitflag,output,lambda]=qpipoptmat(H,f,A,b,Aeq,beq,lb,ub,[],param) // clear H f A b Aeq beq lb ub; // // Examples @@ -83,7 +88,7 @@ function [xopt,fopt,exitflag,output,lambda] = qpipopt_mat (varargin) // b = [2; 2; 3]; // lb = [0; 0]; // ub = [%inf; %inf]; - // [xopt,fopt,exitflag,output,lambda] = qpipopt_mat(H,f,A,b,[],[],lb,ub) + // [xopt,fopt,exitflag,output,lambda] = qpipoptmat(H,f,A,b,[],[],lb,ub) // // Authors // Keyur Joshi, Saikiran, Iswarya, Harpreet Singh @@ -93,8 +98,8 @@ function [xopt,fopt,exitflag,output,lambda] = qpipopt_mat (varargin) [lhs , rhs] = argn(); //To check the number of argument given by user - if ( rhs < 2 | rhs == 3 | rhs == 5 | rhs == 7 | rhs > 8 ) then - errmsg = msprintf(gettext("%s: Unexpected number of input arguments : %d provided while should be in the set of [2 4 6 8]"), "qpipopt", rhs); + if ( rhs < 2 | rhs == 3 | rhs == 5 | rhs == 7 | rhs > 10 ) then + errmsg = msprintf(gettext("%s: Unexpected number of input arguments : %d provided while should be in the set of [2 4 6 8 9 10]"), "qpipoptmat", rhs); error(errmsg) end @@ -126,75 +131,121 @@ function [xopt,fopt,exitflag,output,lambda] = qpipopt_mat (varargin) LB = varargin(7); UB = varargin(8); end - + + + if ( rhs<10 | size(varargin(9)) ==0 ) then + x0 = repmat(0,nbVar,1) + else + x0 = varargin(9); + end + + if ( rhs<11 ) then + param = list(); + else + param =varargin(10); + end + + + if (modulo(size(param),2)) then + errmsg = msprintf(gettext("%s: Size of parameters should be even"), "qpipoptmat"); + error(errmsg); + end + + + options = list(.. + "MaxIter" , [3000], ... + "CpuTime" , [600] ... + ); + + for i = 1:(size(param))/2 + + select param(2*i-1) + case "MaxIter" then + options(2*i-1) = param(2*i); + case "CpuTime" then + options(2*i-1) = param(2*i); + else + errmsg = msprintf(gettext("%s: Unrecognized parameter name ''%s''."), "qpipoptmat", param(2*i-1)); + error(errmsg) + end + end + nbConInEq = size(A,1); nbConEq = size(Aeq,1); //Checking the H matrix which needs to be a symmetric matrix if ( H~=H') then - errmsg = msprintf(gettext("%s: H is not a symmetric matrix"), "qpipopt_mat"); + errmsg = msprintf(gettext("%s: H is not a symmetric matrix"), "qpipoptmat"); error(errmsg); end //Check the size of H which should equal to the number of variable if ( size(H) ~= [nbVar nbVar]) then - errmsg = msprintf(gettext("%s: The Size of H is not equal to the number of variables"), "qpipopt"); + errmsg = msprintf(gettext("%s: The Size of H is not equal to the number of variables"), "qpipoptmat"); error(errmsg); end //Check the size of f which should equal to the number of variable if ( size(f,1) ~= [nbVar]) then - errmsg = msprintf(gettext("%s: The Size of f is not equal to the number of variables"), "qpipopt"); + errmsg = msprintf(gettext("%s: The Size of f is not equal to the number of variables"), "qpipoptmat"); error(errmsg); end //Check the size of inequality constraint which should be equal to the number of variables if ( size(A,2) ~= nbVar & size(A,2) ~= 0) then - errmsg = msprintf(gettext("%s: The size of inequality constraints is not equal to the number of variables"), "qpipopt"); + errmsg = msprintf(gettext("%s: The size of inequality constraints is not equal to the number of variables"), "qpipoptmat"); error(errmsg); end //Check the size of equality constraint which should be equal to the number of variables if ( size(Aeq,2) ~= nbVar & size(Aeq,2) ~= 0 ) then - errmsg = msprintf(gettext("%s: The size of equality constraints is not equal to the number of variables"), "qpipopt"); + errmsg = msprintf(gettext("%s: The size of equality constraints is not equal to the number of variables"), "qpipoptmat"); error(errmsg); end //Check the size of Lower Bound which should be equal to the number of variables if ( size(LB,1) ~= nbVar) then - errmsg = msprintf(gettext("%s: The Lower Bound is not equal to the number of variables"), "qpipopt"); + errmsg = msprintf(gettext("%s: The Lower Bound is not equal to the number of variables"), "qpipoptmat"); error(errmsg); end -//Check the size of Upper Bound which should equal to the number of variables + //Check the size of Upper Bound which should equal to the number of variables if ( size(UB,1) ~= nbVar) then - errmsg = msprintf(gettext("%s: The Upper Bound is not equal to the number of variables"), "qpipopt"); + errmsg = msprintf(gettext("%s: The Upper Bound is not equal to the number of variables"), "qpipoptmat"); error(errmsg); end -//Check the size of constraints of Lower Bound which should equal to the number of constraints + //Check the size of constraints of Lower Bound which should equal to the number of constraints if ( size(b,1) ~= nbConInEq & size(b,1) ~= 0) then - errmsg = msprintf(gettext("%s: The Lower Bound of inequality constraints is not equal to the number of constraints"), "qpipopt"); + errmsg = msprintf(gettext("%s: The Lower Bound of inequality constraints is not equal to the number of constraints"), "qpipoptmat"); error(errmsg); end -//Check the size of constraints of Upper Bound which should equal to the number of constraints + //Check the size of constraints of Upper Bound which should equal to the number of constraints if ( size(beq,1) ~= nbConEq & size(beq,1) ~= 0) then - errmsg = msprintf(gettext("%s: The Upper Bound of equality constraints is not equal to the number of constraints"), "qp_ipopt"); + errmsg = msprintf(gettext("%s: The Upper Bound of equality constraints is not equal to the number of constraints"), "qpipoptmat"); error(errmsg); end + + //Check the size of initial of variables which should equal to the number of variables + if ( size(x0,1) ~= nbVar) then + errmsg = msprintf(gettext("%s: The initial guess of variables is not equal to the number of variables"), "qpipoptmat"); + error(errmsg); + end + //Converting it into ipopt format f = f'; LB = LB'; UB = UB'; + x0 = x0'; conMatrix = [Aeq;A]; nbCon = size(conMatrix,1); conLB = [beq; repmat(-%inf,nbConInEq,1)]'; conUB = [beq;b]' ; - [xopt,fopt,status,iter,Zl,Zu,lmbda] = solveqp(nbVar,nbCon,H,f,conMatrix,conLB,conUB,LB,UB); + [xopt,fopt,status,iter,Zl,Zu,lmbda] = solveqp(nbVar,nbCon,H,f,conMatrix,conLB,conUB,LB,UB,x0,options); xopt = xopt'; exitflag = status; diff --git a/macros/setOptions.bin b/macros/setOptions.bin Binary files differindex c5a69df..8d23e73 100644 --- a/macros/setOptions.bin +++ b/macros/setOptions.bin diff --git a/macros/setOptions.sci b/macros/setOptions.sci index 138e577..68aad02 100644 --- a/macros/setOptions.sci +++ b/macros/setOptions.sci @@ -12,9 +12,8 @@ function setOptions(varargin) options = varargin(1); - nbOpt = size(options,2); + nbOpt = size(options); - value = strtod(options) if (nbOpt~=0) then for i = 1:(nbOpt/2) @@ -22,21 +21,19 @@ function setOptions(varargin) //Setting the parameters //Check if the given parameter is String - if (value(2*i) == %nan ) then - sym_setStrParam(options(2*i - 1),value(2*i)); + if (type(options(2*i)) == 10 ) then + sym_setStrParam(options(2*i - 1),options(2*i)); //Check if the given parameter is Double - elseif(type(value(2*i))==1) then - sym_setDblParam(options(2*i - 1),value(2*i)); + elseif(type(options(2*i))==1) then + sym_setDblParam(options(2*i - 1),options(2*i)); //Check if the given parameter is Integer - elseif(type(value(2*i))==8) + elseif(type(options(2*i))==8) sym_setIntParam(options(2*i - 1),options(2*i)); end - - end + end end - endfunction diff --git a/macros/setOptions.sci~ b/macros/setOptions.sci~ new file mode 100644 index 0000000..ef5c36c --- /dev/null +++ b/macros/setOptions.sci~ @@ -0,0 +1,40 @@ +// Copyright (C) 2015 - IIT Bombay - FOSSEE +// +// Author: Harpreet Singh +// Organization: FOSSEE, IIT Bombay +// Email: harpreet.mertia@gmail.com +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + +function setOptions(varargin) + + options = varargin(1); + nbOpt = size(options); + + + if (nbOpt~=0) then + for i = 1:(nbOpt/2) + + //Setting the parameters + + //Check if the given parameter is String + if (type(options(2*i)) == 10 ) then + sym_setStrParam(options(2*i - 1),options(2*i)); + + //Check if the given parameter is Double + elseif(type(options(2*i))==1) then + sym_setDblParam(options(2*i - 1),options(2*i)); + + //Check if the given parameter is Integer + elseif(type(options(2*i))==8) + sym_setIntParam(options(2*i - 1),options(2*i)); + end + + end + end + +endfunction + diff --git a/macros/symphony.bin b/macros/symphony.bin Binary files differindex ae6c958..d2aa822 100644 --- a/macros/symphony.bin +++ b/macros/symphony.bin diff --git a/macros/symphony.sci b/macros/symphony.sci index f221160..9677720 100644 --- a/macros/symphony.sci +++ b/macros/symphony.sci @@ -71,7 +71,8 @@ function [xopt,fopt,status,output] = symphony (varargin) // xopt = [1 1 0 1 7.25 0 0.25 3.5] // fopt = [8495] // // Calling Symphony - // [x,f,iter] = symphony(8,3,c,isInt,lb,ub,conMatrix,conlb,conub,1); + // [x,f,status,output] = symphony(8,3,c,isInt,lb,ub,conMatrix,conlb,conub,1) + // // Examples // // An advanced case where we set some options in symphony // // This problem is taken from @@ -145,7 +146,7 @@ function [xopt,fopt,status,output] = symphony (varargin) // conLB=repmat(0,nbCon,1); // // Upper Bound of constraints // conUB=[11927 13727 11551 13056 13460 ]'; - // options = ["time_limit" "25"] + // options = list("time_limit", 25); // // The expected solution : // // Output variables // xopt = [0 1 1 0 0 1 0 1 0 1 0 0 0 0 0 0 0 1 0 0 0 0 1 0 1 1 0 1 1 0 1 .. @@ -154,7 +155,7 @@ function [xopt,fopt,status,output] = symphony (varargin) // // Optimal value // fopt = [ 24381 ] // // Calling Symphony - // [x,f,iter]= symphony(nbVar,nbCon,p,isInt,lb,ub,conMatrix,conLB,conUB,-1,options) + // [x,f,status,output] = symphony(nbVar,nbCon,p,isInt,lb,ub,conMatrix,conLB,conUB,-1,options) // // Authors // Keyur Joshi, Saikiran, Iswarya, Harpreet Singh @@ -185,7 +186,7 @@ function [xopt,fopt,status,output] = symphony (varargin) end if (rhs<11) then - options = []; + options = list(); else options = varargin(11); end @@ -224,4 +225,3 @@ function [xopt,fopt,status,output] = symphony (varargin) [xopt,fopt,status,output] = symphony_call(nbVar,nbCon,objCoef,isInt,LB,UB,conMatrix,conLB,conUB,objSense,options); endfunction - diff --git a/macros/symphony.sci~ b/macros/symphony.sci~ new file mode 100644 index 0000000..d5c8e44 --- /dev/null +++ b/macros/symphony.sci~ @@ -0,0 +1,227 @@ +// Copyright (C) 2015 - IIT Bombay - FOSSEE +// +// Author: Harpreet Singh +// Organization: FOSSEE, IIT Bombay +// Email: harpreet.mertia@gmail.com +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + +function [xopt,fopt,status,output] = symphony (varargin) + // Solves a mixed integer linear programming constrained optimization problem. + // + // Calling Sequence + // xopt = symphony(nbVar,nbCon,objCoef,isInt,LB,UB,conMatrix,conLB,conUB) + // xopt = symphony(nbVar,nbCon,objCoef,isInt,LB,UB,conMatrix,conLB,conUB,objSense) + // xopt = symphony(nbVar,nbCon,objCoef,isInt,LB,UB,conMatrix,conLB,conUB,objSense,options) + // [xopt,fopt,status,output] = symphony( ... ) + // + // Parameters + // nbVar : a 1 x 1 matrix of doubles, number of variables + // nbCon : a 1 x 1 matrix of doubles, number of constraints + // objCoeff : a 1 x n matrix of doubles, where n is number of variables, contains coefficients of the variables in the objective + // isInt : a 1 x n matrix of boolean, where n is number of variables, representing wether a variable is constrained to be an integer + // LB : a 1 x n matrix of doubles, where n is number of variables, contains lower bounds of the variables. Bound can be negative infinity + // UB : a 1 x n matrix of doubles, where n is number of variables, contains upper bounds of the variables. Bound can be infinity + // conMatrix : a m x n matrix of doubles, where n is number of variables and m is number of constraints, contains matrix representing the constraint matrix + // conLB : a m x 1 matrix of doubles, where m is number of constraints, contains lower bounds of the constraints. + // conUB : a m x 1 matrix of doubles, where m is number of constraints, contains upper bounds of the constraints + // objSense : The sense (maximization/minimization) of the objective. Use 1(sym_minimize ) or -1 (sym_maximize) here + // options : a 1xq marix of string, provided to set the paramters in symphony + // xopt : a 1xn matrix of doubles, the computed solution of the optimization problem + // fopt : a 1x1 matrix of doubles, the function value at x + // status : status flag from symphony + // output : The output data structure contains detailed informations about the optimization process. + // + // Description + // Search the minimum or maximum of a constrained mixed integer linear programming optimization problem specified by : + // find the minimum or maximum of f(x) such that + // + // <latex> + // \begin{eqnarray} + // &\mbox{min}_{x} + // & f(x) \\ + // & \text{subject to} & conLB \leq C(x) \leq conUB \\ + // & & lb \leq x \leq ub \\ + // \end{eqnarray} + // </latex> + // + // We are calling SYMPHONY written in C by gateway files for the actual computation. SYMPHONY was originally written by Ted Ralphs, Menal Guzelsoy and Ashutosh Mahajan. + // + // Examples + // //A basic case : + // // Objective function + // c = [350*5,330*3,310*4,280*6,500,450,400,100] + // // Lower Bound of variable + // lb = repmat(0,1,8); + // // Upper Bound of variables + // ub = [repmat(1,1,4) repmat(%inf,1,4)]; + // // Constraint Matrix + // conMatrix = [5,3,4,6,1,1,1,1; + // 5*0.05,3*0.04,4*0.05,6*0.03,0.08,0.07,0.06,0.03; + // 5*0.03,3*0.03,4*0.04,6*0.04,0.06,0.07,0.08,0.09;] + // // Lower Bound of constrains + // conlb = [ 25; 1.25; 1.25] + // // Upper Bound of constrains + // conub = [ 25; 1.25; 1.25] + // // Row Matrix for telling symphony that the is integer or not + // isInt = [repmat(%t,1,4) repmat(%f,1,4)]; + // xopt = [1 1 0 1 7.25 0 0.25 3.5] + // fopt = [8495] + // // Calling Symphony + // [x,f,status,output] = symphony(8,3,c,isInt,lb,ub,conMatrix,conlb,conub,1) + // + // Examples + // // An advanced case where we set some options in symphony + // // This problem is taken from + // // P.C.Chu and J.E.Beasley + // // "A genetic algorithm for the multidimensional knapsack problem", + // // Journal of Heuristics, vol. 4, 1998, pp63-86. + // // The problem to be solved is: + // // Max sum{j=1,...,n} p(j)x(j) + // // st sum{j=1,...,n} r(i,j)x(j) <= b(i) i=1,...,m + // // x(j)=0 or 1 + // // The function to be maximize i.e. P(j) + // p = [ 504 803 667 1103 834 585 811 856 690 832 846 813 868 793 .. + // 825 1002 860 615 540 797 616 660 707 866 647 746 1006 608 .. + // 877 900 573 788 484 853 942 630 591 630 640 1169 932 1034 .. + // 957 798 669 625 467 1051 552 717 654 388 559 555 1104 783 .. + // 959 668 507 855 986 831 821 825 868 852 832 828 799 686 .. + // 510 671 575 740 510 675 996 636 826 1022 1140 654 909 799 .. + // 1162 653 814 625 599 476 767 954 906 904 649 873 565 853 1008 632] + // //Constraint Matrix + // conMatrix = [ + // //Constraint 1 + // 42 41 523 215 819 551 69 193 582 375 367 478 162 898 .. + // 550 553 298 577 493 183 260 224 852 394 958 282 402 604 .. + // 164 308 218 61 273 772 191 117 276 877 415 873 902 465 .. + // 320 870 244 781 86 622 665 155 680 101 665 227 597 354 .. + // 597 79 162 998 849 136 112 751 735 884 71 449 266 420 .. + // 797 945 746 46 44 545 882 72 383 714 987 183 731 301 .. + // 718 91 109 567 708 507 983 808 766 615 554 282 995 946 651 298; + // //Constraint 2 + // 509 883 229 569 706 639 114 727 491 481 681 948 687 941 .. + // 350 253 573 40 124 384 660 951 739 329 146 593 658 816 .. + // 638 717 779 289 430 851 937 289 159 260 930 248 656 833 .. + // 892 60 278 741 297 967 86 249 354 614 836 290 893 857 .. + // 158 869 206 504 799 758 431 580 780 788 583 641 32 653 .. + // 252 709 129 368 440 314 287 854 460 594 512 239 719 751 .. + // 708 670 269 832 137 356 960 651 398 893 407 477 552 805 881 850; + // //Constraint 3 + // 806 361 199 781 596 669 957 358 259 888 319 751 275 177 .. + // 883 749 229 265 282 694 819 77 190 551 140 442 867 283 .. + // 137 359 445 58 440 192 485 744 844 969 50 833 57 877 .. + // 482 732 968 113 486 710 439 747 174 260 877 474 841 422 .. + // 280 684 330 910 791 322 404 403 519 148 948 414 894 147 .. + // 73 297 97 651 380 67 582 973 143 732 624 518 847 113 .. + // 382 97 905 398 859 4 142 110 11 213 398 173 106 331 254 447 ; + // //Constraint 4 + // 404 197 817 1000 44 307 39 659 46 334 448 599 931 776 .. + // 263 980 807 378 278 841 700 210 542 636 388 129 203 110 .. + // 817 502 657 804 662 989 585 645 113 436 610 948 919 115 .. + // 967 13 445 449 740 592 327 167 368 335 179 909 825 614 .. + // 987 350 179 415 821 525 774 283 427 275 659 392 73 896 .. + // 68 982 697 421 246 672 649 731 191 514 983 886 95 846 .. + // 689 206 417 14 735 267 822 977 302 687 118 990 323 993 525 322; + // //Constrain 5 + // 475 36 287 577 45 700 803 654 196 844 657 387 518 143 .. + // 515 335 942 701 332 803 265 922 908 139 995 845 487 100 .. + // 447 653 649 738 424 475 425 926 795 47 136 801 904 740 .. + // 768 460 76 660 500 915 897 25 716 557 72 696 653 933 .. + // 420 582 810 861 758 647 237 631 271 91 75 756 409 440 .. + // 483 336 765 637 981 980 202 35 594 689 602 76 767 693 .. + // 893 160 785 311 417 748 375 362 617 553 474 915 457 261 350 635 ; + // ]; + // nbCon = size(conMatrix,1) + // nbVar = size(conMatrix,2) + // // Lower Bound of variables + // lb = repmat(0,1,nbVar) + // // Upper Bound of variables + // ub = repmat(1,1,nbVar) + // // Row Matrix for telling symphony that the is integer or not + // isInt = repmat(%t,1,nbVar) + // // Lower Bound of constrains + // conLB=repmat(0,nbCon,1); + // // Upper Bound of constraints + // conUB=[11927 13727 11551 13056 13460 ]'; + // options = ["time_limit" "25"] + // // The expected solution : + // // Output variables + // xopt = [0 1 1 0 0 1 0 1 0 1 0 0 0 0 0 0 0 1 0 0 0 0 1 0 1 1 0 1 1 0 1 .. + // 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 1 1 0 0 1 0 .. + // 0 1 0 1 0 0 1 0 0 1 0 1 0 0 0 0 0 1 1 0 0 0 0 0 1 1 0 0 1 0 0 1 0] + // // Optimal value + // fopt = [ 24381 ] + // // Calling Symphony + // [x,f,status,output] = symphony(nbVar,nbCon,p,isInt,lb,ub,conMatrix,conLB,conUB,-1,options) + // + // Authors + // Keyur Joshi, Saikiran, Iswarya, Harpreet Singh + +//To check the number of input and output argument + [lhs , rhs] = argn(); + +//To check the number of argument given by user + if ( rhs < 9 | rhs > 11 ) then + errmsg = msprintf(gettext("%s: Unexpected number of input arguments : %d provided while should be in the set [9 10 11]"), "Symphony", rhs); + error(errmsg) + end + + nbVar = varargin(1); + nbCon = varargin(2); + objCoef = varargin(3); + isInt = varargin(4); + LB = varargin(5); + UB = varargin(6); + conMatrix = varargin(7); + conLB = varargin(8); + conUB = varargin(9); + + if ( rhs<10 ) then + objSense = 1; + else + objSense = varargin(10); + end + + if (rhs<11) then + options = list(); + else + options = varargin(11); + end + + +//Check the size of constraint which should equal to the number of constraints + if ( size(conMatrix,1) ~= nbCon) then + errmsg = msprintf(gettext("%s: The Lower Bound is not equal to the number of variables"), "Symphony"); + error(errmsg); + end + +//Check the size of Lower Bound which should equal to the number of variables + if ( size(LB,2) ~= nbVar) then + errmsg = msprintf(gettext("%s: The Lower Bound is not equal to the number of variables"), "Symphony"); + error(errmsg); + end + +//Check the size of Upper Bound which should equal to the number of variables + if ( size(UB,2) ~= nbVar) then + errmsg = msprintf(gettext("%s: The Upper Bound is not equal to the number of variables"), "Symphony"); + error(errmsg); + end + +//Check the size of constraints of Lower Bound which should equal to the number of constraints + if ( size(conLB,1) ~= nbCon) then + errmsg = msprintf(gettext("%s: The Lower Bound of constraints is not equal to the number of constraints"), "Symphony"); + error(errmsg); + end + +//Check the size of constraints of Upper Bound which should equal to the number of constraints + if ( size(conUB,1) ~= nbCon) then + errmsg = msprintf(gettext("%s: The Upper Bound of constraints is not equal to the number of constraints"), "Symphony"); + error(errmsg); + end + + [xopt,fopt,status,output] = symphony_call(nbVar,nbCon,objCoef,isInt,LB,UB,conMatrix,conLB,conUB,objSense,options); + +endfunction diff --git a/macros/symphony_call.bin b/macros/symphony_call.bin Binary files differindex b95e887..5008236 100644 --- a/macros/symphony_call.bin +++ b/macros/symphony_call.bin diff --git a/macros/symphony_call.sci b/macros/symphony_call.sci index ea5f34f..c8323fc 100644 --- a/macros/symphony_call.sci +++ b/macros/symphony_call.sci @@ -16,7 +16,7 @@ function [xopt,fopt,status,output] = symphony_call(nbVar,nbCon,objCoef,isInt,LB, //Setting Options for the Symphpony setOptions(options); - + //Choosing to launch basic or advanced version if(~issparse(conMatrix)) then sym_loadProblemBasic(nbVar,nbCon,LB,UB,objCoef,isInt,objSense,conMatrix,conLB,conUB); @@ -26,8 +26,8 @@ function [xopt,fopt,status,output] = symphony_call(nbVar,nbCon,objCoef,isInt,LB, sym_loadProblem(nbVar,nbCon,LB,UB,objCoef,isInt,objSense,conMatrix_advanced,conLB,conUB); end - op = sym_solve(); + disp(op); xopt = []; fopt = []; diff --git a/macros/symphony_call.sci~ b/macros/symphony_call.sci~ new file mode 100644 index 0000000..057ba63 --- /dev/null +++ b/macros/symphony_call.sci~ @@ -0,0 +1,52 @@ +// Copyright (C) 2015 - IIT Bombay - FOSSEE +// +// Author: Harpreet Singh +// Organization: FOSSEE, IIT Bombay +// Email: harpreet.mertia@gmail.com +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + +function [xopt,fopt,status,output] = symphony_call(nbVar,nbCon,objCoef,isInt,LB,UB,conMatrix,conLB,conUB,objSense,options) + + //Opening Symphony environment + sym_open(); + + //Setting Options for the Symphpony +// setOptions(options); + + //Choosing to launch basic or advanced version + if(~issparse(conMatrix)) then + sym_loadProblemBasic(nbVar,nbCon,LB,UB,objCoef,isInt,objSense,conMatrix,conLB,conUB); + else + // Changing to Constraint Matrix into sparse matrix + conMatrix_advanced=sparse(conMatrix); + sym_loadProblem(nbVar,nbCon,LB,UB,objCoef,isInt,objSense,conMatrix_advanced,conLB,conUB); + end + + op = sym_solve(); + disp(op); + + xopt = []; + fopt = []; + status = []; + output = []; + + if (~op) then + xopt = sym_getVarSoln(); + // Symphony gives a row matrix converting it to column matrix + xopt = xopt'; + + fopt = sym_getObjVal(); + end + + status = sym_getStatus(); + + output = struct("Iterations" , []); + + output.Iterations = sym_getIterCount(); + + +endfunction diff --git a/macros/symphonymat.bin b/macros/symphonymat.bin Binary files differnew file mode 100644 index 0000000..5089973 --- /dev/null +++ b/macros/symphonymat.bin diff --git a/macros/symphonymat.sci b/macros/symphonymat.sci new file mode 100644 index 0000000..ef70b7c --- /dev/null +++ b/macros/symphonymat.sci @@ -0,0 +1,242 @@ +// Copyright (C) 2015 - IIT Bombay - FOSSEE +// +// Author: Harpreet Singh +// Organization: FOSSEE, IIT Bombay +// Email: harpreet.mertia@gmail.com +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + +function [xopt,fopt,status,iter] = symphonymat (varargin) + // Solves a mixed integer linear programming constrained optimization problem in intlinprog format. + // + // Calling Sequence + // xopt = symphonymat(f,intcon,A,b) + // xopt = symphonymat(f,intcon,A,b,Aeq,beq) + // xopt = symphonymat(f,intcon,A,b,Aeq,beq,lb,ub) + // xopt = symphonymat(f,intcon,A,b,Aeq,beq,lb,ub,options) + // [xopt,fopt,status,output] = symphonymat( ... ) + // + // Parameters + // f : a 1xn matrix of doubles, where n is number of variables, contains coefficients of the variables in the objective + // intcon : Vector of integer constraints, specified as a vector of positive integers. The values in intcon indicate the components of the decision variable x that are integer-valued. intcon has values from 1 through number of variable + // A : Linear inequality constraint matrix, specified as a matrix of doubles. A represents the linear coefficients in the constraints A*x ≤ b. A has size M-by-N, where M is the number of constraints and N is number of variables + // b : Linear inequality constraint vector, specified as a vector of doubles. b represents the constant vector in the constraints A*x ≤ b. b has length M, where A is M-by-N + // Aeq : Linear equality constraint matrix, specified as a matrix of doubles. Aeq represents the linear coefficients in the constraints Aeq*x = beq. Aeq has size Meq-by-N, where Meq is the number of constraints and N is number of variables + // beq : Linear equality constraint vector, specified as a vector of doubles. beq represents the constant vector in the constraints Aeq*x = beq. beq has length Meq, where Aeq is Meq-by-N. + // lb : Lower bounds, specified as a vector or array of doubles. lb represents the lower bounds elementwise in lb ≤ x ≤ ub. + // ub : Upper bounds, specified as a vector or array of doubles. ub represents the upper bounds elementwise in lb ≤ x ≤ ub. + // options : a list containing the the parameters to be set. + // xopt : a 1xn matrix of doubles, the computed solution of the optimization problem + // fopt : a 1x1 matrix of doubles, the function value at x + // output : The output data structure contains detailed informations about the optimization process. + // + // Description + // Search the minimum or maximum of a constrained mixed integer linear programming optimization problem specified by : + // find the minimum or maximum of f(x) such that + // + // <latex> + // \begin{eqnarray} + // &\mbox{min}_{x} + // & f(x) \\ + // & \text{subject to} & conLB \leq C(x) \leq conUB \\ + // & & lb \leq x \leq ub \\ + // \end{eqnarray} + // </latex> + // + // We are calling SYMPHONY written in C by gateway files for the actual computation. SYMPHONY was originally written by Ted Ralphs, Menal Guzelsoy and Ashutosh Mahajan. + // + // Examples + // // Objective function + // c = [350*5,330*3,310*4,280*6,500,450,400,100] + // // Lower Bound of variable + // lb = repmat(0,1,8); + // // Upper Bound of variables + // ub = [repmat(1,1,4) repmat(%inf,1,4)]; + // // Constraint Matrix + // Aeq = [5,3,4,6,1,1,1,1; + // 5*0.05,3*0.04,4*0.05,6*0.03,0.08,0.07,0.06,0.03; + // 5*0.03,3*0.03,4*0.04,6*0.04,0.06,0.07,0.08,0.09;] + // beq = [ 25, 1.25, 1.25] + // intcon = [1 2 3 4]; + // // Calling Symphony + // [x,f,status,output] = symphonymat(c,intcon,[],[],Aeq,beq,lb,ub) + // + // Examples + // // An advanced case where we set some options in symphony + // // This problem is taken from + // // P.C.Chu and J.E.Beasley + // // "A genetic algorithm for the multidimensional knapsack problem", + // // Journal of Heuristics, vol. 4, 1998, pp63-86. + // // The problem to be solved is: + // // Max sum{j=1,...,n} p(j)x(j) + // // st sum{j=1,...,n} r(i,j)x(j) <= b(i) i=1,...,m + // // x(j)=0 or 1 + // // The function to be maximize i.e. P(j) + // objCoef = -1*[ 504 803 667 1103 834 585 811 856 690 832 846 813 868 793 .. + // 825 1002 860 615 540 797 616 660 707 866 647 746 1006 608 .. + // 877 900 573 788 484 853 942 630 591 630 640 1169 932 1034 .. + // 957 798 669 625 467 1051 552 717 654 388 559 555 1104 783 .. + // 959 668 507 855 986 831 821 825 868 852 832 828 799 686 .. + // 510 671 575 740 510 675 996 636 826 1022 1140 654 909 799 .. + // 1162 653 814 625 599 476 767 954 906 904 649 873 565 853 1008 632] + // //Constraint Matrix + // conMatrix = [ //Constraint 1 + // 42 41 523 215 819 551 69 193 582 375 367 478 162 898 .. + // 550 553 298 577 493 183 260 224 852 394 958 282 402 604 .. + // 164 308 218 61 273 772 191 117 276 877 415 873 902 465 .. + // 320 870 244 781 86 622 665 155 680 101 665 227 597 354 .. + // 597 79 162 998 849 136 112 751 735 884 71 449 266 420 .. + // 797 945 746 46 44 545 882 72 383 714 987 183 731 301 .. + // 718 91 109 567 708 507 983 808 766 615 554 282 995 946 651 298; + // //Constraint 2 + // 509 883 229 569 706 639 114 727 491 481 681 948 687 941 .. + // 350 253 573 40 124 384 660 951 739 329 146 593 658 816 .. + // 638 717 779 289 430 851 937 289 159 260 930 248 656 833 .. + // 892 60 278 741 297 967 86 249 354 614 836 290 893 857 .. + // 158 869 206 504 799 758 431 580 780 788 583 641 32 653 .. + // 252 709 129 368 440 314 287 854 460 594 512 239 719 751 .. + // 708 670 269 832 137 356 960 651 398 893 407 477 552 805 881 850; + // //Constraint 3 + // 806 361 199 781 596 669 957 358 259 888 319 751 275 177 .. + // 883 749 229 265 282 694 819 77 190 551 140 442 867 283 .. + // 137 359 445 58 440 192 485 744 844 969 50 833 57 877 .. + // 482 732 968 113 486 710 439 747 174 260 877 474 841 422 .. + // 280 684 330 910 791 322 404 403 519 148 948 414 894 147 .. + // 73 297 97 651 380 67 582 973 143 732 624 518 847 113 .. + // 382 97 905 398 859 4 142 110 11 213 398 173 106 331 254 447 ; + // //Constraint 4 + // 404 197 817 1000 44 307 39 659 46 334 448 599 931 776 .. + // 263 980 807 378 278 841 700 210 542 636 388 129 203 110 .. + // 817 502 657 804 662 989 585 645 113 436 610 948 919 115 .. + // 967 13 445 449 740 592 327 167 368 335 179 909 825 614 .. + // 987 350 179 415 821 525 774 283 427 275 659 392 73 896 .. + // 68 982 697 421 246 672 649 731 191 514 983 886 95 846 .. + // 689 206 417 14 735 267 822 977 302 687 118 990 323 993 525 322; + // //Constrain 5 + // 475 36 287 577 45 700 803 654 196 844 657 387 518 143 .. + // 515 335 942 701 332 803 265 922 908 139 995 845 487 100 .. + // 447 653 649 738 424 475 425 926 795 47 136 801 904 740 .. + // 768 460 76 660 500 915 897 25 716 557 72 696 653 933 .. + // 420 582 810 861 758 647 237 631 271 91 75 756 409 440 .. + // 483 336 765 637 981 980 202 35 594 689 602 76 767 693 .. + // 893 160 785 311 417 748 375 362 617 553 474 915 457 261 350 635 ; + // ]; + // nbVar = size(objCoef,2) + // conUB=[11927 13727 11551 13056 13460 ]; + // // Lower Bound of variables + // lb = repmat(0,1,nbVar) + // // Upper Bound of variables + // ub = repmat(1,1,nbVar) + // // Lower Bound of constrains + // intcon = [] + // for i = 1:nbVar + // intcon = [intcon i]; + // end + // options = list("time_limit", 25); + // // The expected solution : + // // Output variables + // xopt = [0 1 1 0 0 1 0 1 0 1 0 0 0 0 0 0 0 1 0 0 0 0 1 0 1 1 0 1 1 0 1 .. + // 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 1 1 .. + // 0 0 1 0 0 1 0 1 0 0 1 0 0 1 0 1 0 0 0 0 0 1 1 0 0 0 0 0 1 1 0 0 1 0 0 1 0] + // // Optimal value + // fopt = [ 24381 ] + // // Calling Symphony + // [x,f,status,output] = symphonymat(objCoef,intcon,conMatrix,conUB,[],[],lb,ub,options); + // + // Authors + // Keyur Joshi, Saikiran, Iswarya, Harpreet Singh + + +//To check the number of input and output argument + [lhs , rhs] = argn(); + +//To check the number of argument given by user + if ( rhs < 4 | rhs == 5 | rhs == 7 | rhs > 9 ) then + errmsg = msprintf(gettext("%s: Unexpected number of input arguments : %d provided while should be in the set [4 6 8 9]"), "Symphony", rhs); + error(errmsg) + end + + + objCoef = varargin(1) + intcon = varargin(2) + A = varargin(3) + b = varargin(4) + + nbVar = size(objCoef,2); + nbCon = size(A,1); + + if ( rhs<4 ) then + Aeq = [] + beq = [] + else + Aeq = varargin(5); + beq = varargin(6); + + if (size(Aeq,1)~=0) then + //Check the size of equality constraint which should equal to the number of inequality constraints + if ( size(Aeq,2) ~= nbVar) then + errmsg = msprintf(gettext("%s: The size of equality constraint is not equal to the number of variables"), "Symphony"); + error(errmsg); + end + + //Check the size of upper bound of inequality constraint which should equal to the number of constraints + if ( size(beq,2) ~= size(Aeq,1)) then + errmsg = msprintf(gettext("%s: The equality constraint upper bound is not equal to the number of equality constraint"), "Symphony"); + error(errmsg); + end + end + + end + + if ( rhs<6 ) then + lb = repmat(-%inf,1,nbVar); + ub = repmat(%inf,1,nbVar); + else + lb = varargin(7); + ub = varargin(8); + end + + if (rhs<9) then + options = list(); + else + options = varargin(9); + end + + +//Check the size of lower bound of inequality constraint which should equal to the number of constraints + if ( size(b,2) ~= size(A,1)) then + errmsg = msprintf(gettext("%s: The Lower Bound of inequality constraint is not equal to the number of constraint"), "Symphony"); + error(errmsg); + end + +//Check the size of Lower Bound which should equal to the number of variables + if ( size(lb,2) ~= nbVar) then + errmsg = msprintf(gettext("%s: The Lower Bound is not equal to the number of variables"), "Symphony"); + error(errmsg); + end + +//Check the size of Upper Bound which should equal to the number of variables + if ( size(ub,2) ~= nbVar) then + errmsg = msprintf(gettext("%s: The Upper Bound is not equal to the number of variables"), "Symphony"); + error(errmsg); + end + + //Changing the inputs in symphony's format + conMatrix = [A;Aeq] + nbCon = size(conMatrix,1); + conLB = [repmat(-%inf,1,size(A,1)), beq]'; + conUB = [b,beq]' ; + + isInt = repmat(%f,1,nbVar); + for i=1:size(intcon,2) + isInt(intcon(i)) = %t + end + + objSense = 1; + + [xopt,fopt,status,iter] = symphony_call(nbVar,nbCon,objCoef,isInt,lb,ub,conMatrix,conLB,conUB,objSense,options); + +endfunction diff --git a/macros/symphonymat.sci~ b/macros/symphonymat.sci~ new file mode 100644 index 0000000..455dd67 --- /dev/null +++ b/macros/symphonymat.sci~ @@ -0,0 +1,242 @@ +// Copyright (C) 2015 - IIT Bombay - FOSSEE +// +// Author: Harpreet Singh +// Organization: FOSSEE, IIT Bombay +// Email: harpreet.mertia@gmail.com +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + +function [xopt,fopt,status,iter] = symphonymat (varargin) + // Solves a mixed integer linear programming constrained optimization problem in intlinprog format. + // + // Calling Sequence + // xopt = symphonymat(f,intcon,A,b) + // xopt = symphonymat(f,intcon,A,b,Aeq,beq) + // xopt = symphonymat(f,intcon,A,b,Aeq,beq,lb,ub) + // xopt = symphonymat(f,intcon,A,b,Aeq,beq,lb,ub,options) + // [xopt,fopt,status,output] = symphonymat( ... ) + // + // Parameters + // f : a 1xn matrix of doubles, where n is number of variables, contains coefficients of the variables in the objective + // intcon : Vector of integer constraints, specified as a vector of positive integers. The values in intcon indicate the components of the decision variable x that are integer-valued. intcon has values from 1 through number of variable + // A : Linear inequality constraint matrix, specified as a matrix of doubles. A represents the linear coefficients in the constraints A*x ≤ b. A has size M-by-N, where M is the number of constraints and N is number of variables + // b : Linear inequality constraint vector, specified as a vector of doubles. b represents the constant vector in the constraints A*x ≤ b. b has length M, where A is M-by-N + // Aeq : Linear equality constraint matrix, specified as a matrix of doubles. Aeq represents the linear coefficients in the constraints Aeq*x = beq. Aeq has size Meq-by-N, where Meq is the number of constraints and N is number of variables + // beq : Linear equality constraint vector, specified as a vector of doubles. beq represents the constant vector in the constraints Aeq*x = beq. beq has length Meq, where Aeq is Meq-by-N. + // lb : Lower bounds, specified as a vector or array of doubles. lb represents the lower bounds elementwise in lb ≤ x ≤ ub. + // ub : Upper bounds, specified as a vector or array of doubles. ub represents the upper bounds elementwise in lb ≤ x ≤ ub. + // options : a list containing the the parameters to be set. + // xopt : a 1xn matrix of doubles, the computed solution of the optimization problem + // fopt : a 1x1 matrix of doubles, the function value at x + // output : The output data structure contains detailed informations about the optimization process. + // + // Description + // Search the minimum or maximum of a constrained mixed integer linear programming optimization problem specified by : + // find the minimum or maximum of f(x) such that + // + // <latex> + // \begin{eqnarray} + // &\mbox{min}_{x} + // & f(x) \\ + // & \text{subject to} & conLB \leq C(x) \leq conUB \\ + // & & lb \leq x \leq ub \\ + // \end{eqnarray} + // </latex> + // + // We are calling SYMPHONY written in C by gateway files for the actual computation. SYMPHONY was originally written by Ted Ralphs, Menal Guzelsoy and Ashutosh Mahajan. + // + // Examples + // // Objective function + // c = [350*5,330*3,310*4,280*6,500,450,400,100] + // // Lower Bound of variable + // lb = repmat(0,1,8); + // // Upper Bound of variables + // ub = [repmat(1,1,4) repmat(%inf,1,4)]; + // // Constraint Matrix + // Aeq = [5,3,4,6,1,1,1,1; + // 5*0.05,3*0.04,4*0.05,6*0.03,0.08,0.07,0.06,0.03; + // 5*0.03,3*0.03,4*0.04,6*0.04,0.06,0.07,0.08,0.09;] + // beq = [ 25, 1.25, 1.25] + // intcon = [1 2 3 4]; + // // Calling Symphony + // [x,f,status,output] = symphonymat(c,intcon,[],[],Aeq,beq,lb,ub) + // + // Examples + // // An advanced case where we set some options in symphony + // // This problem is taken from + // // P.C.Chu and J.E.Beasley + // // "A genetic algorithm for the multidimensional knapsack problem", + // // Journal of Heuristics, vol. 4, 1998, pp63-86. + // // The problem to be solved is: + // // Max sum{j=1,...,n} p(j)x(j) + // // st sum{j=1,...,n} r(i,j)x(j) <= b(i) i=1,...,m + // // x(j)=0 or 1 + // // The function to be maximize i.e. P(j) + // objCoef = -1*[ 504 803 667 1103 834 585 811 856 690 832 846 813 868 793 .. + // 825 1002 860 615 540 797 616 660 707 866 647 746 1006 608 .. + // 877 900 573 788 484 853 942 630 591 630 640 1169 932 1034 .. + // 957 798 669 625 467 1051 552 717 654 388 559 555 1104 783 .. + // 959 668 507 855 986 831 821 825 868 852 832 828 799 686 .. + // 510 671 575 740 510 675 996 636 826 1022 1140 654 909 799 .. + // 1162 653 814 625 599 476 767 954 906 904 649 873 565 853 1008 632] + // //Constraint Matrix + // conMatrix = [ //Constraint 1 + // 42 41 523 215 819 551 69 193 582 375 367 478 162 898 .. + // 550 553 298 577 493 183 260 224 852 394 958 282 402 604 .. + // 164 308 218 61 273 772 191 117 276 877 415 873 902 465 .. + // 320 870 244 781 86 622 665 155 680 101 665 227 597 354 .. + // 597 79 162 998 849 136 112 751 735 884 71 449 266 420 .. + // 797 945 746 46 44 545 882 72 383 714 987 183 731 301 .. + // 718 91 109 567 708 507 983 808 766 615 554 282 995 946 651 298; + // //Constraint 2 + // 509 883 229 569 706 639 114 727 491 481 681 948 687 941 .. + // 350 253 573 40 124 384 660 951 739 329 146 593 658 816 .. + // 638 717 779 289 430 851 937 289 159 260 930 248 656 833 .. + // 892 60 278 741 297 967 86 249 354 614 836 290 893 857 .. + // 158 869 206 504 799 758 431 580 780 788 583 641 32 653 .. + // 252 709 129 368 440 314 287 854 460 594 512 239 719 751 .. + // 708 670 269 832 137 356 960 651 398 893 407 477 552 805 881 850; + // //Constraint 3 + // 806 361 199 781 596 669 957 358 259 888 319 751 275 177 .. + // 883 749 229 265 282 694 819 77 190 551 140 442 867 283 .. + // 137 359 445 58 440 192 485 744 844 969 50 833 57 877 .. + // 482 732 968 113 486 710 439 747 174 260 877 474 841 422 .. + // 280 684 330 910 791 322 404 403 519 148 948 414 894 147 .. + // 73 297 97 651 380 67 582 973 143 732 624 518 847 113 .. + // 382 97 905 398 859 4 142 110 11 213 398 173 106 331 254 447 ; + // //Constraint 4 + // 404 197 817 1000 44 307 39 659 46 334 448 599 931 776 .. + // 263 980 807 378 278 841 700 210 542 636 388 129 203 110 .. + // 817 502 657 804 662 989 585 645 113 436 610 948 919 115 .. + // 967 13 445 449 740 592 327 167 368 335 179 909 825 614 .. + // 987 350 179 415 821 525 774 283 427 275 659 392 73 896 .. + // 68 982 697 421 246 672 649 731 191 514 983 886 95 846 .. + // 689 206 417 14 735 267 822 977 302 687 118 990 323 993 525 322; + // //Constrain 5 + // 475 36 287 577 45 700 803 654 196 844 657 387 518 143 .. + // 515 335 942 701 332 803 265 922 908 139 995 845 487 100 .. + // 447 653 649 738 424 475 425 926 795 47 136 801 904 740 .. + // 768 460 76 660 500 915 897 25 716 557 72 696 653 933 .. + // 420 582 810 861 758 647 237 631 271 91 75 756 409 440 .. + // 483 336 765 637 981 980 202 35 594 689 602 76 767 693 .. + // 893 160 785 311 417 748 375 362 617 553 474 915 457 261 350 635 ; + // ]; + // nbVar = size(objCoef,2) + // conUB=[11927 13727 11551 13056 13460 ]; + // // Lower Bound of variables + // lb = repmat(0,1,nbVar) + // // Upper Bound of variables + // ub = repmat(1,1,nbVar) + // // Lower Bound of constrains + // intcon = [] + // for i = 1:nbVar + // intcon = [intcon i]; + // end + // options = list("time_limit", 25); + // // The expected solution : + // // Output variables + // xopt = [0 1 1 0 0 1 0 1 0 1 0 0 0 0 0 0 0 1 0 0 0 0 1 0 1 1 0 1 1 0 1 .. + // 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 1 1 .. + // 0 0 1 0 0 1 0 1 0 0 1 0 0 1 0 1 0 0 0 0 0 1 1 0 0 0 0 0 1 1 0 0 1 0 0 1 0] + // // Optimal value + // fopt = [ 24381 ] + // // Calling Symphony + // [x,f,status,output] = symphonymat(objCoef,intcon,conMatrix,conUB,[],[],lb,ub,options); + // + // Authors + // Keyur Joshi, Saikiran, Iswarya, Harpreet Singh + + +//To check the number of input and output argument + [lhs , rhs] = argn(); + +//To check the number of argument given by user + if ( rhs < 4 | rhs == 5 | rhs == 7 | rhs > 9 ) then + errmsg = msprintf(gettext("%s: Unexpected number of input arguments : %d provided while should be in the set [4 6 8 9]"), "Symphony", rhs); + error(errmsg) + end + + + objCoef = varargin(1) + intcon = varargin(2) + A = varargin(3) + b = varargin(4) + + nbVar = size(objCoef,2); + nbCon = size(A,1); + + if ( rhs<4 ) then + Aeq = [] + beq = [] + else + Aeq = varargin(5); + beq = varargin(6); + + if (size(Aeq,1)~=0) then + //Check the size of equality constraint which should equal to the number of inequality constraints + if ( size(Aeq,2) ~= nbVar) then + errmsg = msprintf(gettext("%s: The size of equality constraint is not equal to the number of variables"), "Symphony"); + error(errmsg); + end + + //Check the size of upper bound of inequality constraint which should equal to the number of constraints + if ( size(beq,2) ~= size(Aeq,1)) then + errmsg = msprintf(gettext("%s: The equality constraint upper bound is not equal to the number of equality constraint"), "Symphony"); + error(errmsg); + end + end + + end + + if ( rhs<6 ) then + lb = repmat(-%inf,1,nbVar); + ub = repmat(%inf,1,nbVar); + else + lb = varargin(7); + ub = varargin(8); + end + + if (rhs<8) then + options = list(); + else + options = varargin(9); + end + + +//Check the size of lower bound of inequality constraint which should equal to the number of constraints + if ( size(b,2) ~= size(A,1)) then + errmsg = msprintf(gettext("%s: The Lower Bound of inequality constraint is not equal to the number of constraint"), "Symphony"); + error(errmsg); + end + +//Check the size of Lower Bound which should equal to the number of variables + if ( size(lb,2) ~= nbVar) then + errmsg = msprintf(gettext("%s: The Lower Bound is not equal to the number of variables"), "Symphony"); + error(errmsg); + end + +//Check the size of Upper Bound which should equal to the number of variables + if ( size(ub,2) ~= nbVar) then + errmsg = msprintf(gettext("%s: The Upper Bound is not equal to the number of variables"), "Symphony"); + error(errmsg); + end + + //Changing the inputs in symphony's format + conMatrix = [A;Aeq] + nbCon = size(conMatrix,1); + conLB = [repmat(-%inf,1,size(A,1)), beq]'; + conUB = [b,beq]' ; + + isInt = repmat(%f,1,nbVar); + for i=1:size(intcon,2) + isInt(intcon(i)) = %t + end + + objSense = 1; + + [xopt,fopt,status,iter] = symphony_call(nbVar,nbCon,objCoef,isInt,lb,ub,conMatrix,conLB,conUB,objSense,options); + +endfunction diff --git a/sci_gateway/cpp/README.rst b/sci_gateway/cpp/README.rst new file mode 100644 index 0000000..3348354 --- /dev/null +++ b/sci_gateway/cpp/README.rst @@ -0,0 +1,49 @@ +SCILAB GATEWAY +============== + +It is used to call the native functions written in C to scilab. + +List of Files +============= + +Symphony +-------- + +List of files used for symphony: + +1. globals.cpp +2. sci_solver_status_query_functions.cpp +3. sci_sym_addrowcal.cpp +4. sci_sym_getinfinity.cpp +5. sci_sym_getobjsense.cpp +6. sci_sym_getrowact.cpp +7. sci_sym_isenactive.cpp +8. sci_sym_load_mps.cpp +9. sci_sym_loadproblem.cpp +10. sci_sym_openclose.cpp +11. sci_sym_primalbound.cpp +12. sci_sym_remove.cpp +13. sci_sym_rowmod.cpp +14. sci_sym_setcolsoln.cpp +15. sci_sym_set_indices.cpp +16. sci_sym_setobj.cpp +17. sci_sym_set_variables.cpp +18. sci_sym_solution.cpp +19. sci_sym_solve.cpp +20. sci_sym_varbounds.cpp +21. sci_vartype.cpp +22. sym_data_query_functions.cpp +23. sci_iofunc.cpp +24. sci_iofunc.hpp + +qpipopt +------- + +List of files used for qpipopt: + +1. sci_iofunc.cpp +2. sci_iofunc.hpp +3. QuadNLP.hpp +4. sci_ipopt.cpp +5. sci_QuadNLP.cpp + diff --git a/sci_gateway/cpp/README.rst~ b/sci_gateway/cpp/README.rst~ new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/sci_gateway/cpp/README.rst~ diff --git a/sci_gateway/cpp/builder_gateway_cpp.sce b/sci_gateway/cpp/builder_gateway_cpp.sce index b42ac8e..225edd8 100644 --- a/sci_gateway/cpp/builder_gateway_cpp.sce +++ b/sci_gateway/cpp/builder_gateway_cpp.sce @@ -12,7 +12,7 @@ mode(-1) lines(0) -toolbox_title = "FAMOS" +toolbox_title = "FAMOS"; [a, opt] = getversion(); Version = opt(2); @@ -138,8 +138,8 @@ Files = [ "sci_sym_getrowact.cpp", "sci_sym_getobjsense.cpp", "sci_sym_remove.cpp", - "sci_QuadNLP.cpp" - "QuadNLP.hpp" + "sci_QuadNLP.cpp", + "QuadNLP.hpp", "sci_ipopt.cpp" ] diff --git a/sci_gateway/cpp/builder_gateway_cpp.sce~ b/sci_gateway/cpp/builder_gateway_cpp.sce~ new file mode 100644 index 0000000..225edd8 --- /dev/null +++ b/sci_gateway/cpp/builder_gateway_cpp.sce~ @@ -0,0 +1,149 @@ +// Copyright (C) 2015 - IIT Bombay - FOSSEE +// +// Author: Keyur Joshi, Sai Kiran, Iswarya and Harpreet Singh +// Organization: FOSSEE, IIT Bombay +// Email: harpreet.mertia@gmail.com +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + +mode(-1) +lines(0) + +toolbox_title = "FAMOS"; + +[a, opt] = getversion(); +Version = opt(2); + +path_builder = get_absolute_file_path('builder_gateway_cpp.sce'); + +tools_path = path_builder + "../../thirdparty/linux/"; + +C_Flags=["-w -fpermissive -I"+tools_path+"include/coin -Wl,-rpath="+tools_path+"lib/"+Version+filesep()+" "] + +Linker_Flag = ["-L"+tools_path+"lib/"+Version+filesep()+"libSym"+" "+"-L"+tools_path+"lib/"+Version+filesep()+"libipopt" ] + + +//Name of All the Functions +Function_Names = [ + //for opening/closing environment and checking if it is open/close + "sym_open","sci_sym_open"; + "sym_close","sci_sym_close"; + "sym_isEnvActive","sci_sym_isEnvActive"; + + //run time parameters + "sym_resetParams","sci_sym_set_defaults"; + "sym_setIntParam","sci_sym_set_int_param"; + "sym_getIntParam","sci_sym_get_int_param"; + "sym_setDblParam","sci_sym_set_dbl_param"; + "sym_getDblParam","sci_sym_get_dbl_param"; + "sym_setStrParam","sci_sym_set_str_param"; + "sym_getStrParam","sci_sym_get_str_param"; + "sym_getInfinity","sci_sym_getInfinity"; + + //problem loaders + "sym_loadProblemBasic","sci_sym_loadProblemBasic"; + "sym_loadProblem","sci_sym_loadProblem"; + "sym_loadMPS","sci_sym_load_mps"; + + //basic data + "sym_getNumConstr","sci_sym_get_num_int"; + "sym_getNumVar","sci_sym_get_num_int"; + "sym_getNumElements","sci_sym_get_num_int"; + + //variable and objective data + "sym_isContinuous","sci_sym_isContinuous"; + "sym_isBinary","sci_sym_isBinary"; + "sym_isInteger","sci_sym_isInteger"; + "sym_setContinuous","sci_sym_set_continuous"; + "sym_setInteger","sci_sym_set_integer"; + "sym_getVarLower","sci_sym_get_dbl_arr"; + "sym_getVarUpper","sci_sym_get_dbl_arr"; + "sym_setVarLower","sci_sym_setVarBound"; + "sym_setVarUpper","sci_sym_setVarBound"; + "sym_getObjCoeff","sci_sym_get_dbl_arr"; + "sym_setObjCoeff","sci_sym_setObjCoeff"; + "sym_getObjSense","sci_sym_getObjSense"; + "sym_setObjSense","sci_sym_setObjSense"; + + //constraint data + "sym_getRhs","sci_sym_get_dbl_arr"; + "sym_getConstrRange","sci_sym_get_dbl_arr"; + "sym_getConstrLower","sci_sym_get_dbl_arr"; + "sym_getConstrUpper","sci_sym_get_dbl_arr"; + "sym_setConstrLower","sci_sym_setConstrBound"; + "sym_setConstrUpper","sci_sym_setConstrBound"; + "sym_setConstrType","sci_sym_setConstrType"; + "sym_getMatrix","sci_sym_get_matrix"; + "sym_getConstrSense","sci_sym_get_row_sense"; + + //add/remove variables and constraints + "sym_addConstr","sci_sym_addConstr"; + "sym_addVar","sci_sym_addVar"; + "sym_deleteVars","sci_sym_delete_cols"; + "sym_deleteConstrs","sci_sym_delete_rows"; + + //primal bound + "sym_getPrimalBound","sci_sym_getPrimalBound"; + "sym_setPrimalBound","sci_sym_setPrimalBound"; + + //set preliminary solution + "sym_setVarSoln","sci_sym_setColSoln"; + + //solve + "sym_solve","sci_sym_solve"; + + //post solve functions + "sym_getStatus","sci_sym_get_status"; + "sym_isOptimal","sci_sym_get_solver_status"; + "sym_isInfeasible","sci_sym_get_solver_status"; + "sym_isAbandoned","sci_sym_get_solver_status"; + "sym_isIterLimitReached","sci_sym_get_solver_status"; + "sym_isTimeLimitReached","sci_sym_get_solver_status"; + "sym_isTargetGapAchieved","sci_sym_get_solver_status"; + "sym_getVarSoln","sci_sym_getVarSoln"; + "sym_getObjVal","sci_sym_getObjVal"; + "sym_getIterCount","sci_sym_get_iteration_count"; + "sym_getConstrActivity","sci_sym_getRowActivity"; + + //QP function + "solveqp","sci_solveqp" + ]; + +//Name of all the files to be compiled +Files = [ + "globals.cpp", + "sci_iofunc.hpp", + "sci_iofunc.cpp", + "sci_sym_openclose.cpp", + "sci_solver_status_query_functions.cpp", + "sci_sym_solve.cpp", + "sci_sym_loadproblem.cpp", + "sci_sym_isenvactive.cpp", + "sci_sym_load_mps.cpp", + "sci_vartype.cpp", + "sci_sym_getinfinity.cpp", + "sci_sym_solution.cpp", + "sym_data_query_functions.cpp" + "sci_sym_set_variables.cpp", + "sci_sym_setobj.cpp", + "sci_sym_varbounds.cpp", + "sci_sym_rowmod.cpp", + "sci_sym_set_indices.cpp", + "sci_sym_addrowcol.cpp", + "sci_sym_primalbound.cpp", + "sci_sym_setcolsoln.cpp", + "sci_sym_getrowact.cpp", + "sci_sym_getobjsense.cpp", + "sci_sym_remove.cpp", + "sci_QuadNLP.cpp", + "QuadNLP.hpp", + "sci_ipopt.cpp" + + ] + +tbx_build_gateway(toolbox_title,Function_Names,Files,get_absolute_file_path("builder_gateway_cpp.sce"), [], Linker_Flag, C_Flags, [], "g++"); + +clear WITHOUT_AUTO_PUTLHSVAR toolbox_title Function_Names Files Linker_Flag C_Flags; diff --git a/sci_gateway/cpp/libFAMOS.so b/sci_gateway/cpp/libFAMOS.so Binary files differindex d3b1e35..4a210ee 100755 --- a/sci_gateway/cpp/libFAMOS.so +++ b/sci_gateway/cpp/libFAMOS.so diff --git a/sci_gateway/cpp/sci_iofunc.cpp b/sci_gateway/cpp/sci_iofunc.cpp index 8895010..e1c8610 100644 --- a/sci_gateway/cpp/sci_iofunc.cpp +++ b/sci_gateway/cpp/sci_iofunc.cpp @@ -173,7 +173,7 @@ int return0toScilab() //make it the output variable AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx)+1; //return it to scilab - ReturnArguments(pvApiCtx); + //ReturnArguments(pvApiCtx); return 0; } @@ -189,6 +189,6 @@ int returnDoubleToScilab(double retVal) return 1; } AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx)+1; - ReturnArguments(pvApiCtx); + //ReturnArguments(pvApiCtx); return 0; } diff --git a/sci_gateway/cpp/sci_ipopt.cpp b/sci_gateway/cpp/sci_ipopt.cpp index 5837df1..4168488 100644 --- a/sci_gateway/cpp/sci_ipopt.cpp +++ b/sci_gateway/cpp/sci_ipopt.cpp @@ -4,6 +4,7 @@ Sai Kiran Keyur Joshi Iswarya + Harpreet Singh */ @@ -51,13 +52,14 @@ bool readSparse(int arg,int *iRows,int *iCols,int *iNbItem,int** piNbItemRow, in int sci_solveqp(char *fname) { - CheckInputArgument(pvApiCtx, 10, 10); // We need total 10 input arguments. + CheckInputArgument(pvApiCtx, 11, 11); // We need total 10 input arguments. CheckOutputArgument(pvApiCtx, 7, 7); // Error management variable SciErr sciErr; - int retVal=0, *piAddressVarQ = NULL,*piAddressVarP = NULL,*piAddressVarCM = NULL,*piAddressVarCUB = NULL,*piAddressVarCLB = NULL, *piAddressVarLB = NULL,*piAddressVarUB = NULL,*piAddressVarG = NULL; - double *QItems=NULL,*PItems=NULL,*ConItems=NULL,*conUB=NULL,*conLB=NULL,*varUB=NULL,*varLB=NULL,*init_guess = NULL,x,f,iter; + int retVal=0, *piAddressVarQ = NULL,*piAddressVarP = NULL,*piAddressVarCM = NULL,*piAddressVarCUB = NULL,*piAddressVarCLB = NULL, *piAddressVarLB = NULL,*piAddressVarUB = NULL,*piAddressVarG = NULL,*piAddressVarParam = NULL; + double *QItems=NULL,*PItems=NULL,*ConItems=NULL,*conUB=NULL,*conLB=NULL,*varUB=NULL,*varLB=NULL,*init_guess = NULL; + double *cpu_time=NULL, *max_iter=NULL, x,f,iter; static unsigned int nVars = 0,nCons = 0; unsigned int temp1 = 0,temp2 = 0; @@ -294,6 +296,34 @@ int sci_solveqp(char *fname) return 0; } + //Setting the parameters + /* get Address of inputs */ + sciErr = getVarAddressFromPosition(pvApiCtx, 11, &piAddressVarParam); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return 0; + } + + temp1 = 1; + temp2 = 1; + + /* get matrix */ + sciErr = getMatrixOfDoubleInList(pvApiCtx, piAddressVarParam, 2, &temp1,&temp2, &max_iter); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return 0; + } + + /* get matrix */ + sciErr = getMatrixOfDoubleInList(pvApiCtx, piAddressVarParam, 4, &temp1,&temp2, &cpu_time); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return 0; + } + using namespace Ipopt; SmartPtr<QuadNLP> Prob = new QuadNLP(nVars,nCons,QItems,PItems,ConItems,conUB,conLB,varUB,varLB,init_guess); @@ -304,6 +334,8 @@ int sci_solveqp(char *fname) // Note: The following choices are only examples, they might not be // suitable for your optimization problem. app->Options()->SetNumericValue("tol", 1e-7); + app->Options()->SetIntegerValue("max_iter", (int)*max_iter); + app->Options()->SetNumericValue("max_cpu_time", *cpu_time); app->Options()->SetStringValue("mu_strategy", "adaptive"); // Indicates whether all equality constraints are linear diff --git a/sci_gateway/cpp/sci_sym_getrowact.cpp b/sci_gateway/cpp/sci_sym_getrowact.cpp index fac3ddf..ebfd9ff 100644 --- a/sci_gateway/cpp/sci_sym_getrowact.cpp +++ b/sci_gateway/cpp/sci_sym_getrowact.cpp @@ -58,7 +58,7 @@ int sci_sym_getRowActivity(char *fname){ return 1; } AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx)+1; - ReturnArguments(pvApiCtx); + //ReturnArguments(pvApiCtx); delete[] rowAct; diff --git a/sci_gateway/cpp/sci_sym_loadproblem.cpp b/sci_gateway/cpp/sci_sym_loadproblem.cpp index 6d7f538..b732eeb 100644 --- a/sci_gateway/cpp/sci_sym_loadproblem.cpp +++ b/sci_gateway/cpp/sci_sym_loadproblem.cpp @@ -42,7 +42,7 @@ static void cleanupBeforeExit() return; } AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx)+1; - ReturnArguments(pvApiCtx); + //ReturnArguments(pvApiCtx); } static int checkNumArgs() diff --git a/sci_gateway/cpp/sci_sym_remove.cpp b/sci_gateway/cpp/sci_sym_remove.cpp index d4e9c49..be9c72b 100644 --- a/sci_gateway/cpp/sci_sym_remove.cpp +++ b/sci_gateway/cpp/sci_sym_remove.cpp @@ -126,7 +126,7 @@ int sci_sym_delete_cols(char *fname, unsigned long fname_len){ } AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1; - ReturnArguments(pvApiCtx); + //ReturnArguments(pvApiCtx); free(value);//freeing the memory of the allocated pointer return 0; } @@ -242,7 +242,7 @@ int sci_sym_delete_rows(char *fname, unsigned long fname_len){ } AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1; - ReturnArguments(pvApiCtx); + //ReturnArguments(pvApiCtx); free(value);//freeing the memory of the allocated pointer return 0; } diff --git a/sci_gateway/cpp/sci_sym_set_variables.cpp b/sci_gateway/cpp/sci_sym_set_variables.cpp index 327bf84..384de6f 100644 --- a/sci_gateway/cpp/sci_sym_set_variables.cpp +++ b/sci_gateway/cpp/sci_sym_set_variables.cpp @@ -50,7 +50,7 @@ int sci_sym_set_defaults(char *fname, unsigned long fname_len){ } AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1; - ReturnArguments(pvApiCtx); + //ReturnArguments(pvApiCtx); return 0; } @@ -123,7 +123,7 @@ int sci_sym_set_int_param(char *fname, unsigned long fname_len){ } AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1; - ReturnArguments(pvApiCtx); + //ReturnArguments(pvApiCtx); return 0; } @@ -181,7 +181,7 @@ int sci_sym_get_int_param(char *fname, unsigned long fname_len){ } AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1; - ReturnArguments(pvApiCtx); + //ReturnArguments(pvApiCtx); return 0; } @@ -243,7 +243,7 @@ int sci_sym_set_dbl_param(char *fname, unsigned long fname_len){ } AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1; - ReturnArguments(pvApiCtx); + //ReturnArguments(pvApiCtx); return 0; } @@ -302,7 +302,7 @@ int sci_sym_get_dbl_param(char *fname, unsigned long fname_len){ } AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1; - ReturnArguments(pvApiCtx); + //ReturnArguments(pvApiCtx); return 0; } @@ -363,7 +363,7 @@ int sci_sym_set_str_param(char *fname, unsigned long fname_len){ } AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1; - ReturnArguments(pvApiCtx); + //ReturnArguments(pvApiCtx); return 0; } @@ -421,7 +421,7 @@ int sci_sym_get_str_param(char *fname, unsigned long fname_len){ } AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1; - ReturnArguments(pvApiCtx); + //ReturnArguments(pvApiCtx); return 0; } diff --git a/sci_gateway/cpp/sci_sym_solution.cpp b/sci_gateway/cpp/sci_sym_solution.cpp index a08e5b9..dff3b60 100644 --- a/sci_gateway/cpp/sci_sym_solution.cpp +++ b/sci_gateway/cpp/sci_sym_solution.cpp @@ -58,7 +58,7 @@ int sci_sym_getVarSoln(char *fname){ return 1; } AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx)+1; - ReturnArguments(pvApiCtx); + //ReturnArguments(pvApiCtx); delete[] solution; diff --git a/sci_gateway/cpp/sci_sym_solve.cpp~ b/sci_gateway/cpp/sci_sym_solve.cpp~ new file mode 100644 index 0000000..4abb268 --- /dev/null +++ b/sci_gateway/cpp/sci_sym_solve.cpp~ @@ -0,0 +1,49 @@ +/* + * Implementation Symphony Tool Box for Scilab + * Contains sym_solve function + * Author : Sai Kiran + */ + +#include <symphony.h> +#include <sci_iofunc.hpp> +extern sym_environment* global_sym_env;//defined in globals.cpp + +extern "C" { +#include <api_scilab.h> +#include <Scierror.h> +#include <BOOL.h> +#include <localization.h> +#include <sciprint.h> +#include <stdio.h> +int process_ret_val(int); + +int sci_sym_solve(char *fname, unsigned long fname_len){ + + int status=0; + + //check whether we have no input and one output argument or not + CheckInputArgument(pvApiCtx, 0, 0) ;//no input argument + CheckOutputArgument(pvApiCtx, 1, 1) ;//one output argument + + // Check environment + if(global_sym_env==NULL) + sciprint("Error: Symphony environment is not initialized.\n"); + else {// There is an environment opened + double time_limit = -1.0; + status = sym_get_dbl_param(global_sym_env,"time_limit",&time_limit); + + if (status == FUNCTION_TERMINATED_NORMALLY) { + if ( time_limit < 0.0 ) + sciprint("\nNote: There is no limit on time.\n"); + else sciprint("\nNote: Time limit has been set to %lf.\n",time_limit); + status=process_ret_val(sym_solve(global_sym_env));// Call function + } + else { + sciprint("\nUnable to read time limit.\n"); + status = 1; //Error state + } + } + // Return result to scilab + return returnDoubleToScilab(status); + } +} diff --git a/sci_gateway/cpp/sym_data_query_functions.cpp b/sci_gateway/cpp/sym_data_query_functions.cpp index b0d0989..9f38094 100644 --- a/sci_gateway/cpp/sym_data_query_functions.cpp +++ b/sci_gateway/cpp/sym_data_query_functions.cpp @@ -162,7 +162,7 @@ int sci_sym_get_dbl_arr(char *fname, unsigned long fname_len){ //assign result position to output argument AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1; - ReturnArguments(pvApiCtx); + //ReturnArguments(pvApiCtx); return 0; } @@ -230,7 +230,7 @@ int sci_sym_get_row_sense(char *fname, unsigned long fname_len) { //assign result position to output argument AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1; - ReturnArguments(pvApiCtx); + //ReturnArguments(pvApiCtx); return 0; } @@ -339,7 +339,7 @@ int sci_sym_get_matrix(char *fname, unsigned long fname_len){ //assign result position to output argument AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1; - ReturnArguments(pvApiCtx); + //ReturnArguments(pvApiCtx); return 0; } diff --git a/tests/unit_tests/README.rst b/tests/unit_tests/README.rst new file mode 100644 index 0000000..266e05c --- /dev/null +++ b/tests/unit_tests/README.rst @@ -0,0 +1,4 @@ +UNIT TESTS +========== + +These are test files for qpipopt, qpipoptmat, symphony and symphonymat. Generated by examples from demo files. diff --git a/tests/unit_tests/README.rst~ b/tests/unit_tests/README.rst~ new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/unit_tests/README.rst~ diff --git a/tests/unit_tests/qpipopt_base.dia.ref b/tests/unit_tests/qpipopt_base.dia.ref new file mode 100644 index 0000000..ffe546a --- /dev/null +++ b/tests/unit_tests/qpipopt_base.dia.ref @@ -0,0 +1,76 @@ +// Copyright (C) 2015 - IIT Bombay - FOSSEE +// +// Author: Harpreet Singh +// Organization: FOSSEE, IIT Bombay +// Email: harpreet.mertia@gmail.com +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + +// <-- JVM NOT MANDATORY --> +// <-- ENGLISH IMPOSED --> + + +// +// assert_close -- +// Returns 1 if the two real matrices computed and expected are close, +// i.e. if the relative distance between computed and expected is lesser than epsilon. +// Arguments +// computed, expected : the two matrices to compare +// epsilon : a small number +// +function flag = assert_close ( computed, expected, epsilon ) + if expected==0.0 then + shift = norm(computed-expected); + else + shift = norm(computed-expected)/norm(expected); + end +// if shift < epsilon then +// flag = 1; +// else +// flag = 0; +// end +// if flag <> 1 then pause,end + flag = assert_checktrue ( shift < epsilon ); +endfunction +// +// assert_equal -- +// Returns 1 if the two real matrices computed and expected are equal. +// Arguments +// computed, expected : the two matrices to compare +// epsilon : a small number +// +//function flag = assert_equal ( computed , expected ) +// if computed==expected then +// flag = 1; +// else +// flag = 0; +// end +// if flag <> 1 then pause,end +//endfunction + +//Find the value of x that minimize following function +// f(x) = 0.5*x1^2 + x2^2 - x1*x2 - 2*x1 - 6*x2 +// Subject to: +// x1 + x2 ≤ 2 +// –x1 + 2x2 ≤ 2 +// 2x1 + x2 ≤ 3 +// 0 ≤ x1, 0 ≤ x2. +Q = [1 -1; -1 2]; +p = [-2; -6]; +conMatrix = [1 1; -1 2; 2 1]; +conUB = [2; 2; 3]; +conLB = [-%inf; -%inf; -%inf]; +lb = [0; 0]; +ub = [%inf; %inf]; +nbVar = 2; +nbCon = 3; +[xopt,fopt,exitflag,output,lambda] = qpipopt(nbVar,nbCon,Q,p,lb,ub,conMatrix,conLB,conUB) + +assert_close ( x , [0.6666667 1.3333333]' , 1.e-7 ); +assert_close ( f , [ - 8.2222223] , 1.e-7 ); + +assert_checkequal( exitflag , 0 ); diff --git a/tests/unit_tests/qpipopt_base.tst b/tests/unit_tests/qpipopt_base.tst new file mode 100644 index 0000000..ffe546a --- /dev/null +++ b/tests/unit_tests/qpipopt_base.tst @@ -0,0 +1,76 @@ +// Copyright (C) 2015 - IIT Bombay - FOSSEE +// +// Author: Harpreet Singh +// Organization: FOSSEE, IIT Bombay +// Email: harpreet.mertia@gmail.com +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + +// <-- JVM NOT MANDATORY --> +// <-- ENGLISH IMPOSED --> + + +// +// assert_close -- +// Returns 1 if the two real matrices computed and expected are close, +// i.e. if the relative distance between computed and expected is lesser than epsilon. +// Arguments +// computed, expected : the two matrices to compare +// epsilon : a small number +// +function flag = assert_close ( computed, expected, epsilon ) + if expected==0.0 then + shift = norm(computed-expected); + else + shift = norm(computed-expected)/norm(expected); + end +// if shift < epsilon then +// flag = 1; +// else +// flag = 0; +// end +// if flag <> 1 then pause,end + flag = assert_checktrue ( shift < epsilon ); +endfunction +// +// assert_equal -- +// Returns 1 if the two real matrices computed and expected are equal. +// Arguments +// computed, expected : the two matrices to compare +// epsilon : a small number +// +//function flag = assert_equal ( computed , expected ) +// if computed==expected then +// flag = 1; +// else +// flag = 0; +// end +// if flag <> 1 then pause,end +//endfunction + +//Find the value of x that minimize following function +// f(x) = 0.5*x1^2 + x2^2 - x1*x2 - 2*x1 - 6*x2 +// Subject to: +// x1 + x2 ≤ 2 +// –x1 + 2x2 ≤ 2 +// 2x1 + x2 ≤ 3 +// 0 ≤ x1, 0 ≤ x2. +Q = [1 -1; -1 2]; +p = [-2; -6]; +conMatrix = [1 1; -1 2; 2 1]; +conUB = [2; 2; 3]; +conLB = [-%inf; -%inf; -%inf]; +lb = [0; 0]; +ub = [%inf; %inf]; +nbVar = 2; +nbCon = 3; +[xopt,fopt,exitflag,output,lambda] = qpipopt(nbVar,nbCon,Q,p,lb,ub,conMatrix,conLB,conUB) + +assert_close ( x , [0.6666667 1.3333333]' , 1.e-7 ); +assert_close ( f , [ - 8.2222223] , 1.e-7 ); + +assert_checkequal( exitflag , 0 ); diff --git a/tests/unit_tests/qpipopt_base.tst~ b/tests/unit_tests/qpipopt_base.tst~ new file mode 100644 index 0000000..9de0d6b --- /dev/null +++ b/tests/unit_tests/qpipopt_base.tst~ @@ -0,0 +1,76 @@ +// Copyright (C) 2015 - IIT Bombay - FOSSEE +// +// Author: Harpreet Singh +// Organization: FOSSEE, IIT Bombay +// Email: harpreet.mertia@gmail.com +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + +// <-- JVM NOT MANDATORY --> +// <-- ENGLISH IMPOSED --> + + +// +// assert_close -- +// Returns 1 if the two real matrices computed and expected are close, +// i.e. if the relative distance between computed and expected is lesser than epsilon. +// Arguments +// computed, expected : the two matrices to compare +// epsilon : a small number +// +function flag = assert_close ( computed, expected, epsilon ) + if expected==0.0 then + shift = norm(computed-expected); + else + shift = norm(computed-expected)/norm(expected); + end +// if shift < epsilon then +// flag = 1; +// else +// flag = 0; +// end +// if flag <> 1 then pause,end + flag = assert_checktrue ( shift < epsilon ); +endfunction +// +// assert_equal -- +// Returns 1 if the two real matrices computed and expected are equal. +// Arguments +// computed, expected : the two matrices to compare +// epsilon : a small number +// +//function flag = assert_equal ( computed , expected ) +// if computed==expected then +// flag = 1; +// else +// flag = 0; +// end +// if flag <> 1 then pause,end +//endfunction + +///Find the value of x that minimize following function +// f(x) = 0.5*x1^2 + x2^2 - x1*x2 - 2*x1 - 6*x2 +// Subject to: +// x1 + x2 ≤ 2 +// –x1 + 2x2 ≤ 2 +// 2x1 + x2 ≤ 3 +// 0 ≤ x1, 0 ≤ x2. +Q = [1 -1; -1 2]; +p = [-2; -6]; +conMatrix = [1 1; -1 2; 2 1]; +conUB = [2; 2; 3]; +conLB = [-%inf; -%inf; -%inf]; +lb = [0; 0]; +ub = [%inf; %inf]; +nbVar = 2; +nbCon = 3; +[xopt,fopt,exitflag,output,lambda] = qpipopt(nbVar,nbCon,Q,p,lb,ub,conMatrix,conLB,conUB) + +assert_close ( x , [0.6666667 1.3333333]' , 1.e-7 ); +assert_close ( f , [ - 8.2222223] , 1.e-7 ); + +assert_checkequal( exitflag , 0 ); diff --git a/tests/unit_tests/qpipoptmat_base .dia.ref b/tests/unit_tests/qpipoptmat_base .dia.ref new file mode 100644 index 0000000..aacbc4e --- /dev/null +++ b/tests/unit_tests/qpipoptmat_base .dia.ref @@ -0,0 +1,73 @@ +// Copyright (C) 2015 - IIT Bombay - FOSSEE +// +// Author: Harpreet Singh +// Organization: FOSSEE, IIT Bombay +// Email: harpreet.mertia@gmail.com +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + +// <-- JVM NOT MANDATORY --> +// <-- ENGLISH IMPOSED --> + + +// +// assert_close -- +// Returns 1 if the two real matrices computed and expected are close, +// i.e. if the relative distance between computed and expected is lesser than epsilon. +// Arguments +// computed, expected : the two matrices to compare +// epsilon : a small number +// +function flag = assert_close ( computed, expected, epsilon ) + if expected==0.0 then + shift = norm(computed-expected); + else + shift = norm(computed-expected)/norm(expected); + end +// if shift < epsilon then +// flag = 1; +// else +// flag = 0; +// end +// if flag <> 1 then pause,end + flag = assert_checktrue ( shift < epsilon ); +endfunction +// +// assert_equal -- +// Returns 1 if the two real matrices computed and expected are equal. +// Arguments +// computed, expected : the two matrices to compare +// epsilon : a small number +// +//function flag = assert_equal ( computed , expected ) +// if computed==expected then +// flag = 1; +// else +// flag = 0; +// end +// if flag <> 1 then pause,end +//endfunction + +//Find the value of x that minimize following function +// f(x) = 0.5*x1^2 + x2^2 - x1*x2 - 2*x1 - 6*x2 +// Subject to: +// x1 + x2 ≤ 2 +// –x1 + 2x2 ≤ 2 +// 2x1 + x2 ≤ 3 +// 0 ≤ x1, 0 ≤ x2. +H = [1 -1; -1 2]; +f = [-2; -6]; +A = [1 1; -1 2; 2 1]; +b = [2; 2; 3]; +lb = [0; 0]; +ub = [%inf; %inf]; +[xopt,fopt,exitflag,output,lambda] = qpipoptmat(H,f,A,b,[],[],lb,ub) + +assert_close ( x , [0.6666667 1.3333333]' , 1.e-7 ); +assert_close ( f , [ - 8.2222223] , 1.e-7 ); + +assert_checkequal( exitflag , 0 ); diff --git a/tests/unit_tests/qpipoptmat_base .tst b/tests/unit_tests/qpipoptmat_base .tst new file mode 100644 index 0000000..aacbc4e --- /dev/null +++ b/tests/unit_tests/qpipoptmat_base .tst @@ -0,0 +1,73 @@ +// Copyright (C) 2015 - IIT Bombay - FOSSEE +// +// Author: Harpreet Singh +// Organization: FOSSEE, IIT Bombay +// Email: harpreet.mertia@gmail.com +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + +// <-- JVM NOT MANDATORY --> +// <-- ENGLISH IMPOSED --> + + +// +// assert_close -- +// Returns 1 if the two real matrices computed and expected are close, +// i.e. if the relative distance between computed and expected is lesser than epsilon. +// Arguments +// computed, expected : the two matrices to compare +// epsilon : a small number +// +function flag = assert_close ( computed, expected, epsilon ) + if expected==0.0 then + shift = norm(computed-expected); + else + shift = norm(computed-expected)/norm(expected); + end +// if shift < epsilon then +// flag = 1; +// else +// flag = 0; +// end +// if flag <> 1 then pause,end + flag = assert_checktrue ( shift < epsilon ); +endfunction +// +// assert_equal -- +// Returns 1 if the two real matrices computed and expected are equal. +// Arguments +// computed, expected : the two matrices to compare +// epsilon : a small number +// +//function flag = assert_equal ( computed , expected ) +// if computed==expected then +// flag = 1; +// else +// flag = 0; +// end +// if flag <> 1 then pause,end +//endfunction + +//Find the value of x that minimize following function +// f(x) = 0.5*x1^2 + x2^2 - x1*x2 - 2*x1 - 6*x2 +// Subject to: +// x1 + x2 ≤ 2 +// –x1 + 2x2 ≤ 2 +// 2x1 + x2 ≤ 3 +// 0 ≤ x1, 0 ≤ x2. +H = [1 -1; -1 2]; +f = [-2; -6]; +A = [1 1; -1 2; 2 1]; +b = [2; 2; 3]; +lb = [0; 0]; +ub = [%inf; %inf]; +[xopt,fopt,exitflag,output,lambda] = qpipoptmat(H,f,A,b,[],[],lb,ub) + +assert_close ( x , [0.6666667 1.3333333]' , 1.e-7 ); +assert_close ( f , [ - 8.2222223] , 1.e-7 ); + +assert_checkequal( exitflag , 0 ); diff --git a/tests/unit_tests/qpipoptmat_base .tst~ b/tests/unit_tests/qpipoptmat_base .tst~ new file mode 100644 index 0000000..9de0d6b --- /dev/null +++ b/tests/unit_tests/qpipoptmat_base .tst~ @@ -0,0 +1,76 @@ +// Copyright (C) 2015 - IIT Bombay - FOSSEE +// +// Author: Harpreet Singh +// Organization: FOSSEE, IIT Bombay +// Email: harpreet.mertia@gmail.com +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + +// <-- JVM NOT MANDATORY --> +// <-- ENGLISH IMPOSED --> + + +// +// assert_close -- +// Returns 1 if the two real matrices computed and expected are close, +// i.e. if the relative distance between computed and expected is lesser than epsilon. +// Arguments +// computed, expected : the two matrices to compare +// epsilon : a small number +// +function flag = assert_close ( computed, expected, epsilon ) + if expected==0.0 then + shift = norm(computed-expected); + else + shift = norm(computed-expected)/norm(expected); + end +// if shift < epsilon then +// flag = 1; +// else +// flag = 0; +// end +// if flag <> 1 then pause,end + flag = assert_checktrue ( shift < epsilon ); +endfunction +// +// assert_equal -- +// Returns 1 if the two real matrices computed and expected are equal. +// Arguments +// computed, expected : the two matrices to compare +// epsilon : a small number +// +//function flag = assert_equal ( computed , expected ) +// if computed==expected then +// flag = 1; +// else +// flag = 0; +// end +// if flag <> 1 then pause,end +//endfunction + +///Find the value of x that minimize following function +// f(x) = 0.5*x1^2 + x2^2 - x1*x2 - 2*x1 - 6*x2 +// Subject to: +// x1 + x2 ≤ 2 +// –x1 + 2x2 ≤ 2 +// 2x1 + x2 ≤ 3 +// 0 ≤ x1, 0 ≤ x2. +Q = [1 -1; -1 2]; +p = [-2; -6]; +conMatrix = [1 1; -1 2; 2 1]; +conUB = [2; 2; 3]; +conLB = [-%inf; -%inf; -%inf]; +lb = [0; 0]; +ub = [%inf; %inf]; +nbVar = 2; +nbCon = 3; +[xopt,fopt,exitflag,output,lambda] = qpipopt(nbVar,nbCon,Q,p,lb,ub,conMatrix,conLB,conUB) + +assert_close ( x , [0.6666667 1.3333333]' , 1.e-7 ); +assert_close ( f , [ - 8.2222223] , 1.e-7 ); + +assert_checkequal( exitflag , 0 ); diff --git a/thirdparty/linux/README.rst b/thirdparty/linux/README.rst new file mode 100644 index 0000000..bddf213 --- /dev/null +++ b/thirdparty/linux/README.rst @@ -0,0 +1,4 @@ +THIRD PARTY LINUX +================= + +Third party C libraries of symphony and IPOpt. Installed in Ubuntu 64 and 32 bit. diff --git a/thirdparty/linux/README.rst~ b/thirdparty/linux/README.rst~ new file mode 100644 index 0000000..280ed22 --- /dev/null +++ b/thirdparty/linux/README.rst~ @@ -0,0 +1,4 @@ +THIRD PARTY LINUX +================= + + diff --git a/thirdparty/linux/lib/x86/libcoinblas.la b/thirdparty/linux/lib/x86/libcoinblas.la new file mode 100755 index 0000000..9386e57 --- /dev/null +++ b/thirdparty/linux/lib/x86/libcoinblas.la @@ -0,0 +1,35 @@ +# libcoinblas.la - a libtool library file +# Generated by ltmain.sh - GNU libtool 1.5.22 (1.1220.2.365 2005/12/18 22:14:06) +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# The name that we can dlopen(3). +dlname='libcoinblas.so.1' + +# Names of this library. +library_names='libcoinblas.so.1.4.4 libcoinblas.so.1 libcoinblas.so' + +# The name of the static archive. +old_library='' + +# Libraries that this one depends upon. +dependency_libs='' + +# Version information for libcoinblas. +current=5 +age=4 +revision=4 + +# Is this an already installed library? +installed=yes + +# Should we warn about portability when linking against -modules? +shouldnotlink=no + +# Files to dlopen/dlpreopen +dlopen='' +dlpreopen='' + +# Directory that this library needs to be installed in: +libdir='/home/mushirahmed/Desktop/Ipopt-3.12.4/build32_ipopt/lib' diff --git a/thirdparty/linux/lib/x86/libcoinblas.so b/thirdparty/linux/lib/x86/libcoinblas.so new file mode 120000 index 0000000..ddd18ab --- /dev/null +++ b/thirdparty/linux/lib/x86/libcoinblas.so @@ -0,0 +1 @@ +libcoinblas.so.1.4.4
\ No newline at end of file diff --git a/thirdparty/linux/lib/x86/libcoinblas.so.1 b/thirdparty/linux/lib/x86/libcoinblas.so.1 new file mode 120000 index 0000000..ddd18ab --- /dev/null +++ b/thirdparty/linux/lib/x86/libcoinblas.so.1 @@ -0,0 +1 @@ +libcoinblas.so.1.4.4
\ No newline at end of file diff --git a/thirdparty/linux/lib/x86/libcoinblas.so.1.4.4 b/thirdparty/linux/lib/x86/libcoinblas.so.1.4.4 Binary files differnew file mode 100755 index 0000000..a1a56f6 --- /dev/null +++ b/thirdparty/linux/lib/x86/libcoinblas.so.1.4.4 diff --git a/thirdparty/linux/lib/x86/libcoinlapack.la b/thirdparty/linux/lib/x86/libcoinlapack.la new file mode 100755 index 0000000..8c9b979 --- /dev/null +++ b/thirdparty/linux/lib/x86/libcoinlapack.la @@ -0,0 +1,35 @@ +# libcoinlapack.la - a libtool library file +# Generated by ltmain.sh - GNU libtool 1.5.22 (1.1220.2.365 2005/12/18 22:14:06) +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# The name that we can dlopen(3). +dlname='libcoinlapack.so.1' + +# Names of this library. +library_names='libcoinlapack.so.1.5.4 libcoinlapack.so.1 libcoinlapack.so' + +# The name of the static archive. +old_library='' + +# Libraries that this one depends upon. +dependency_libs=' -lblas' + +# Version information for libcoinlapack. +current=6 +age=5 +revision=4 + +# Is this an already installed library? +installed=yes + +# Should we warn about portability when linking against -modules? +shouldnotlink=no + +# Files to dlopen/dlpreopen +dlopen='' +dlpreopen='' + +# Directory that this library needs to be installed in: +libdir='/home/mushirahmed/Desktop/Ipopt-3.12.4/build32_ipopt/lib' diff --git a/thirdparty/linux/lib/x86/libcoinlapack.so b/thirdparty/linux/lib/x86/libcoinlapack.so new file mode 120000 index 0000000..68af160 --- /dev/null +++ b/thirdparty/linux/lib/x86/libcoinlapack.so @@ -0,0 +1 @@ +libcoinlapack.so.1.5.4
\ No newline at end of file diff --git a/thirdparty/linux/lib/x86/libcoinlapack.so.1 b/thirdparty/linux/lib/x86/libcoinlapack.so.1 new file mode 120000 index 0000000..68af160 --- /dev/null +++ b/thirdparty/linux/lib/x86/libcoinlapack.so.1 @@ -0,0 +1 @@ +libcoinlapack.so.1.5.4
\ No newline at end of file diff --git a/thirdparty/linux/lib/x86/libcoinlapack.so.1.5.4 b/thirdparty/linux/lib/x86/libcoinlapack.so.1.5.4 Binary files differnew file mode 100755 index 0000000..fd3453e --- /dev/null +++ b/thirdparty/linux/lib/x86/libcoinlapack.so.1.5.4 diff --git a/thirdparty/linux/lib/x86/libcoinmumps.la b/thirdparty/linux/lib/x86/libcoinmumps.la index 22e37ea..944fd37 100755 --- a/thirdparty/linux/lib/x86/libcoinmumps.la +++ b/thirdparty/linux/lib/x86/libcoinmumps.la @@ -8,18 +8,18 @@ dlname='libcoinmumps.so.1' # Names of this library. -library_names='libcoinmumps.so.1.4.7 libcoinmumps.so.1 libcoinmumps.so' +library_names='libcoinmumps.so.1.5.4 libcoinmumps.so.1 libcoinmumps.so' # The name of the static archive. old_library='' # Libraries that this one depends upon. -dependency_libs='' +dependency_libs=' -lblas -L/usr/lib/gcc/i686-linux-gnu/4.6 -L/usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu -L/usr/lib/gcc/i686-linux-gnu/4.6/../../../../lib -L/lib/i386-linux-gnu -L/lib/../lib -L/usr/lib/i386-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/i686-linux-gnu/4.6/../../.. -lgfortran -lm -lquadmath' # Version information for libcoinmumps. -current=5 -age=4 -revision=7 +current=6 +age=5 +revision=4 # Is this an already installed library? installed=yes @@ -32,4 +32,4 @@ dlopen='' dlpreopen='' # Directory that this library needs to be installed in: -libdir='/home/tonio/Ipopt-3.11.0/build/lib' +libdir='/home/mushirahmed/Desktop/Ipopt-3.12.4/build32_ipopt/lib' diff --git a/thirdparty/linux/lib/x86/libcoinmumps.so b/thirdparty/linux/lib/x86/libcoinmumps.so index 1a9edbe..c2d14a9 120000 --- a/thirdparty/linux/lib/x86/libcoinmumps.so +++ b/thirdparty/linux/lib/x86/libcoinmumps.so @@ -1 +1 @@ -libcoinmumps.so.1.4.7
\ No newline at end of file +libcoinmumps.so.1.5.4
\ No newline at end of file diff --git a/thirdparty/linux/lib/x86/libcoinmumps.so.1 b/thirdparty/linux/lib/x86/libcoinmumps.so.1 index 1a9edbe..c2d14a9 120000 --- a/thirdparty/linux/lib/x86/libcoinmumps.so.1 +++ b/thirdparty/linux/lib/x86/libcoinmumps.so.1 @@ -1 +1 @@ -libcoinmumps.so.1.4.7
\ No newline at end of file +libcoinmumps.so.1.5.4
\ No newline at end of file diff --git a/thirdparty/linux/lib/x86/libcoinmumps.so.1.5.4 b/thirdparty/linux/lib/x86/libcoinmumps.so.1.5.4 Binary files differnew file mode 100755 index 0000000..deeb8d3 --- /dev/null +++ b/thirdparty/linux/lib/x86/libcoinmumps.so.1.5.4 diff --git a/thirdparty/linux/lib/x86/libipopt.la b/thirdparty/linux/lib/x86/libipopt.la index d38333a..e7d4b76 100755 --- a/thirdparty/linux/lib/x86/libipopt.la +++ b/thirdparty/linux/lib/x86/libipopt.la @@ -8,18 +8,18 @@ dlname='libipopt.so.1' # Names of this library. -library_names='libipopt.so.1.9.0 libipopt.so.1 libipopt.so' +library_names='libipopt.so.1.10.4 libipopt.so.1 libipopt.so' # The name of the static archive. old_library='' # Libraries that this one depends upon. -dependency_libs='' +dependency_libs=' /home/mushirahmed/Desktop/Ipopt-3.12.4/build32_ipopt/lib/libcoinmumps.la -lgfortran -lquadmath -llapack -lblas -ldl' # Version information for libipopt. -current=10 -age=9 -revision=0 +current=11 +age=10 +revision=4 # Is this an already installed library? installed=yes @@ -32,4 +32,4 @@ dlopen='' dlpreopen='' # Directory that this library needs to be installed in: -libdir='/home/tonio/Ipopt-3.11.0/build/lib' +libdir='/home/mushirahmed/Desktop/Ipopt-3.12.4/build32_ipopt/lib' diff --git a/thirdparty/linux/lib/x86/libipopt.so b/thirdparty/linux/lib/x86/libipopt.so index eec8a79..5cfe046 120000 --- a/thirdparty/linux/lib/x86/libipopt.so +++ b/thirdparty/linux/lib/x86/libipopt.so @@ -1 +1 @@ -libipopt.so.1.9.0
\ No newline at end of file +libipopt.so.1.10.4
\ No newline at end of file diff --git a/thirdparty/linux/lib/x86/libipopt.so.1 b/thirdparty/linux/lib/x86/libipopt.so.1 index eec8a79..5cfe046 120000 --- a/thirdparty/linux/lib/x86/libipopt.so.1 +++ b/thirdparty/linux/lib/x86/libipopt.so.1 @@ -1 +1 @@ -libipopt.so.1.9.0
\ No newline at end of file +libipopt.so.1.10.4
\ No newline at end of file diff --git a/thirdparty/linux/lib/x86/libipopt.so.1.10.4 b/thirdparty/linux/lib/x86/libipopt.so.1.10.4 Binary files differnew file mode 100755 index 0000000..29c6300 --- /dev/null +++ b/thirdparty/linux/lib/x86/libipopt.so.1.10.4 |