diff options
author | Harpreet | 2015-12-29 00:38:48 +0530 |
---|---|---|
committer | Harpreet | 2015-12-29 00:38:48 +0530 |
commit | eb9ca1191c94059cd7adcf69805906c809fe9712 (patch) | |
tree | f98e728341812b8a0eb46aa4159b062a22225f05 /macros | |
parent | 0eee95dfb1edec6ce52ec3065a3adb1bf169c9f9 (diff) | |
download | FOSSEE-Optimization-toolbox-eb9ca1191c94059cd7adcf69805906c809fe9712.tar.gz FOSSEE-Optimization-toolbox-eb9ca1191c94059cd7adcf69805906c809fe9712.tar.bz2 FOSSEE-Optimization-toolbox-eb9ca1191c94059cd7adcf69805906c809fe9712.zip |
Bugs fixed 4
Diffstat (limited to 'macros')
-rw-r--r-- | macros/lsqlin.bin | bin | 52024 -> 53548 bytes | |||
-rw-r--r-- | macros/lsqlin.sci | 108 | ||||
-rw-r--r-- | macros/lsqnonneg.bin | bin | 23608 -> 23840 bytes | |||
-rw-r--r-- | macros/lsqnonneg.sci | 42 | ||||
-rw-r--r-- | macros/qpipopt.bin | bin | 49616 -> 50496 bytes | |||
-rw-r--r-- | macros/qpipopt.sci | 170 | ||||
-rw-r--r-- | macros/qpipoptmat.bin | bin | 51240 -> 52464 bytes | |||
-rw-r--r-- | macros/qpipoptmat.sci | 75 | ||||
-rw-r--r-- | macros/symphony.bin | bin | 54820 -> 54340 bytes | |||
-rw-r--r-- | macros/symphony.sci | 195 | ||||
-rw-r--r-- | macros/symphonymat.bin | bin | 60724 -> 60108 bytes | |||
-rw-r--r-- | macros/symphonymat.sci | 215 |
12 files changed, 427 insertions, 378 deletions
diff --git a/macros/lsqlin.bin b/macros/lsqlin.bin Binary files differindex ce5d4a4..8c30789 100644 --- a/macros/lsqlin.bin +++ b/macros/lsqlin.bin diff --git a/macros/lsqlin.sci b/macros/lsqlin.sci index 08554e1..fba036d 100644 --- a/macros/lsqlin.sci +++ b/macros/lsqlin.sci @@ -22,22 +22,22 @@ function [xopt,resnorm,residual,exitflag,output,lambda] = lsqlin (varargin) // [xopt,resnorm,residual,exitflag,output,lambda] = lsqlin( ... ) // // Parameters - // C : a matrix of double, represents the multiplier of the solution x in the expression C*x - d. C is M-by-N, where M is the number of equations, and N is the number of elements of x. - // d : a vector of double, represents the additive constant term in the expression C*x - d. d is M-by-1, where M is the number of equations. + // C : a matrix of double, represents the multiplier of the solution x in the expression C*x - d. Number of columns in C is equal to the number of elements in x. + // d : a vector of double, represents the additive constant term in the expression C*x - d. Number of elements in d is equal to the number of rows in C matrix. // A : a vector of double, represents the linear coefficients in the inequality constraints // b : a vector of double, represents the linear coefficients in the inequality constraints // Aeq : a matrix of double, represents the linear coefficients in the equality constraints // beq : a vector of double, represents the linear coefficients in the equality constraints - // LB : a vector of double, contains lower bounds of the variables. - // UB : a vector of double, contains upper bounds of the variables. + // lb : a vector of double, contains lower bounds of the variables. + // ub : a vector of double, contains upper bounds of the variables. // x0 : a vector of double, contains initial guess of variables. // param : a list containing the the parameters to be set. // xopt : a vector of double, the computed solution of the optimization problem. // resnorm : a double, objective value returned as the scalar value norm(C*x-d)^2. // residual : a vector of double, solution residuals returned as the vector C*x-d. - // exitflag : Integer identifying the reason the algorithm terminated. - // output : Structure containing information about the optimization. Right now it contains number of iteration. - // lambda : Structure containing the Lagrange multipliers at the solution x (separated by constraint type).It contains lower, upper and linear equality, inequality constraints. + // exitflag : Integer identifying the reason the algorithm terminated. It could be 0, 1 or 2 etc. i.e. Optimal, Maximum Number of Iterations Exceeded, CPU time exceeded. Other flags one can see in the lsqlin macro. + // output : Structure containing information about the optimization. This version only contains number of iterations. + // lambda : Structure containing the Lagrange multipliers at the solution x (separated by constraint type).It contains lower, upper bound multiplier and linear equality, inequality constraints. // // Description // Search the minimum of a constrained linear least square problem specified by : @@ -45,14 +45,14 @@ function [xopt,resnorm,residual,exitflag,output,lambda] = lsqlin (varargin) // <latex> // \begin{eqnarray} // &\mbox{min}_{x} - // & 1/2||C*x - d||_2^2 \\ - // & \text{subject to} & A*x \leq b \\ - // & & Aeq*x = beq \\ + // & 1/2||C⋅x - d||_2^2 \\ + // & \text{subject to} & A⋅x \leq b \\ + // & & Aeq⋅x = beq \\ // & & lb \leq x \leq ub \\ // \end{eqnarray} // </latex> // - // We are calling IPOpt for solving the linear least square problem, IPOpt is a library written in C++. + // The routine calls Ipopt for solving the linear least square problem, Ipopt is a library written in C++. // // Examples // //A simple linear least square example @@ -76,7 +76,7 @@ function [xopt,resnorm,residual,exitflag,output,lambda] = lsqlin (varargin) // // Press ENTER to continue // // Examples - // //A basic example for equality, inequality and bounds + // //A basic example for equality, inequality constraints and variable bounds // C = [0.9501 0.7620 0.6153 0.4057 // 0.2311 0.4564 0.7919 0.9354 // 0.6068 0.0185 0.9218 0.9169 @@ -111,11 +111,22 @@ function [xopt,resnorm,residual,exitflag,output,lambda] = lsqlin (varargin) error(errmsg) end +// Initializing all the values to empty matrix + C=[]; + d=[]; + A=[]; + b=[]; + Aeq=[]; + beq=[]; + lb=[]; + ub=[]; + x0=[]; + C = varargin(1); d = varargin(2); A = varargin(3); b = varargin(4); - nbVar = size(C,2); + nbVar = size(C,2); if ( rhs<5 ) then Aeq = [] @@ -126,11 +137,11 @@ function [xopt,resnorm,residual,exitflag,output,lambda] = lsqlin (varargin) end if ( rhs<7 ) then - LB = repmat(-%inf,nbVar,1); - UB = repmat(%inf,nbVar,1); + lb = repmat(-%inf,nbVar,1); + ub = repmat(%inf,nbVar,1); else - LB = varargin(7); - UB = varargin(8); + lb = varargin(7); + ub = varargin(8); end @@ -146,12 +157,12 @@ function [xopt,resnorm,residual,exitflag,output,lambda] = lsqlin (varargin) param =varargin(10); end - if (size(LB,2)==0) then - LB = repmat(-%inf,nbVar,1); + if (size(lb,2)==0) then + lb = repmat(-%inf,nbVar,1); end - if (size(UB,2)==0) then - UB = repmat(%inf,nbVar,1); + if (size(ub,2)==0) then + ub = repmat(%inf,nbVar,1); end if (type(param) ~= 15) then @@ -193,12 +204,12 @@ function [xopt,resnorm,residual,exitflag,output,lambda] = lsqlin (varargin) d=d'; end - if (size(LB,2)== [nbVar]) then - LB = LB'; + if (size(lb,2)== [nbVar]) then + lb = lb'; end - if (size(UB,2)== [nbVar]) then - UB = UB'; + if (size(ub,2)== [nbVar]) then + ub = ub'; end if (size(b,2)==nbConInEq) then @@ -221,7 +232,7 @@ function [xopt,resnorm,residual,exitflag,output,lambda] = lsqlin (varargin) //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 number of columns in A must be the same as the number of elements of d"), "lsqlin"); + errmsg = msprintf(gettext("%s: The number of columns in A must be the same as the number of columns in C"), "lsqlin"); error(errmsg); end @@ -232,20 +243,20 @@ function [xopt,resnorm,residual,exitflag,output,lambda] = lsqlin (varargin) end //Check the size of Lower Bound which should be equal to the number of variables - if ( size(LB,1) ~= nbVar) then + if ( size(lb,1) ~= nbVar) then errmsg = msprintf(gettext("%s: The Lower Bound is not equal to the number of variables"), "lsqlin"); error(errmsg); end //Check the size of Upper Bound which should equal to the number of variables - if ( size(UB,1) ~= nbVar) then + if ( size(ub,1) ~= nbVar) then errmsg = msprintf(gettext("%s: The Upper Bound is not equal to the number of variables"), "lsqlin"); error(errmsg); end //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 number of rows in A must be the same as the number of elementsof b"), "lsqlin"); + errmsg = msprintf(gettext("%s: The number of rows in A must be the same as the number of elements of b"), "lsqlin"); error(errmsg); end @@ -259,6 +270,7 @@ function [xopt,resnorm,residual,exitflag,output,lambda] = lsqlin (varargin) if ( size(x0,1) ~= nbVar) then warnmsg = msprintf(gettext("%s: Ignoring initial guess of variables as it is not equal to the number of variables"), "lsqlin"); warning(warnmsg); + x0 = repmat(0,nbVar,1); end //Check if the user gives a matrix instead of a vector @@ -268,12 +280,12 @@ function [xopt,resnorm,residual,exitflag,output,lambda] = lsqlin (varargin) error(errmsg); end - if (size(LB,1)~=1)& (size(LB,2)~=1) then + if (size(lb,1)~=1)& (size(lb,2)~=1) then errmsg = msprintf(gettext("%s: Lower Bound should be a vector"), "lsqlin"); error(errmsg); end - if (size(UB,1)~=1)& (size(UB,2)~=1) then + if (size(ub,1)~=1)& (size(ub,2)~=1) then errmsg = msprintf(gettext("%s: Upper Bound should be a vector"), "lsqlin"); error(errmsg); end @@ -294,31 +306,31 @@ function [xopt,resnorm,residual,exitflag,output,lambda] = lsqlin (varargin) for i = 1:nbConInEq if (b(i) == -%inf) - errmsg = msprintf(gettext("%s: Value of b can not be negative infinity"), "qpipoptmat"); + errmsg = msprintf(gettext("%s: Value of b can not be negative infinity"), "lsqlin"); error(errmsg); end end for i = 1:nbConEq if (beq(i) == -%inf) - errmsg = msprintf(gettext("%s: Value of beq can not be negative infinity"), "qpipoptmat"); + errmsg = msprintf(gettext("%s: Value of beq can not be negative infinity"), "lsqlin"); error(errmsg); end end //Converting it into Quadratic Programming Problem - Q = C'*C; - p = [-C'*d]'; + H = C'*C; + f = [-C'*d]'; op_add = d'*d; - LB = LB'; - UB = UB'; + 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,Q,p,conMatrix,conLB,conUB,LB,UB,x0,options); + [xopt,fopt,status,iter,Zl,Zu,lmbda] = solveqp(nbVar,nbCon,H,f,conMatrix,conLB,conUB,lb,ub,x0,options); xopt = xopt'; residual = -1*(C*xopt-d); @@ -326,15 +338,15 @@ function [xopt,resnorm,residual,exitflag,output,lambda] = lsqlin (varargin) exitflag = status; output = struct("Iterations" , []); output.Iterations = iter; - lambda = struct("lower" , [], .. - "upper" , [], .. - "eqlin" , [], .. + lambda = struct("lower" , [], .. + "upper" , [], .. + "eqlin" , [], .. "ineqlin" , []); - - lambda.lower = Zl; - lambda.upper = Zu; - lambda.eqlin = lmbda(1:nbConEq); - lambda.ineqlin = lmbda(nbConEq+1:nbCon); + + lambda.lower = Zl; + lambda.upper = Zu; + lambda.eqlin = lmbda(1:nbConEq); + lambda.ineqlin = lmbda(nbConEq+1:nbCon); select status case 0 then @@ -362,11 +374,11 @@ function [xopt,resnorm,residual,exitflag,output,lambda] = lsqlin (varargin) case 12 then printf("\nProblem has too few degrees of freedom.\n"); case 13 then - printf("\nInvalid option thrown back by IPOpt\n"); + printf("\nInvalid option thrown back by Ipopt\n"); case 14 then printf("\nNot enough memory.\n"); case 15 then - printf("\nINTERNAL ERROR: Unknown SolverReturn value - Notify IPOPT Authors.\n"); + printf("\nINTERNAL ERROR: Unknown SolverReturn value - Notify Ipopt Authors.\n"); else printf("\nInvalid status returned. Notify the Toolbox authors\n"); break; diff --git a/macros/lsqnonneg.bin b/macros/lsqnonneg.bin Binary files differindex 84e307b..182cfa9 100644 --- a/macros/lsqnonneg.bin +++ b/macros/lsqnonneg.bin diff --git a/macros/lsqnonneg.sci b/macros/lsqnonneg.sci index b8694b4..5f6ffa2 100644 --- a/macros/lsqnonneg.sci +++ b/macros/lsqnonneg.sci @@ -19,14 +19,14 @@ function [xopt,resnorm,residual,exitflag,output,lambda] = lsqnonneg (varargin) // [xopt,resnorm,residual,exitflag,output,lambda] = lsqnonneg( ... ) // // Parameters - // C : a matrix of doubles, represents the multiplier of the solution x in the expression C*x - d. C is M-by-N, where M is the number of equations, and N is the number of elements of x. - // d : a vector of doubles, represents the additive constant term in the expression C*x - d. d is M-by-1, where M is the number of equations. - // xopt : a vector of doubles, the computed solution of the optimization problem. + // C : a matrix of double, represents the multiplier of the solution x in the expression C*x - d. Number of columns in C is equal to the number of elements in x. + // d : a vector of double, represents the additive constant term in the expression C*x - d. Number of elements in d is equal to the number of rows in C matrix. + // xopt : a vector of double, the computed solution of the optimization problem. // resnorm : a double, objective value returned as the scalar value norm(C*x-d)^2. - // residual : a vector of doubles, solution residuals returned as the vector C*x-d. - // exitflag : Integer identifying the reason the algorithm terminated. - // output : Structure containing information about the optimization. Right now it contains number of iteration. - // lambda : Structure containing the Lagrange multipliers at the solution x (separated by constraint type).It contains lower, upper and linear equality, inequality constraints. + // residual : a vector of double, solution residuals returned as the vector C*x-d. + // exitflag : Integer identifying the reason the algorithm terminated. It could be 0, 1 or 2 i.e. Optimal, Maximum Number of Iterations Exceeded, CPU time exceeded. + // output : Structure containing information about the optimization. This version only contains number of iterations. + // lambda : Structure containing the Lagrange multipliers at the solution x. It contains lower and upper bound multiplier. // // Description // Solves nonnegative least-squares curve fitting problems specified by : @@ -34,12 +34,12 @@ function [xopt,resnorm,residual,exitflag,output,lambda] = lsqnonneg (varargin) // <latex> // \begin{eqnarray} // &\mbox{min}_{x} - // & 1/2||C*x - d||_2^2 \\ + // & 1/2||C⋅x - d||_2^2 \\ // & & x \geq 0 \\ // \end{eqnarray} // </latex> // - // We are calling IPOpt for solving the nonnegative least-squares curve fitting problems, IPOpt is a library written in C++. + // The routine calls Ipopt for solving the nonnegative least-squares curve fitting problems, Ipopt is a library written in C++. // // Examples // // A basic lsqnonneg problem @@ -63,7 +63,7 @@ function [xopt,resnorm,residual,exitflag,output,lambda] = lsqnonneg (varargin) //To check the number of argument given by user if ( rhs < 2 | rhs > 3 ) then - errmsg = msprintf(gettext("%s: Unexpected number of input arguments : %d provided while should be in the set of [2 3]"), "lsqlin", rhs); + errmsg = msprintf(gettext("%s: Unexpected number of input arguments : %d provided while should be in the set of [2 3]"), "lsqnonneg", rhs); error(errmsg) end @@ -73,21 +73,21 @@ function [xopt,resnorm,residual,exitflag,output,lambda] = lsqnonneg (varargin) if ( rhs<3 | size(varargin(3)) ==0 ) then param = list(); else - param =varargin(10); + param =varargin(3); end if (type(param) ~= 15) then - errmsg = msprintf(gettext("%s: param should be a list "), "lsqlin"); + errmsg = msprintf(gettext("%s: param should be a list "), "lsqnonneg"); error(errmsg); end if (modulo(size(param),2)) then - errmsg = msprintf(gettext("%s: Size of parameters should be even"), "lsqlin"); + errmsg = msprintf(gettext("%s: Size of parameters should be even"), "lsqnonneg"); error(errmsg); end - options = list( "MaxIter" , [3000], ... + options = list( "MaxIter" , [3000], ... "CpuTime" , [600] ... ); @@ -99,7 +99,7 @@ function [xopt,resnorm,residual,exitflag,output,lambda] = lsqnonneg (varargin) case "CpuTime" then options(2*i) = param(2*i); else - errmsg = msprintf(gettext("%s: Unrecognized parameter name ''%s''."), "lsqlin", param(2*i-1)); + errmsg = msprintf(gettext("%s: Unrecognized parameter name ''%s''."), "lsqnonneg", param(2*i-1)); error(errmsg) end end @@ -114,7 +114,7 @@ function [xopt,resnorm,residual,exitflag,output,lambda] = lsqnonneg (varargin) //Check the size of f which should equal to the number of variable if ( size(d,1) ~= size(C,1)) then - errmsg = msprintf(gettext("%s: The number of rows in C must be equal the number of elements of d"), "lsqlin"); + errmsg = msprintf(gettext("%s: The number of rows in C must be equal the number of elements of d"), "lsqnonneg"); error(errmsg); end @@ -123,14 +123,14 @@ function [xopt,resnorm,residual,exitflag,output,lambda] = lsqnonneg (varargin) Q = C'*C; p = [-C'*d]'; op_add = d'*d; - LB = repmat(0,1,nbVar); - UB = repmat(%inf,1,nbVar); + lb = repmat(0,1,nbVar); + ub = repmat(%inf,1,nbVar); x0 = repmat(0,1,nbVar);; conMatrix = []; nbCon = size(conMatrix,1); conLB = []; conUB = [] ; - [xopt,fopt,status,iter,Zl,Zu,lmbda] = solveqp(nbVar,nbCon,Q,p,conMatrix,conLB,conUB,LB,UB,x0,options); + [xopt,fopt,status,iter,Zl,Zu,lmbda] = solveqp(nbVar,nbCon,Q,p,conMatrix,conLB,conUB,lb,ub,x0,options); xopt = xopt'; residual = -1*(C*xopt-d); @@ -170,11 +170,11 @@ function [xopt,resnorm,residual,exitflag,output,lambda] = lsqnonneg (varargin) case 12 then printf("\nProblem has too few degrees of freedom.\n"); case 13 then - printf("\nInvalid option thrown back by IPOpt\n"); + printf("\nInvalid option thrown back by Ipopt\n"); case 14 then printf("\nNot enough memory.\n"); case 15 then - printf("\nINTERNAL ERROR: Unknown SolverReturn value - Notify IPOPT Authors.\n"); + printf("\nINTERNAL ERROR: Unknown SolverReturn value - Notify Ipopt Authors.\n"); else printf("\nInvalid status returned. Notify the Toolbox authors\n"); break; diff --git a/macros/qpipopt.bin b/macros/qpipopt.bin Binary files differindex f4b14b9..4a407c4 100644 --- a/macros/qpipopt.bin +++ b/macros/qpipopt.bin diff --git a/macros/qpipopt.sci b/macros/qpipopt.sci index 6a53693..ed531e1 100644 --- a/macros/qpipopt.sci +++ b/macros/qpipopt.sci @@ -14,27 +14,27 @@ 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 = qpipopt(nbVar,nbCon,H,f,lb,ub,A,conLB,conUB) + // xopt = qpipopt(nbVar,nbCon,H,f,lb,ub,A,conLB,conUB,x0) + // xopt = qpipopt(nbVar,nbCon,H,f,lb,ub,A,conLB,conUB,x0,param) // [xopt,fopt,exitflag,output,lamda] = qpipopt( ... ) // // Parameters // nbVar : a double, number of variables // nbCon : a double, number of constraints - // Q : a symmetric matrix of double, represents coefficients of quadratic in the quadratic problem. - // p : a vector of double, represents coefficients of linear in the quadratic problem - // LB : a vector of double, contains lower bounds of the variables. - // UB : a vector of double, contains upper bounds of the variables. - // conMatrix : a matrix of double, contains matrix representing the constraint matrix + // H : a symmetric matrix of double, represents coefficients of quadratic in the quadratic problem. + // f : a vector of double, represents coefficients of linear in the quadratic problem + // lb : a vector of double, contains lower bounds of the variables. + // ub : a vector of double, contains upper bounds of the variables. + // A : a matrix of double, contains matrix representing the constraint matrix // conLB : a vector of double, contains lower bounds of the constraints. // conUB : a vector of double, contains upper bounds of the constraints. // x0 : a vector of double, contains initial guess of variables. // param : a list containing the the parameters to be set. // xopt : a vector of double, 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. Right now it contains number of iteration. + // exitflag : Integer identifying the reason the algorithm terminated. It could be 0, 1 or 2 etc. i.e. Optimal, Maximum Number of Iterations Exceeded, CPU time exceeded. Other flags one can see in the qpipopt macro. + // output : Structure containing information about the optimization. This version only contains number of iterations // lambda : Structure containing the Lagrange multipliers at the solution x (separated by constraint type).It contains lower, upper and linear equality, inequality constraints. // // Description @@ -44,32 +44,32 @@ function [xopt,fopt,exitflag,output,lambda] = qpipopt (varargin) // <latex> // \begin{eqnarray} // &\mbox{min}_{x} - // & 1/2*x'*Q*x + p'*x \\ - // & \text{subject to} & conLB \leq C(x) \leq conUB \\ + // & 1/2⋅x^T⋅H⋅x + f^T⋅x \\ + // & \text{subject to} & conLB \leq A⋅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 routine calls Ipopt for solving the quadratic problem, Ipopt is a library written in C++. // // 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]; + // A= [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); + // //and minimize 0.5*x'⋅H⋅x + f'⋅x with + // f=[1; 2; 3; 4; 5; 6]; H=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) + // [xopt,fopt,exitflag,output,lambda]=qpipopt(nbVar,nbCon,H,f,lb,ub,A,conLB,conUB,x0,param) // // Press ENTER to continue // // Examples @@ -80,16 +80,16 @@ function [xopt,fopt,exitflag,output,lambda] = qpipopt (varargin) // // –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]; + // H = [1 -1; -1 2]; + // f = [-2; -6]; + // A = [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) + // [xopt,fopt,exitflag,output,lambda] = qpipopt(nbVar,nbCon,H,f,lb,ub,A,conLB,conUB) // Authors // Keyur Joshi, Saikiran, Iswarya, Harpreet Singh @@ -103,35 +103,43 @@ function [xopt,fopt,exitflag,output,lambda] = qpipopt (varargin) error(errmsg) end + nbVar = []; + nbCon = []; + H = []; + f = []; + A = []; + conLB = []; + conUB = []; + lb = []; + ub = []; - 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); + nbVar = varargin(1); + nbCon = varargin(2); + H = varargin(3); + f = varargin(4); + lb = varargin(5); + ub = varargin(6); + A = varargin(7); + conLB = varargin(8); + conUB = varargin(9); - if (size(LB,2)==0) then - LB = repmat(-%inf,nbVar,1); + if (size(lb,2)==0) then + lb = repmat(-%inf,nbVar,1); end - if (size(UB,2)==0) then - UB = repmat(%inf,nbVar,1); + if (size(ub,2)==0) then + ub = repmat(%inf,nbVar,1); end - if (size(p,2)==0) then - p = repmat(0,nbVar,1); + if (size(f,2)==0) then + f = repmat(0,nbVar,1); end - - if ( rhs<10 | size(varargin(10)) ==0 ) then - x0 = repmat(0,nbVar,1); - else - x0 = varargin(10); - end + if ( rhs<10 | size(varargin(10)) ==0 ) then + x0 = repmat(0,nbVar,1); + else + x0 = varargin(10); + end if ( rhs<11 | size(varargin(11)) ==0 ) then param = list(); @@ -144,11 +152,10 @@ function [xopt,fopt,exitflag,output,lambda] = qpipopt (varargin) error(errmsg); end - if (modulo(size(param),2)) then - errmsg = msprintf(gettext("%s: Size of parameters should be even"), "qpipopt"); - error(errmsg); - 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], ... @@ -171,16 +178,16 @@ function [xopt,fopt,exitflag,output,lambda] = qpipopt (varargin) // 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(f,2)== [nbVar]) then + f=f'; + end - if (size(LB,2)== [nbVar]) then - LB = LB'; - end + if (size(lb,2)== [nbVar]) then + lb = lb'; + end - if (size(UB,2)== [nbVar]) then - UB = UB'; + if (size(ub,2)== [nbVar]) then + ub = ub'; end if (size(conUB,2)== [nbCon]) then @@ -196,53 +203,53 @@ function [xopt,fopt,exitflag,output,lambda] = qpipopt (varargin) end //IPOpt wants it in row matrix form - p = p'; - LB = LB'; - UB = UB'; + f = f'; + 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"); + //Checking the H matrix which needs to be a symmetric matrix + if ( ~isequal(H,H') ) then + errmsg = msprintf(gettext("%s: H 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"); + //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"); 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"); + if ( size(f,2) ~= [nbVar]) then + errmsg = msprintf(gettext("%s: The Size of f is not equal to the number of variables"), "qpipopt"); error(errmsg); end if (nbCon) then //Check the size of constraint which should equal to the number of variables - if ( size(conMatrix,2) ~= nbVar) then + if ( size(A,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 + if ( size(A,1) ~= nbCon) then errmsg = msprintf(gettext("%s: The size of constraint matrix is not equal to the number of constraint given i.e. %d"), "qpipopt", nbCon); error(errmsg); end //Check the size of Lower Bound which should equal to the number of variables - if ( size(LB,2) ~= nbVar) then + if ( size(lb,2) ~= nbVar) then errmsg = msprintf(gettext("%s: The size of 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 + if ( size(ub,2) ~= nbVar) then errmsg = msprintf(gettext("%s: The size of Upper Bound is not equal to the number of variables"), "qpipopt"); error(errmsg); end @@ -263,21 +270,22 @@ function [xopt,fopt,exitflag,output,lambda] = qpipopt (varargin) if ( size(x0,2) ~= nbVar | size(x0,"*")>nbVar) then warnmsg = msprintf(gettext("%s: Ignoring initial guess of variables as it is not equal to the number of variables"), "qpipopt"); warning(warnmsg); + x0 = repmat(0,1,nbVar); end //Check if the user gives a matrix instead of a vector - if ((size(p,1)~=1)& (size(p,2)~=1)) then - errmsg = msprintf(gettext("%s: p should be a vector"), "qpipopt"); + if ((size(f,1)~=1)& (size(f,2)~=1)) then + errmsg = msprintf(gettext("%s: f should be a vector"), "qpipopt"); error(errmsg); end - if (size(LB,1)~=1)& (size(LB,2)~=1) then + if (size(lb,1)~=1)& (size(lb,2)~=1) then errmsg = msprintf(gettext("%s: Lower Bound should be a vector"), "qpipopt"); error(errmsg); end - if (size(UB,1)~=1)& (size(UB,2)~=1) then + if (size(ub,1)~=1)& (size(ub,2)~=1) then errmsg = msprintf(gettext("%s: Upper Bound should be a vector"), "qpipopt"); error(errmsg); end @@ -307,7 +315,7 @@ function [xopt,fopt,exitflag,output,lambda] = qpipopt (varargin) end end - [xopt,fopt,status,iter,Zl,Zu,lmbda] = solveqp(nbVar,nbCon,Q,p,conMatrix,conLB,conUB,LB,UB,x0,options); + [xopt,fopt,status,iter,Zl,Zu,lmbda] = solveqp(nbVar,nbCon,H,f,A,conLB,conUB,lb,ub,x0,options); xopt = xopt'; exitflag = status; @@ -348,11 +356,11 @@ function [xopt,fopt,exitflag,output,lambda] = qpipopt (varargin) case 12 then printf("\nProblem has too few degrees of freedom.\n"); case 13 then - printf("\nInvalid option thrown back by IPOpt\n"); + printf("\nInvalid option thrown back by Ipopt\n"); case 14 then printf("\nNot enough memory.\n"); case 15 then - printf("\nINTERNAL ERROR: Unknown SolverReturn value - Notify IPOPT Authors.\n"); + printf("\nINTERNAL ERROR: Unknown SolverReturn value - Notify Ipopt Authors.\n"); else printf("\nInvalid status returned. Notify the Toolbox authors\n"); break; diff --git a/macros/qpipoptmat.bin b/macros/qpipoptmat.bin Binary files differindex 89ce559..35142ae 100644 --- a/macros/qpipoptmat.bin +++ b/macros/qpipoptmat.bin diff --git a/macros/qpipoptmat.sci b/macros/qpipoptmat.sci index e9ed9a5..8e9c67e 100644 --- a/macros/qpipoptmat.sci +++ b/macros/qpipoptmat.sci @@ -29,14 +29,14 @@ function [xopt,fopt,exitflag,output,lambda] = qpipoptmat (varargin) // b : a vector of double, represents the linear coefficients in the inequality constraints // Aeq : a matrix of double, represents the linear coefficients in the equality constraints // beq : a vector of double, represents the linear coefficients in the equality constraints - // LB : a vector of double, contains lower bounds of the variables. - // UB : a vector of double, contains upper bounds of the variables. + // lb : a vector of double, contains lower bounds of the variables. + // ub : a vector of double, contains upper bounds of the variables. // x0 : a vector of double, contains initial guess of variables. // param : a list containing the the parameters to be set. // xopt : a vector of double, 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. Right now it contains number of iteration. + // exitflag : Integer identifying the reason the algorithm terminated.It could be 0, 1 or 2 etc. i.e. Optimal, Maximum Number of Iterations Exceeded, CPU time exceeded. Other flags one can see in the qpipoptmat macro. + // output : Structure containing information about the optimization. This version only contains number of iterations. // lambda : Structure containing the Lagrange multipliers at the solution x (separated by constraint type).It contains lower, upper and linear equality, inequality constraints. // // Description @@ -46,14 +46,14 @@ function [xopt,fopt,exitflag,output,lambda] = qpipoptmat (varargin) // <latex> // \begin{eqnarray} // &\mbox{min}_{x} - // & 1/2*x'*H*x + f'*x \\ - // & \text{subject to} & A*x \leq b \\ - // & & Aeq*x = beq \\ + // & 1/2⋅x^T⋅H⋅x + f^T⋅x \\ + // & \text{subject to} & A⋅x \leq b \\ + // & & Aeq⋅x = beq \\ // & & 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 routine calls Ipopt for solving the quadratic problem, Ipopt is a library written in C++. // // Examples // //Find the value of x that minimize following function @@ -101,9 +101,18 @@ function [xopt,fopt,exitflag,output,lambda] = qpipoptmat (varargin) error(errmsg) end - H = varargin(1); - f = varargin(2); - nbVar = size(H,1); + H = []; + f = []; + A = []; + b = []; + Aeq = []; + beq = []; + lb = []; + ub = []; + + H = varargin(1); + f = varargin(2); + nbVar = size(H,1); if ( rhs<3 ) then @@ -123,11 +132,11 @@ function [xopt,fopt,exitflag,output,lambda] = qpipoptmat (varargin) end if ( rhs<7 ) then - LB = repmat(-%inf,nbVar,1); - UB = repmat(%inf,nbVar,1); + lb = repmat(-%inf,nbVar,1); + ub = repmat(%inf,nbVar,1); else - LB = varargin(7); - UB = varargin(8); + lb = varargin(7); + ub = varargin(8); end @@ -143,12 +152,12 @@ function [xopt,fopt,exitflag,output,lambda] = qpipoptmat (varargin) param =varargin(10); end - if (size(LB,2)==0) then - LB = repmat(-%inf,nbVar,1); + if (size(lb,2)==0) then + lb = repmat(-%inf,nbVar,1); end - if (size(UB,2)==0) then - UB = repmat(%inf,nbVar,1); + if (size(ub,2)==0) then + ub = repmat(%inf,nbVar,1); end if (size(f,2)==0) then @@ -195,12 +204,12 @@ function [xopt,fopt,exitflag,output,lambda] = qpipoptmat (varargin) f=f'; end - if (size(LB,2)== [nbVar]) then - LB = LB'; + if (size(lb,2)== [nbVar]) then + lb = lb'; end - if (size(UB,2)== [nbVar]) then - UB = UB'; + if (size(ub,2)== [nbVar]) then + ub = ub'; end if (size(b,2)==nbConInEq) then @@ -228,7 +237,6 @@ function [xopt,fopt,exitflag,output,lambda] = qpipoptmat (varargin) 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 number of columns in A must be the same as the number of elements of f"), "qpipoptmat"); @@ -243,13 +251,13 @@ function [xopt,fopt,exitflag,output,lambda] = qpipoptmat (varargin) //Check the size of Lower Bound which should be equal to the number of variables - if ( size(LB,1) ~= nbVar) then + if ( size(lb,1) ~= nbVar) then 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 - if ( size(UB,1) ~= nbVar) then + 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 @@ -270,6 +278,7 @@ function [xopt,fopt,exitflag,output,lambda] = qpipoptmat (varargin) if ( size(x0,1) ~= nbVar) then warnmsg = msprintf(gettext("%s: Ignoring initial guess of variables as it is not equal to the number of variables"), "qpipoptmat"); warning(warnmsg); + x0 = repmat(0,nbVar,1); end //Check if the user gives a matrix instead of a vector @@ -279,12 +288,12 @@ function [xopt,fopt,exitflag,output,lambda] = qpipoptmat (varargin) error(errmsg); end - if (size(LB,1)~=1)& (size(LB,2)~=1) then + if (size(lb,1)~=1)& (size(ub,2)~=1) then errmsg = msprintf(gettext("%s: Lower Bound should be a vector"), "qpipoptmat"); error(errmsg); end - if (size(UB,1)~=1)& (size(UB,2)~=1) then + if (size(ub,1)~=1)& (size(ub,2)~=1) then errmsg = msprintf(gettext("%s: Upper Bound should be a vector"), "qpipoptmat"); error(errmsg); end @@ -319,14 +328,14 @@ function [xopt,fopt,exitflag,output,lambda] = qpipoptmat (varargin) //Converting it into ipopt format f = f'; - LB = LB'; - UB = UB'; + 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,x0,options); + [xopt,fopt,status,iter,Zl,Zu,lmbda] = solveqp(nbVar,nbCon,H,f,conMatrix,conLB,conUB,lb,ub,x0,options); xopt = xopt'; exitflag = status; @@ -369,11 +378,11 @@ function [xopt,fopt,exitflag,output,lambda] = qpipoptmat (varargin) case 12 then printf("\nProblem has too few degrees of freedom.\n"); case 13 then - printf("\nInvalid option thrown back by IPOpt\n"); + printf("\nInvalid option thrown back by Ipopt\n"); case 14 then printf("\nNot enough memory.\n"); case 15 then - printf("\nINTERNAL ERROR: Unknown SolverReturn value - Notify IPOPT Authors.\n"); + printf("\nINTERNAL ERROR: Unknown SolverReturn value - Notify Ipopt Authors.\n"); else printf("\nInvalid status returned. Notify the Toolbox authors\n"); break; diff --git a/macros/symphony.bin b/macros/symphony.bin Binary files differindex 562f5cc..9217660 100644 --- a/macros/symphony.bin +++ b/macros/symphony.bin diff --git a/macros/symphony.sci b/macros/symphony.sci index cc05dcd..264a513 100644 --- a/macros/symphony.sci +++ b/macros/symphony.sci @@ -13,27 +13,27 @@ 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 = symphony(nbVar,nbCon,c,isInt,lb,ub,A,conLB,conUB) + // xopt = symphony(nbVar,nbCon,c,isInt,lb,ub,A,conLB,conUB,objSense) + // xopt = symphony(nbVar,nbCon,c,isInt,lb,ub,A,conLB,conUB,objSense,options) // [xopt,fopt,status,output] = symphony( ... ) // // Parameters // nbVar : a double, number of variables. // nbCon : a double, number of constraints. - // objCoeff : a vector of double, represents coefficients of the variables in the objective. + // c : a vector of double, 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 double, represents lower bounds of the variables. - // UB : a vector of double, represents upper bounds of the variables. - // conMatrix : a matrix of double, represents matrix representing the constraint matrix. + // lb : a vector of double, represents lower bounds of the variables. + // ub : a vector of double, represents upper bounds of the variables. + // A : a matrix of double, represents matrix representing the constraint matrix. // conLB : a vector of double, represents lower bounds of the constraints. // conUB : a vector of double, 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. + // options : a list containing the the parameters to be set. // xopt : a vector of double, 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. Right now it contains number of iteration. + // status : status flag from symphony. 227 is optimal, 228 is Time limit exceeded, 230 is iteration limit exceeded. + // output : The output data structure contains detailed information about the optimization process. This version only contains number of iterations // // Description // Search the minimum or maximum of a constrained mixed integer linear programming optimization problem specified by : @@ -42,37 +42,37 @@ function [xopt,fopt,status,output] = symphony (varargin) // <latex> // \begin{eqnarray} // &\mbox{min}_{x} - // & f^T*x \\ - // & \text{subject to} & conLB \leq C*x \leq conUB \\ + // & f^T⋅x \\ + // & \text{subject to} & conLB \leq A⋅x \leq conUB \\ // & & lb \leq x \leq ub \\ // & & x_i \in \!\, \mathbb{Z}, i \in \!\, I // \end{eqnarray} // </latex> // - // We are calling SYMPHONY written in C by gateway files for the actual computation. + // The routine calls SYMPHONY written in C by gateway files for the actual computation. // // Examples // //A basic case : // // Objective function - // objCoef = [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,8,1); // // Upper Bound of variables // 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; - // 5*0.03,3*0.03,4*0.04,6*0.04,0.06,0.07,0.08,0.09;] - // // Lower Bound of constrains + // A = [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 constraints // conlb = [ 25; 1.25; 1.25] - // // Upper Bound of constrains + // // Upper Bound of constraints // 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) + // [x,f,status,output] = symphony(8,3,c,isInt,lb,ub,A,conlb,conub,1) // // Press ENTER to continue // // Examples @@ -86,7 +86,7 @@ function [xopt,fopt,status,output] = symphony (varargin) // // 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 .. + // c = [ 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 .. @@ -94,57 +94,57 @@ function [xopt,fopt,status,output] = symphony (varargin) // 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) + // A = [ + // //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(A,1) + // nbVar = size(A,2) // // Lower Bound of variables // lb = repmat(0,nbVar,1) // // Upper Bound of variables // 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 + // // Lower Bound of constraints // conLB=repmat(0,nbCon,1); // // Upper Bound of constraints // conUB=[11927 13727 11551 13056 13460 ]'; @@ -157,7 +157,7 @@ function [xopt,fopt,status,output] = symphony (varargin) // // Optimal value // fopt = [ 24381 ] // // Calling Symphony - // [x,f,status,output] = symphony(nbVar,nbCon,p,isInt,lb,ub,conMatrix,conLB,conUB,-1,options); + // [x,f,status,output] = symphony(nbVar,nbCon,c,isInt,lb,ub,A,conLB,conUB,-1,options); // Authors // Keyur Joshi, Saikiran, Iswarya, Harpreet Singh @@ -170,15 +170,26 @@ function [xopt,fopt,status,output] = symphony (varargin) 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); +// Initializing all the variables to empty matrix + nbVar = []; + nbCon = []; + c = []; + isInt = []; + lb = []; + ub = []; + A = []; + conLB = []; + conUB = []; + + nbVar = varargin(1); + nbCon = varargin(2); + c = varargin(3); + isInt = varargin(4); + lb = varargin(5); + ub = varargin(6); + A = varargin(7); + conLB = varargin(8); + conUB = varargin(9); if ( rhs<10 ) then objSense = 1; @@ -199,12 +210,12 @@ function [xopt,fopt,status,output] = symphony (varargin) isInt = isInt'; end - if (size(LB,2)== [nbVar]) then - LB = LB'; + if (size(lb,2)== [nbVar]) then + lb = lb'; end - if (size(UB,2)== [nbVar]) then - UB = UB'; + if (size(ub,2)== [nbVar]) then + ub = ub'; end if (size(conLB,2)== [nbCon]) then @@ -216,12 +227,12 @@ function [xopt,fopt,status,output] = symphony (varargin) end - if (size(objCoef,2)~=1) then + if (size(c,2)~=1) then errmsg = msprintf(gettext("%s: Objective Coefficients should be a column matrix"), "Symphony"); error(errmsg); end - if (size(objCoef,1)~=nbVar) then + if (size(c,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 @@ -245,25 +256,25 @@ function [xopt,fopt,status,output] = symphony (varargin) end //Check the row of constraint which should equal to the number of constraints - if ( size(conMatrix,1) ~= nbCon) then + if ( size(A,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 column of constraint which should equal to the number of variables - if ( size(conMatrix,2) ~= nbVar) then + if ( size(A,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 Lower Bound which should equal to the number of variables - if ( size(LB,1) ~= nbVar) then + 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 + 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 @@ -285,12 +296,12 @@ function [xopt,fopt,status,output] = symphony (varargin) error(errmsg); end - if (size(LB,1)~=1)& (size(LB,2)~=1) then + if (size(lb,1)~=1)& (size(lb,2)~=1) then errmsg = msprintf(gettext("%s: Lower Bound should be a vector"), "qpipopt"); error(errmsg); end - if (size(UB,1)~=1)& (size(UB,2)~=1) then + if (size(ub,1)~=1)& (size(ub,2)~=1) then errmsg = msprintf(gettext("%s: Upper Bound should be a vector"), "qpipopt"); error(errmsg); end @@ -308,11 +319,11 @@ function [xopt,fopt,status,output] = symphony (varargin) end - LB = LB'; - UB = UB'; + lb = lb'; + ub = ub'; isInt = isInt'; - objCoef = objCoef'; + c = c'; - [xopt,fopt,status,output] = symphony_call(nbVar,nbCon,objCoef,isInt,LB,UB,conMatrix,conLB,conUB,objSense,options); + [xopt,fopt,status,output] = symphony_call(nbVar,nbCon,c,isInt,lb,ub,A,conLB,conUB,objSense,options); endfunction diff --git a/macros/symphonymat.bin b/macros/symphonymat.bin Binary files differindex c6d4fbc..0841d41 100644 --- a/macros/symphonymat.bin +++ b/macros/symphonymat.bin diff --git a/macros/symphonymat.sci b/macros/symphonymat.sci index 9226bd6..2c0c18d 100644 --- a/macros/symphonymat.sci +++ b/macros/symphonymat.sci @@ -13,47 +13,47 @@ function [xopt,fopt,status,iter] = symphonymat (varargin) // Solves a mixed integer linear programming constrained optimization problem in intlinprog format. // // Calling Sequence - // xopt = symphonymat(C,intcon,A,b) - // xopt = symphonymat(C,intcon,A,b,Aeq,beq) - // xopt = symphonymat(C,intcon,A,b,Aeq,beq,lb,ub) - // xopt = symphonymat(C,intcon,A,b,Aeq,beq,lb,ub,options) + // xopt = symphonymat(c,intcon,A,b) + // xopt = symphonymat(c,intcon,A,b,Aeq,beq) + // xopt = symphonymat(c,intcon,A,b,Aeq,beq,lb,ub) + // xopt = symphonymat(c,intcon,A,b,Aeq,beq,lb,ub,options) // [xopt,fopt,status,output] = symphonymat( ... ) // // Parameters - // f : a vector of double, contains coefficients of the variables in the objective + // c : a vector of double, 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 double. 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 double. 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 double. 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 double. beq represents the constant vector in the constraints Aeq*x = beq. beq has length Meq, where Aeq is Meq-by-N. + // A : Linear inequality constraint matrix, specified as a matrix of double. A represents the linear coefficients in the constraints A*x ≤ b. A has the size where columns equals to the number of variables. + // b : Linear inequality constraint vector, specified as a vector of double. b represents the constant vector in the constraints A*x ≤ b. b has size equals to the number of rows in A. + // Aeq : Linear equality constraint matrix, specified as a matrix of double. Aeq represents the linear coefficients in the constraints Aeq*x = beq. Aeq has the size where columns equals to the number of variables. + // beq : Linear equality constraint vector, specified as a vector of double. beq represents the constant vector in the constraints Aeq*x = beq. beq has size equals to the number of rows in Aeq. // lb : Lower bounds, specified as a vector or array of double. lb represents the lower bounds elementwise in lb ≤ x ≤ ub. // ub : Upper bounds, specified as a vector or array of double. ub represents the upper bounds elementwise in lb ≤ x ≤ ub. // options : a list containing the the parameters to be set. - // xopt : a vector of double, the computed solution of the optimization problem + // xopt : a vector of double, 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. Right now it contains number of iteration. + // status : status flag from symphony. 227 is optimal, 228 is Time limit exceeded, 230 is iteration limit exceeded. + // output : The output data structure contains detailed information about the optimization process. This version only contains number of iterations. // // 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 + // find the minimum or maximum of C'⋅x such that // // <latex> // \begin{eqnarray} // &\mbox{min}_{x} - // & C^T*x \\ - // & \text{subject to} & A*x \leq b \\ - // & & Aeq*x = beq \\ + // & C^T⋅x \\ + // & \text{subject to} & A⋅x \leq b \\ + // & & Aeq⋅x = beq \\ // & & lb \leq x \leq ub \\ // & & x_i \in \!\, \mathbb{Z}, i \in \!\, I // \end{eqnarray} // </latex> // - // We are calling SYMPHONY written in C by gateway files for the actual computation. + // The routine calls SYMPHONY written in C by gateway files for the actual computation. // // 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 @@ -79,7 +79,7 @@ function [xopt,fopt,status,iter] = symphonymat (varargin) // // 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) - // C = -1*[ 504 803 667 1103 834 585 811 856 690 832 846 813 868 793 .. + // c = -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 .. @@ -88,47 +88,47 @@ function [xopt,fopt,status,iter] = symphonymat (varargin) // 1162 653 814 625 599 476 767 954 906 904 649 873 565 853 1008 632]'; // //Constraint Matrix // A = [ //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 ; + // 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,1) + // nbVar = size(c,1) // b=[11927 13727 11551 13056 13460 ]; // // Lower Bound of variables // lb = repmat(0,1,nbVar) @@ -148,7 +148,7 @@ function [xopt,fopt,status,iter] = symphonymat (varargin) // // Optimal value // fopt = [ 24381 ] // // Calling Symphony - // [x,f,status,output] = symphonymat(C,intcon,A,b,[],[],lb,ub,options); + // [x,f,status,output] = symphonymat(c,intcon,A,b,[],[],lb,ub,options); // Authors // Keyur Joshi, Saikiran, Iswarya, Harpreet Singh @@ -157,24 +157,33 @@ function [xopt,fopt,status,iter] = symphonymat (varargin) [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 - + 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) + c = []; + intcon = []; + A = []; + b = []; + Aeq = []; + beq = []; + lb = []; + ub = []; + + + c = varargin(1) + intcon = varargin(2) + A = varargin(3) + b = varargin(4) - if (size(objCoef,2)~=1) then + if (size(c,2)~=1) then errmsg = msprintf(gettext("%s: Objective Coefficients should be a column matrix"), "Symphonymat"); error(errmsg); end - nbVar = size(objCoef,1); + nbVar = size(c,1); if ( rhs<5 ) then Aeq = [] @@ -218,25 +227,25 @@ function [xopt,fopt,status,iter] = symphonymat (varargin) // 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(lb,2)== [nbVar]) then + lb = lb'; + end - if (size(ub,2)== [nbVar]) then - ub = ub'; - end + if (size(ub,2)== [nbVar]) then + ub = ub'; + end - if (size(b,2)== [nbConInEq]) then - b = b'; - end + if (size(b,2)== [nbConInEq]) then + b = b'; + end - if (size(beq,2)== [nbConEq]) then - beq = beq'; - 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"); + errmsg = msprintf(gettext("%s: The values inside intcon should be less than the number of variables"), "Symphonymat"); error(errmsg); end @@ -246,35 +255,35 @@ function [xopt,fopt,status,iter] = symphonymat (varargin) end if(modulo(intcon(i),1)) then - errmsg = msprintf(gettext("%s: The values inside intcon should be integer "), "Symphonymat"); + errmsg = msprintf(gettext("%s: The values inside intcon should be an 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 + 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 + 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 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 + 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 + 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 @@ -349,9 +358,9 @@ function [xopt,fopt,status,iter] = symphonymat (varargin) //Changing into row vector lb = lb'; ub = ub'; - objCoef = objCoef'; + c = c'; - [xopt,fopt,status,iter] = symphony_call(nbVar,nbCon,objCoef,isInt,lb,ub,conMatrix,conLB,conUB,objSense,options); + [xopt,fopt,status,iter] = symphony_call(nbVar,nbCon,c,isInt,lb,ub,conMatrix,conLB,conUB,objSense,options); endfunction |