summaryrefslogtreecommitdiff
path: root/macros
diff options
context:
space:
mode:
authorHarpreet2015-11-24 11:50:13 +0530
committerHarpreet2015-11-24 11:50:13 +0530
commit92e88ea2600cc66ff8e8b7bb9c63bf72d78f1619 (patch)
treee4ae42f00de606e65ec3e6acb7fc7ce3366e2209 /macros
parent5d6df2fd95bc566d3b9efab874ad26c4a4789b71 (diff)
downloadFOSSEE-Optimization-toolbox-92e88ea2600cc66ff8e8b7bb9c63bf72d78f1619.tar.gz
FOSSEE-Optimization-toolbox-92e88ea2600cc66ff8e8b7bb9c63bf72d78f1619.tar.bz2
FOSSEE-Optimization-toolbox-92e88ea2600cc66ff8e8b7bb9c63bf72d78f1619.zip
code optimization
Diffstat (limited to 'macros')
-rw-r--r--macros/qpipopt.sci22
-rw-r--r--macros/qpipoptmat.sci25
2 files changed, 38 insertions, 9 deletions
diff --git a/macros/qpipopt.sci b/macros/qpipopt.sci
index c17371e..e25aad9 100644
--- a/macros/qpipopt.sci
+++ b/macros/qpipopt.sci
@@ -121,6 +121,11 @@ function [xopt,fopt,exitflag,output,lambda] = qpipopt (varargin)
if (size(UB,2)==0) then
UB = repmat(%inf,nbVar,1);
end
+
+ if (size(p,2)==0) then
+ p = repmat(0,nbVar,1);
+ end
+
if ( rhs<10 | size(varargin(10)) ==0 ) then
x0 = repmat(0,nbVar,1);
@@ -289,8 +294,19 @@ function [xopt,fopt,exitflag,output,lambda] = qpipopt (varargin)
end
end
-
-
+ // Check if the user gives infinity or negative infinity in conLB or conUB
+ for i = 1:nbCon
+ if (conLB(i) == %inf)
+ errmsg = msprintf(gettext("%s: Value of Lower Bound can not be infinity"), "qpipopt");
+ error(errmsg);
+ end
+
+ if (conUB(i) == -%inf)
+ errmsg = msprintf(gettext("%s: Value of Upper Bound can not be negative infinity"), "qpipopt");
+ error(errmsg);
+ end
+ end
+
[xopt,fopt,status,iter,Zl,Zu,lmbda] = solveqp(nbVar,nbCon,Q,p,conMatrix,conLB,conUB,LB,UB,x0,options);
xopt = xopt';
@@ -324,7 +340,7 @@ function [xopt,fopt,exitflag,output,lambda] = qpipopt (varargin)
case 7 then
printf("\nFeasible point for square problem found.\n");
case 8 then
- printf("\nIterates divering; problem might be unbounded.\n");
+ printf("\nIterates diverging; problem might be unbounded.\n");
case 9 then
printf("\nRestoration Failed!\n");
case 10 then
diff --git a/macros/qpipoptmat.sci b/macros/qpipoptmat.sci
index 01b0eef..33e3bd6 100644
--- a/macros/qpipoptmat.sci
+++ b/macros/qpipoptmat.sci
@@ -152,7 +152,10 @@ function [xopt,fopt,exitflag,output,lambda] = qpipoptmat (varargin)
if (size(UB,2)==0) then
UB = repmat(%inf,nbVar,1);
end
-
+
+ if (size(f,2)==0) then
+ f = repmat(0,nbVar,1);
+ end
if (type(param) ~= 15) then
errmsg = msprintf(gettext("%s: param should be a list "), "qpipopt");
@@ -302,7 +305,19 @@ function [xopt,fopt,exitflag,output,lambda] = qpipoptmat (varargin)
end
end
+ for i = 1:nbConInEq
+ if (b(i) == -%inf)
+ errmsg = msprintf(gettext("%s: Value of b can not be negative infinity"), "qpipopt");
+ error(errmsg);
+ end
+ end
+ for i = 1:nbConEq
+ if (beq(i) == -%inf)
+ errmsg = msprintf(gettext("%s: Value of beq can not be negative infinity"), "qpipopt");
+ error(errmsg);
+ end
+ end
//Converting it into ipopt format
f = f';
@@ -321,13 +336,11 @@ function [xopt,fopt,exitflag,output,lambda] = qpipoptmat (varargin)
output.Iterations = iter;
lambda = struct("lower" , [], ..
"upper" , [], ..
- "ineqlin" , [], ..
- "eqlin" , []);
+ "constraint" , []);
lambda.lower = Zl;
lambda.upper = Zu;
- lambda.eqlin = lmbda(1:nbConEq);
- lambda.ineqlin = lmbda(nbConEq+1:nbCon);
+ lambda.constraint = lmbda;
select status
@@ -348,7 +361,7 @@ function [xopt,fopt,exitflag,output,lambda] = qpipoptmat (varargin)
case 7 then
printf("\nFeasible point for square problem found.\n");
case 8 then
- printf("\nIterates divering; problem might be unbounded.\n");
+ printf("\nIterates diverging; problem might be unbounded.\n");
case 9 then
printf("\nRestoration Failed!\n");
case 10 then