diff options
Diffstat (limited to 'macros')
-rw-r--r-- | macros/lib | bin | 480 -> 504 bytes | |||
-rw-r--r-- | macros/names | 1 | ||||
-rw-r--r-- | macros/qpipopt.bin | bin | 37220 -> 47232 bytes | |||
-rw-r--r-- | macros/qpipopt.sci | 78 | ||||
-rw-r--r-- | macros/qpipoptmat.bin | bin | 39808 -> 49536 bytes | |||
-rw-r--r-- | macros/qpipoptmat.sci | 75 | ||||
-rw-r--r-- | macros/symphony.bin | bin | 50332 -> 54860 bytes | |||
-rw-r--r-- | macros/symphony.sci | 32 | ||||
-rw-r--r-- | macros/symphony_call.bin | bin | 4064 -> 4592 bytes | |||
-rw-r--r-- | macros/symphony_call.sci | 16 | ||||
-rw-r--r-- | macros/symphonymat.bin | bin | 54444 -> 60860 bytes | |||
-rw-r--r-- | macros/symphonymat.sci | 49 |
12 files changed, 232 insertions, 19 deletions
Binary files differ diff --git a/macros/names b/macros/names index e068c5a..4f0ba56 100644 --- a/macros/names +++ b/macros/names @@ -3,4 +3,5 @@ qpipoptmat setOptions symphony symphony_call +symphony_mat symphonymat diff --git a/macros/qpipopt.bin b/macros/qpipopt.bin Binary files differindex 6eea1fa..0c65c0b 100644 --- a/macros/qpipopt.bin +++ b/macros/qpipopt.bin diff --git a/macros/qpipopt.sci b/macros/qpipopt.sci index 5f08067..c17371e 100644 --- a/macros/qpipopt.sci +++ b/macros/qpipopt.sci @@ -226,40 +226,69 @@ function [xopt,fopt,exitflag,output,lambda] = qpipopt (varargin) //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); + 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 - errmsg = msprintf(gettext("%s: The Lower Bound is not equal to the number of variables"), "qpipopt"); + 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 - errmsg = msprintf(gettext("%s: The Upper Bound is not equal to the number of variables"), "qpipopt"); + errmsg = msprintf(gettext("%s: The size of Upper Bound is not equal to the number of variables"), "qpipopt"); error(errmsg); end //Check the size of constraints of Lower Bound which should equal to the number of constraints if ( size(conLB,2) ~= nbCon) then - errmsg = msprintf(gettext("%s: The Lower Bound of constraints is not equal to the number of constraints"), "qpipopt"); + errmsg = msprintf(gettext("%s: The size of Lower Bound of constraints is not equal to the number of constraints"), "qpipopt"); error(errmsg); end //Check the size of constraints of Upper Bound which should equal to the number of constraints if ( size(conUB,2) ~= nbCon) then - errmsg = msprintf(gettext("%s: The Upper Bound of constraints is not equal to the number of constraints"), "qpipopt"); + errmsg = msprintf(gettext("%s: The size of Upper Bound of constraints is not equal to the number of constraints"), "qpipopt"); error(errmsg); end //Check the size of initial of variables which should equal to the number of variables - if ( size(x0,2) ~= nbVar) then + 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); 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"); + error(errmsg); + end + + 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 + errmsg = msprintf(gettext("%s: Upper Bound should be a vector"), "qpipopt"); + error(errmsg); + end + + if (nbCon) then + if ((size(conLB,1)~=1)& (size(b,2)~=1)) then + errmsg = msprintf(gettext("%s: Constraint Lower Bound should be a vector"), "qpipopt"); + error(errmsg); + end + if (size(conUB,1)~=1)& (size(beq,2)~=1) then + errmsg = msprintf(gettext("%s: Constraint should be a vector"), "qpipopt"); + error(errmsg); + end + end + [xopt,fopt,status,iter,Zl,Zu,lmbda] = solveqp(nbVar,nbCon,Q,p,conMatrix,conLB,conUB,LB,UB,x0,options); @@ -275,6 +304,43 @@ function [xopt,fopt,exitflag,output,lambda] = qpipopt (varargin) lambda.lower = Zl; lambda.upper = Zu; lambda.constraint = lmbda; + + select status + + case 0 then + printf("\nOptimal Solution Found.\n"); + case 1 then + printf("\nMaximum Number of Iterations Exceeded. Output may not be optimal.\n"); + case 2 then + printf("\nMaximum CPU Time exceeded. Output may not be optimal.\n"); + case 3 then + printf("\nStop at Tiny Step\n"); + case 4 then + printf("\nSolved To Acceptable Level\n"); + case 5 then + printf("\nConverged to a point of local infeasibility.\n"); + case 6 then + printf("\nStopping optimization at current point as requested by user.\n"); + case 7 then + printf("\nFeasible point for square problem found.\n"); + case 8 then + printf("\nIterates divering; problem might be unbounded.\n"); + case 9 then + printf("\nRestoration Failed!\n"); + case 10 then + printf("\nError in step computation (regularization becomes too large?)!\n"); + case 12 then + printf("\nProblem has too few degrees of freedom.\n"); + case 13 then + 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"); + else + printf("\nInvalid status returned. Notify the Toolbox authors\n"); + break; + end endfunction diff --git a/macros/qpipoptmat.bin b/macros/qpipoptmat.bin Binary files differindex 2cb90c9..6ca5589 100644 --- a/macros/qpipoptmat.bin +++ b/macros/qpipoptmat.bin diff --git a/macros/qpipoptmat.sci b/macros/qpipoptmat.sci index 7924ba6..01b0eef 100644 --- a/macros/qpipoptmat.sci +++ b/macros/qpipoptmat.sci @@ -174,9 +174,9 @@ function [xopt,fopt,exitflag,output,lambda] = qpipoptmat (varargin) select param(2*i-1) case "MaxIter" then - options(2*i-1) = param(2*i); + options(2*i) = param(2*i); case "CpuTime" then - options(2*i-1) = param(2*i); + options(2*i) = param(2*i); else errmsg = msprintf(gettext("%s: Unrecognized parameter name ''%s''."), "qpipoptmat", param(2*i-1)); error(errmsg) @@ -270,7 +270,39 @@ function [xopt,fopt,exitflag,output,lambda] = qpipoptmat (varargin) warnmsg = msprintf(gettext("%s: Ignoring initial guess of variables as it is not equal to the number of variables"), "qpipopt"); warning(warnmsg); end - + + //Check if the user gives a matrix instead of a vector + + 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 + errmsg = msprintf(gettext("%s: Lower Bound should be a vector"), "qpipopt"); + error(errmsg); + end + + if (size(UB,1)~=1)& (size(UB,2)~=1) then + errmsg = msprintf(gettext("%s: Upper Bound should be a vector"), "qpipopt"); + error(errmsg); + end + + if (nbConInEq) then + if ((size(b,1)~=1)& (size(b,2)~=1)) then + errmsg = msprintf(gettext("%s: Constraint Lower Bound should be a vector"), "qpipopt"); + error(errmsg); + end + end + + if (nbConEq) then + if (size(beq,1)~=1)& (size(beq,2)~=1) then + errmsg = msprintf(gettext("%s: Constraint should be a vector"), "qpipopt"); + error(errmsg); + end + end + + //Converting it into ipopt format f = f'; @@ -296,6 +328,43 @@ function [xopt,fopt,exitflag,output,lambda] = qpipoptmat (varargin) lambda.upper = Zu; lambda.eqlin = lmbda(1:nbConEq); lambda.ineqlin = lmbda(nbConEq+1:nbCon); + + select status + + case 0 then + printf("\nOptimal Solution Found.\n"); + case 1 then + printf("\nMaximum Number of Iterations Exceeded. Output may not be optimal.\n"); + case 2 then + printf("\nMaximum CPU Time exceeded. Output may not be optimal.\n"); + case 3 then + printf("\nStop at Tiny Step\n"); + case 4 then + printf("\nSolved To Acceptable Level\n"); + case 5 then + printf("\nConverged to a point of local infeasibility.\n"); + case 6 then + printf("\nStopping optimization at current point as requested by user.\n"); + case 7 then + printf("\nFeasible point for square problem found.\n"); + case 8 then + printf("\nIterates divering; problem might be unbounded.\n"); + case 9 then + printf("\nRestoration Failed!\n"); + case 10 then + printf("\nError in step computation (regularization becomes too large?)!\n"); + case 12 then + printf("\nProblem has too few degrees of freedom.\n"); + case 13 then + 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"); + else + printf("\nInvalid status returned. Notify the Toolbox authors\n"); + break; + end endfunction diff --git a/macros/symphony.bin b/macros/symphony.bin Binary files differindex 2ef2f57..d126d9f 100644 --- a/macros/symphony.bin +++ b/macros/symphony.bin diff --git a/macros/symphony.sci b/macros/symphony.sci index 217a209..a0d2975 100644 --- a/macros/symphony.sci +++ b/macros/symphony.sci @@ -210,7 +210,7 @@ function [xopt,fopt,status,output] = symphony (varargin) conLB = conLB'; end - if (size(conUB,2)== [nbVar]) then + if (size(conUB,2)== [nbCon]) then conUB = conUB'; end @@ -277,6 +277,36 @@ function [xopt,fopt,status,output] = symphony (varargin) error(errmsg); end + //Check if the user gives a matrix instead of a vector + + if ((size(isInt,1)~=1)& (size(isInt,2)~=1)) then + errmsg = msprintf(gettext("%s: isInt should be a vector"), "qpipopt"); + error(errmsg); + end + + 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 + errmsg = msprintf(gettext("%s: Upper Bound should be a vector"), "qpipopt"); + error(errmsg); + end + + if (nbCon) then + if ((size(conLB,1)~=1)& (size(conLB,2)~=1)) then + errmsg = msprintf(gettext("%s: Constraint Lower Bound should be a vector"), "qpipopt"); + error(errmsg); + end + + if (size(conUB,1)~=1)& (size(conUB,2)~=1) then + errmsg = msprintf(gettext("%s: Constraint Upper Bound should be a vector"), "qpipopt"); + error(errmsg); + end + end + + LB = LB'; UB = UB'; isInt = isInt'; diff --git a/macros/symphony_call.bin b/macros/symphony_call.bin Binary files differindex 5008236..53671fa 100644 --- a/macros/symphony_call.bin +++ b/macros/symphony_call.bin diff --git a/macros/symphony_call.sci b/macros/symphony_call.sci index c8323fc..cfe73ae 100644 --- a/macros/symphony_call.sci +++ b/macros/symphony_call.sci @@ -11,6 +11,11 @@ function [xopt,fopt,status,output] = symphony_call(nbVar,nbCon,objCoef,isInt,LB,UB,conMatrix,conLB,conUB,objSense,options) + xopt = []; + fopt = []; + status = []; + output = []; + //Opening Symphony environment sym_open(); @@ -27,14 +32,9 @@ function [xopt,fopt,status,output] = symphony_call(nbVar,nbCon,objCoef,isInt,LB, end op = sym_solve(); - disp(op); - xopt = []; - fopt = []; - status = []; - output = []; - - if (~op) then + status = sym_getStatus(); + if (status == 228 | status == 227 | status == 229 | status == 230 | status == 231 | status == 232 | status == 233) then xopt = sym_getVarSoln(); // Symphony gives a row matrix converting it to column matrix xopt = xopt'; @@ -46,7 +46,7 @@ function [xopt,fopt,status,output] = symphony_call(nbVar,nbCon,objCoef,isInt,LB, output = struct("Iterations" , []); - output.Iterations = sym_getIterCount(); + output.Iterations = sym_getIterCount(); endfunction diff --git a/macros/symphonymat.bin b/macros/symphonymat.bin Binary files differindex 01460d6..95bba1a 100644 --- a/macros/symphonymat.bin +++ b/macros/symphonymat.bin diff --git a/macros/symphonymat.sci b/macros/symphonymat.sci index 87427e1..9e1ffaf 100644 --- a/macros/symphonymat.sci +++ b/macros/symphonymat.sci @@ -196,6 +196,20 @@ function [xopt,fopt,status,iter] = symphonymat (varargin) options = varargin(9); end +// Check if the user gives empty matrix + if (size(lb,2)==0) then + lb = repmat(-%inf,nbVar,1); + end + + if (size(intcon,2)==0) then + intcon = 0; + end + + if (size(ub,2)==0) then + ub = repmat(%inf,nbVar,1); + end + +// Calculating the size of equality and inequality constraints nbConInEq = size(A,1); nbConEq = size(Aeq,1); @@ -283,6 +297,37 @@ function [xopt,fopt,status,iter] = symphonymat (varargin) error(errmsg); end + //Check if the user gives a matrix instead of a vector + + if ((size(intcon,1)~=1)& (size(intcon,2)~=1)) then + errmsg = msprintf(gettext("%s: intcon should be a vector"), "symphonymat"); + error(errmsg); + end + + if (size(lb,1)~=1)& (size(lb,2)~=1) then + errmsg = msprintf(gettext("%s: Lower Bound should be a vector"), "symphonymat"); + error(errmsg); + end + + if (size(ub,1)~=1)& (size(ub,2)~=1) then + errmsg = msprintf(gettext("%s: Upper Bound should be a vector"), "symphonymat"); + error(errmsg); + end + + if (nbConInEq) then + if ((size(b,1)~=1)& (size(b,2)~=1)) then + errmsg = msprintf(gettext("%s: Constraint Lower Bound should be a vector"), "symphonymat"); + error(errmsg); + end + end + + if (nbConEq) then + if (size(beq,1)~=1)& (size(beq,2)~=1) then + errmsg = msprintf(gettext("%s: Constraint Upper Bound should be a vector"), "symphonymat"); + error(errmsg); + end + end + //Changing the inputs in symphony's format conMatrix = [A;Aeq] @@ -291,7 +336,9 @@ function [xopt,fopt,status,iter] = symphonymat (varargin) conUB = [b;beq] ; isInt = repmat(%f,1,nbVar); - for i=1:size(intcon,2) + // Changing intcon into column vector + intcon = intcon(:); + for i=1:size(intcon,1) isInt(intcon(i)) = %t end |