From 95d920496cc4b3263c3ea1bc698e6fd5745917bd Mon Sep 17 00:00:00 2001 From: Harpreet Date: Tue, 17 Nov 2015 22:28:26 +0530 Subject: error management updated --- demos/symphony.dem.sce | 12 +- demos/symphonymat.dem.sce | 11 +- help/en_US/qpipopt.xml | 24 ++-- help/en_US/qpipoptmat.xml | 22 ++-- help/en_US/scilab_en_US_help/JavaHelpSearch/DOCS | Bin 7157 -> 7152 bytes .../scilab_en_US_help/JavaHelpSearch/DOCS.TAB | 4 +- .../en_US/scilab_en_US_help/JavaHelpSearch/OFFSETS | Bin 258 -> 260 bytes .../scilab_en_US_help/JavaHelpSearch/POSITIONS | Bin 35046 -> 34771 bytes help/en_US/scilab_en_US_help/JavaHelpSearch/TMAP | Bin 16384 -> 16384 bytes .../scilab_en_US_help/_LaTeX_symphonymat.xml_1.png | Bin 2934 -> 2547 bytes help/en_US/scilab_en_US_help/qpipopt.html | 24 ++-- help/en_US/scilab_en_US_help/qpipoptmat.html | 22 ++-- help/en_US/scilab_en_US_help/symphony.html | 40 +++--- help/en_US/scilab_en_US_help/symphonymat.html | 8 +- help/en_US/symphony.xml | 40 +++--- help/en_US/symphonymat.xml | 9 +- jar/scilab_en_US_help.jar | Bin 203066 -> 202485 bytes macros/qpipopt.bin | Bin 33680 -> 37220 bytes macros/qpipopt.sci | 88 ++++++++++--- macros/qpipoptmat.bin | Bin 38128 -> 39808 bytes macros/qpipoptmat.sci | 93 ++++++++----- macros/symphony.bin | Bin 43868 -> 50332 bytes macros/symphony.sci | 134 +++++++++++++------ macros/symphonymat.bin | Bin 45960 -> 54444 bytes macros/symphonymat.sci | 146 +++++++++++++++------ 25 files changed, 442 insertions(+), 235 deletions(-) diff --git a/demos/symphony.dem.sce b/demos/symphony.dem.sce index 627c857..c17c14d 100644 --- a/demos/symphony.dem.sce +++ b/demos/symphony.dem.sce @@ -5,11 +5,11 @@ mode(1) //A basic case : // Objective function -c = [350*5,330*3,310*4,280*6,500,450,400,100] +c = [350*5,330*3,310*4,280*6,500,450,400,100]'; // Lower Bound of variable -lb = repmat(0,1,8); +lb = repmat(0,8,1); // Upper Bound of variables -ub = [repmat(1,1,4) repmat(%inf,1,4)]; +ub = [repmat(1,4,1);repmat(%inf,4,1)]; // 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; @@ -42,7 +42,7 @@ p = [ 504 803 667 1103 834 585 811 856 690 832 846 813 868 793 .. 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] +1162 653 814 625 599 476 767 954 906 904 649 873 565 853 1008 632]'; //Constraint Matrix conMatrix = [ //Constraint 1 @@ -89,9 +89,9 @@ conMatrix = [ nbCon = size(conMatrix,1) nbVar = size(conMatrix,2) // Lower Bound of variables -lb = repmat(0,1,nbVar) +lb = repmat(0,nbVar,1) // Upper Bound of variables -ub = repmat(1,1,nbVar) +ub = repmat(1,nbVar,1) // Row Matrix for telling symphony that the is integer or not isInt = repmat(%t,1,nbVar) // Lower Bound of constrains diff --git a/demos/symphonymat.dem.sce b/demos/symphonymat.dem.sce index 441eb51..f069d38 100644 --- a/demos/symphonymat.dem.sce +++ b/demos/symphonymat.dem.sce @@ -4,7 +4,7 @@ mode(1) // // Objective function -c = [350*5,330*3,310*4,280*6,500,450,400,100] +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 @@ -35,8 +35,9 @@ objCoef = -1*[ 504 803 667 1103 834 585 811 856 690 832 846 813 868 793 .. 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 +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 .. @@ -78,14 +79,14 @@ conMatrix = [ //Constraint 1 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) +nbVar = size(objCoef,1) 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 = [] +intcon = []; for i = 1:nbVar intcon = [intcon i]; end diff --git a/help/en_US/qpipopt.xml b/help/en_US/qpipopt.xml index aecbe40..2edd0ec 100644 --- a/help/en_US/qpipopt.xml +++ b/help/en_US/qpipopt.xml @@ -36,31 +36,31 @@ Parameters nbVar : - a 1 x 1 matrix of doubles, number of variables + a double, number of variables nbCon : - a 1 x 1 matrix of doubles, number of constraints + a double, 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. + a symmetric matrix of doubles, 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 + a vector of doubles, 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. + a vector of doubles, 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. + a vector 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 + a matrix of doubles, 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. + a vector of doubles, 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. + a vector of doubles, 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. + a vector of doubles, 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. + a vector of doubles, the computed solution of the optimization problem. fopt : - a 1x1 matrix of doubles, the function value at x. + a double, the function value at x. exitflag : Integer identifying the reason the algorithm terminated. output : diff --git a/help/en_US/qpipoptmat.xml b/help/en_US/qpipoptmat.xml index eb8e737..3c9e6a4 100644 --- a/help/en_US/qpipoptmat.xml +++ b/help/en_US/qpipoptmat.xml @@ -39,29 +39,29 @@ Parameters H : - a n x n matrix of doubles, where n is number of variables, represents coefficients of quadratic in the quadratic problem. + a vector of doubles, where n is number of variables, represents coefficients of quadratic in the quadratic problem. f : - a n x 1 matrix of doubles, where n is number of variables, represents coefficients of linear in the quadratic problem + a vector of doubles, where n is number of variables, represents coefficients of linear in the quadratic problem A : - a m x n matrix of doubles, represents the linear coefficients in the inequality constraints + a vector of doubles, represents the linear coefficients in the inequality constraints b : - a column vector of doubles, represents the linear coefficients in the inequality constraints + a vector of doubles, represents the linear coefficients in the inequality constraints Aeq : - a meq x n matrix of doubles, represents the linear coefficients in the equality constraints + a matrix of doubles, represents the linear coefficients in the equality constraints 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. + a vector 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. + a vector 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. + a vector of doubles, 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. + a vector of doubles, the computed solution of the optimization problem. fopt : - a 1x1 matrix of doubles, the function value at x. + a double, the function value at x. exitflag : Integer identifying the reason the algorithm terminated. output : @@ -113,7 +113,7 @@ 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); +[xopt,fopt,exitflag,output,lambda]=qpipoptmat(H,f,A,b,Aeq,beq,lb,ub,[],param) clear H f A b Aeq beq lb ub; ]]> diff --git a/help/en_US/scilab_en_US_help/JavaHelpSearch/DOCS b/help/en_US/scilab_en_US_help/JavaHelpSearch/DOCS index bf90ce2..02038f6 100644 Binary files a/help/en_US/scilab_en_US_help/JavaHelpSearch/DOCS and b/help/en_US/scilab_en_US_help/JavaHelpSearch/DOCS differ 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 1b174ab..23181b6 100644 --- a/help/en_US/scilab_en_US_help/JavaHelpSearch/DOCS.TAB +++ b/help/en_US/scilab_en_US_help/JavaHelpSearch/DOCS.TAB @@ -1,2 +1,2 @@ -eџџџџџџџџџџџџџї_џџџџџџџџџџџџџџџџџџџџџї_џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџy§езџ§зџї_џ§зџuџџџџџџ§Я'\вџџџџџџџџџџџџџџџџѓ ї_§ЕџџџѓЩџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџЧџ4Ÿџџ§зџї_ќhT‘‘_e4Нs ќвџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџє _ -C`Є7FF$рЈє  œ6Ј(qˆ\tX6‘ТБPа$ t и ”`6 Š |*Vƒ@ЊXRЎ†Хф ‚AёX{0lHтЃJ (3\/ тХЦPАГ…$2 …YGеЫ†G…r†Ž Ч$Vƒ(&QoЁŸцZ№Р(0–OўКЉзuџ8Љ?Ћї_Ь)[Й’j_иТzяџЬ&eџкЉY;7|T0Т !аФ,ЁBŒ(ђ*2 Uё‘rŒ‡&(OЏЫѓ 0П0ГаМйБFŠ6/ЭtŸаГебђЯвлЦ]~жm*œ`QгІBѓjЇђЬ/џѓ џџЭ/Ь/9Y.,пdъЊПџeџџЫџ7џџџ§ЕeџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџйrЬДЋЊЊdВЬЋtЂџ0Г 0МЫЈПќТЬ,Тџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџи \ No newline at end of file +eџџџџџџџџџџџџџї_џџџџџџџџџџџџџџџџџџџџџї_џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџy§езџ§зџї_џ§зџuџџџџџџ§Я'\вџџџџџџџџџџџџџџџќТ}зџmџџќђџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџќpGџќвџџџ§зџї_ќhT‘‘_e4Нs ќвџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџє _ +C`Є7FF$рЌє  œ6Ј(qˆ\tX6‘ТБPа$ t и ”`6 Š |*Vƒ@ЊXRЎ†Хф ‚AёX{0lHтЃJ (3\/ тХЦPАГ…O$2 …YGеЫ†G…r† Ч$Vƒ(&QoЁŸцZ№Р(0–OўКЉзuџ<Љ?Ћї_Ь)[Й’j_иТzяџЬ&eџкЉY;7|T0Т !аФ,ЁBŒ(ђ*2 Uё‘rŒ‡&(OЏЫѓ 0П0ГаМйБFŠ6/ЭtŸаГеаГєЗGWG_ŸЦѕ›JЇtщМкЉќГ џќТџџѓKѓ ЮV,пdъЊПџeџџЫџ7џџџ§ЙYџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџі\Геб’юЊЉ’ЊЫ2­в‹ќТЬ,Тѓ.Ђџѓ 0Г џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ` \ 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 index ac2dfed..d20c98d 100644 Binary files a/help/en_US/scilab_en_US_help/JavaHelpSearch/OFFSETS and b/help/en_US/scilab_en_US_help/JavaHelpSearch/OFFSETS differ diff --git a/help/en_US/scilab_en_US_help/JavaHelpSearch/POSITIONS b/help/en_US/scilab_en_US_help/JavaHelpSearch/POSITIONS index 8be86f0..e2773de 100644 Binary files a/help/en_US/scilab_en_US_help/JavaHelpSearch/POSITIONS and b/help/en_US/scilab_en_US_help/JavaHelpSearch/POSITIONS differ diff --git a/help/en_US/scilab_en_US_help/JavaHelpSearch/TMAP b/help/en_US/scilab_en_US_help/JavaHelpSearch/TMAP index 28f8966..7e8baef 100644 Binary files a/help/en_US/scilab_en_US_help/JavaHelpSearch/TMAP and b/help/en_US/scilab_en_US_help/JavaHelpSearch/TMAP differ 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 index 07dafd6..2e81ca1 100644 Binary files a/help/en_US/scilab_en_US_help/_LaTeX_symphonymat.xml_1.png and b/help/en_US/scilab_en_US_help/_LaTeX_symphonymat.xml_1.png differ diff --git a/help/en_US/scilab_en_US_help/qpipopt.html b/help/en_US/scilab_en_US_help/qpipopt.html index 6659f44..b1c18ac 100644 --- a/help/en_US/scilab_en_US_help/qpipopt.html +++ b/help/en_US/scilab_en_US_help/qpipopt.html @@ -44,31 +44,31 @@

Parameters

nbVar : -

a 1 x 1 matrix of doubles, number of variables

+

a double, number of variables

nbCon : -

a 1 x 1 matrix of doubles, number of constraints

+

a double, 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.

+

a symmetric matrix of doubles, 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

+

a vector of doubles, 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.

+

a vector of doubles, 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.

+

a vector 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

+

a matrix of doubles, 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.

+

a vector of doubles, 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.

+

a vector of doubles, 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.

+

a vector of doubles, 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.

+

a vector of doubles, the computed solution of the optimization problem.

fopt : -

a 1x1 matrix of doubles, the function value at x.

+

a double, the function value at x.

exitflag :

Integer identifying the reason the algorithm terminated.

output : diff --git a/help/en_US/scilab_en_US_help/qpipoptmat.html b/help/en_US/scilab_en_US_help/qpipoptmat.html index 5e7518e..a9f97aa 100644 --- a/help/en_US/scilab_en_US_help/qpipoptmat.html +++ b/help/en_US/scilab_en_US_help/qpipoptmat.html @@ -47,29 +47,29 @@

Parameters

H : -

a n x n matrix of doubles, where n is number of variables, represents coefficients of quadratic in the quadratic problem.

+

a vector of doubles, where n is number of variables, represents coefficients of quadratic in the quadratic problem.

f : -

a n x 1 matrix of doubles, where n is number of variables, represents coefficients of linear in the quadratic problem

+

a vector of doubles, where n is number of variables, represents coefficients of linear in the quadratic problem

A : -

a m x n matrix of doubles, represents the linear coefficients in the inequality constraints

+

a vector of doubles, represents the linear coefficients in the inequality constraints

b : -

a column vector of doubles, represents the linear coefficients in the inequality constraints

+

a vector of doubles, represents the linear coefficients in the inequality constraints

Aeq : -

a meq x n matrix of doubles, represents the linear coefficients in the equality constraints

+

a matrix of doubles, represents the linear coefficients in the equality constraints

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.

+

a vector 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.

+

a vector 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.

+

a vector of doubles, 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.

+

a vector of doubles, the computed solution of the optimization problem.

fopt : -

a 1x1 matrix of doubles, the function value at x.

+

a double, the function value at x.

exitflag :

Integer identifying the reason the algorithm terminated.

output : @@ -100,7 +100,7 @@ find the minimum of f(x) such that

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); +[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

diff --git a/help/en_US/scilab_en_US_help/symphony.html b/help/en_US/scilab_en_US_help/symphony.html index a1e3eea..c5b8336 100644 --- a/help/en_US/scilab_en_US_help/symphony.html +++ b/help/en_US/scilab_en_US_help/symphony.html @@ -44,33 +44,33 @@

Parameters

nbVar : -

a 1 x 1 matrix of doubles, number of variables

+

a double, number of variables.

nbCon : -

a 1 x 1 matrix of doubles, number of constraints

+

a double, 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

+

a 1 x n matrix of doubles, where n is number of variables, represents 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

+

a vector of boolean, represents 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

+

a vector of doubles, represents lower bounds of the variables.

UB : -

a 1 x n matrix of doubles, where n is number of variables, contains upper bounds of the variables. Bound can be infinity

+

a vector of doubles, represents 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

+

a matrix of doubles, represents 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.

+

a vector of doubles, represents 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

+

a vector of doubles, represents upper bounds of the constraints

objSense : -

The sense (maximization/minimization) of the objective. Use 1(sym_minimize ) or -1 (sym_maximize) here

+

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

+

a a list containing the the parameters to be set.

xopt : -

a 1xn matrix of doubles, the computed solution of the optimization problem

+

a vector of doubles, the computed solution of the optimization problem.

fopt : -

a 1x1 matrix of doubles, the function value at x

+

a double, the function value at x.

status : -

status flag from symphony

+

status flag from symphony.

output :

The output data structure contains detailed informations about the optimization process.

@@ -84,11 +84,11 @@ find the minimum or maximum of f(x) such that

Examples

//A basic case :
 // Objective function
-c = [350*5,330*3,310*4,280*6,500,450,400,100]
+c = [350*5,330*3,310*4,280*6,500,450,400,100]';
 // Lower Bound of variable
-lb = repmat(0,1,8);
+lb = repmat(0,8,1);
 // Upper Bound of variables
-ub = [repmat(1,1,4) repmat(%inf,1,4)];
+ub = [repmat(1,4,1);repmat(%inf,4,1)];
 // 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;
@@ -121,7 +121,7 @@ find the minimum or maximum of f(x) such that

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] +1162 653 814 625 599 476 767 954 906 904 649 873 565 853 1008 632]'; //Constraint Matrix conMatrix = [ //Constraint 1 @@ -168,9 +168,9 @@ find the minimum or maximum of f(x) such that

nbCon = size(conMatrix,1) nbVar = size(conMatrix,2) // Lower Bound of variables -lb = repmat(0,1,nbVar) +lb = repmat(0,nbVar,1) // Upper Bound of variables -ub = repmat(1,1,nbVar) +ub = repmat(1,nbVar,1) // Row Matrix for telling symphony that the is integer or not isInt = repmat(%t,1,nbVar) // Lower Bound of constrains diff --git a/help/en_US/scilab_en_US_help/symphonymat.html b/help/en_US/scilab_en_US_help/symphonymat.html index 23ff2c6..8001136 100644 --- a/help/en_US/scilab_en_US_help/symphonymat.html +++ b/help/en_US/scilab_en_US_help/symphonymat.html @@ -45,9 +45,9 @@

Parameters

f : -

a 1xn matrix of doubles, where n is number of variables, contains coefficients of the variables in the objective

+

a vector 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

+

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 : @@ -72,7 +72,7 @@

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

-

+

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.

@@ -159,7 +159,7 @@ find the minimum or maximum of f(x) such that

// Upper Bound of variables ub = repmat(1,1,nbVar) // Lower Bound of constrains -intcon = [] +intcon = []; for i = 1:nbVar intcon = [intcon i]; end diff --git a/help/en_US/symphony.xml b/help/en_US/symphony.xml index c33b95c..972bfc1 100644 --- a/help/en_US/symphony.xml +++ b/help/en_US/symphony.xml @@ -36,33 +36,33 @@ Parameters nbVar : - a 1 x 1 matrix of doubles, number of variables + a double, number of variables. nbCon : - a 1 x 1 matrix of doubles, number of constraints + a double, 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 + a 1 x n matrix of doubles, where n is number of variables, represents 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 + a vector of boolean, represents 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 + a vector of doubles, represents lower bounds of the variables. UB : - a 1 x n matrix of doubles, where n is number of variables, contains upper bounds of the variables. Bound can be infinity + a vector of doubles, represents 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 + a matrix of doubles, represents 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. + a vector of doubles, represents 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 + a vector of doubles, represents upper bounds of the constraints objSense : - The sense (maximization/minimization) of the objective. Use 1(sym_minimize ) or -1 (sym_maximize) here + 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 + a a list containing the the parameters to be set. xopt : - a 1xn matrix of doubles, the computed solution of the optimization problem + a vector of doubles, the computed solution of the optimization problem. fopt : - a 1x1 matrix of doubles, the function value at x + a double, the function value at x. status : - status flag from symphony + status flag from symphony. output : The output data structure contains detailed informations about the optimization process. @@ -96,11 +96,11 @@ We are calling SYMPHONY written in C by gateway files for the actual computation Parameters f : - a 1xn matrix of doubles, where n is number of variables, contains coefficients of the variables in the objective + a vector 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 + 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 : @@ -74,7 +74,8 @@ find the minimum or maximum of f(x) such that \begin{eqnarray} &\mbox{min}_{x} & f(x) \\ -& \text{subject to} & conLB \leq C(x) \leq conUB \\ +& \text{subject to} & A.x \leq b \\ +& & Aeq.x \leq beq \\ & & lb \leq x \leq ub \\ \end{eqnarray} @@ -176,7 +177,7 @@ lb = repmat(0,1,nbVar) // Upper Bound of variables ub = repmat(1,1,nbVar) // Lower Bound of constrains -intcon = [] +intcon = []; for i = 1:nbVar intcon = [intcon i]; end diff --git a/jar/scilab_en_US_help.jar b/jar/scilab_en_US_help.jar index 2f1f947..749cb54 100644 Binary files a/jar/scilab_en_US_help.jar and b/jar/scilab_en_US_help.jar differ diff --git a/macros/qpipopt.bin b/macros/qpipopt.bin index 07db2ad..6eea1fa 100644 Binary files a/macros/qpipopt.bin and b/macros/qpipopt.bin differ diff --git a/macros/qpipopt.sci b/macros/qpipopt.sci index 8f3945e..5f08067 100644 --- a/macros/qpipopt.sci +++ b/macros/qpipopt.sci @@ -20,19 +20,19 @@ function [xopt,fopt,exitflag,output,lambda] = qpipopt (varargin) // [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. + // nbVar : a double, number of variables + // nbCon : a double, number of constraints + // Q : a symmetric matrix of doubles, represents coefficients of quadratic in the quadratic problem. + // p : a vector of doubles, represents coefficients of linear in the quadratic problem + // LB : a vector of doubles, contains lower bounds of the variables. + // UB : a vector of doubles, where n is number of variables, contains upper bounds of the variables. + // conMatrix : a matrix of doubles, contains matrix representing the constraint matrix + // conLB : a vector of doubles, contains lower bounds of the constraints. + // conUB : a vector of doubles, contains upper bounds of the constraints. + // x0 : a vector of doubles, 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. + // xopt : a vector of doubles, the computed solution of the optimization problem. + // fopt : a double, 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). @@ -114,19 +114,31 @@ function [xopt,fopt,exitflag,output,lambda] = qpipopt (varargin) conLB = varargin(8); conUB = varargin(9); - + if (size(LB,2)==0) then + LB = repmat(-%inf,nbVar,1); + end + + if (size(UB,2)==0) then + UB = repmat(%inf,nbVar,1); + end + if ( rhs<10 | size(varargin(10)) ==0 ) then x0 = repmat(0,nbVar,1); else x0 = varargin(10); end - if ( rhs<11 ) then + if ( rhs<11 | size(varargin(11)) ==0 ) then param = list(); else param =varargin(11); end + if (type(param) ~= 15) then + errmsg = msprintf(gettext("%s: param should be a list "), "qpipopt"); + error(errmsg); + end + if (modulo(size(param),2)) then errmsg = msprintf(gettext("%s: Size of parameters should be even"), "qpipopt"); error(errmsg); @@ -137,6 +149,7 @@ function [xopt,fopt,exitflag,output,lambda] = qpipopt (varargin) "MaxIter" , [3000], ... "CpuTime" , [600] ... ); + for i = 1:(size(param))/2 select param(2*i-1) @@ -150,6 +163,33 @@ function [xopt,fopt,exitflag,output,lambda] = qpipopt (varargin) end end +// Check if the user gives row vector +// and Changing it to a column matrix + + if (size(p,2)== [nbVar]) then + p=p'; + end + + if (size(LB,2)== [nbVar]) then + LB = LB'; + end + + if (size(UB,2)== [nbVar]) then + UB = UB'; + end + + if (size(conUB,2)== [nbCon]) then + conUB = conUB'; + end + + if (size(conLB,2)== [nbCon]) then + conLB = conLB'; + end + + if (size(x0,2)== [nbVar]) then + x0=x0'; + end + //IPOpt wants it in row matrix form p = p'; LB = LB'; @@ -176,10 +216,17 @@ function [xopt,fopt,exitflag,output,lambda] = qpipopt (varargin) 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"); + if (nbCon) then + //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 + end + + //Check the number of constraint + if ( size(conMatrix,1) ~= nbCon) then + errmsg = msprintf(gettext("%s: The number of constraints is not equal to the number of constraint given i.e. %d"), "qpipopt", nbCon); error(errmsg); end @@ -209,9 +256,10 @@ function [xopt,fopt,exitflag,output,lambda] = qpipopt (varargin) //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); + warnmsg = msprintf(gettext("%s: Ignoring initial guess of variables as it is not equal to the number of variables"), "qpipopt"); + warning(warnmsg); end + [xopt,fopt,status,iter,Zl,Zu,lmbda] = solveqp(nbVar,nbCon,Q,p,conMatrix,conLB,conUB,LB,UB,x0,options); diff --git a/macros/qpipoptmat.bin b/macros/qpipoptmat.bin index 668402c..2cb90c9 100644 Binary files a/macros/qpipoptmat.bin and b/macros/qpipoptmat.bin differ diff --git a/macros/qpipoptmat.sci b/macros/qpipoptmat.sci index 6ae20c0..7924ba6 100644 --- a/macros/qpipoptmat.sci +++ b/macros/qpipoptmat.sci @@ -23,18 +23,18 @@ function [xopt,fopt,exitflag,output,lambda] = qpipoptmat (varargin) // [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. - // f : a n x 1 matrix of doubles, where n is number of variables, represents coefficients of linear in the quadratic problem - // A : a m x n matrix of doubles, represents the linear coefficients in the inequality constraints - // b : a column vector of doubles, represents the linear coefficients in the inequality constraints - // Aeq : a meq x n matrix of doubles, represents the linear coefficients in the equality constraints + // H : a vector of doubles, where n is number of variables, represents coefficients of quadratic in the quadratic problem. + // f : a vector of doubles, where n is number of variables, represents coefficients of linear in the quadratic problem + // A : a vector of doubles, represents the linear coefficients in the inequality constraints + // b : a vector of doubles, represents the linear coefficients in the inequality constraints + // Aeq : a matrix of doubles, represents the linear coefficients in the equality constraints // 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. + // LB : a vector of doubles, where n is number of variables, contains lower bounds of the variables. + // UB : a vector of doubles, where n is number of variables, contains upper bounds of the variables. + // x0 : a vector of doubles, 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. + // xopt : a vector of doubles, the computed solution of the optimization problem. + // fopt : a double, 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). @@ -108,7 +108,7 @@ function [xopt,fopt,exitflag,output,lambda] = qpipoptmat (varargin) nbVar = size(H,1); - if ( rhs<2 ) then + if ( rhs<3 ) then A = [] b = [] else @@ -116,7 +116,7 @@ function [xopt,fopt,exitflag,output,lambda] = qpipoptmat (varargin) b = varargin(4); end - if ( rhs<4 ) then + if ( rhs<5 ) then Aeq = [] beq = [] else @@ -124,7 +124,7 @@ function [xopt,fopt,exitflag,output,lambda] = qpipoptmat (varargin) beq = varargin(6); end - if ( rhs<6 ) then + if ( rhs<7 ) then LB = repmat(-%inf,nbVar,1); UB = repmat(%inf,nbVar,1); else @@ -139,24 +139,32 @@ function [xopt,fopt,exitflag,output,lambda] = qpipoptmat (varargin) x0 = varargin(9); end - if ( rhs<10 ) then + if ( rhs<10 | size(varargin(10)) ==0 ) then param = list(); else param =varargin(10); end + if (size(LB,2)==0) then + LB = repmat(-%inf,nbVar,1); + end + + if (size(UB,2)==0) then + UB = repmat(%inf,nbVar,1); + end + - if (modulo(size(param),2)) then - errmsg = msprintf(gettext("%s: Size of parameters should be even"), "qpipoptmat"); - error(errmsg); + if (type(param) ~= 15) then + errmsg = msprintf(gettext("%s: param should be a list "), "qpipopt"); + 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] ... @@ -178,34 +186,57 @@ function [xopt,fopt,exitflag,output,lambda] = qpipoptmat (varargin) nbConInEq = size(A,1); nbConEq = size(Aeq,1); +// Check if the user gives row vector +// and Changing it to a column matrix + + + if (size(f,2)== [nbVar]) then + f=f'; + end + + if (size(LB,2)== [nbVar]) then + LB = LB'; + end + + if (size(UB,2)== [nbVar]) then + UB = UB'; + end + + if (size(b,2)==nbConInEq) then + b = b'; + end + + if (size(beq,2)== nbConEq) then + beq = beq'; + end + + if (size(x0,2)== [nbVar]) then + x0=x0'; + end + //Checking the H matrix which needs to be a symmetric matrix - if ( H~=H') then + if ( ~isequal(H,H')) then 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"), "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"), "qpipoptmat"); + errmsg = msprintf(gettext("%s: The number of rows and columns in H must be equal the number of elements of f"), "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"), "qpipoptmat"); + errmsg = msprintf(gettext("%s: The number of columns in A must be the same as the number of elements of f"), "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"), "qpipoptmat"); + errmsg = msprintf(gettext("%s: The number of columns in Aeq must be the same as the number of elements of f"), "qpipoptmat"); error(errmsg); end @@ -224,20 +255,20 @@ function [xopt,fopt,exitflag,output,lambda] = qpipoptmat (varargin) //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"); + errmsg = msprintf(gettext("%s: The number of rows in A must be the same as the number of elementsof b"), "qpipoptmat"); error(errmsg); end //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"); + errmsg = msprintf(gettext("%s: The number of rows in Aeq must be the same as the number of elements of beq"), "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); + warnmsg = msprintf(gettext("%s: Ignoring initial guess of variables as it is not equal to the number of variables"), "qpipopt"); + warning(warnmsg); end diff --git a/macros/symphony.bin b/macros/symphony.bin index d2aa822..2ef2f57 100644 Binary files a/macros/symphony.bin and b/macros/symphony.bin differ diff --git a/macros/symphony.sci b/macros/symphony.sci index 9677720..0f57751 100644 --- a/macros/symphony.sci +++ b/macros/symphony.sci @@ -19,20 +19,20 @@ function [xopt,fopt,status,output] = symphony (varargin) // [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 + // nbVar : a double, number of variables. + // nbCon : a double, number of constraints. + // objCoeff : a 1 x n matrix of doubles, where n is number of variables, represents coefficients of the variables in the objective. + // isInt : a vector of boolean, represents wether a variable is constrained to be an integer. + // LB : a vector of doubles, represents lower bounds of the variables. + // UB : a vector of doubles, represents upper bounds of the variables. + // conMatrix : a matrix of doubles, represents matrix representing the constraint matrix. + // conLB : a vector of doubles, represents lower bounds of the constraints. + // conUB : a vector of doubles, represents upper bounds of the constraints + // objSense : The sense (maximization/minimization) of the objective. Use 1(sym_minimize ) or -1 (sym_maximize) here. + // options : a a list containing the the parameters to be set. + // xopt : a vector of doubles, the computed solution of the optimization problem. + // fopt : a double, the function value at x. + // status : status flag from symphony. // output : The output data structure contains detailed informations about the optimization process. // // Description @@ -53,11 +53,11 @@ function [xopt,fopt,status,output] = symphony (varargin) // Examples // //A basic case : // // Objective function - // c = [350*5,330*3,310*4,280*6,500,450,400,100] + // c = [350*5,330*3,310*4,280*6,500,450,400,100]'; // // Lower Bound of variable - // lb = repmat(0,1,8); + // lb = repmat(0,8,1); // // Upper Bound of variables - // ub = [repmat(1,1,4) repmat(%inf,1,4)]; + // ub = [repmat(1,4,1);repmat(%inf,4,1)]; // // 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; @@ -90,7 +90,7 @@ function [xopt,fopt,status,output] = symphony (varargin) // 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] + // 1162 653 814 625 599 476 767 954 906 904 649 873 565 853 1008 632]'; // //Constraint Matrix // conMatrix = [ // //Constraint 1 @@ -137,9 +137,9 @@ function [xopt,fopt,status,output] = symphony (varargin) // nbCon = size(conMatrix,1) // nbVar = size(conMatrix,2) // // Lower Bound of variables - // lb = repmat(0,1,nbVar) + // lb = repmat(0,nbVar,1) // // Upper Bound of variables - // ub = repmat(1,1,nbVar) + // ub = repmat(1,nbVar,1) // // Row Matrix for telling symphony that the is integer or not // isInt = repmat(%t,1,nbVar) // // Lower Bound of constrains @@ -185,43 +185,103 @@ function [xopt,fopt,status,output] = symphony (varargin) objSense = varargin(10); end - if (rhs<11) then + if (rhs<11|size(varargin(11)==0)) 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"); +// Check if the user gives row vector +// and Changing it to a column matrix + + if (size(isInt,2)== [nbVar]) then + isInt = isInt'; + end + + if (size(LB,2)== [nbVar]) then + LB = LB'; + end + + if (size(UB,2)== [nbVar]) then + UB = UB'; + end + + if (size(conLB,2)== [nbVar]) then + conLB = conLB'; + end + + if (size(conUB,2)== [nbVar]) then + conUB = conUB'; + end + + + if (size(objCoef,2)~=1) then + errmsg = msprintf(gettext("%s: Objective Coefficients should be a column matrix"), "Symphony"); + error(errmsg); + end + + if (size(objCoef,1)~=nbVar) then + errmsg = msprintf(gettext("%s: Number of variables in Objective Coefficients is not equal to number of variables given"), "Symphony"); + error(errmsg); + end + + //Check the size of isInt which should equal to the number of variables + if(size(isInt,1)~=nbVar) then + errmsg = msprintf(gettext("%s: The size of isInt is not equal to the number of variables"), "Symphony"); + error(errmsg); + end + + //Check the size of lower bound of inequality constraint which should equal to the number of constraints + if ( size(conLB,1) ~= nbCon) then + errmsg = msprintf(gettext("%s: The Lower Bound of 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"); + //Check the size of lower bound of inequality constraint which should equal to the number of constraints + if ( size(conUB,1) ~= nbCon) then + errmsg = msprintf(gettext("%s: The Upper Bound of constraint is not equal to the number of constraint"), "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"); + //Check the row of constraint which should equal to the number of constraints + if ( size(conMatrix,1) ~= nbCon) then + errmsg = msprintf(gettext("%s: The number of rows in constraint should be equal to the number of constraints"), "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"); + //Check the column of constraint which should equal to the number of variables + if ( size(conMatrix,2) ~= nbVar) then + errmsg = msprintf(gettext("%s: The number of columns in constraint should equal to the number of variables"), "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"); + //Check the size of Lower Bound which should 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"), "Symphony"); error(errmsg); end + //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"), "Symphony"); + error(errmsg); + end + + if (type(options) ~= 15) then + errmsg = msprintf(gettext("%s: Options should be a list "), "Symphony"); + error(errmsg); + end + + if (modulo(size(options),2)) then + errmsg = msprintf(gettext("%s: Size of parameters should be even"), "Symphony"); + error(errmsg); + end + + LB = LB'; + UB = UB'; + isInt = isInt'; + objCoef = objCoef'; + [xopt,fopt,status,output] = symphony_call(nbVar,nbCon,objCoef,isInt,LB,UB,conMatrix,conLB,conUB,objSense,options); endfunction diff --git a/macros/symphonymat.bin b/macros/symphonymat.bin index 5089973..01460d6 100644 Binary files a/macros/symphonymat.bin and b/macros/symphonymat.bin differ diff --git a/macros/symphonymat.sci b/macros/symphonymat.sci index ef70b7c..87427e1 100644 --- a/macros/symphonymat.sci +++ b/macros/symphonymat.sci @@ -20,8 +20,8 @@ function [xopt,fopt,status,iter] = symphonymat (varargin) // [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 + // f : a vector 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 @@ -41,7 +41,8 @@ function [xopt,fopt,status,iter] = symphonymat (varargin) // \begin{eqnarray} // &\mbox{min}_{x} // & f(x) \\ - // & \text{subject to} & conLB \leq C(x) \leq conUB \\ + // & \text{subject to} & A.x \leq b \\ + // & & Aeq.x \leq beq \\ // & & lb \leq x \leq ub \\ // \end{eqnarray} // @@ -50,7 +51,7 @@ function [xopt,fopt,status,iter] = symphonymat (varargin) // // Examples // // Objective function - // c = [350*5,330*3,310*4,280*6,500,450,400,100] + // 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 @@ -81,7 +82,7 @@ function [xopt,fopt,status,iter] = symphonymat (varargin) // 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] + // 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 .. @@ -131,7 +132,7 @@ function [xopt,fopt,status,iter] = symphonymat (varargin) // // Upper Bound of variables // ub = repmat(1,1,nbVar) // // Lower Bound of constrains - // intcon = [] + // intcon = []; // for i = 1:nbVar // intcon = [intcon i]; // end @@ -164,34 +165,24 @@ function [xopt,fopt,status,iter] = symphonymat (varargin) intcon = varargin(2) A = varargin(3) b = varargin(4) - - nbVar = size(objCoef,2); - nbCon = size(A,1); - - if ( rhs<4 ) then + + if (size(objCoef,2)~=1) then + errmsg = msprintf(gettext("%s: Objective Coefficients should be a column matrix"), "Symphonymat"); + error(errmsg); + end + + + nbVar = size(objCoef,1); + + if ( rhs<5 ) 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 + if ( rhs<7 ) then lb = repmat(-%inf,1,nbVar); ub = repmat(%inf,1,nbVar); else @@ -199,36 +190,105 @@ function [xopt,fopt,status,iter] = symphonymat (varargin) ub = varargin(8); end - if (rhs<9) then + if (rhs<9|size(varargin(9))==0) 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"); + nbConInEq = size(A,1); + nbConEq = size(Aeq,1); + +// Check if the user gives row vector +// and Changing it to a column matrix + + if (size(lb,2)== [nbVar]) then + lb = lb'; + end + + if (size(ub,2)== [nbVar]) then + ub = ub'; + end + + if (size(b,2)== [nbConInEq]) then + b = b'; + end + + if (size(beq,2)== [nbConEq]) then + beq = beq'; + end + + for i=1:size(intcon,2) + if(intcon(i)>nbVar) then + errmsg = msprintf(gettext("%s: The values inside intcon should not exceed total number of variable "), "Symphonymat"); + error(errmsg); + end + + if (intcon(i)<1) then + errmsg = msprintf(gettext("%s: The values inside intcon should be greater than 0 "), "Symphonymat"); + error(errmsg); + end + + if(modulo(intcon(i),1)) then + errmsg = msprintf(gettext("%s: The values inside intcon should be integer "), "Symphonymat"); + error(errmsg); + end + end + + //Check the size of inequality constraint which should equal to the number of inequality constraints + if ( size(A,2) ~= nbVar & size(A,2) ~= 0) then + errmsg = msprintf(gettext("%s: The size of inequality constraint is not equal to the number of variables"), "Symphonymat"); + error(errmsg); + end + + + //Check the size of lower bound of inequality constraint which should equal to the number of constraints + if ( size(b,1) ~= size(A,1)) then + errmsg = msprintf(gettext("%s: The Lower Bound of inequality constraint is not equal to the number of constraint"), "Symphonymat"); 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"); + //Check the size of equality constraint which should equal to the number of inequality constraints + if ( size(Aeq,2) ~= nbVar & size(Aeq,2) ~= 0) then + errmsg = msprintf(gettext("%s: The size of equality constraint is not equal to the number of variables"), "Symphonymat"); + error(errmsg); + end + + //Check the size of upper bound of equality constraint which should equal to the number of constraints + if ( size(beq,1) ~= size(Aeq,1)) then + errmsg = msprintf(gettext("%s: The equality constraint upper bound is not equal to the number of equality constraint"), "Symphonymat"); + error(errmsg); + end + + //Check the size of Lower Bound which should 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"), "Symphonymat"); 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"); + //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"), "Symphonymat"); error(errmsg); end + if (type(options) ~= 15) then + errmsg = msprintf(gettext("%s: Options should be a list "), "Symphonymat"); + error(errmsg); + end + + + if (modulo(size(options),2)) then + errmsg = msprintf(gettext("%s: Size of parameters should be even"), "Symphonymat"); + 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]' ; + conLB = [repmat(-%inf,size(A,1),1); beq]; + conUB = [b;beq] ; isInt = repmat(%f,1,nbVar); for i=1:size(intcon,2) @@ -236,7 +296,13 @@ function [xopt,fopt,status,iter] = symphonymat (varargin) end objSense = 1; + + //Changing into row vector + lb = lb'; + ub = ub'; + objCoef = objCoef'; + [xopt,fopt,status,iter] = symphony_call(nbVar,nbCon,objCoef,isInt,lb,ub,conMatrix,conLB,conUB,objSense,options); endfunction -- cgit