-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]';
-lb = repmat(0,1,8);
+lb = repmat(0,8,1);
-ub = [repmat(1,1,4) repmat(%inf,1,4)];
+ub = [repmat(1,4,1);repmat(%inf,4,1)];
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]';
conMatrix = [
@@ -168,9 +168,9 @@ find the minimum or maximum of f(x) such that
nbCon = size(conMatrix,1)
nbVar = size(conMatrix,2)
-lb = repmat(0,1,nbVar)
+lb = repmat(0,nbVar,1)
-ub = repmat(1,1,nbVar)
+ub = repmat(1,nbVar,1)
isInt = repmat(%t,1,nbVar)
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
ub = repmat(1,1,nbVar)
-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
|