diff options
32 files changed, 402 insertions, 77 deletions
diff --git a/help/en_US/master_help.xml b/help/en_US/master_help.xml index 67338f2..66b8e0d 100644 --- a/help/en_US/master_help.xml +++ b/help/en_US/master_help.xml @@ -2,8 +2,10 @@ <!DOCTYPE book [ <!--Begin Entities--> <!ENTITY a6b85f6e0c98751f20b68663a23cb4cd2 SYSTEM "/home/harpreet/symphony_work/symphony/help/en_US/qpipopt.xml"> +<!ENTITY a44928acec52adf395379e18fcff06730 SYSTEM "/home/harpreet/symphony_work/symphony/help/en_US/qpipopt_mat.xml"> <!ENTITY a8549a3935858ed104f4749ca2243456a SYSTEM "/home/harpreet/symphony_work/symphony/help/en_US/qpipoptmat.xml"> <!ENTITY aca972f273143ecb39f56b42e4723ac67 SYSTEM "/home/harpreet/symphony_work/symphony/help/en_US/symphony.xml"> +<!ENTITY a9953e61e8dd264a86df73772d3055e7f SYSTEM "/home/harpreet/symphony_work/symphony/help/en_US/symphony_mat.xml"> <!ENTITY a9910ada35b57b0581e8a77d145abac4a SYSTEM "/home/harpreet/symphony_work/symphony/help/en_US/symphonymat.xml"> <!ENTITY acc223314e8a8bc290a13618df33a6237 SYSTEM "/home/harpreet/symphony_work/symphony/help/en_US/Symphony Native Function/sym_addConstr.xml"> <!ENTITY a5e032b3334f53385f0ce250f0d5c18f2 SYSTEM "/home/harpreet/symphony_work/symphony/help/en_US/Symphony Native Function/sym_addVar.xml"> @@ -80,8 +82,10 @@ <part xml:id='section_19f4f1e5726c01d683e8b82be0a7e910'> <title>Symphony Toolbox</title> &a6b85f6e0c98751f20b68663a23cb4cd2; +&a44928acec52adf395379e18fcff06730; &a8549a3935858ed104f4749ca2243456a; &aca972f273143ecb39f56b42e4723ac67; +&a9953e61e8dd264a86df73772d3055e7f; &a9910ada35b57b0581e8a77d145abac4a; <chapter xml:id='section_508f0b211d17ea6769714cc144e6b731'> <title>Symphony Native Functions</title> diff --git a/help/en_US/scilab_en_US_help/JavaHelpSearch/DOCS b/help/en_US/scilab_en_US_help/JavaHelpSearch/DOCS Binary files differindex 02038f6..d5a7298 100644 --- a/help/en_US/scilab_en_US_help/JavaHelpSearch/DOCS +++ b/help/en_US/scilab_en_US_help/JavaHelpSearch/DOCS diff --git a/help/en_US/scilab_en_US_help/JavaHelpSearch/DOCS.TAB b/help/en_US/scilab_en_US_help/JavaHelpSearch/DOCS.TAB Binary files differindex 23181b6..0095d6c 100644 --- a/help/en_US/scilab_en_US_help/JavaHelpSearch/DOCS.TAB +++ b/help/en_US/scilab_en_US_help/JavaHelpSearch/DOCS.TAB diff --git a/help/en_US/scilab_en_US_help/JavaHelpSearch/OFFSETS b/help/en_US/scilab_en_US_help/JavaHelpSearch/OFFSETS Binary files differindex d20c98d..3fdc4c1 100644 --- a/help/en_US/scilab_en_US_help/JavaHelpSearch/OFFSETS +++ b/help/en_US/scilab_en_US_help/JavaHelpSearch/OFFSETS diff --git a/help/en_US/scilab_en_US_help/JavaHelpSearch/POSITIONS b/help/en_US/scilab_en_US_help/JavaHelpSearch/POSITIONS Binary files differindex e2773de..d69ed8d 100644 --- a/help/en_US/scilab_en_US_help/JavaHelpSearch/POSITIONS +++ b/help/en_US/scilab_en_US_help/JavaHelpSearch/POSITIONS diff --git a/help/en_US/scilab_en_US_help/JavaHelpSearch/TMAP b/help/en_US/scilab_en_US_help/JavaHelpSearch/TMAP Binary files differindex 7e8baef..39ca223 100644 --- a/help/en_US/scilab_en_US_help/JavaHelpSearch/TMAP +++ b/help/en_US/scilab_en_US_help/JavaHelpSearch/TMAP diff --git a/help/en_US/scilab_en_US_help/index.html b/help/en_US/scilab_en_US_help/index.html index 12fb83c..b1cfd9c 100644 --- a/help/en_US/scilab_en_US_help/index.html +++ b/help/en_US/scilab_en_US_help/index.html @@ -38,6 +38,12 @@ +<li><a href="qpipopt_mat.html" class="refentry">qpipopt_mat</a> — <span class="refentry-description">Solves a linear quadratic problem.</span></li> + + + + + <li><a href="qpipoptmat.html" class="refentry">qpipoptmat</a> — <span class="refentry-description">Solves a linear quadratic problem.</span></li> @@ -50,6 +56,12 @@ +<li><a href="symphony_mat.html" class="refentry">symphony_mat</a> — <span class="refentry-description">Solves a mixed integer linear programming constrained optimization problem in intlinprog format.</span></li> + + + + + <li><a href="symphonymat.html" class="refentry">symphonymat</a> — <span class="refentry-description">Solves a mixed integer linear programming constrained optimization problem in intlinprog format.</span></li> <li><a href="section_508f0b211d17ea6769714cc144e6b731.html" class="chapter">Symphony Native Functions</a> diff --git a/help/en_US/scilab_en_US_help/jhelpmap.jhm b/help/en_US/scilab_en_US_help/jhelpmap.jhm index 9dfdea5..47f4429 100644 --- a/help/en_US/scilab_en_US_help/jhelpmap.jhm +++ b/help/en_US/scilab_en_US_help/jhelpmap.jhm @@ -4,8 +4,10 @@ <mapID target="index" url="index.html"/> <mapID target="section_19f4f1e5726c01d683e8b82be0a7e910" url="section_19f4f1e5726c01d683e8b82be0a7e910.html"/> <mapID target="qpipopt" url="qpipopt.html"/> +<mapID target="qpipopt_mat" url="qpipopt_mat.html"/> <mapID target="qpipoptmat" url="qpipoptmat.html"/> <mapID target="symphony" url="symphony.html"/> +<mapID target="symphony_mat" url="symphony_mat.html"/> <mapID target="symphonymat" url="symphonymat.html"/> <mapID target="section_508f0b211d17ea6769714cc144e6b731" url="section_508f0b211d17ea6769714cc144e6b731.html"/> <mapID target="sym_addConstr" url="sym_addConstr.html"/> diff --git a/help/en_US/scilab_en_US_help/jhelptoc.xml b/help/en_US/scilab_en_US_help/jhelptoc.xml index 84c6d37..95d4995 100644 --- a/help/en_US/scilab_en_US_help/jhelptoc.xml +++ b/help/en_US/scilab_en_US_help/jhelptoc.xml @@ -4,8 +4,10 @@ <tocitem target="index" text="Symphony Toolbox"> <tocitem target="section_19f4f1e5726c01d683e8b82be0a7e910" text="Symphony Toolbox"> <tocitem target="qpipopt" text="qpipopt"/> +<tocitem target="qpipopt_mat" text="qpipopt_mat"/> <tocitem target="qpipoptmat" text="qpipoptmat"/> <tocitem target="symphony" text="symphony"/> +<tocitem target="symphony_mat" text="symphony_mat"/> <tocitem target="symphonymat" text="symphonymat"/> <tocitem target="section_508f0b211d17ea6769714cc144e6b731" text="Symphony Native Functions"> <tocitem target="sym_addConstr" text="sym_addConstr"/> diff --git a/help/en_US/scilab_en_US_help/qpipopt.html b/help/en_US/scilab_en_US_help/qpipopt.html index b1c18ac..63da9d2 100644 --- a/help/en_US/scilab_en_US_help/qpipopt.html +++ b/help/en_US/scilab_en_US_help/qpipopt.html @@ -20,7 +20,7 @@ </td> <td width="30%" class="next"> - <span class="next"><a href="qpipoptmat.html">qpipoptmat >></a></span> + <span class="next"><a href="qpipopt_mat.html">qpipopt_mat >></a></span> </td> </tr></table> @@ -138,7 +138,7 @@ find the minimum of f(x) such that</p> </td> <td width="30%" class="next"> - <span class="next"><a href="qpipoptmat.html">qpipoptmat >></a></span> + <span class="next"><a href="qpipopt_mat.html">qpipopt_mat >></a></span> </td> </tr></table> diff --git a/help/en_US/scilab_en_US_help/qpipopt_mat.html b/help/en_US/scilab_en_US_help/qpipopt_mat.html index 5e30769..2089d8b 100644 --- a/help/en_US/scilab_en_US_help/qpipopt_mat.html +++ b/help/en_US/scilab_en_US_help/qpipopt_mat.html @@ -20,7 +20,7 @@ </td> <td width="30%" class="next"> - <span class="next"><a href="symphony.html">symphony >></a></span> + <span class="next"><a href="qpipoptmat.html">qpipoptmat >></a></span> </td> </tr></table> @@ -129,7 +129,7 @@ find the minimum of f(x) such that</p> </td> <td width="30%" class="next"> - <span class="next"><a href="symphony.html">symphony >></a></span> + <span class="next"><a href="qpipoptmat.html">qpipoptmat >></a></span> </td> </tr></table> diff --git a/help/en_US/scilab_en_US_help/qpipoptmat.html b/help/en_US/scilab_en_US_help/qpipoptmat.html index a9f97aa..10cb590 100644 --- a/help/en_US/scilab_en_US_help/qpipoptmat.html +++ b/help/en_US/scilab_en_US_help/qpipoptmat.html @@ -12,7 +12,7 @@ <div class="manualnavbar"> <table width="100%"><tr> <td width="30%"> - <span class="previous"><a href="qpipopt.html"><< qpipopt</a></span> + <span class="previous"><a href="qpipopt_mat.html"><< qpipopt_mat</a></span> </td> <td width="40%" class="center"> @@ -128,7 +128,7 @@ find the minimum of f(x) such that</p> <tr><td colspan="3" class="next"><a href="http://bugzilla.scilab.org/enter_bug.cgi?product=Scilab%20software&component=Documentation%20pages" class="ulink">Report an issue</a></td></tr> <tr> <td width="30%"> - <span class="previous"><a href="qpipopt.html"><< qpipopt</a></span> + <span class="previous"><a href="qpipopt_mat.html"><< qpipopt_mat</a></span> </td> <td width="40%" class="center"> diff --git a/help/en_US/scilab_en_US_help/section_19f4f1e5726c01d683e8b82be0a7e910.html b/help/en_US/scilab_en_US_help/section_19f4f1e5726c01d683e8b82be0a7e910.html index 1e5e538..52d6d9e 100644 --- a/help/en_US/scilab_en_US_help/section_19f4f1e5726c01d683e8b82be0a7e910.html +++ b/help/en_US/scilab_en_US_help/section_19f4f1e5726c01d683e8b82be0a7e910.html @@ -37,6 +37,12 @@ +<li><a href="qpipopt_mat.html" class="refentry">qpipopt_mat</a> — <span class="refentry-description">Solves a linear quadratic problem.</span></li> + + + + + <li><a href="qpipoptmat.html" class="refentry">qpipoptmat</a> — <span class="refentry-description">Solves a linear quadratic problem.</span></li> @@ -49,6 +55,12 @@ +<li><a href="symphony_mat.html" class="refentry">symphony_mat</a> — <span class="refentry-description">Solves a mixed integer linear programming constrained optimization problem in intlinprog format.</span></li> + + + + + <li><a href="symphonymat.html" class="refentry">symphonymat</a> — <span class="refentry-description">Solves a mixed integer linear programming constrained optimization problem in intlinprog format.</span></li> <li><a href="section_508f0b211d17ea6769714cc144e6b731.html" class="chapter">Symphony Native Functions</a> diff --git a/help/en_US/scilab_en_US_help/symphony.html b/help/en_US/scilab_en_US_help/symphony.html index c5b8336..48ea705 100644 --- a/help/en_US/scilab_en_US_help/symphony.html +++ b/help/en_US/scilab_en_US_help/symphony.html @@ -20,7 +20,7 @@ </td> <td width="30%" class="next"> - <span class="next"><a href="symphonymat.html">symphonymat >></a></span> + <span class="next"><a href="symphony_mat.html">symphony_mat >></a></span> </td> </tr></table> @@ -205,7 +205,7 @@ find the minimum or maximum of f(x) such that</p> </td> <td width="30%" class="next"> - <span class="next"><a href="symphonymat.html">symphonymat >></a></span> + <span class="next"><a href="symphony_mat.html">symphony_mat >></a></span> </td> </tr></table> diff --git a/help/en_US/scilab_en_US_help/symphony_mat.html b/help/en_US/scilab_en_US_help/symphony_mat.html index cc337f4..4f07aca 100644 --- a/help/en_US/scilab_en_US_help/symphony_mat.html +++ b/help/en_US/scilab_en_US_help/symphony_mat.html @@ -20,7 +20,7 @@ </td> <td width="30%" class="next"> - <span class="next"><a href="section_508f0b211d17ea6769714cc144e6b731.html">Symphony Native Functions >></a></span> + <span class="next"><a href="symphonymat.html">symphonymat >></a></span> </td> </tr></table> @@ -190,7 +190,7 @@ find the minimum or maximum of f(x) such that</p> </td> <td width="30%" class="next"> - <span class="next"><a href="section_508f0b211d17ea6769714cc144e6b731.html">Symphony Native Functions >></a></span> + <span class="next"><a href="symphonymat.html">symphonymat >></a></span> </td> </tr></table> diff --git a/help/en_US/scilab_en_US_help/symphonymat.html b/help/en_US/scilab_en_US_help/symphonymat.html index 8001136..b559c8a 100644 --- a/help/en_US/scilab_en_US_help/symphonymat.html +++ b/help/en_US/scilab_en_US_help/symphonymat.html @@ -12,7 +12,7 @@ <div class="manualnavbar"> <table width="100%"><tr> <td width="30%"> - <span class="previous"><a href="symphony.html"><< symphony</a></span> + <span class="previous"><a href="symphony_mat.html"><< symphony_mat</a></span> </td> <td width="40%" class="center"> @@ -183,7 +183,7 @@ find the minimum or maximum of f(x) such that</p> <tr><td colspan="3" class="next"><a href="http://bugzilla.scilab.org/enter_bug.cgi?product=Scilab%20software&component=Documentation%20pages" class="ulink">Report an issue</a></td></tr> <tr> <td width="30%"> - <span class="previous"><a href="symphony.html"><< symphony</a></span> + <span class="previous"><a href="symphony_mat.html"><< symphony_mat</a></span> </td> <td width="40%" class="center"> diff --git a/jar/scilab_en_US_help.jar b/jar/scilab_en_US_help.jar Binary files differBinary files differindex 749cb54..79b480b 100644 --- a/jar/scilab_en_US_help.jar +++ b/jar/scilab_en_US_help.jar 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 diff --git a/sci_gateway/cpp/libFAMOS.so b/sci_gateway/cpp/libFAMOS.so Binary files differindex 4a210ee..ec45532 100755 --- a/sci_gateway/cpp/libFAMOS.so +++ b/sci_gateway/cpp/libFAMOS.so diff --git a/sci_gateway/cpp/sci_QuadNLP.cpp b/sci_gateway/cpp/sci_QuadNLP.cpp index 99987a2..50e8109 100644 --- a/sci_gateway/cpp/sci_QuadNLP.cpp +++ b/sci_gateway/cpp/sci_QuadNLP.cpp @@ -209,10 +209,11 @@ void QuadNLP::finalize_solution(SolverReturn status, finalLambda_[i] = lambda[i]; } - iter_ = ip_data->iter_count(); finalObjVal_ = obj_value; status_ = status; - + if (status_ == 0 | status_ == 1 | status_ == 2){ + iter_ = ip_data->iter_count(); + } } const double * QuadNLP::getX() diff --git a/sci_gateway/cpp/sci_ipopt.cpp b/sci_gateway/cpp/sci_ipopt.cpp index 4168488..98ed153 100644 --- a/sci_gateway/cpp/sci_ipopt.cpp +++ b/sci_gateway/cpp/sci_ipopt.cpp @@ -324,46 +324,45 @@ int sci_solveqp(char *fname) return 0; } - using namespace Ipopt; - - SmartPtr<QuadNLP> Prob = new QuadNLP(nVars,nCons,QItems,PItems,ConItems,conUB,conLB,varUB,varLB,init_guess); - SmartPtr<IpoptApplication> app = IpoptApplicationFactory(); - app->RethrowNonIpoptException(true); - - // Change some options - // Note: The following choices are only examples, they might not be - // suitable for your optimization problem. - app->Options()->SetNumericValue("tol", 1e-7); - app->Options()->SetIntegerValue("max_iter", (int)*max_iter); - app->Options()->SetNumericValue("max_cpu_time", *cpu_time); - app->Options()->SetStringValue("mu_strategy", "adaptive"); - - // Indicates whether all equality constraints are linear - app->Options()->SetStringValue("jac_c_constant", "yes"); - // Indicates whether all inequality constraints are linear - app->Options()->SetStringValue("jac_d_constant", "yes"); - // Indicates whether the problem is a quadratic problem - app->Options()->SetStringValue("hessian_constant", "yes"); + using namespace Ipopt; + + SmartPtr<QuadNLP> Prob = new QuadNLP(nVars,nCons,QItems,PItems,ConItems,conUB,conLB,varUB,varLB,init_guess); + SmartPtr<IpoptApplication> app = IpoptApplicationFactory(); + app->RethrowNonIpoptException(true); + + // Change some options + // Note: The following choices are only examples, they might not be + // suitable for your optimization problem. + app->Options()->SetNumericValue("tol", 1e-7); + app->Options()->SetIntegerValue("max_iter", (int)*max_iter); + app->Options()->SetNumericValue("max_cpu_time", *cpu_time); + app->Options()->SetStringValue("mu_strategy", "adaptive"); + + // Indicates whether all equality constraints are linear + app->Options()->SetStringValue("jac_c_constant", "yes"); + // Indicates whether all inequality constraints are linear + app->Options()->SetStringValue("jac_d_constant", "yes"); + // Indicates whether the problem is a quadratic problem + app->Options()->SetStringValue("hessian_constant", "yes"); + + // Initialize the IpoptApplication and process the options + ApplicationReturnStatus status; + status = app->Initialize(); + if (status != Solve_Succeeded) { + sciprint("\n*** Error during initialization!\n"); + return (int) status; + } + // Ask Ipopt to solve the problem - // Initialize the IpoptApplication and process the options - ApplicationReturnStatus status; - status = app->Initialize(); - if (status != Solve_Succeeded) { - sciprint("\n*** Error during initialization!\n"); - return0toScilab(); - return (int) status; - } - // Ask Ipopt to solve the problem - - status = app->OptimizeTNLP(Prob); + status = app->OptimizeTNLP(Prob); + + int stats = Prob->returnStatus(); + if (stats == 0 | stats == 1 | stats == 2){ double *fX = Prob->getX(); double ObjVal = Prob->getObjVal(); - double *Zl = Prob->getZl(); - double *Zu = Prob->getZu(); - double *Lambda = Prob->getLambda(); double iteration = Prob->iterCount(); - int stats = Prob->returnStatus(); + sciErr = createMatrixOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 1, 1, nVars, fX); if (sciErr.iErr) { @@ -392,41 +391,121 @@ int sci_solveqp(char *fname) return 0; } - sciErr = createMatrixOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 5, 1, nVars, Zl); + AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1; + AssignOutputVariable(pvApiCtx, 2) = nbInputArgument(pvApiCtx) + 2; + AssignOutputVariable(pvApiCtx, 3) = nbInputArgument(pvApiCtx) + 3; + AssignOutputVariable(pvApiCtx, 4) = nbInputArgument(pvApiCtx) + 4; + } + + else + { + double *fX = NULL; + double ObjVal = 0; + int stats = Prob->returnStatus(); + double iteration = 0; + + sciErr = createMatrixOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 1, 0, 0, fX); if (sciErr.iErr) { printError(&sciErr, 0); return 0; } - sciErr = createMatrixOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 6, 1, nVars, Zu); + sciErr = createMatrixOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 2,1,1,&ObjVal); if (sciErr.iErr) { printError(&sciErr, 0); return 0; } - - sciErr = createMatrixOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 7, 1, nCons, Lambda); + + sciErr = createMatrixOfInteger32(pvApiCtx, nbInputArgument(pvApiCtx) + 3,1,1,&stats); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return 0; + } + + sciErr = createMatrixOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 4,1,1,&iteration); if (sciErr.iErr) { printError(&sciErr, 0); return 0; } - AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1; AssignOutputVariable(pvApiCtx, 2) = nbInputArgument(pvApiCtx) + 2; AssignOutputVariable(pvApiCtx, 3) = nbInputArgument(pvApiCtx) + 3; AssignOutputVariable(pvApiCtx, 4) = nbInputArgument(pvApiCtx) + 4; + } + + + if(stats == 0){ + + double *Zl = Prob->getZl(); + double *Zu = Prob->getZu(); + double *Lambda = Prob->getLambda(); + + sciErr = createMatrixOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 5, 1, nVars, Zl); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return 0; + } + + sciErr = createMatrixOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 6, 1, nVars, Zu); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return 0; + } + + sciErr = createMatrixOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 7, 1, nCons, Lambda); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return 0; + } + AssignOutputVariable(pvApiCtx, 5) = nbInputArgument(pvApiCtx) + 5; AssignOutputVariable(pvApiCtx, 6) = nbInputArgument(pvApiCtx) + 6; - AssignOutputVariable(pvApiCtx, 7) = nbInputArgument(pvApiCtx) + 7; + AssignOutputVariable(pvApiCtx, 7) = nbInputArgument(pvApiCtx) + 7; + } - // As the SmartPtrs go out of scope, the reference count - // will be decremented and the objects will automatically - // be deleted. + else{ + double *Zl = NULL; + double *Zu = NULL; + double *Lambda = NULL; + sciErr = createMatrixOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 5, 0, 0, Zl); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return 0; + } + + sciErr = createMatrixOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 6, 0, 0, Zu); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return 0; + } + + sciErr = createMatrixOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 7, 0, 0, Lambda); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return 0; + } + + AssignOutputVariable(pvApiCtx, 5) = nbInputArgument(pvApiCtx) + 5; + AssignOutputVariable(pvApiCtx, 6) = nbInputArgument(pvApiCtx) + 6; + AssignOutputVariable(pvApiCtx, 7) = nbInputArgument(pvApiCtx) + 7; + } + // As the SmartPtrs go out of scope, the reference count + // will be decremented and the objects will automatically + // be deleted. + return 0; } |