diff options
author | Harpreet | 2015-10-20 14:23:25 +0530 |
---|---|---|
committer | Harpreet | 2015-10-20 14:23:25 +0530 |
commit | e4b59ea62dd9903445375c2aa1f52a52c5eab99f (patch) | |
tree | d761e8819990b031344e58c9016562bea157c05b | |
parent | e34332a406e4f3fba9b99c6f9ec5138edfcc6aa2 (diff) | |
download | FOSSEE-Optimization-toolbox-e4b59ea62dd9903445375c2aa1f52a52c5eab99f.tar.gz FOSSEE-Optimization-toolbox-e4b59ea62dd9903445375c2aa1f52a52c5eab99f.tar.bz2 FOSSEE-Optimization-toolbox-e4b59ea62dd9903445375c2aa1f52a52c5eab99f.zip |
qpipopt_mat added
58 files changed, 2356 insertions, 292 deletions
diff --git a/demos/qpipopt.dem.sce b/demos/qpipopt.dem.sce index 4f20a4a..3b36ff1 100644 --- a/demos/qpipopt.dem.sce +++ b/demos/qpipopt.dem.sce @@ -4,40 +4,38 @@ mode(1) // //Find x in R^6 such that: -halt() // Press return to continue - 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]; -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]; +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); +p=[1; 2; 3; 4; 5; 6]; Q=eye(6,6); nbVar = 6; nbCon = 5; [xopt,fopt,exitflag,output,lambda]=qpipopt(nbVar,nbCon,Q,p,lb,ub,conMatrix,conLB,conUB) halt() // Press return to continue -//min. -8*x1 -16*x2 + x1^2 + 4* x2^2 -// such that -// x1 + x2 <= 5, -// x1 <= 3, -// x1 >= 0, -// x2 >= 0 -conMatrix= [1 1]; -conLB=[-%inf]; -conUB = [5]; -lb=[0,0]; -ub=[3,%inf]; -//and minimize 0.5*x'*Q*x + p'*x with -p=[-8,-16]; -Q=[1,0;0,4]; +//Find the value of x that minimize following function +// f(x) = 0.5*x1^2 + x2^2 - x1*x2 - 2*x1 - 6*x2 +// Subject to: +// x1 + x2 ≤ 2 +// –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]; +conUB = [2; 2; 3]; +conLB = [-%inf; -%inf; -%inf]; +lb = [0; 0]; +ub = [%inf; %inf]; nbVar = 2; -nbCon = 1; +nbCon = 3; [xopt,fopt,exitflag,output,lambda] = qpipopt(nbVar,nbCon,Q,p,lb,ub,conMatrix,conLB,conUB) halt() // Press return to continue diff --git a/demos/qpipopt_mat.dem.sce b/demos/qpipopt_mat.dem.sce new file mode 100644 index 0000000..0f65036 --- /dev/null +++ b/demos/qpipopt_mat.dem.sce @@ -0,0 +1,40 @@ +mode(1) +// +// Demo of qpipopt_mat.sci +// + +//Find x in R^6 such that: +halt() // Press return to continue + +Aeq= [1,-1,1,0,3,1; +-1,0,-3,-4,5,6; +2,5,3,0,1,0]; +beq=[1; 2; 3]; +A= [0,1,0,1,2,-1; +-1,0,2,1,1,0]; +b = [-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 +f=[1; 2; 3; 4; 5; 6]; H=eye(6,6); +[xopt,fopt,exitflag,output,lambda]=qpipopt_mat(H,f,A,b,Aeq,beq,lb,ub) +clear H f A b Aeq beq lb ub; +halt() // Press return to continue + +//Find the value of x that minimize following function +// f(x) = 0.5*x1^2 + x2^2 - x1*x2 - 2*x1 - 6*x2 +// Subject to: +// x1 + x2 ≤ 2 +// –x1 + 2x2 ≤ 2 +// 2x1 + x2 ≤ 3 +// 0 ≤ x1, 0 ≤ x2. +H = [1 -1; -1 2]; +f = [-2; -6]; +A = [1 1; -1 2; 2 1]; +b = [2; 2; 3]; +lb = [0; 0]; +ub = [%inf; %inf]; +[xopt,fopt,exitflag,output,lambda] = qpipopt_mat(H,f,A,b,[],[],lb,ub) +halt() // Press return to continue + +//========= E N D === O F === D E M O =========// diff --git a/demos/symphony_knapsack.sce b/demos/symphony_knapsack.sce index 12a6788..42c192c 100644 --- a/demos/symphony_knapsack.sce +++ b/demos/symphony_knapsack.sce @@ -93,7 +93,7 @@ conLB=repmat(0,nbCon,1); // Upper Bound of constraints conUB=[11927 13727 11551 13056 13460 ]'; -options = ["time_limit" "40"]; +options = ["tie_limit" "40"]; // The expected solution : diff --git a/etc/Symphony.start b/etc/Symphony.start index 61eedbc..328357a 100644 --- a/etc/Symphony.start +++ b/etc/Symphony.start @@ -48,7 +48,7 @@ else link(lib_path + "/libSym.so"); link(lib_path + "/libOsiSym.so"); link(lib_path + "/libcoinblas.so"); - link(lib_path + "/libcoinmetis.so"); + link(lib_path + "/libcoinlapack.so"); link(lib_path + "/libcoinmumps.so"); link(lib_path + "/libipopt.so"); diff --git a/etc/Symphony.start~ b/etc/Symphony.start~ new file mode 100644 index 0000000..e019451 --- /dev/null +++ b/etc/Symphony.start~ @@ -0,0 +1,91 @@ +// Copyright (C) 2015 - IIT Bombay - FOSSEE +// +// Author: Harpreet Singh +// Organization: FOSSEE, IIT Bombay +// Email: harpreet.mertia@gmail.com +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + +mprintf("Start FAMOS\n"); + +if ( isdef("sym_open") ) then + warning("Library is already loaded"); + return; +end + +etc_tlbx = get_absolute_file_path("Symphony.start"); +etc_tlbx = getshortpathname(etc_tlbx); +root_tlbx = strncpy( etc_tlbx, length(etc_tlbx)-length("\etc\") ); + +//Load functions library +// ============================================================================= +mprintf("\tLoad macros\n"); +pathmacros = pathconvert( root_tlbx ) + "macros" + filesep(); +symphony_lib = lib(pathmacros); +clear pathmacros; + +// load gateways +// ============================================================================= + +mprintf("\tLoad gateways\n"); +[a, opt] = getversion(); +Version = opt(2); +ilib_verbose(0); +if getos()=="Windows" then + error(msprintf(gettext("Module is not for Windows."))); +else + lib_path = root_tlbx + "/thirdparty/linux/lib/" + Version; + link(lib_path + "/libCoinUtils.so"); + link(lib_path + "/libClp.so"); + link(lib_path + "/libClpSolver.so"); + link(lib_path + "/libOsi.so"); + link(lib_path + "/libOsiCommonTests.so"); + link(lib_path + "/libOsiClp.so"); + link(lib_path + "/libCgl.so"); + link(lib_path + "/libSym.so"); + link(lib_path + "/libOsiSym.so"); + link(lib_path + "/libcoinblas.so"); + link(lib_path + "/libcoinmumps.so"); + link(lib_path + "/libipopt.so"); + + +end +exec(pathconvert(root_tlbx + filesep() + "sci_gateway" + filesep() + "loader_gateway.sce",%f)); + + + + +// Load and add help chapter +// ============================================================================= +if ( %t ) then +if or(getscilabmode() == ["NW";"STD"]) then + mprintf("\tLoad help\n"); + path_addchapter = pathconvert(root_tlbx+"/jar"); + if ( isdir(path_addchapter) <> [] ) then + add_help_chapter("Symphony", path_addchapter, %F); + clear add_help_chapter; + end + clear path_addchapter; +end +end + +// add demos +// ============================================================================= + +if ( %t ) then +if or(getscilabmode() == ["NW";"STD"]) then + mprintf("\tLoad demos\n"); + pathdemos = pathconvert(root_tlbx+"/demos/sci_symphony.dem.gateway.sce",%f,%t); + add_demo("Symphony",pathdemos); + clear pathdemos ; +end +end + +// ============================================================================= + +clear root_tlbx; +clear etc_tlbx; + diff --git a/help/en_US/master_help.xml b/help/en_US/master_help.xml index 85ff9e0..791d3d0 100644 --- a/help/en_US/master_help.xml +++ b/help/en_US/master_help.xml @@ -2,6 +2,7 @@ <!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 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 acc223314e8a8bc290a13618df33a6237 SYSTEM "/home/harpreet/symphony_work/symphony/help/en_US/Symphony Native Function/sym_addConstr.xml"> @@ -79,6 +80,7 @@ <part xml:id='section_19f4f1e5726c01d683e8b82be0a7e910'> <title>Symphony Toolbox</title> &a6b85f6e0c98751f20b68663a23cb4cd2; +&a44928acec52adf395379e18fcff06730; &aca972f273143ecb39f56b42e4723ac67; &a9953e61e8dd264a86df73772d3055e7f; <chapter xml:id='section_508f0b211d17ea6769714cc144e6b731'> diff --git a/help/en_US/qpipopt.xml b/help/en_US/qpipopt.xml index d93f758..144fe18 100644 --- a/help/en_US/qpipopt.xml +++ b/help/en_US/qpipopt.xml @@ -38,7 +38,7 @@ <varlistentry><term>nbCon :</term> <listitem><para> a 1 x 1 matrix of doubles, number of constraints</para></listitem></varlistentry> <varlistentry><term>Q :</term> - <listitem><para> a n x n matrix of doubles, where n is number of variables, represents coefficients of quadratic in the quadratic problem.</para></listitem></varlistentry> + <listitem><para> a n x n symmetric matrix of doubles, where n is number of variables, represents coefficients of quadratic in the quadratic problem.</para></listitem></varlistentry> <varlistentry><term>p :</term> <listitem><para> a 1 x n matrix of doubles, where n is number of variables, represents coefficients of linear in the quadratic problem</para></listitem></varlistentry> <varlistentry><term>LB :</term> @@ -91,19 +91,17 @@ We are calling IPOpt for solving the quadratic problem, IPOpt is a library writt <title>Examples</title> <programlisting role="example"><![CDATA[ //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]; -conLB=[1 2 3 -%inf -%inf]'; -conUB = [1 2 3 -1 2.5]'; -//with x between ci and cs: -lb=[-1000 -10000 0 -1000 -1000 -1000]; -ub=[10000 100 1.5 100 100 1000]; +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); +p=[1; 2; 3; 4; 5; 6]; Q=eye(6,6); nbVar = 6; nbCon = 5; [xopt,fopt,exitflag,output,lambda]=qpipopt(nbVar,nbCon,Q,p,lb,ub,conMatrix,conLB,conUB) @@ -114,23 +112,22 @@ nbCon = 5; <refsection> <title>Examples</title> <programlisting role="example"><![CDATA[ -//min. -8*x1 -16*x2 + x1^2 + 4* x2^2 -// such that -// x1 + x2 <= 5, -// x1 <= 3, -// x1 >= 0, -// x2 >= 0 -conMatrix= [1 1]; -conLB=[-%inf]; -conUB = [5]; -//with x between ci and cs: -lb=[0,0]; -ub=[3,%inf]; -//and minimize 0.5*x'*Q*x + p'*x with -p=[-8,-16]; -Q=[1,0;0,4]; +//Find the value of x that minimize following function +// f(x) = 0.5*x1^2 + x2^2 - x1*x2 - 2*x1 - 6*x2 +// Subject to: +// x1 + x2 ≤ 2 +// –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]; +conUB = [2; 2; 3]; +conLB = [-%inf; -%inf; -%inf]; +lb = [0; 0]; +ub = [%inf; %inf]; nbVar = 2; -nbCon = 1; +nbCon = 3; [xopt,fopt,exitflag,output,lambda] = qpipopt(nbVar,nbCon,Q,p,lb,ub,conMatrix,conLB,conUB) ]]></programlisting> diff --git a/help/en_US/qpipopt_mat.xml b/help/en_US/qpipopt_mat.xml new file mode 100644 index 0000000..7dec2b1 --- /dev/null +++ b/help/en_US/qpipopt_mat.xml @@ -0,0 +1,142 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + * + * This help file was generated from qpipopt_mat.sci using help_from_sci(). + * + --> + +<refentry version="5.0-subset Scilab" xml:id="qpipopt_mat" xml:lang="en" + xmlns="http://docbook.org/ns/docbook" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns:ns3="http://www.w3.org/1999/xhtml" + xmlns:mml="http://www.w3.org/1998/Math/MathML" + xmlns:scilab="http://www.scilab.org" + xmlns:db="http://docbook.org/ns/docbook"> + + <refnamediv> + <refname>qpipopt_mat</refname> + <refpurpose>Solves a linear quadratic problem.</refpurpose> + </refnamediv> + + +<refsynopsisdiv> + <title>Calling Sequence</title> + <synopsis> + xopt = qpipopt_mat(nbVar,nbCon,Q,p,LB,UB,conMatrix,conLB,conUB) + x = qpipopt_mat(H,f) + x = qpipopt_mat(H,f,A,b) + x = qpipopt_mat(H,f,A,b,Aeq,beq) + x = qpipopt_mat(H,f,A,b,Aeq,beq,lb,ub) + [xopt,fopt,exitflag,output,lamda] = qpipopt_mat( ... ) + + </synopsis> +</refsynopsisdiv> + +<refsection> + <title>Parameters</title> + <variablelist> + <varlistentry><term>H :</term> + <listitem><para> a n x n matrix of doubles, where n is number of variables, represents coefficients of quadratic in the quadratic problem.</para></listitem></varlistentry> + <varlistentry><term>f :</term> + <listitem><para> a n x 1 matrix of doubles, where n is number of variables, represents coefficients of linear in the quadratic problem</para></listitem></varlistentry> + <varlistentry><term>A :</term> + <listitem><para> a m x n matrix of doubles, represents the linear coefficients in the inequality constraints</para></listitem></varlistentry> + <varlistentry><term>b :</term> + <listitem><para> a column vector of doubles, represents the linear coefficients in the inequality constraints</para></listitem></varlistentry> + <varlistentry><term>Aeq :</term> + <listitem><para> a meq x n matrix of doubles, represents the linear coefficients in the equality constraints</para></listitem></varlistentry> + <varlistentry><term>beq :</term> + <listitem><para> a vector of doubles, represents the linear coefficients in the equality constraints</para></listitem></varlistentry> + <varlistentry><term>LB :</term> + <listitem><para> a n x 1 matrix of doubles, where n is number of variables, contains lower bounds of the variables.</para></listitem></varlistentry> + <varlistentry><term>UB :</term> + <listitem><para> a n x 1 matrix of doubles, where n is number of variables, contains upper bounds of the variables.</para></listitem></varlistentry> + <varlistentry><term>xopt :</term> + <listitem><para> a nx1 matrix of doubles, the computed solution of the optimization problem.</para></listitem></varlistentry> + <varlistentry><term>fopt :</term> + <listitem><para> a 1x1 matrix of doubles, the function value at x.</para></listitem></varlistentry> + <varlistentry><term>exitflag :</term> + <listitem><para> Integer identifying the reason the algorithm terminated.</para></listitem></varlistentry> + <varlistentry><term>output :</term> + <listitem><para> Structure containing information about the optimization.</para></listitem></varlistentry> + <varlistentry><term>lambda :</term> + <listitem><para> Structure containing the Lagrange multipliers at the solution x (separated by constraint type).</para></listitem></varlistentry> + </variablelist> +</refsection> + +<refsection> + <title>Description</title> + <para> +Search the minimum of a constrained linear quadratic optimization problem specified by : +find the minimum of f(x) such that + </para> + <para> +<latex> +\begin{eqnarray} +&\mbox{min}_{x} +& 1/2*x'*H*x + f'*x \\ +& \text{subject to} & A.x \leq b \\ +& & Aeq.x \leq beq \\ +& & lb \leq x \leq ub \\ +\end{eqnarray} +</latex> + </para> + <para> +We are calling IPOpt for solving the quadratic problem, IPOpt is a library written in C++. The code has been written by Andreas Wächter and Carl Laird. + </para> + <para> +</para> +</refsection> + +<refsection> + <title>Examples</title> + <programlisting role="example"><![CDATA[ +//Find x in R^6 such that: + +Aeq= [1,-1,1,0,3,1; +-1,0,-3,-4,5,6; +2,5,3,0,1,0]; +beq=[1; 2; 3]; +A= [0,1,0,1,2,-1; +-1,0,2,1,1,0]; +b = [-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 +f=[1; 2; 3; 4; 5; 6]; H=eye(6,6); +[xopt,fopt,exitflag,output,lambda]=qpipopt_mat(H,f,A,b,Aeq,beq,lb,ub) +clear H f A b Aeq beq lb ub; + + ]]></programlisting> +</refsection> + +<refsection> + <title>Examples</title> + <programlisting role="example"><![CDATA[ +//Find the value of x that minimize following function +// f(x) = 0.5*x1^2 + x2^2 - x1*x2 - 2*x1 - 6*x2 +// Subject to: +// x1 + x2 ≤ 2 +// –x1 + 2x2 ≤ 2 +// 2x1 + x2 ≤ 3 +// 0 ≤ x1, 0 ≤ x2. +H = [1 -1; -1 2]; +f = [-2; -6]; +A = [1 1; -1 2; 2 1]; +b = [2; 2; 3]; +lb = [0; 0]; +ub = [%inf; %inf]; +[xopt,fopt,exitflag,output,lambda] = qpipopt_mat(H,f,A,b,[],[],lb,ub) + + ]]></programlisting> +</refsection> + +<refsection> + <title>Authors</title> + <simplelist type="vert"> + <member>Keyur Joshi, Saikiran, Iswarya, Harpreet Singh</member> + </simplelist> +</refsection> +</refentry> 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 388e399..1b55b83 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 7682874..3b7b18b 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 d55c7ec..e290f81 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 b598af6..7fd9ab2 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/SCHEMA b/help/en_US/scilab_en_US_help/JavaHelpSearch/SCHEMA index 60e895c..59337ab 100644 --- a/help/en_US/scilab_en_US_help/JavaHelpSearch/SCHEMA +++ b/help/en_US/scilab_en_US_help/JavaHelpSearch/SCHEMA @@ -1,2 +1,2 @@ JavaSearch 1.0 -TMAP bs=2048 rt=1 fl=-1 id1=1344 id2=1 +TMAP bs=2048 rt=1 fl=-1 id1=1347 id2=1 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 31347cf..0f25c4d 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/_LaTeX_qpipopt_mat.xml_1.png b/help/en_US/scilab_en_US_help/_LaTeX_qpipopt_mat.xml_1.png Binary files differnew file mode 100644 index 0000000..b6e2743 --- /dev/null +++ b/help/en_US/scilab_en_US_help/_LaTeX_qpipopt_mat.xml_1.png diff --git a/help/en_US/scilab_en_US_help/index.html b/help/en_US/scilab_en_US_help/index.html index 49a4619..2b1442a 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="symphony.html" class="refentry">symphony</a> — <span class="refentry-description">Solves a mixed integer linear programming constrained optimization problem.</span></li> diff --git a/help/en_US/scilab_en_US_help/jhelpmap.jhm b/help/en_US/scilab_en_US_help/jhelpmap.jhm index 54670c0..1601f23 100644 --- a/help/en_US/scilab_en_US_help/jhelpmap.jhm +++ b/help/en_US/scilab_en_US_help/jhelpmap.jhm @@ -4,6 +4,7 @@ <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="symphony" url="symphony.html"/> <mapID target="symphony_mat" url="symphony_mat.html"/> <mapID target="section_508f0b211d17ea6769714cc144e6b731" url="section_508f0b211d17ea6769714cc144e6b731.html"/> diff --git a/help/en_US/scilab_en_US_help/jhelptoc.xml b/help/en_US/scilab_en_US_help/jhelptoc.xml index b2d66e1..463b86d 100644 --- a/help/en_US/scilab_en_US_help/jhelptoc.xml +++ b/help/en_US/scilab_en_US_help/jhelptoc.xml @@ -4,6 +4,7 @@ <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="symphony" text="symphony"/> <tocitem target="symphony_mat" text="symphony_mat"/> <tocitem target="section_508f0b211d17ea6769714cc144e6b731" text="Symphony Native Functions"> diff --git a/help/en_US/scilab_en_US_help/qpipopt.html b/help/en_US/scilab_en_US_help/qpipopt.html index 46b56c7..fba4521 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="symphony.html">symphony >></a></span> + <span class="next"><a href="qpipopt_mat.html">qpipopt_mat >></a></span> </td> </tr></table> @@ -46,7 +46,7 @@ <dt><span class="term">nbCon :</span> <dd><p class="para">a 1 x 1 matrix of doubles, number of constraints</p></dd></dt> <dt><span class="term">Q :</span> - <dd><p class="para">a n x n matrix of doubles, where n is number of variables, represents coefficients of quadratic in the quadratic problem.</p></dd></dt> + <dd><p class="para">a n x n symmetric matrix of doubles, where n is number of variables, represents coefficients of quadratic in the quadratic problem.</p></dd></dt> <dt><span class="term">p :</span> <dd><p class="para">a 1 x n matrix of doubles, where n is number of variables, represents coefficients of linear in the quadratic problem</p></dd></dt> <dt><span class="term">LB :</span> @@ -79,41 +79,38 @@ find the minimum of f(x) such that</p> <div class="refsection"><h3 class="title">Examples</h3> <div class="programlisting"><table border="0" width="100%"><tr><td width="98%"><pre class="scilabcode"><span class="scilabcomment">//Find x in R^6 such that:</span> - <span class="scilabid">conMatrix</span><span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">3</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabdefault">;</span> <span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabnumber">3</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabnumber">4</span><span class="scilabdefault">,</span><span class="scilabnumber">5</span><span class="scilabdefault">,</span><span class="scilabnumber">6</span><span class="scilabdefault">;</span> <span class="scilabnumber">2</span><span class="scilabdefault">,</span><span class="scilabnumber">5</span><span class="scilabdefault">,</span><span class="scilabnumber">3</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span> <span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">2</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">;</span> <span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">2</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> -<span class="scilabid">conLB</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabnumber">1</span> <span class="scilabnumber">2</span> <span class="scilabnumber">3</span> <span class="scilaboperator">-</span><span class="scilabconstants">%inf</span> <span class="scilaboperator">-</span><span class="scilabconstants">%inf</span><span class="scilabopenclose">]</span><span class="scilaboperator">'</span><span class="scilabdefault">;</span> -<span class="scilabid">conUB</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilabnumber">1</span> <span class="scilabnumber">2</span> <span class="scilabnumber">3</span> <span class="scilaboperator">-</span><span class="scilabnumber">1</span> <span class="scilabnumber">2.5</span><span class="scilabopenclose">]</span><span class="scilaboperator">'</span><span class="scilabdefault">;</span> -<span class="scilabcomment">//with x between ci and cs:</span> -<span class="scilabid">lb</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilaboperator">-</span><span class="scilabnumber">1000</span> <span class="scilaboperator">-</span><span class="scilabnumber">10000</span> <span class="scilabnumber">0</span> <span class="scilaboperator">-</span><span class="scilabnumber">1000</span> <span class="scilaboperator">-</span><span class="scilabnumber">1000</span> <span class="scilaboperator">-</span><span class="scilabnumber">1000</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> -<span class="scilabid">ub</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabnumber">10000</span> <span class="scilabnumber">100</span> <span class="scilabnumber">1.5</span> <span class="scilabnumber">100</span> <span class="scilabnumber">100</span> <span class="scilabnumber">1000</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> +<span class="scilabid">conLB</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabnumber">1</span><span class="scilabdefault">;</span><span class="scilabnumber">2</span><span class="scilabdefault">;</span><span class="scilabnumber">3</span><span class="scilabdefault">;</span><span class="scilaboperator">-</span><span class="scilabconstants">%inf</span><span class="scilabdefault">;</span><span class="scilaboperator">-</span><span class="scilabconstants">%inf</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> +<span class="scilabid">conUB</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilabnumber">1</span><span class="scilabdefault">;</span><span class="scilabnumber">2</span><span class="scilabdefault">;</span><span class="scilabnumber">3</span><span class="scilabdefault">;</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">;</span><span class="scilabnumber">2.5</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> +<span class="scilabid">lb</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilaboperator">-</span><span class="scilabnumber">1000</span><span class="scilabdefault">;</span><span class="scilaboperator">-</span><span class="scilabnumber">10000</span><span class="scilabdefault">;</span> <span class="scilabnumber">0</span><span class="scilabdefault">;</span> <span class="scilaboperator">-</span><span class="scilabnumber">1000</span><span class="scilabdefault">;</span> <span class="scilaboperator">-</span><span class="scilabnumber">1000</span><span class="scilabdefault">;</span> <span class="scilaboperator">-</span><span class="scilabnumber">1000</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> +<span class="scilabid">ub</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabnumber">10000</span><span class="scilabdefault">;</span> <span class="scilabnumber">100</span><span class="scilabdefault">;</span> <span class="scilabnumber">1.5</span><span class="scilabdefault">;</span> <span class="scilabnumber">100</span><span class="scilabdefault">;</span> <span class="scilabnumber">100</span><span class="scilabdefault">;</span> <span class="scilabnumber">1000</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> <span class="scilabcomment">//and minimize 0.5*x</span><span class="scilabcomment">'</span><span class="scilabcomment">*Q*x + p</span><span class="scilabcomment">'</span><span class="scilabcomment">*x with</span> -<span class="scilabid">p</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabnumber">1</span><span class="scilabdefault">;</span><span class="scilabnumber">2</span><span class="scilabdefault">;</span><span class="scilabnumber">3</span><span class="scilabdefault">;</span><span class="scilabnumber">4</span><span class="scilabdefault">;</span><span class="scilabnumber">5</span><span class="scilabdefault">;</span><span class="scilabnumber">6</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> <span class="scilabid">Q</span><span class="scilaboperator">=</span><a class="scilabcommand" href="scilab://eye">eye</a><span class="scilabopenclose">(</span><span class="scilabnumber">6</span><span class="scilabdefault">,</span><span class="scilabnumber">6</span><span class="scilabopenclose">)</span><span class="scilabdefault">;</span> +<span class="scilabid">p</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabnumber">1</span><span class="scilabdefault">;</span> <span class="scilabnumber">2</span><span class="scilabdefault">;</span> <span class="scilabnumber">3</span><span class="scilabdefault">;</span> <span class="scilabnumber">4</span><span class="scilabdefault">;</span> <span class="scilabnumber">5</span><span class="scilabdefault">;</span> <span class="scilabnumber">6</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> <span class="scilabid">Q</span><span class="scilaboperator">=</span><a class="scilabcommand" href="scilab://eye">eye</a><span class="scilabopenclose">(</span><span class="scilabnumber">6</span><span class="scilabdefault">,</span><span class="scilabnumber">6</span><span class="scilabopenclose">)</span><span class="scilabdefault">;</span> <span class="scilabid">nbVar</span> <span class="scilaboperator">=</span> <span class="scilabnumber">6</span><span class="scilabdefault">;</span> <span class="scilabid">nbCon</span> <span class="scilaboperator">=</span> <span class="scilabnumber">5</span><span class="scilabdefault">;</span> <span class="scilabopenclose">[</span><span class="scilabid">xopt</span><span class="scilabdefault">,</span><span class="scilabid">fopt</span><span class="scilabdefault">,</span><span class="scilabid">exitflag</span><span class="scilabdefault">,</span><span class="scilabid">output</span><span class="scilabdefault">,</span><span class="scilabid">lambda</span><span class="scilabopenclose">]</span><span class="scilaboperator">=</span><span class="scilabid">qpipopt</span><span class="scilabopenclose">(</span><span class="scilabid">nbVar</span><span class="scilabdefault">,</span><span class="scilabid">nbCon</span><span class="scilabdefault">,</span><span class="scilabid">Q</span><span class="scilabdefault">,</span><span class="scilabid">p</span><span class="scilabdefault">,</span><span class="scilabid">lb</span><span class="scilabdefault">,</span><span class="scilabid">ub</span><span class="scilabdefault">,</span><span class="scilabid">conMatrix</span><span class="scilabdefault">,</span><span class="scilabid">conLB</span><span class="scilabdefault">,</span><span class="scilabid">conUB</span><span class="scilabopenclose">)</span></pre></td><td valign="top"><a href="scilab://scilab.execexample/"><img src="ScilabExecute.png" border="0"/></a></td><td valign="top"><a href="scilab://scilab.editexample/"><img src="ScilabEdit.png" border="0"/></a></td><td></td></tr></table></div></div> <div class="refsection"><h3 class="title">Examples</h3> - <div class="programlisting"><table border="0" width="100%"><tr><td width="98%"><pre class="scilabcode"><span class="scilabcomment">//min. -8*x1 -16*x2 + x1^2 + 4* x2^2</span> -<span class="scilabcomment">// such that</span> -<span class="scilabcomment">// x1 + x2 </span><span class="scilabcomment"><</span><span class="scilabcomment">= 5,</span> -<span class="scilabcomment">// x1 </span><span class="scilabcomment"><</span><span class="scilabcomment">= 3,</span> -<span class="scilabcomment">// x1 </span><span class="scilabcomment">></span><span class="scilabcomment">= 0,</span> -<span class="scilabcomment">// x2 </span><span class="scilabcomment">></span><span class="scilabcomment">= 0</span> -<span class="scilabid">conMatrix</span><span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilabnumber">1</span> <span class="scilabnumber">1</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> -<span class="scilabid">conLB</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilaboperator">-</span><span class="scilabconstants">%inf</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> -<span class="scilabid">conUB</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilabnumber">5</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> -<span class="scilabcomment">//with x between ci and cs:</span> -<span class="scilabid">lb</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> -<span class="scilabid">ub</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabnumber">3</span><span class="scilabdefault">,</span><span class="scilabconstants">%inf</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> -<span class="scilabcomment">//and minimize 0.5*x</span><span class="scilabcomment">'</span><span class="scilabcomment">*Q*x + p</span><span class="scilabcomment">'</span><span class="scilabcomment">*x with</span> -<span class="scilabid">p</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilaboperator">-</span><span class="scilabnumber">8</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabnumber">16</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> -<span class="scilabid">Q</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">;</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">4</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> + <div class="programlisting"><table border="0" width="100%"><tr><td width="98%"><pre class="scilabcode"><span class="scilabcomment">//Find the value of x that minimize following function</span> +<span class="scilabcomment">// f(x) = 0.5*x1^2 + x2^2 - x1*x2 - 2*x1 - 6*x2</span> +<span class="scilabcomment">// Subject to:</span> +<span class="scilabcomment">// x1 + x2 ≤ 2</span> +<span class="scilabcomment">// –x1 + 2x2 ≤ 2</span> +<span class="scilabcomment">// 2x1 + x2 ≤ 3</span> +<span class="scilabcomment">// 0 ≤ x1, 0 ≤ x2.</span> +<span class="scilabid">Q</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilabnumber">1</span> <span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">;</span> <span class="scilaboperator">-</span><span class="scilabnumber">1</span> <span class="scilabnumber">2</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> +<span class="scilabid">p</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilaboperator">-</span><span class="scilabnumber">2</span><span class="scilabdefault">;</span> <span class="scilaboperator">-</span><span class="scilabnumber">6</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> +<span class="scilabid">conMatrix</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilabnumber">1</span> <span class="scilabnumber">1</span><span class="scilabdefault">;</span> <span class="scilaboperator">-</span><span class="scilabnumber">1</span> <span class="scilabnumber">2</span><span class="scilabdefault">;</span> <span class="scilabnumber">2</span> <span class="scilabnumber">1</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> +<span class="scilabid">conUB</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilabnumber">2</span><span class="scilabdefault">;</span> <span class="scilabnumber">2</span><span class="scilabdefault">;</span> <span class="scilabnumber">3</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> +<span class="scilabid">conLB</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilaboperator">-</span><span class="scilabconstants">%inf</span><span class="scilabdefault">;</span> <span class="scilaboperator">-</span><span class="scilabconstants">%inf</span><span class="scilabdefault">;</span> <span class="scilaboperator">-</span><span class="scilabconstants">%inf</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> +<span class="scilabid">lb</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilabnumber">0</span><span class="scilabdefault">;</span> <span class="scilabnumber">0</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> +<span class="scilabid">ub</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilabconstants">%inf</span><span class="scilabdefault">;</span> <span class="scilabconstants">%inf</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> <span class="scilabid">nbVar</span> <span class="scilaboperator">=</span> <span class="scilabnumber">2</span><span class="scilabdefault">;</span> -<span class="scilabid">nbCon</span> <span class="scilaboperator">=</span> <span class="scilabnumber">1</span><span class="scilabdefault">;</span> +<span class="scilabid">nbCon</span> <span class="scilaboperator">=</span> <span class="scilabnumber">3</span><span class="scilabdefault">;</span> <span class="scilabopenclose">[</span><span class="scilabid">xopt</span><span class="scilabdefault">,</span><span class="scilabid">fopt</span><span class="scilabdefault">,</span><span class="scilabid">exitflag</span><span class="scilabdefault">,</span><span class="scilabid">output</span><span class="scilabdefault">,</span><span class="scilabid">lambda</span><span class="scilabopenclose">]</span> <span class="scilaboperator">=</span> <span class="scilabid">qpipopt</span><span class="scilabopenclose">(</span><span class="scilabid">nbVar</span><span class="scilabdefault">,</span><span class="scilabid">nbCon</span><span class="scilabdefault">,</span><span class="scilabid">Q</span><span class="scilabdefault">,</span><span class="scilabid">p</span><span class="scilabdefault">,</span><span class="scilabid">lb</span><span class="scilabdefault">,</span><span class="scilabid">ub</span><span class="scilabdefault">,</span><span class="scilabid">conMatrix</span><span class="scilabdefault">,</span><span class="scilabid">conLB</span><span class="scilabdefault">,</span><span class="scilabid">conUB</span><span class="scilabopenclose">)</span></pre></td><td valign="top"><a href="scilab://scilab.execexample/"><img src="ScilabExecute.png" border="0"/></a></td><td valign="top"><a href="scilab://scilab.editexample/"><img src="ScilabEdit.png" border="0"/></a></td><td></td></tr></table></div></div> <div class="refsection"><h3 class="title">Authors</h3> @@ -133,7 +130,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="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 new file mode 100644 index 0000000..5e30769 --- /dev/null +++ b/help/en_US/scilab_en_US_help/qpipopt_mat.html @@ -0,0 +1,139 @@ +<html><head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> + <title>qpipopt_mat</title> + <style type="text/css" media="all"> + @import url("scilab_code.css"); + @import url("xml_code.css"); + @import url("c_code.css"); + @import url("style.css"); + </style> + </head> + <body> + <div class="manualnavbar"> + <table width="100%"><tr> + <td width="30%"> + <span class="previous"><a href="qpipopt.html"><< qpipopt</a></span> + + </td> + <td width="40%" class="center"> + <span class="top"><a href="section_19f4f1e5726c01d683e8b82be0a7e910.html">Symphony Toolbox</a></span> + + </td> + <td width="30%" class="next"> + <span class="next"><a href="symphony.html">symphony >></a></span> + + </td> + </tr></table> + <hr /> + </div> + + + + <span class="path"><a href="index.html">Symphony Toolbox</a> >> <a href="section_19f4f1e5726c01d683e8b82be0a7e910.html">Symphony Toolbox</a> > qpipopt_mat</span> + + <br /><br /> + <div class="refnamediv"><h1 class="refname">qpipopt_mat</h1> + <p class="refpurpose">Solves a linear quadratic problem.</p></div> + + +<div class="refsynopsisdiv"><h3 class="title">Calling Sequence</h3> + <div class="synopsis"><pre><span class="default">xopt</span><span class="default"> = </span><span class="functionid">qpipopt_mat</span><span class="default">(</span><span class="default">nbVar</span><span class="default">,</span><span class="default">nbCon</span><span class="default">,</span><span class="default">Q</span><span class="default">,</span><span class="default">p</span><span class="default">,</span><span class="default">LB</span><span class="default">,</span><span class="default">UB</span><span class="default">,</span><span class="default">conMatrix</span><span class="default">,</span><span class="default">conLB</span><span class="default">,</span><span class="default">conUB</span><span class="default">)</span> +<span class="default">x</span><span class="default"> = </span><span class="functionid">qpipopt_mat</span><span class="default">(</span><span class="default">H</span><span class="default">,</span><span class="default">f</span><span class="default">)</span> +<span class="default">x</span><span class="default"> = </span><span class="functionid">qpipopt_mat</span><span class="default">(</span><span class="default">H</span><span class="default">,</span><span class="default">f</span><span class="default">,</span><span class="default">A</span><span class="default">,</span><span class="default">b</span><span class="default">)</span> +<span class="default">x</span><span class="default"> = </span><span class="functionid">qpipopt_mat</span><span class="default">(</span><span class="default">H</span><span class="default">,</span><span class="default">f</span><span class="default">,</span><span class="default">A</span><span class="default">,</span><span class="default">b</span><span class="default">,</span><span class="default">Aeq</span><span class="default">,</span><span class="default">beq</span><span class="default">)</span> +<span class="default">x</span><span class="default"> = </span><span class="functionid">qpipopt_mat</span><span class="default">(</span><span class="default">H</span><span class="default">,</span><span class="default">f</span><span class="default">,</span><span class="default">A</span><span class="default">,</span><span class="default">b</span><span class="default">,</span><span class="default">Aeq</span><span class="default">,</span><span class="default">beq</span><span class="default">,</span><span class="default">lb</span><span class="default">,</span><span class="default">ub</span><span class="default">)</span> +<span class="default">[</span><span class="default">xopt</span><span class="default">,</span><span class="default">fopt</span><span class="default">,</span><span class="default">exitflag</span><span class="default">,</span><span class="default">output</span><span class="default">,</span><span class="default">lamda</span><span class="default">] = </span><span class="functionid">qpipopt_mat</span><span class="default">( ... )</span></pre></div></div> + +<div class="refsection"><h3 class="title">Parameters</h3> + <dl><dt><span class="term">H :</span> + <dd><p class="para">a n x n matrix of doubles, where n is number of variables, represents coefficients of quadratic in the quadratic problem.</p></dd></dt> + <dt><span class="term">f :</span> + <dd><p class="para">a n x 1 matrix of doubles, where n is number of variables, represents coefficients of linear in the quadratic problem</p></dd></dt> + <dt><span class="term">A :</span> + <dd><p class="para">a m x n matrix of doubles, represents the linear coefficients in the inequality constraints</p></dd></dt> + <dt><span class="term">b :</span> + <dd><p class="para">a column vector of doubles, represents the linear coefficients in the inequality constraints</p></dd></dt> + <dt><span class="term">Aeq :</span> + <dd><p class="para">a meq x n matrix of doubles, represents the linear coefficients in the equality constraints</p></dd></dt> + <dt><span class="term">beq :</span> + <dd><p class="para">a vector of doubles, represents the linear coefficients in the equality constraints</p></dd></dt> + <dt><span class="term">LB :</span> + <dd><p class="para">a n x 1 matrix of doubles, where n is number of variables, contains lower bounds of the variables.</p></dd></dt> + <dt><span class="term">UB :</span> + <dd><p class="para">a n x 1 matrix of doubles, where n is number of variables, contains upper bounds of the variables.</p></dd></dt> + <dt><span class="term">xopt :</span> + <dd><p class="para">a nx1 matrix of doubles, the computed solution of the optimization problem.</p></dd></dt> + <dt><span class="term">fopt :</span> + <dd><p class="para">a 1x1 matrix of doubles, the function value at x.</p></dd></dt> + <dt><span class="term">exitflag :</span> + <dd><p class="para">Integer identifying the reason the algorithm terminated.</p></dd></dt> + <dt><span class="term">output :</span> + <dd><p class="para">Structure containing information about the optimization.</p></dd></dt> + <dt><span class="term">lambda :</span> + <dd><p class="para">Structure containing the Lagrange multipliers at the solution x (separated by constraint type).</p></dd></dt></dl></div> + +<div class="refsection"><h3 class="title">Description</h3> + <p class="para">Search the minimum of a constrained linear quadratic optimization problem specified by : +find the minimum of f(x) such that</p> + <p class="para"><span><img src='./_LaTeX_qpipopt_mat.xml_1.png' style='position:relative;top:40px;width:284px;height:88px'/></span></p> + <p class="para">We are calling IPOpt for solving the quadratic problem, IPOpt is a library written in C++. The code has been written by Andreas Wächter and Carl Laird.</p> + <p class="para"></p></div> + +<div class="refsection"><h3 class="title">Examples</h3> + <div class="programlisting"><table border="0" width="100%"><tr><td width="98%"><pre class="scilabcode"><span class="scilabcomment">//Find x in R^6 such that:</span> + +<span class="scilabid">Aeq</span><span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">3</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabdefault">;</span> +<span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabnumber">3</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabnumber">4</span><span class="scilabdefault">,</span><span class="scilabnumber">5</span><span class="scilabdefault">,</span><span class="scilabnumber">6</span><span class="scilabdefault">;</span> +<span class="scilabnumber">2</span><span class="scilabdefault">,</span><span class="scilabnumber">5</span><span class="scilabdefault">,</span><span class="scilabnumber">3</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> +<span class="scilabid">beq</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabnumber">1</span><span class="scilabdefault">;</span> <span class="scilabnumber">2</span><span class="scilabdefault">;</span> <span class="scilabnumber">3</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> +<span class="scilabid">A</span><span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">2</span><span class="scilabdefault">,</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">;</span> +<span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabdefault">,</span><span class="scilabnumber">2</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">1</span><span class="scilabdefault">,</span><span class="scilabnumber">0</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> +<span class="scilabid">b</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">;</span> <span class="scilabnumber">2.5</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> +<span class="scilabid">lb</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilaboperator">-</span><span class="scilabnumber">1000</span><span class="scilabdefault">;</span> <span class="scilaboperator">-</span><span class="scilabnumber">10000</span><span class="scilabdefault">;</span> <span class="scilabnumber">0</span><span class="scilabdefault">;</span> <span class="scilaboperator">-</span><span class="scilabnumber">1000</span><span class="scilabdefault">;</span> <span class="scilaboperator">-</span><span class="scilabnumber">1000</span><span class="scilabdefault">;</span> <span class="scilaboperator">-</span><span class="scilabnumber">1000</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> +<span class="scilabid">ub</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabnumber">10000</span><span class="scilabdefault">;</span> <span class="scilabnumber">100</span><span class="scilabdefault">;</span> <span class="scilabnumber">1.5</span><span class="scilabdefault">;</span> <span class="scilabnumber">100</span><span class="scilabdefault">;</span> <span class="scilabnumber">100</span><span class="scilabdefault">;</span> <span class="scilabnumber">1000</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> +<span class="scilabcomment">//and minimize 0.5*x</span><span class="scilabcomment">'</span><span class="scilabcomment">*Q*x + p</span><span class="scilabcomment">'</span><span class="scilabcomment">*x with</span> +<span class="scilabid">f</span><span class="scilaboperator">=</span><span class="scilabopenclose">[</span><span class="scilabnumber">1</span><span class="scilabdefault">;</span> <span class="scilabnumber">2</span><span class="scilabdefault">;</span> <span class="scilabnumber">3</span><span class="scilabdefault">;</span> <span class="scilabnumber">4</span><span class="scilabdefault">;</span> <span class="scilabnumber">5</span><span class="scilabdefault">;</span> <span class="scilabnumber">6</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> <span class="scilabid">H</span><span class="scilaboperator">=</span><a class="scilabcommand" href="scilab://eye">eye</a><span class="scilabopenclose">(</span><span class="scilabnumber">6</span><span class="scilabdefault">,</span><span class="scilabnumber">6</span><span class="scilabopenclose">)</span><span class="scilabdefault">;</span> +<span class="scilabopenclose">[</span><span class="scilabid">xopt</span><span class="scilabdefault">,</span><span class="scilabid">fopt</span><span class="scilabdefault">,</span><span class="scilabid">exitflag</span><span class="scilabdefault">,</span><span class="scilabid">output</span><span class="scilabdefault">,</span><span class="scilabid">lambda</span><span class="scilabopenclose">]</span><span class="scilaboperator">=</span><span class="scilabid">qpipopt_mat</span><span class="scilabopenclose">(</span><span class="scilabid">H</span><span class="scilabdefault">,</span><span class="scilabid">f</span><span class="scilabdefault">,</span><span class="scilabid">A</span><span class="scilabdefault">,</span><span class="scilabid">b</span><span class="scilabdefault">,</span><span class="scilabid">Aeq</span><span class="scilabdefault">,</span><span class="scilabid">beq</span><span class="scilabdefault">,</span><span class="scilabid">lb</span><span class="scilabdefault">,</span><span class="scilabid">ub</span><span class="scilabopenclose">)</span> +<span class="scilabid">clear</span> <span class="scilabid">H</span> <span class="scilabid">f</span> <span class="scilabid">A</span> <span class="scilabid">b</span> <span class="scilabid">Aeq</span> <span class="scilabid">beq</span> <span class="scilabid">lb</span> <span class="scilabid">ub</span><span class="scilabdefault">;</span></pre></td><td valign="top"><a href="scilab://scilab.execexample/"><img src="ScilabExecute.png" border="0"/></a></td><td valign="top"><a href="scilab://scilab.editexample/"><img src="ScilabEdit.png" border="0"/></a></td><td></td></tr></table></div></div> + +<div class="refsection"><h3 class="title">Examples</h3> + <div class="programlisting"><table border="0" width="100%"><tr><td width="98%"><pre class="scilabcode"><span class="scilabcomment">//Find the value of x that minimize following function</span> +<span class="scilabcomment">// f(x) = 0.5*x1^2 + x2^2 - x1*x2 - 2*x1 - 6*x2</span> +<span class="scilabcomment">// Subject to:</span> +<span class="scilabcomment">// x1 + x2 ≤ 2</span> +<span class="scilabcomment">// –x1 + 2x2 ≤ 2</span> +<span class="scilabcomment">// 2x1 + x2 ≤ 3</span> +<span class="scilabcomment">// 0 ≤ x1, 0 ≤ x2.</span> +<span class="scilabid">H</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilabnumber">1</span> <span class="scilaboperator">-</span><span class="scilabnumber">1</span><span class="scilabdefault">;</span> <span class="scilaboperator">-</span><span class="scilabnumber">1</span> <span class="scilabnumber">2</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> +<span class="scilabid">f</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilaboperator">-</span><span class="scilabnumber">2</span><span class="scilabdefault">;</span> <span class="scilaboperator">-</span><span class="scilabnumber">6</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> +<span class="scilabid">A</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilabnumber">1</span> <span class="scilabnumber">1</span><span class="scilabdefault">;</span> <span class="scilaboperator">-</span><span class="scilabnumber">1</span> <span class="scilabnumber">2</span><span class="scilabdefault">;</span> <span class="scilabnumber">2</span> <span class="scilabnumber">1</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> +<span class="scilabid">b</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilabnumber">2</span><span class="scilabdefault">;</span> <span class="scilabnumber">2</span><span class="scilabdefault">;</span> <span class="scilabnumber">3</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> +<span class="scilabid">lb</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilabnumber">0</span><span class="scilabdefault">;</span> <span class="scilabnumber">0</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> +<span class="scilabid">ub</span> <span class="scilaboperator">=</span> <span class="scilabopenclose">[</span><span class="scilabconstants">%inf</span><span class="scilabdefault">;</span> <span class="scilabconstants">%inf</span><span class="scilabopenclose">]</span><span class="scilabdefault">;</span> +<span class="scilabopenclose">[</span><span class="scilabid">xopt</span><span class="scilabdefault">,</span><span class="scilabid">fopt</span><span class="scilabdefault">,</span><span class="scilabid">exitflag</span><span class="scilabdefault">,</span><span class="scilabid">output</span><span class="scilabdefault">,</span><span class="scilabid">lambda</span><span class="scilabopenclose">]</span> <span class="scilaboperator">=</span> <span class="scilabid">qpipopt_mat</span><span class="scilabopenclose">(</span><span class="scilabid">H</span><span class="scilabdefault">,</span><span class="scilabid">f</span><span class="scilabdefault">,</span><span class="scilabid">A</span><span class="scilabdefault">,</span><span class="scilabid">b</span><span class="scilabdefault">,</span><span class="scilabopenclose">[</span><span class="scilabopenclose">]</span><span class="scilabdefault">,</span><span class="scilabopenclose">[</span><span class="scilabopenclose">]</span><span class="scilabdefault">,</span><span class="scilabid">lb</span><span class="scilabdefault">,</span><span class="scilabid">ub</span><span class="scilabopenclose">)</span></pre></td><td valign="top"><a href="scilab://scilab.execexample/"><img src="ScilabExecute.png" border="0"/></a></td><td valign="top"><a href="scilab://scilab.editexample/"><img src="ScilabEdit.png" border="0"/></a></td><td></td></tr></table></div></div> + +<div class="refsection"><h3 class="title">Authors</h3> + <ul class="itemizedlist"><li class="member">Keyur Joshi, Saikiran, Iswarya, Harpreet Singh</li></ul></div> + <br /> + + <div class="manualnavbar"> + <table width="100%"> + <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> + + </td> + <td width="40%" class="center"> + <span class="top"><a href="section_19f4f1e5726c01d683e8b82be0a7e910.html">Symphony Toolbox</a></span> + + </td> + <td width="30%" class="next"> + <span class="next"><a href="symphony.html">symphony >></a></span> + + </td> + </tr></table> + <hr /> + </div> + </body> +</html> 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 0f8d441..ed07ab6 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="symphony.html" class="refentry">symphony</a> — <span class="refentry-description">Solves a mixed integer linear programming constrained optimization problem.</span></li> diff --git a/help/en_US/scilab_en_US_help/symphony.html b/help/en_US/scilab_en_US_help/symphony.html index 7e155bc..0af9d1b 100644 --- a/help/en_US/scilab_en_US_help/symphony.html +++ b/help/en_US/scilab_en_US_help/symphony.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"> @@ -197,7 +197,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="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/hs_err_pid20719.log b/hs_err_pid20719.log new file mode 100644 index 0000000..c1efcc0 --- /dev/null +++ b/hs_err_pid20719.log @@ -0,0 +1,173 @@ +# +# A fatal error has been detected by the Java Runtime Environment: +# +# SIGSEGV (0xb) at pc=0x0000000000000020, pid=20719, tid=140693220591488 +# +# JRE version: OpenJDK Runtime Environment (7.0_79-b14) (build 1.7.0_79-b14) +# Java VM: OpenJDK 64-Bit Server VM (24.79-b02 mixed mode linux-amd64 compressed oops) +# Derivative: IcedTea 2.5.6 +# Distribution: Ubuntu 14.04 LTS, package 7u79-2.5.6-0ubuntu1.14.04.1 +# Problematic frame: +# C 0x0000000000000020 +# +# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again +# +# If you would like to submit a bug report, please include +# instructions on how to reproduce the bug and visit: +# http://icedtea.classpath.org/bugzilla +# The crash happened outside the Java Virtual Machine in native code. +# See problematic frame for where to report the bug. +# + +--------------- T H R E A D --------------- + +Current thread (0x000000000093d800): JavaThread "main" [_thread_in_native, id=20719, stack(0x00007fffa831b000,0x00007fffa841b000)] + +siginfo:si_signo=SIGSEGV: si_errno=0, si_code=1 (SEGV_MAPERR), si_addr=0x0000000000000020 + +Registers: +RAX=0x0000000000001000, RBX=0x000000000112b5f0, RCX=0x00007ff5a652282d, RDX=0x0000000000001000 +RSP=0x00007fffa84180f0, RBP=0x0000000000000000, RSI=0x00007ff544005000, RDI=0x0000000000000000 +R8 =0x0000000000001000, R9 =0x00007fffa841823c, R10=0x0000000000000022, R11=0x0000000000000000 +R12=0x0000000000000004, R13=0x0000000000000004, R14=0x00007fffa841823c, R15=0x0000000000000001 +RIP=0x0000000000000020, EFLAGS=0x0000000000010217, CSGSFS=0x0000000000000033, ERR=0x0000000000000014 + TRAPNO=0x000000000000000e + +Top of Stack: (sp=0x00007fffa84180f0) +0x00007fffa84180f0: 000000000000000b 0000000000000001 +0x00007fffa8418100: 00007fffa84385b0 00007ff5a64b0498 +0x00007fffa8418110: ffff88012ed93e80 0000000000000000 +0x00007fffa8418120: 0000000000000004 0000000000000001 +0x00007fffa8418130: 00007fffa8418230 00007ff5a64a593f +0x00007fffa8418140: 0000000000000fd9 00007fffa841823c +0x00007fffa8418150: 00007ff5ae66d288 00007ff5ae40da8d +0x00007fffa8418160: 000000000112b5f0 00007ff5ae0b00c3 +0x00007fffa8418170: 00007fffa8418230 000000000000003a +0x00007fffa8418180: 000000000000037f 00007ff5b05ef0c0 +0x00007fffa8418190: 00007ff5b0596280 0002ffff00001fa0 +0x00007fffa84181a0: 0000000000000000 0000000000000000 +0x00007fffa84181b0: 0000000000000000 0000000000000000 +0x00007fffa84181c0: 0000000000000000 0000000000000000 +0x00007fffa84181d0: 0000000000000000 0000000000000000 +0x00007fffa84181e0: 0000000000000000 0000000000000000 +0x00007fffa84181f0: 0000000000000000 0000000000000000 +0x00007fffa8418200: 0000000000000000 0000000000000000 +0x00007fffa8418210: 0000000000000000 0000000000000000 +0x00007fffa8418220: 00000000000000ff 00000000000000ff +0x00007fffa8418230: 2525252525252525 2525252525252525 +0x00007fffa8418240: 6f7272652d2d2120 2020203939392072 +0x00007fffa8418250: 0000000000000000 0000000000000000 +0x00007fffa8418260: 00000000000000ff 00000000000000ff +0x00007fffa8418270: 000000003717f7d1 0000000000000000 +0x00007fffa8418280: 00000000bcc8d589 0000000000000000 +0x00007fffa8418290: 0000000000000000 0000000000000000 +0x00007fffa84182a0: 0000000000ff0000 0000000000000000 +0x00007fffa84182b0: 0000000000000000 0000ff0000000000 +0x00007fffa84182c0: 0000000000000000 ff00000000000000 +0x00007fffa84182d0: 0000ff0000000000 0000000000000000 +0x00007fffa84182e0: 0000000000ff0000 0000000000000000 + +Instructions: (pc=0x0000000000000020) +0x0000000000000000: +[error occurred during error reporting (printing registers, top of stack, instructions near pc), id 0xb] + +Register to memory mapping: + +RAX=0x0000000000001000 is an unknown value +RBX=0x000000000112b5f0 is an unknown value +RCX=0x00007ff5a652282d: __read+0x2d in /lib/x86_64-linux-gnu/libc.so.6 at 0x00007ff5a6437000 +RDX=0x0000000000001000 is an unknown value +RSP=0x00007fffa84180f0 is pointing into the stack for thread: 0x000000000093d800 +RBP=0x0000000000000000 is an unknown value +RSI=0x00007ff544005000 is an unknown value +RDI=0x0000000000000000 is an unknown value +R8 =0x0000000000001000 is an unknown value +R9 =0x00007fffa841823c is pointing into the stack for thread: 0x000000000093d800 +R10=0x0000000000000022 is an unknown value +R11=0x0000000000000000 is an unknown value +R12=0x0000000000000004 is an unknown value +R13=0x0000000000000004 is an unknown value +R14=0x00007fffa841823c is pointing into the stack for thread: 0x000000000093d800 +R15=0x0000000000000001 is an unknown value + + +Stack: [0x00007fffa831b000,0x00007fffa841b000], sp=0x00007fffa84180f0, free space=1012k +Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) +C 0x0000000000000020 + +[error occurred during error reporting (printing native stack), id 0xb] + + +--------------- P R O C E S S --------------- + +Java Threads: ( => current thread ) + 0x0000000000e4f800 JavaThread "main-SharedResourceRunner" daemon [_thread_blocked, id=20736, stack(0x00007ff5915c7000,0x00007ff5916c8000)] + 0x0000000000d12000 JavaThread "AWT-XAWT" daemon [_thread_in_vm, id=20733, stack(0x00007ff592783000,0x00007ff592884000)] + 0x0000000000cfa000 JavaThread "Java2D Disposer" daemon [_thread_blocked, id=20732, stack(0x00007ff592c94000,0x00007ff592d95000)] + 0x0000000000a23800 JavaThread "Service Thread" daemon [_thread_blocked, id=20730, stack(0x00007ff599c9d000,0x00007ff599d9e000)] + 0x0000000000a21800 JavaThread "C2 CompilerThread1" daemon [_thread_blocked, id=20729, stack(0x00007ff599d9e000,0x00007ff599e9f000)] + 0x0000000000a1e800 JavaThread "C2 CompilerThread0" daemon [_thread_blocked, id=20728, stack(0x00007ff599e9f000,0x00007ff599fa0000)] + 0x0000000000a1c800 JavaThread "Attach Listener" daemon [_thread_blocked, id=20727, stack(0x00007ff599fa0000,0x00007ff59a0a1000)] + 0x00000000009f2800 JavaThread "Finalizer" daemon [_thread_blocked, id=20726, stack(0x00007ff59a0a1000,0x00007ff59a1a2000)] + 0x00000000009f0800 JavaThread "Reference Handler" daemon [_thread_blocked, id=20725, stack(0x00007ff59a1a2000,0x00007ff59a2a3000)] +=>0x000000000093d800 JavaThread "main" [_thread_in_native, id=20719, stack(0x00007fffa831b000,0x00007fffa841b000)] + +Other Threads: + 0x00000000009ec000 VMThread [stack: 0x00007ff59a2a3000,0x00007ff59a3a4000] [id=20724] + 0x0000000000a2e800 WatcherThread [stack: 0x00007ff599b9c000,0x00007ff599c9d000] [id=20731] + +VM state:not at safepoint (normal execution) + +VM Mutex/Monitor currently owned by a thread: None + +Heap + PSYoungGen total 62464K, used 16672K [0x00000000faa80000, 0x0000000100000000, 0x0000000100000000) + eden space 54272K, 19% used [0x00000000faa80000,0x00000000fb4e6e88,0x00000000fdf80000) + from space 8192K, 73% used [0x00000000fdf80000,0x00000000fe5612c0,0x00000000fe780000) + to space 8704K, 0% used [0x00000000ff780000,0x00000000ff780000,0x0000000100000000) + ParOldGen total 35328K, used 10290K [0x00000000f0000000, 0x00000000f2280000, 0x00000000faa80000) + object space 35328K, 29% used [0x00000000f0000000,0x00000000f0a0cbd0,0x00000000f2280000) + PSPermGen total 24064K, used 23724K [0x00000000e5a00000, 0x00000000e7180000, 0x00000000f0000000) + object space 24064K, 98% used [0x00000000e5a00000,0x00000000e712b1f8,0x00000000e7180000) + +Card table byte_map: [0x00007ff5b1563000,0x00007ff5b1637000] byte_map_base: 0x00007ff5b0e36000 + +Polling page: 0x00007ff5b173d000 + +Code Cache [0x00007ff59bad0000, 0x00007ff59bd40000, 0x00007ff59ead0000) + total_blobs=1355 nmethods=500 adapters=809 free_code_cache=47022Kb largest_free_block=48093248 + +Compilation events (10 events): +Event: 8180.565 Thread 0x0000000000a21800 520 java.util.concurrent.locks.AbstractOwnableSynchronizer::getExclusiveOwnerThread (5 bytes) +Event: 8180.566 Thread 0x0000000000a21800 nmethod 520 0x00007ff59bc1d450 code [0x00007ff59bc1d580, 0x00007ff59bc1d5d8] +Event: 8233.641 Thread 0x0000000000a1e800 521 java.util.concurrent.locks.AbstractQueuedSynchronizer::setState (6 bytes) +Event: 8233.642 Thread 0x0000000000a1e800 nmethod 521 0x00007ff59bce8690 code [0x00007ff59bce87c0, 0x00007ff59bce8818] +Event: 8520.046 Thread 0x0000000000a21800 522 java.util.concurrent.locks.AbstractQueuedSynchronizer::compareAndSetState (13 bytes) +Event: 8520.047 Thread 0x0000000000a21800 nmethod 522 0x00007ff59bce8490 code [0x00007ff59bce85c0, 0x00007ff59bce8618] +Event: 8520.547 Thread 0x0000000000a1e800 523 java.util.concurrent.locks.AbstractQueuedSynchronizer::release (33 bytes) +Event: 8520.551 Thread 0x0000000000a1e800 nmethod 523 0x00007ff59bc4a550 code [0x00007ff59bc4a6a0, 0x00007ff59bc4a788] +Event: 8522.049 Thread 0x0000000000a21800 524 java.util.concurrent.locks.ReentrantLock::unlock (10 bytes) +Event: 8522.054 Thread 0x0000000000a21800 nmethod 524 0x00007ff59bc4a210 code [0x00007ff59bc4a360, 0x00007ff59bc4a448] + +GC Heap History (10 events): +Event: 3.643 GC heap before +{Heap before GC invocations=3 (full 0): + PSYoungGen total 15872K, used 15840K [0x00000000faa80000, 0x00000000fc980000, 0x0000000100000000) + eden space 13824K, 100% used [0x00000000faa80000,0x00000000fb800000,0x00000000fb800000) + from space 2048K, 98% used [0x00000000fba00000,0x00000000fbbf8020,0x00000000fbc00000) + to space 2048K, 0% used [0x00000000fb800000,0x00000000fb800000,0x00000000fba00000) + ParOldGen total 35328K, used 3941K [0x00000000f0000000, 0x00000000f2280000, 0x00000000faa80000) + object space 35328K, 11% used [0x00000000f0000000,0x00000000f03d96d8,0x00000000f2280000) + PSPermGen total 21504K, used 17695K [0x00000000e5a00000, 0x00000000e6f00000, 0x00000000f0000000) + object space 21504K, 82% used [0x00000000e5a00000,0x00000000e6b47ef8,0x00000000e6f00000) +Event: 3.667 GC heap after +Heap after GC invocations=3 (full 0): + PSYoungGen total 15872K, used 2016K [0x00000000faa80000, 0x00000000fc980000, 0x0000000100000000) + eden space 13824K, 0% used [0x00000000faa80000,0x00000000faa80000,0x00000000fb800000) + from space 2048K, 98% used [0x00000000fb800000,0x00000000fb9f8020,0x00000000fba00000) + to space 2048K, 0% used [0x00000000fc780000,0x00000000fc780000,0x00000000fc980000) + ParOldGen total 35328K, used 4411K [0x00000000f0000000, 0x00000000f2280000, 0x00000000faa80000) + object space 35328K, 12% used [0x00000000f0000000,0x00000000f044efd8,0x00000000f2280000) + PSPermGen total 21504K, used 17695K [0x00000000e5a00000, 0x00000000e6f00000, 0x00000000f0000000) + object space 21504K, 82% used [0x00000000e5a00000,0x00000000e6b47ef8,0x00000000e6f00000) +} diff --git a/jar/scilab_en_US_help.jar b/jar/scilab_en_US_help.jar Binary files differBinary files differindex 51f187b..61cfd75 100644 --- a/jar/scilab_en_US_help.jar +++ b/jar/scilab_en_US_help.jar diff --git a/macros/names b/macros/names index da92859..ef678fc 100644 --- a/macros/names +++ b/macros/names @@ -1,4 +1,5 @@ qpipopt +qpipopt_mat setOptions symphony symphony_call diff --git a/macros/qpipopt.bin b/macros/qpipopt.bin Binary files differindex 594d645..757b5b6 100644 --- a/macros/qpipopt.bin +++ b/macros/qpipopt.bin diff --git a/macros/qpipopt.sci b/macros/qpipopt.sci index 0d1b6b6..4f8c535 100644 --- a/macros/qpipopt.sci +++ b/macros/qpipopt.sci @@ -20,7 +20,7 @@ function [xopt,fopt,exitflag,output,lambda] = qpipopt (varargin) // 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 matrix of doubles, where n is number of variables, represents coefficients of quadratic in the quadratic problem. + // 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 1 x n matrix of doubles, where n is number of variables, represents coefficients of linear in the quadratic problem // LB : a 1 x n matrix of doubles, where n is number of variables, contains 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. @@ -50,42 +50,39 @@ function [xopt,fopt,exitflag,output,lambda] = qpipopt (varargin) // // 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]; - // conLB=[1 2 3 -%inf -%inf]'; - // conUB = [1 2 3 -1 2.5]'; - // //with x between ci and cs: - // lb=[-1000 -10000 0 -1000 -1000 -1000]; - // ub=[10000 100 1.5 100 100 1000]; + // 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); + // p=[1; 2; 3; 4; 5; 6]; Q=eye(6,6); // nbVar = 6; // nbCon = 5; // [xopt,fopt,exitflag,output,lambda]=qpipopt(nbVar,nbCon,Q,p,lb,ub,conMatrix,conLB,conUB) // // Examples - // //min. -8*x1 -16*x2 + x1^2 + 4* x2^2 - // // such that - // // x1 + x2 <= 5, - // // x1 <= 3, - // // x1 >= 0, - // // x2 >= 0 - // conMatrix= [1 1]; - // conLB=[-%inf]; - // conUB = [5]; - // //with x between ci and cs: - // lb=[0,0]; - // ub=[3,%inf]; - // //and minimize 0.5*x'*Q*x + p'*x with - // p=[-8,-16]; - // Q=[1,0;0,4]; - // nbVar = 2; - // nbCon = 1; - // [xopt,fopt,exitflag,output,lambda] = qpipopt(nbVar,nbCon,Q,p,lb,ub,conMatrix,conLB,conUB) + // //Find the value of x that minimize following function + // // f(x) = 0.5*x1^2 + x2^2 - x1*x2 - 2*x1 - 6*x2 + // // Subject to: + // // x1 + x2 ≤ 2 + // // –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]; + // 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) // // Authors // Keyur Joshi, Saikiran, Iswarya, Harpreet Singh @@ -109,10 +106,21 @@ function [xopt,fopt,exitflag,output,lambda] = qpipopt (varargin) UB = varargin(6); conMatrix = varargin(7); conLB = varargin(8); - conLB = conLB'; //IPOpt wants it in row matrix form conUB = varargin(9); - conUB = conUB'; //IPOpt wants it in row matrix form + //IPOpt wants it in row matrix form + p = p'; + LB = LB'; + UB = UB'; + conLB = conLB'; + conUB = conUB'; + + //Checking the Q matrix which needs to be a symmetric matrix + if ( Q~=Q') then + errmsg = msprintf(gettext("%s: Q 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"); @@ -126,31 +134,31 @@ function [xopt,fopt,exitflag,output,lambda] = qpipopt (varargin) 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"), "qpipopt"); + //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 -//Check the size of Lower Bound which should equal to the number of variables + //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"); error(errmsg); end -//Check the size of Upper Bound which should equal to the number of variables + //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"); error(errmsg); end -//Check the size of constraints of Lower Bound which should equal to the number of constraints + //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"); error(errmsg); end -//Check the size of constraints of Upper Bound which should equal to the number of constraints + //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"), "qp_ipopt"); error(errmsg); diff --git a/macros/qpipopt.sci~ b/macros/qpipopt.sci~ new file mode 100644 index 0000000..407a6b7 --- /dev/null +++ b/macros/qpipopt.sci~ @@ -0,0 +1,172 @@ +// Copyright (C) 2015 - IIT Bombay - FOSSEE +// +// Author: Harpreet Singh +// Organization: FOSSEE, IIT Bombay +// Email: harpreet.mertia@gmail.com +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + + +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,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 1 x n matrix of doubles, where n is number of variables, represents coefficients of linear in the quadratic problem + // LB : a 1 x n matrix of doubles, where n is number of variables, contains 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. + // 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. + // xopt : a 1xn matrix of doubles, the computed solution of the optimization problem. + // fopt : a 1x1 matrix of doubles, 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). + // + // Description + // Search the minimum of a constrained linear quadratic optimization problem specified by : + // find the minimum of f(x) such that + // + // <latex> + // \begin{eqnarray} + // &\mbox{min}_{x} + // & 1/2*x'*Q*x + p'*x \\ + // & \text{subject to} & conLB \leq C(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 code has been written by Andreas Wächter and Carl Laird. + // + // 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]; + // 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); + // nbVar = 6; + // nbCon = 5; + // [xopt,fopt,exitflag,output,lambda]=qpipopt(nbVar,nbCon,Q,p,lb,ub,conMatrix,conLB,conUB) + // + // Examples + // Q = [1 -1; -1 2]; + // p = [-2 -6]; + // conMatrix = [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) + // + // Authors + // Keyur Joshi, Saikiran, Iswarya, Harpreet Singh + + +//To check the number of input and output argument + [lhs , rhs] = argn(); + +//To check the number of argument given by user + if ( rhs ~= 9 ) then + errmsg = msprintf(gettext("%s: Unexpected number of input arguments : %d provided while should be 9"), "qpipopt", rhs); + error(errmsg) + end + + + nbVar = varargin(1); + nbCon = varargin(2); + Q = varargin(3); + p = varargin(4); + LB = varargin(5); + UB = varargin(6); + conMatrix = varargin(7); + conLB = varargin(8); + conLB = conLB'; //IPOpt wants it in row matrix form + conUB = varargin(9); + conUB = conUB'; //IPOpt wants it in row matrix form + + + //Checking the Q matrix which needs to be a symmetric matrix + if ( Q~=Q') then + errmsg = msprintf(gettext("%s: Q 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"); + 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"); + 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"); + 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"); + 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"); + 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"); + 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"), "qp_ipopt"); + error(errmsg); + end + + [xopt,fopt,status,iter,Zl,Zu,lmbda] = solveqp(nbVar,nbCon,Q,p,conMatrix,conLB,conUB,LB,UB); + + xopt = xopt'; + exitflag = status; + output = struct("Iterations" , []); + output.Iterations = iter; + lambda = struct("lower" , [], .. + "upper" , [], .. + "constraint" , []); + + lambda.lower = Zl; + lambda.upper = Zu; + lambda.constraint = lmbda; + + +endfunction diff --git a/macros/qpipopt_mat.bin b/macros/qpipopt_mat.bin Binary files differnew file mode 100644 index 0000000..43cce6e --- /dev/null +++ b/macros/qpipopt_mat.bin diff --git a/macros/qpipopt_mat.sci b/macros/qpipopt_mat.sci new file mode 100644 index 0000000..4c72216 --- /dev/null +++ b/macros/qpipopt_mat.sci @@ -0,0 +1,214 @@ +// Copyright (C) 2015 - IIT Bombay - FOSSEE +// +// Author: Harpreet Singh +// Organization: FOSSEE, IIT Bombay +// Email: harpreet.mertia@gmail.com +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + + +function [xopt,fopt,exitflag,output,lambda] = qpipopt_mat (varargin) + // Solves a linear quadratic problem. + // + // Calling Sequence + // xopt = qpipopt_mat(nbVar,nbCon,Q,p,LB,UB,conMatrix,conLB,conUB) + // x = qpipopt_mat(H,f) + // x = qpipopt_mat(H,f,A,b) + // x = qpipopt_mat(H,f,A,b,Aeq,beq) + // x = qpipopt_mat(H,f,A,b,Aeq,beq,lb,ub) + // [xopt,fopt,exitflag,output,lamda] = qpipopt_mat( ... ) + // + // 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 + // 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. + // xopt : a nx1 matrix of doubles, the computed solution of the optimization problem. + // fopt : a 1x1 matrix of doubles, 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). + // + // Description + // Search the minimum of a constrained linear quadratic optimization problem specified by : + // find the minimum of f(x) such that + // + // <latex> + // \begin{eqnarray} + // &\mbox{min}_{x} + // & 1/2*x'*H*x + f'*x \\ + // & \text{subject to} & A.x \leq b \\ + // & & Aeq.x \leq 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 code has been written by Andreas Wächter and Carl Laird. + // + // Examples + // //Find x in R^6 such that: + // + // Aeq= [1,-1,1,0,3,1; + // -1,0,-3,-4,5,6; + // 2,5,3,0,1,0]; + // beq=[1; 2; 3]; + // A= [0,1,0,1,2,-1; + // -1,0,2,1,1,0]; + // b = [-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 + // f=[1; 2; 3; 4; 5; 6]; H=eye(6,6); + // [xopt,fopt,exitflag,output,lambda]=qpipopt_mat(H,f,A,b,Aeq,beq,lb,ub) + // clear H f A b Aeq beq lb ub; + // + // Examples + // //Find the value of x that minimize following function + // // f(x) = 0.5*x1^2 + x2^2 - x1*x2 - 2*x1 - 6*x2 + // // Subject to: + // // x1 + x2 ≤ 2 + // // –x1 + 2x2 ≤ 2 + // // 2x1 + x2 ≤ 3 + // // 0 ≤ x1, 0 ≤ x2. + // H = [1 -1; -1 2]; + // f = [-2; -6]; + // A = [1 1; -1 2; 2 1]; + // b = [2; 2; 3]; + // lb = [0; 0]; + // ub = [%inf; %inf]; + // [xopt,fopt,exitflag,output,lambda] = qpipopt_mat(H,f,A,b,[],[],lb,ub) + // + // Authors + // Keyur Joshi, Saikiran, Iswarya, Harpreet Singh + + +//To check the number of input and output argument + [lhs , rhs] = argn(); + +//To check the number of argument given by user + if ( rhs < 2 | rhs == 3 | rhs == 5 | rhs == 7 | rhs > 8 ) then + errmsg = msprintf(gettext("%s: Unexpected number of input arguments : %d provided while should be in the set of [2 4 6 8]"), "qpipopt", rhs); + error(errmsg) + end + + H = varargin(1); + f = varargin(2); + nbVar = size(H,1); + + + if ( rhs<2 ) then + A = [] + b = [] + else + A = varargin(3); + b = varargin(4); + end + + if ( rhs<4 ) then + Aeq = [] + beq = [] + else + Aeq = varargin(5); + beq = varargin(6); + end + + if ( rhs<6 ) then + LB = repmat(-%inf,nbVar,1); + UB = repmat(%inf,nbVar,1); + else + LB = varargin(7); + UB = varargin(8); + end + + nbConInEq = size(A,1); + nbConEq = size(Aeq,1); + + //Checking the H matrix which needs to be a symmetric matrix + if ( H~=H') then + errmsg = msprintf(gettext("%s: H is not a symmetric matrix"), "qpipopt_mat"); + 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"), "qpipopt"); + 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"), "qpipopt"); + 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"), "qpipopt"); + 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"), "qpipopt"); + error(errmsg); + end + + + //Check the size of Lower Bound which should be 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"), "qpipopt"); + 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"), "qpipopt"); + 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 Lower Bound of inequality 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(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"), "qp_ipopt"); + error(errmsg); + end + + //Converting it into ipopt format + f = f'; + LB = LB'; + UB = UB'; + 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); + + xopt = xopt'; + exitflag = status; + output = struct("Iterations" , []); + output.Iterations = iter; + lambda = struct("lower" , [], .. + "upper" , [], .. + "ineqlin" , [], .. + "eqlin" , []); + + lambda.lower = Zl; + lambda.upper = Zu; + lambda.eqlin = lmbda(1:nbConEq); + lambda.ineqlin = lmbda(nbConEq+1:nbCon); + + +endfunction diff --git a/macros/qpipopt_mat.sci~ b/macros/qpipopt_mat.sci~ new file mode 100644 index 0000000..4c72216 --- /dev/null +++ b/macros/qpipopt_mat.sci~ @@ -0,0 +1,214 @@ +// Copyright (C) 2015 - IIT Bombay - FOSSEE +// +// Author: Harpreet Singh +// Organization: FOSSEE, IIT Bombay +// Email: harpreet.mertia@gmail.com +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + + +function [xopt,fopt,exitflag,output,lambda] = qpipopt_mat (varargin) + // Solves a linear quadratic problem. + // + // Calling Sequence + // xopt = qpipopt_mat(nbVar,nbCon,Q,p,LB,UB,conMatrix,conLB,conUB) + // x = qpipopt_mat(H,f) + // x = qpipopt_mat(H,f,A,b) + // x = qpipopt_mat(H,f,A,b,Aeq,beq) + // x = qpipopt_mat(H,f,A,b,Aeq,beq,lb,ub) + // [xopt,fopt,exitflag,output,lamda] = qpipopt_mat( ... ) + // + // 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 + // 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. + // xopt : a nx1 matrix of doubles, the computed solution of the optimization problem. + // fopt : a 1x1 matrix of doubles, 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). + // + // Description + // Search the minimum of a constrained linear quadratic optimization problem specified by : + // find the minimum of f(x) such that + // + // <latex> + // \begin{eqnarray} + // &\mbox{min}_{x} + // & 1/2*x'*H*x + f'*x \\ + // & \text{subject to} & A.x \leq b \\ + // & & Aeq.x \leq 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 code has been written by Andreas Wächter and Carl Laird. + // + // Examples + // //Find x in R^6 such that: + // + // Aeq= [1,-1,1,0,3,1; + // -1,0,-3,-4,5,6; + // 2,5,3,0,1,0]; + // beq=[1; 2; 3]; + // A= [0,1,0,1,2,-1; + // -1,0,2,1,1,0]; + // b = [-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 + // f=[1; 2; 3; 4; 5; 6]; H=eye(6,6); + // [xopt,fopt,exitflag,output,lambda]=qpipopt_mat(H,f,A,b,Aeq,beq,lb,ub) + // clear H f A b Aeq beq lb ub; + // + // Examples + // //Find the value of x that minimize following function + // // f(x) = 0.5*x1^2 + x2^2 - x1*x2 - 2*x1 - 6*x2 + // // Subject to: + // // x1 + x2 ≤ 2 + // // –x1 + 2x2 ≤ 2 + // // 2x1 + x2 ≤ 3 + // // 0 ≤ x1, 0 ≤ x2. + // H = [1 -1; -1 2]; + // f = [-2; -6]; + // A = [1 1; -1 2; 2 1]; + // b = [2; 2; 3]; + // lb = [0; 0]; + // ub = [%inf; %inf]; + // [xopt,fopt,exitflag,output,lambda] = qpipopt_mat(H,f,A,b,[],[],lb,ub) + // + // Authors + // Keyur Joshi, Saikiran, Iswarya, Harpreet Singh + + +//To check the number of input and output argument + [lhs , rhs] = argn(); + +//To check the number of argument given by user + if ( rhs < 2 | rhs == 3 | rhs == 5 | rhs == 7 | rhs > 8 ) then + errmsg = msprintf(gettext("%s: Unexpected number of input arguments : %d provided while should be in the set of [2 4 6 8]"), "qpipopt", rhs); + error(errmsg) + end + + H = varargin(1); + f = varargin(2); + nbVar = size(H,1); + + + if ( rhs<2 ) then + A = [] + b = [] + else + A = varargin(3); + b = varargin(4); + end + + if ( rhs<4 ) then + Aeq = [] + beq = [] + else + Aeq = varargin(5); + beq = varargin(6); + end + + if ( rhs<6 ) then + LB = repmat(-%inf,nbVar,1); + UB = repmat(%inf,nbVar,1); + else + LB = varargin(7); + UB = varargin(8); + end + + nbConInEq = size(A,1); + nbConEq = size(Aeq,1); + + //Checking the H matrix which needs to be a symmetric matrix + if ( H~=H') then + errmsg = msprintf(gettext("%s: H is not a symmetric matrix"), "qpipopt_mat"); + 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"), "qpipopt"); + 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"), "qpipopt"); + 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"), "qpipopt"); + 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"), "qpipopt"); + error(errmsg); + end + + + //Check the size of Lower Bound which should be 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"), "qpipopt"); + 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"), "qpipopt"); + 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 Lower Bound of inequality 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(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"), "qp_ipopt"); + error(errmsg); + end + + //Converting it into ipopt format + f = f'; + LB = LB'; + UB = UB'; + 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); + + xopt = xopt'; + exitflag = status; + output = struct("Iterations" , []); + output.Iterations = iter; + lambda = struct("lower" , [], .. + "upper" , [], .. + "ineqlin" , [], .. + "eqlin" , []); + + lambda.lower = Zl; + lambda.upper = Zu; + lambda.eqlin = lmbda(1:nbConEq); + lambda.ineqlin = lmbda(nbConEq+1:nbCon); + + +endfunction diff --git a/macros/symphony_mat.bin b/macros/symphony_mat.bin Binary files differindex 3b72644..600bd9a 100644 --- a/macros/symphony_mat.bin +++ b/macros/symphony_mat.bin diff --git a/macros/symphony_mat.sci b/macros/symphony_mat.sci index 068e9cf..b30d84d 100644 --- a/macros/symphony_mat.sci +++ b/macros/symphony_mat.sci @@ -153,7 +153,7 @@ function [xopt,fopt,status,iter] = symphony_mat (varargin) [lhs , rhs] = argn(); //To check the number of argument given by user - if ( rhs < 4 | rhs = 5 | rhs = 7 | rhs > 9 ) then + 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 diff --git a/sci_gateway/cpp/QuadNLP.hpp b/sci_gateway/cpp/QuadNLP.hpp index eff92da..6f01241 100644 --- a/sci_gateway/cpp/QuadNLP.hpp +++ b/sci_gateway/cpp/QuadNLP.hpp @@ -23,48 +23,48 @@ using namespace Ipopt; class QuadNLP : public TNLP { private: - Index numVars_; // Number of variables. + Index numVars_; // Number of variables. - Index numConstr_; // Number of constraints. + Index numConstr_; // Number of constraints. - Number *qMatrix_; //qMatrix_ is a pointer to matrix of size numVars X numVars_ - // with coefficents of quadratic terms in objective function. + const Number *qMatrix_ = NULL; //qMatrix_ is a pointer to matrix of size numVars X numVars_ + // with coefficents of quadratic terms in objective function. - Number *lMatrix_; //lMatrix_ is a pointer to matrix of size 1*numVars_ - // with coefficents of linear terms in objective function. + const Number *lMatrix_ = NULL;//lMatrix_ is a pointer to matrix of size 1*numVars_ + // with coefficents of linear terms in objective function. - Number *conMatrix_; //conMatrix_ is a pointer to matrix of size numConstr X numVars - // with coefficients of terms in a each objective in each row. + const Number *conMatrix_ = NULL;//conMatrix_ is a pointer to matrix of size numConstr X numVars + // with coefficients of terms in a each objective in each row. - Number *conUB_; //conUB_ is a pointer to a matrix of size of 1*numConstr_ - // with upper bounds of all constraints. + const Number *conUB_= NULL; //conUB_ is a pointer to a matrix of size of 1*numConstr_ + // with upper bounds of all constraints. - Number *conLB_; //conLB_ is a pointer to a matrix of size of 1*numConstr_ - // with lower bounds of all constraints. + const Number *conLB_ = NULL; //conLB_ is a pointer to a matrix of size of 1*numConstr_ + // with lower bounds of all constraints. - Number *varUB_; //varUB_ is a pointer to a matrix of size of 1*numVar_ - // with upper bounds of all variables. + const Number *varUB_= NULL; //varUB_ is a pointer to a matrix of size of 1*numVar_ + // with upper bounds of all variables. - Number *varLB_; //varLB_ is a pointer to a matrix of size of 1*numVar_ - // with lower bounds of all variables. - - Number *finalX_; //finalX_ is a pointer to a matrix of size of 1*numVar_ - // with final value for the primal variables. + const Number *varLB_= NULL; //varLB_ is a pointer to a matrix of size of 1*numVar_ + // with lower bounds of all variables. + + Number *finalX_= NULL; //finalX_ is a pointer to a matrix of size of 1*numVar_ + // with final value for the primal variables. - Number *finalZl_; //finalZl_ is a pointer to a matrix of size of 1*numVar_ - // with final values for the lower bound multipliers + Number *finalZl_= NULL; //finalZl_ is a pointer to a matrix of size of 1*numVar_ + // with final values for the lower bound multipliers - Number *finalZu_; //finalZu_ is a pointer to a matrix of size of 1*numVar_ - // with final values for the upper bound multipliers + Number *finalZu_= NULL; //finalZu_ is a pointer to a matrix of size of 1*numVar_ + // with final values for the upper bound multipliers - Number *finalLambda_; //finalLambda_ is a pointer to a matrix of size of 1*numConstr_ - // with final values for the upper bound multipliers + Number *finalLambda_= NULL; //finalLambda_ is a pointer to a matrix of size of 1*numConstr_ + // with final values for the upper bound multipliers - Number finalObjVal_; //finalObjVal_ is a scalar with the final value of the objective. + Number finalObjVal_; //finalObjVal_ is a scalar with the final value of the objective. - int iter_; //Number of iteration. + int iter_; //Number of iteration. - int status_; //Solver return status + int status_; //Solver return status QuadNLP(const QuadNLP&); QuadNLP& operator=(const QuadNLP&); diff --git a/sci_gateway/cpp/QuadNLP.hpp~ b/sci_gateway/cpp/QuadNLP.hpp~ new file mode 100644 index 0000000..f47ab4d --- /dev/null +++ b/sci_gateway/cpp/QuadNLP.hpp~ @@ -0,0 +1,131 @@ +/* + * Quadratic Programming Toolbox for Scilab using IPOPT library + * Authors : + Sai Kiran + Keyur Joshi + Iswarya + + + * Optimizing (minimizing) the quadratic objective function having any number of variables and linear constraints. + * +*/ + +#ifndef __QuadNLP_HPP__ +#define __QuadNLP_HPP__ + +#include "IpTNLP.hpp" +extern "C"{ +#include <sciprint.h> + +} +using namespace Ipopt; + +class QuadNLP : public TNLP +{ + private: + Index numVars_; // Number of variables. + + Index numConstr_; // Number of constraints. + + const Number *qMatrix_ = NULL; //qMatrix_ is a pointer to matrix of size numVars X numVars_ + // with coefficents of quadratic terms in objective function. + + const Number *lMatrix_ = NULL;//lMatrix_ is a pointer to matrix of size 1*numVars_ + // with coefficents of linear terms in objective function. + + const Number *conMatrix_ = NULL;//conMatrix_ is a pointer to matrix of size numConstr X numVars + // with coefficients of terms in a each objective in each row. + + const Number *conUB_= NULL; //conUB_ is a pointer to a matrix of size of 1*numConstr_ + // with upper bounds of all constraints. + + const Number *conLB_; //conLB_ is a pointer to a matrix of size of 1*numConstr_ + // with lower bounds of all constraints. + + const Number *varUB_; //varUB_ is a pointer to a matrix of size of 1*numVar_ + // with upper bounds of all variables. + + const Number *varLB_; //varLB_ is a pointer to a matrix of size of 1*numVar_ + // with lower bounds of all variables. + + Number *finalX_; //finalX_ is a pointer to a matrix of size of 1*numVar_ + // with final value for the primal variables. + + Number *finalZl_; //finalZl_ is a pointer to a matrix of size of 1*numVar_ + // with final values for the lower bound multipliers + + Number *finalZu_; //finalZu_ is a pointer to a matrix of size of 1*numVar_ + // with final values for the upper bound multipliers + + Number *finalLambda_; //finalLambda_ is a pointer to a matrix of size of 1*numConstr_ + // with final values for the upper bound multipliers + + Number finalObjVal_; //finalObjVal_ is a scalar with the final value of the objective. + + int iter_; //Number of iteration. + + int status_; //Solver return status + + QuadNLP(const QuadNLP&); + QuadNLP& operator=(const QuadNLP&); + public: + /* + * Constructor + */ + QuadNLP(Index nV, Index nC, Number *qM, Number *lM, Number *cM, Number *cUB, Number *cLB, Number *vUB, Number *vLB): + numVars_(nV),numConstr_(nC),qMatrix_(qM),lMatrix_(lM),conMatrix_(cM),conUB_(cUB),conLB_(cLB),varUB_(vUB),varLB_(vLB),finalX_(0), finalZl_(0), finalZu_(0), finalObjVal_(1e20){ } + + + /* Go to : + + http://www.coin-or.org/Ipopt/documentation/node23.html#SECTION00053130000000000000 + For details about these below methods. + */ + virtual ~QuadNLP(); + virtual bool get_nlp_info(Index& n, Index& m, Index& nnz_jac_g, + Index& nnz_h_lag, IndexStyleEnum& index_style); + virtual bool get_bounds_info(Index n, Number* x_l, Number* x_u, + Index m, Number* g_l, Number* g_u); + virtual bool get_starting_point(Index n, bool init_x, Number* x, + bool init_z, Number* z_L, Number* z_U, + Index m, bool init_lambda, + Number* lambda); + virtual bool eval_f(Index n, const Number* x, bool new_x, Number& obj_value); + virtual bool eval_grad_f(Index n, const Number* x, bool new_x, Number* grad_f); + virtual bool eval_g(Index n, const Number* x, bool new_x, Index m, Number* g); + virtual bool eval_jac_g(Index n, const Number* x, bool new_x, + Index m, Index nele_jac, Index* iRow, Index *jCol, + Number* values); + virtual bool eval_h(Index n, const Number* x, bool new_x, + Number obj_factor, Index m, const Number* lambda, + bool new_lambda, Index nele_hess, Index* iRow, + Index* jCol, Number* values); + virtual void finalize_solution(SolverReturn status, + Index n, const Number* x, const Number* z_L, const Number* z_U, + Index m, const Number* g, const Number* lambda, Number obj_value, + const IpoptData* ip_data, + IpoptCalculatedQuantities* ip_cq); + + const double * getX(); //Returns a pointer to a matrix of size of 1*numVar + // with final value for the primal variables. + + const double * getZu(); //Returns a pointer to a matrix of size of 1*numVars + // with final values for the upper bound multipliers + + const double * getZl(); //Returns a pointer to a matrix of size of 1*numVars + // with final values for the upper bound multipliers + + const double * getLambda(); //Returns a pointer to a matrix of size of 1*numConstr + // with final values for the constraint multipliers + + + double getObjVal(); //Returns the output of the final value of the objective. + + double iterCount(); //Returns the iteration count + + int returnStatus(); //Returns the status count + + +}; + +#endif __QuadNLP_HPP__ diff --git a/sci_gateway/cpp/libFAMOS.so b/sci_gateway/cpp/libFAMOS.so Binary files differindex f148cca..5e885f4 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 2c484b7..ddca7cf 100644 --- a/sci_gateway/cpp/sci_QuadNLP.cpp +++ b/sci_gateway/cpp/sci_QuadNLP.cpp @@ -56,12 +56,11 @@ bool QuadNLP::get_bounds_info(Index n, Number* x_l, Number* x_u, Index m, Number //get value of objective function at vector x bool QuadNLP::eval_f(Index n, const Number* x, bool new_x, Number& obj_value){ unsigned int i,j; - Number temp; obj_value=0; - for (i=0;i<n;++i){ - for (j=0;j<n;++j){ - obj_value+=x[i]*x[j]*qMatrix_[n*i+j]; + for (i=0;i<=n;i++){ + for (j=0;j<=n;j++){ + obj_value+=0.5*x[i]*x[j]*qMatrix_[n*i+j]; } obj_value+=x[i]*lMatrix_[i]; } @@ -71,24 +70,30 @@ bool QuadNLP::eval_f(Index n, const Number* x, bool new_x, Number& obj_value){ //get value of gradient of objective function at vector x. bool QuadNLP::eval_grad_f(Index n, const Number* x, bool new_x, Number* grad_f){ unsigned int i,j; - for(i=0;i<n;i++){ + for(i=0;i<n;i++) + { grad_f[i]=lMatrix_[i]; for(j=0;j<n;j++) - grad_f[i]+=(qMatrix_[n*i+j]+qMatrix_[n*j+i])*x[j]; - } - return true; + { + grad_f[i]+=(qMatrix_[n*i+j])*x[j]; + } } + return true; +} //Get the values of constraints at vector x. bool QuadNLP::eval_g(Index n, const Number* x, bool new_x, Index m, Number* g){ unsigned int i,j; - for(i=0;i<m;i++){ + for(i=0;i<m;i++) + { g[i]=0; for(j=0;j<n;j++) - g[i]+=x[j]*conMatrix_[n*i+j]; + { + g[i]+=x[j]*conMatrix_[i+j*m]; } - return true; } + return true; +} // This method sets initial values for required vectors . For now we are assuming 0 to all values. bool QuadNLP::get_starting_point(Index n, bool init_x, Number* x, @@ -137,7 +142,7 @@ bool QuadNLP::eval_jac_g(Index n, const Number* x, bool new_x, int index=0; for (int var=0;var<m;++var) for (int flag=0;flag<n;++flag) - values[index++]=conMatrix_[n*var+flag]; + values[index++]=conMatrix_[var+flag*m]; } return true; } @@ -166,7 +171,7 @@ bool QuadNLP::eval_h(Index n, const Number* x, bool new_x, Index index=0; for (Index row=0;row < n;++row){ for (Index col=0; col <= row; ++col){ - values[index++]=obj_factor*(qMatrix_[n*row+col]+qMatrix_[n*col+row]); + values[index++]=obj_factor*(qMatrix_[n*row+col]); } } } diff --git a/sci_gateway/cpp/sci_QuadNLP.cpp~ b/sci_gateway/cpp/sci_QuadNLP.cpp~ new file mode 100644 index 0000000..4ff99ce --- /dev/null +++ b/sci_gateway/cpp/sci_QuadNLP.cpp~ @@ -0,0 +1,255 @@ +/* + * Quadratic Programming Toolbox for Scilab using IPOPT library + * Authors : + Sai Kiran + Keyur Joshi + Iswarya + */ + +#include "QuadNLP.hpp" +#include "IpIpoptData.hpp" + +extern "C"{ +#include <api_scilab.h> +#include <Scierror.h> +#include <BOOL.h> +#include <localization.h> +#include <sciprint.h> + + +double x_static,i, *op_obj_x = NULL,*op_obj_value = NULL; + +using namespace Ipopt; + +QuadNLP::~QuadNLP() + { + free(finalX_); + free(finalZl_); + free(finalZu_);} + +//get NLP info such as number of variables,constraints,no.of elements in jacobian and hessian to allocate memory +bool QuadNLP::get_nlp_info(Index& n, Index& m, Index& nnz_jac_g, Index& nnz_h_lag, IndexStyleEnum& index_style){ + n=numVars_; // Number of variables + m=numConstr_; // Number of constraints + nnz_jac_g = n*m; // No. of elements in Jacobian of constraints + nnz_h_lag = n*(n+1)/2; // No. of elements in lower traingle of Hessian of the Lagrangian. + index_style=C_STYLE; // Index style of matrices + return true; + } + +//get variable and constraint bound info +bool QuadNLP::get_bounds_info(Index n, Number* x_l, Number* x_u, Index m, Number* g_l, Number* g_u){ + + unsigned int i; + for(i=0;i<n;i++){ + x_l[i]=varLB_[i]; + x_u[i]=varUB_[i]; + sciprint("VarLU %lf %lf \n",x_l[i],x_u[i]); + } + + for(i=0;i<m;i++){ + g_l[i]=conLB_[i]; + g_u[i]=conUB_[i]; + sciprint("conLU %lf %lf \n",g_l[i],g_u[i]); + } + return true; + } + +//get value of objective function at vector x +bool QuadNLP::eval_f(Index n, const Number* x, bool new_x, Number& obj_value){ + unsigned int i,j; + obj_value=0; + + for (i=0;i<=n;i++){ + for (j=0;j<=n;j++){ + obj_value+=0.5*x[i]*x[j]*qMatrix_[n*i+j]; + } + obj_value+=x[i]*lMatrix_[i]; + } + return true; + } + +//get value of gradient of objective function at vector x. +bool QuadNLP::eval_grad_f(Index n, const Number* x, bool new_x, Number* grad_f){ + unsigned int i,j; + for(i=0;i<n;i++) + { + grad_f[i]=lMatrix_[i]; + for(j=0;j<n;j++) + { + grad_f[i]+=(qMatrix_[n*i+j])*x[j]; + } + } + return true; +} + +//Get the values of constraints at vector x. +bool QuadNLP::eval_g(Index n, const Number* x, bool new_x, Index m, Number* g){ + unsigned int i,j; + for(i=0;i<m;i++) + { + g[i]=0; + for(j=0;j<n;j++) + { + g[i]+=x[j]*conMatrix_[i+j*m]; + } + } + return true; +} + +// This method sets initial values for required vectors . For now we are assuming 0 to all values. +bool QuadNLP::get_starting_point(Index n, bool init_x, Number* x, + bool init_z, Number* z_L, Number* z_U, + Index m, bool init_lambda, + Number* lambda){ + if (init_x == true){ //we need to set initial values for vector x + for (Index var=0;var<n;++var) + x[var]=0.0;//initialize with 0 or we can change. + } + + if (init_z == true){ //we need to provide initial values for vector bound multipliers + for (Index var=0;var<n;++var){ + z_L[var]=0.0; //initialize with 0 or we can change. + z_U[var]=0.0;//initialize with 0 or we can change. + } + } + + if (init_lambda == true){ //we need to provide initial values for lambda values. + for (Index var=0;var<m;++var){ + lambda[var]=0.0; //initialize with 0 or we can change. + } + } + + return true; + } +/* Return either the sparsity structure of the Jacobian of the constraints, or the values for the Jacobian of the constraints at the point x. + +*/ +bool QuadNLP::eval_jac_g(Index n, const Number* x, bool new_x, + Index m, Index nele_jac, Index* iRow, Index *jCol, + Number* values){ + + //It asked for structure of jacobian. + if (values==NULL){ //Structure of jacobian (full structure) + int index=0; + for (int var=0;var<m;++var)//no. of constraints + for (int flag=0;flag<n;++flag){//no. of variables + iRow[index]=var; + jCol[index]=flag; + index++; + } + } + //It asked for values + else { + int index=0; + for (int var=0;var<m;++var) + for (int flag=0;flag<n;++flag) + values[index++]=conMatrix_[var+flag*m]; + } + return true; + } + +/* + * Return either the sparsity structure of the Hessian of the Lagrangian, + * or the values of the Hessian of the Lagrangian for the given values for + * x,lambda,obj_factor. +*/ +bool QuadNLP::eval_h(Index n, const Number* x, bool new_x, + Number obj_factor, Index m, const Number* lambda, + bool new_lambda, Index nele_hess, Index* iRow, + Index* jCol, Number* values){ + + if (values==NULL){ + Index idx=0; + for (Index row = 0; row < n; row++) { + for (Index col = 0; col <= row; col++) { + iRow[idx] = row; + jCol[idx] = col; + idx++; + } + } + } + else { + Index index=0; + for (Index row=0;row < n;++row){ + for (Index col=0; col <= row; ++col){ + values[index++]=obj_factor*(qMatrix_[n*row+col]); + } + } + } + return true; + } + + +void QuadNLP::finalize_solution(SolverReturn status, + Index n, const Number* x, const Number* z_L, const Number* z_U, + Index m, const Number* g, const Number* lambda, Number obj_value, + const IpoptData* ip_data, + IpoptCalculatedQuantities* ip_cq){ + + finalX_ = (double*)malloc(sizeof(double) * numVars_ * 1); + for (Index i=0; i<n; i++) + { + finalX_[i] = x[i]; + } + + finalZl_ = (double*)malloc(sizeof(double) * numVars_ * 1); + for (Index i=0; i<n; i++) + { + finalZl_[i] = z_L[i]; + } + + finalZu_ = (double*)malloc(sizeof(double) * numVars_ * 1); + for (Index i=0; i<n; i++) + { + finalZu_[i] = z_U[i]; + } + + finalLambda_ = (double*)malloc(sizeof(double) * numConstr_ * 1); + for (Index i=0; i<m; i++) + { + finalLambda_[i] = lambda[i]; + } + + iter_ = ip_data->iter_count(); + finalObjVal_ = obj_value; + status_ = status; + + } + + const double * QuadNLP::getX() + { + return finalX_; + } + + const double * QuadNLP::getZl() + { + return finalZl_; + } + + const double * QuadNLP::getZu() + { + return finalZu_; + } + + const double * QuadNLP::getLambda() + { + return finalLambda_; + } + + double QuadNLP::getObjVal() + { + return finalObjVal_; + } + + double QuadNLP::iterCount() + { + return (double)iter_; + } + + int QuadNLP::returnStatus() + { + return status_; + } + +} diff --git a/sci_gateway/cpp/sci_ipopt.cpp b/sci_gateway/cpp/sci_ipopt.cpp index a7ea33e..06796a9 100644 --- a/sci_gateway/cpp/sci_ipopt.cpp +++ b/sci_gateway/cpp/sci_ipopt.cpp @@ -53,25 +53,216 @@ int sci_solveqp(char *fname) CheckInputArgument(pvApiCtx, 9, 9); // We need total 9 input arguments. CheckOutputArgument(pvApiCtx, 7, 7); - + + // Error management variable + SciErr sciErr; + int retVal=0, *piAddressVarQ = NULL,*piAddressVarP = NULL,*piAddressVarCM = NULL,*piAddressVarCUB = NULL,*piAddressVarCLB = NULL, *piAddressVarLB = NULL,*piAddressVarUB = NULL; double *QItems=NULL,*PItems=NULL,*ConItems=NULL,*conUB=NULL,*conLB=NULL,*varUB=NULL,*varLB=NULL,x,f,iter; - unsigned int nVars,nCons; + static unsigned int nVars = 0,nCons = 0; + unsigned int temp1 = 0,temp2 = 0; + + + ////////// Manage the input argument ////////// + + + //Number of Variables + getIntFromScilab(1,&nVars); + + //Number of Constraints + getIntFromScilab(2,&nCons); + + temp1 = nVars; + temp2 = nCons; + + //Q matrix from scilab + /* get Address of inputs */ + sciErr = getVarAddressFromPosition(pvApiCtx, 3, &piAddressVarQ); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return 0; + } + + /* Check that the first input argument is a real matrix (and not complex) */ + if ( !isDoubleType(pvApiCtx, piAddressVarQ) || isVarComplex(pvApiCtx, piAddressVarQ) ) + { + Scierror(999, "%s: Wrong type for input argument #%d: A real matrix expected.\n", fname, 3); + return 0; + } + + /* get matrix */ + sciErr = getMatrixOfDouble(pvApiCtx, piAddressVarQ, &temp1, &temp1, &QItems); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return 0; + } + + //P matrix from scilab + /* get Address of inputs */ + sciErr = getVarAddressFromPosition(pvApiCtx, 4, &piAddressVarP); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return 0; + } + + /* Check that the first input argument is a real matrix (and not complex) */ + if ( !isDoubleType(pvApiCtx, piAddressVarP) || isVarComplex(pvApiCtx, piAddressVarP) ) + { + Scierror(999, "%s: Wrong type for input argument #%d: A real matrix expected.\n", fname, 4); + return 0; + } + + temp1 = 1; + temp2 = nVars; + /* get matrix */ + sciErr = getMatrixOfDouble(pvApiCtx, piAddressVarP, &temp1,&temp2, &PItems); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return 0; + } + + if (nCons!=0) + { + //conMatrix matrix from scilab + /* get Address of inputs */ + sciErr = getVarAddressFromPosition(pvApiCtx, 5, &piAddressVarCM); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return 0; + } + + /* Check that the first input argument is a real matrix (and not complex) */ + if ( !isDoubleType(pvApiCtx, piAddressVarCM) || isVarComplex(pvApiCtx, piAddressVarCM) ) + { + Scierror(999, "%s: Wrong type for input argument #%d: A real matrix expected.\n", fname, 5); + return 0; + } + temp1 = nCons; + temp2 = nVars; + + /* get matrix */ + sciErr = getMatrixOfDouble(pvApiCtx, piAddressVarCM,&temp1, &temp2, &ConItems); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return 0; + } + + + //conLB matrix from scilab + /* get Address of inputs */ + sciErr = getVarAddressFromPosition(pvApiCtx, 6, &piAddressVarCLB); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return 0; + } + /* Check that the first input argument is a real matrix (and not complex) */ + if ( !isDoubleType(pvApiCtx, piAddressVarCLB) || isVarComplex(pvApiCtx, piAddressVarCLB) ) + { + Scierror(999, "%s: Wrong type for input argument #%d: A real matrix expected.\n", fname, 6); + return 0; + } + temp1 = nCons; + temp2 = 1; - unsigned int arg = 1,temp1,temp2; + /* get matrix */ + sciErr = getMatrixOfDouble(pvApiCtx, piAddressVarCLB,&temp1, &temp2, &conLB); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return 0; + } + + //conUB matrix from scilab + /* get Address of inputs */ + sciErr = getVarAddressFromPosition(pvApiCtx, 7, &piAddressVarCUB); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return 0; + } - if ( !getIntFromScilab(arg,&nVars) && arg++ && !getIntFromScilab(arg,&nCons) && arg++ && - !getDoubleMatrixFromScilab(arg,&temp1,&temp2,&QItems) && temp1 == nVars && temp2 == nVars && arg++ && - !getDoubleMatrixFromScilab(arg,&temp1,&temp2,&PItems) && temp2 == nVars && arg++ && - !getDoubleMatrixFromScilab(arg,&temp1,&temp2,&ConItems) && temp1 == nCons &&((nCons !=0 && temp2 == nVars)||(temp2==0)) && arg++ && - !getDoubleMatrixFromScilab(arg,&temp1,&temp2,&conLB) && temp2 == nCons && arg++ && - !getDoubleMatrixFromScilab(arg,&temp1,&temp2,&conUB) && temp2 == nCons && arg++ && - !getDoubleMatrixFromScilab(arg,&temp1,&temp2,&varLB) && temp2 == nVars && arg++ && - !getDoubleMatrixFromScilab(arg,&temp1,&temp2,&varUB) && temp2 == nVars){ + /* Check that the first input argument is a real matrix (and not complex) */ + if ( !isDoubleType(pvApiCtx, piAddressVarCUB) || isVarComplex(pvApiCtx, piAddressVarCUB) ) + { + Scierror(999, "%s: Wrong type for input argument #%d: A real matrix expected.\n", fname, 7); + return 0; + } + temp1 = nCons; + temp2 = 1; + /* get matrix */ + sciErr = getMatrixOfDouble(pvApiCtx, piAddressVarCUB,&temp1, &temp2, &conUB); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return 0; + } + + } + + //varLB matrix from scilab + /* get Address of inputs */ + sciErr = getVarAddressFromPosition(pvApiCtx, 8, &piAddressVarLB); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return 0; + } + + /* Check that the first input argument is a real matrix (and not complex) */ + if ( !isDoubleType(pvApiCtx, piAddressVarLB) || isVarComplex(pvApiCtx, piAddressVarLB) ) + { + Scierror(999, "%s: Wrong type for input argument #%d: A real matrix expected.\n", fname, 8); + return 0; + } + temp1 = 1; + temp2 = nVars; + + /* get matrix */ + sciErr = getMatrixOfDouble(pvApiCtx, piAddressVarLB, &temp1,&temp2, &varLB); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return 0; + } + + //varUB matrix from scilab + /* get Address of inputs */ + sciErr = getVarAddressFromPosition(pvApiCtx, 9, &piAddressVarUB); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return 0; + } + /* Check that the first input argument is a real matrix (and not complex) */ + if ( !isDoubleType(pvApiCtx, piAddressVarUB) || isVarComplex(pvApiCtx, piAddressVarUB) ) + { + Scierror(999, "%s: Wrong type for input argument #%d: A real matrix expected.\n", fname, 9); + return 0; + } + + temp1 = 1; + temp2 = nVars; + + /* get matrix */ + sciErr = getMatrixOfDouble(pvApiCtx, piAddressVarUB, &temp1,&temp2, &varUB); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return 0; + } + using namespace Ipopt; + SmartPtr<QuadNLP> Prob = new QuadNLP(nVars,nCons,QItems,PItems,ConItems,conUB,conLB,varUB,varLB); SmartPtr<IpoptApplication> app = IpoptApplicationFactory(); app->RethrowNonIpoptException(true); @@ -108,7 +299,6 @@ int sci_solveqp(char *fname) double *Lambda = Prob->getLambda(); double iteration = Prob->iterCount(); int stats = Prob->returnStatus(); - SciErr sciErr; sciErr = createMatrixOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 1, 1, nVars, fX); if (sciErr.iErr) { @@ -171,14 +361,6 @@ int sci_solveqp(char *fname) // will be decremented and the objects will automatically // be deleted. - - } - else { - - sciprint("\nError:: check argument %d\n",arg); - return0toScilab(); - return 1; - } return 0; } diff --git a/sci_gateway/cpp/sci_ipopt.cpp~ b/sci_gateway/cpp/sci_ipopt.cpp~ new file mode 100644 index 0000000..12cbf81 --- /dev/null +++ b/sci_gateway/cpp/sci_ipopt.cpp~ @@ -0,0 +1,400 @@ +/* + * Quadratic Programming Toolbox for Scilab using IPOPT library + * Authors : + Sai Kiran + Keyur Joshi + Iswarya + */ + + +#include "sci_iofunc.hpp" +#include "IpIpoptApplication.hpp" +#include "QuadNLP.hpp" + +extern "C"{ +#include <api_scilab.h> +#include <Scierror.h> +#include <BOOL.h> +#include <localization.h> +#include <sciprint.h> + +int j; +double *op_x, *op_obj,*p; + +bool readSparse(int arg,int *iRows,int *iCols,int *iNbItem,int** piNbItemRow, int** piColPos, double** pdblReal){ + SciErr sciErr; + int* piAddr = NULL; + int iType = 0; + int iRet = 0; + sciErr = getVarAddressFromPosition(pvApiCtx, arg, &piAddr); + if(sciErr.iErr) { + printError(&sciErr, 0); + return false; + } + sciprint("\ndone\n"); + if(isSparseType(pvApiCtx, piAddr)){ + sciprint("done\n"); + sciErr =getSparseMatrix(pvApiCtx, piAddr, iRows, iCols, iNbItem, piNbItemRow, piColPos, pdblReal); + if(sciErr.iErr) { + printError(&sciErr, 0); + return false; + } + } + + else { + sciprint("\nSparse matrix required\n"); + return false; + } + return true; + } + +int sci_solveqp(char *fname) +{ + + CheckInputArgument(pvApiCtx, 9, 9); // We need total 9 input arguments. + CheckOutputArgument(pvApiCtx, 7, 7); + + // Error management variable + SciErr sciErr; + int retVal=0, *piAddressVarQ = NULL,*piAddressVarP = NULL,*piAddressVarCM = NULL,*piAddressVarCUB = NULL,*piAddressVarCLB = NULL, *piAddressVarLB = NULL,*piAddressVarUB = NULL; + double *QItems=NULL,*PItems=NULL,*ConItems=NULL,*conUB=NULL,*conLB=NULL,*varUB=NULL,*varLB=NULL,x,f,iter; + static unsigned int nVars = 0,nCons = 0; + unsigned int temp1 = 0,temp2 = 0; + + + ////////// Manage the input argument ////////// + + + //Number of Variables + getIntFromScilab(1,&nVars); + + //Number of Constraints + getIntFromScilab(2,&nCons); + + temp1 = nVars; + temp2 = nCons; + + //Q matrix from scilab + /* get Address of inputs */ + sciErr = getVarAddressFromPosition(pvApiCtx, 3, &piAddressVarQ); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return 0; + } + + /* Check that the first input argument is a real matrix (and not complex) */ + if ( !isDoubleType(pvApiCtx, piAddressVarQ) || isVarComplex(pvApiCtx, piAddressVarQ) ) + { + Scierror(999, "%s: Wrong type for input argument #%d: A real matrix expected.\n", fname, 3); + return 0; + } + + /* get matrix */ + sciErr = getMatrixOfDouble(pvApiCtx, piAddressVarQ, &temp1, &temp1, &QItems); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return 0; + } + + + for(int i=0;i<temp1;i++) + { + for(int j=0;j<temp1;j++) + { + sciprint("conMatrix %lf \t",QItems[temp1*i+j]); + } + sciprint("\n"); + } + + //P matrix from scilab + /* get Address of inputs */ + sciErr = getVarAddressFromPosition(pvApiCtx, 4, &piAddressVarP); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return 0; + } + + /* Check that the first input argument is a real matrix (and not complex) */ + if ( !isDoubleType(pvApiCtx, piAddressVarP) || isVarComplex(pvApiCtx, piAddressVarP) ) + { + Scierror(999, "%s: Wrong type for input argument #%d: A real matrix expected.\n", fname, 4); + return 0; + } + + temp1 = 1; + temp2 = nVars; + /* get matrix */ + sciErr = getMatrixOfDouble(pvApiCtx, piAddressVarP, &temp1,&temp2, &PItems); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return 0; + } + + if (nCons!=0) + { + //conMatrix matrix from scilab + /* get Address of inputs */ + sciErr = getVarAddressFromPosition(pvApiCtx, 5, &piAddressVarCM); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return 0; + } + + /* Check that the first input argument is a real matrix (and not complex) */ + if ( !isDoubleType(pvApiCtx, piAddressVarCM) || isVarComplex(pvApiCtx, piAddressVarCM) ) + { + Scierror(999, "%s: Wrong type for input argument #%d: A real matrix expected.\n", fname, 5); + return 0; + } + temp1 = nCons; + temp2 = nVars; + + /* get matrix */ + sciErr = getMatrixOfDouble(pvApiCtx, piAddressVarCM,&temp1, &temp2, &ConItems); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return 0; + } + + for(int i=0;i<temp1;i++) + { + for(int j=0;j<temp2;j++) + { + sciprint("conMatrix %lf \t",ConItems[i+j*temp1]); + } + sciprint("\n"); + } + + + //conLB matrix from scilab + /* get Address of inputs */ + sciErr = getVarAddressFromPosition(pvApiCtx, 6, &piAddressVarCLB); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return 0; + } + + /* Check that the first input argument is a real matrix (and not complex) */ + if ( !isDoubleType(pvApiCtx, piAddressVarCLB) || isVarComplex(pvApiCtx, piAddressVarCLB) ) + { + Scierror(999, "%s: Wrong type for input argument #%d: A real matrix expected.\n", fname, 6); + return 0; + } + temp1 = nCons; + temp2 = 1; + + /* get matrix */ + sciErr = getMatrixOfDouble(pvApiCtx, piAddressVarCLB,&temp1, &temp2, &conLB); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return 0; + } + + //conUB matrix from scilab + /* get Address of inputs */ + sciErr = getVarAddressFromPosition(pvApiCtx, 7, &piAddressVarCUB); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return 0; + } + + /* Check that the first input argument is a real matrix (and not complex) */ + if ( !isDoubleType(pvApiCtx, piAddressVarCUB) || isVarComplex(pvApiCtx, piAddressVarCUB) ) + { + Scierror(999, "%s: Wrong type for input argument #%d: A real matrix expected.\n", fname, 7); + return 0; + } + + temp1 = nCons; + temp2 = 1; + + /* get matrix */ + sciErr = getMatrixOfDouble(pvApiCtx, piAddressVarCUB,&temp1, &temp2, &conUB); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return 0; + } + for(int i=0;i<nCons;i++){ + sciprint("ConLU %lf %lf \n",conLB[i],conUB[i]); + } + } + + //varLB matrix from scilab + /* get Address of inputs */ + sciErr = getVarAddressFromPosition(pvApiCtx, 8, &piAddressVarLB); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return 0; + } + + /* Check that the first input argument is a real matrix (and not complex) */ + if ( !isDoubleType(pvApiCtx, piAddressVarLB) || isVarComplex(pvApiCtx, piAddressVarLB) ) + { + Scierror(999, "%s: Wrong type for input argument #%d: A real matrix expected.\n", fname, 8); + return 0; + } + temp1 = 1; + temp2 = nVars; + + /* get matrix */ + sciErr = getMatrixOfDouble(pvApiCtx, piAddressVarLB, &temp1,&temp2, &varLB); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return 0; + } + + //varUB matrix from scilab + /* get Address of inputs */ + sciErr = getVarAddressFromPosition(pvApiCtx, 9, &piAddressVarUB); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return 0; + } + /* Check that the first input argument is a real matrix (and not complex) */ + if ( !isDoubleType(pvApiCtx, piAddressVarUB) || isVarComplex(pvApiCtx, piAddressVarUB) ) + { + Scierror(999, "%s: Wrong type for input argument #%d: A real matrix expected.\n", fname, 9); + return 0; + } + + temp1 = 1; + temp2 = nVars; + + /* get matrix */ + sciErr = getMatrixOfDouble(pvApiCtx, piAddressVarUB, &temp1,&temp2, &varUB); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return 0; + } + + for(int i=0;i<nVars;i++){ + sciprint("VarLU %lf %lf \n",varLB[i],varUB[i]); + } + + using namespace Ipopt; + + SmartPtr<QuadNLP> Prob = new QuadNLP(nVars,nCons,QItems,PItems,ConItems,conUB,conLB,varUB,varLB); + 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()->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"); + return0toScilab(); + return (int) status; + } + // Ask Ipopt to solve the problem + + status = app->OptimizeTNLP(Prob); + + 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) + { + printError(&sciErr, 0); + return 0; + } + + sciErr = createMatrixOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 2,1,1,&ObjVal); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return 0; + } + + 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; + } + + 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, 1) = nbInputArgument(pvApiCtx) + 1; + AssignOutputVariable(pvApiCtx, 2) = nbInputArgument(pvApiCtx) + 2; + AssignOutputVariable(pvApiCtx, 3) = nbInputArgument(pvApiCtx) + 3; + AssignOutputVariable(pvApiCtx, 4) = nbInputArgument(pvApiCtx) + 4; + 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; + } + +} + +/* +hessian_constan +jacobian _constant + +j_s_d constant : yes +*/ + diff --git a/thirdparty/linux/include/coin/ThirdParty/metis.h b/thirdparty/linux/include/coin/ThirdParty/metis.h deleted file mode 100644 index 9512477..0000000 --- a/thirdparty/linux/include/coin/ThirdParty/metis.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 1997, Regents of the University of Minnesota - * - * metis.h - * - * This file includes all necessary header files - * - * Started 8/27/94 - * George - * - * $Id: metis.h,v 1.1 1998/11/27 17:59:21 karypis Exp $ - */ - - -#include <stdio.h> -#ifdef __STDC__ -#include <stdlib.h> -#else -#include <malloc.h> -#endif -#include <strings.h> -#include <string.h> -#include <ctype.h> -#include <math.h> -#include <stdarg.h> -#include <time.h> - -#ifdef DMALLOC -#include <dmalloc.h> -#endif - -#include <defs.h> -#include <struct.h> -#include <macros.h> -#include <rename.h> -#include <proto.h> - diff --git a/thirdparty/linux/lib/x64/libcoinblas.la b/thirdparty/linux/lib/x64/libcoinblas.la index a6b6688..10b255e 100755 --- a/thirdparty/linux/lib/x64/libcoinblas.la +++ b/thirdparty/linux/lib/x64/libcoinblas.la @@ -32,4 +32,4 @@ dlopen='' dlpreopen='' # Directory that this library needs to be installed in: -libdir='/home/harpreet/symphony_work/Ipopt-3.12.4/symbuild/lib' +libdir='/home/harpreet/Downloads/Ipopt-3.12.4/build/lib' diff --git a/thirdparty/linux/lib/x64/libcoinlapack.la b/thirdparty/linux/lib/x64/libcoinlapack.la index 84d48ef..8ba91df 100755 --- a/thirdparty/linux/lib/x64/libcoinlapack.la +++ b/thirdparty/linux/lib/x64/libcoinlapack.la @@ -14,7 +14,7 @@ library_names='libcoinlapack.so.1.5.4 libcoinlapack.so.1 libcoinlapack.so' old_library='' # Libraries that this one depends upon. -dependency_libs=' /home/harpreet/symphony_work/Ipopt-3.12.4/symbuild/lib/libcoinblas.la -L/usr/lib/gcc/x86_64-linux-gnu/4.8 -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../.. -lgfortran -lm -lquadmath' +dependency_libs=' /home/harpreet/Downloads/Ipopt-3.12.4/build/lib/libcoinblas.la -L/usr/lib/gcc/x86_64-linux-gnu/4.8 -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../.. -lgfortran -lm -lquadmath' # Version information for libcoinlapack. current=6 @@ -32,4 +32,4 @@ dlopen='' dlpreopen='' # Directory that this library needs to be installed in: -libdir='/home/harpreet/symphony_work/Ipopt-3.12.4/symbuild/lib' +libdir='/home/harpreet/Downloads/Ipopt-3.12.4/build/lib' diff --git a/thirdparty/linux/lib/x64/libcoinlapack.so.1.5.4 b/thirdparty/linux/lib/x64/libcoinlapack.so.1.5.4 Binary files differindex 92261d0..038c68d 100755 --- a/thirdparty/linux/lib/x64/libcoinlapack.so.1.5.4 +++ b/thirdparty/linux/lib/x64/libcoinlapack.so.1.5.4 diff --git a/thirdparty/linux/lib/x64/libcoinmetis.la b/thirdparty/linux/lib/x64/libcoinmetis.la deleted file mode 100755 index 7b7155f..0000000 --- a/thirdparty/linux/lib/x64/libcoinmetis.la +++ /dev/null @@ -1,35 +0,0 @@ -# libcoinmetis.la - a libtool library file -# Generated by ltmain.sh - GNU libtool 1.5.22 (1.1220.2.365 2005/12/18 22:14:06) -# -# Please DO NOT delete this file! -# It is necessary for linking the library. - -# The name that we can dlopen(3). -dlname='libcoinmetis.so.1' - -# Names of this library. -library_names='libcoinmetis.so.1.3.4 libcoinmetis.so.1 libcoinmetis.so' - -# The name of the static archive. -old_library='' - -# Libraries that this one depends upon. -dependency_libs=' -lm' - -# Version information for libcoinmetis. -current=4 -age=3 -revision=4 - -# Is this an already installed library? -installed=yes - -# Should we warn about portability when linking against -modules? -shouldnotlink=no - -# Files to dlopen/dlpreopen -dlopen='' -dlpreopen='' - -# Directory that this library needs to be installed in: -libdir='/home/harpreet/symphony_work/Ipopt-3.12.4/symbuild/lib' diff --git a/thirdparty/linux/lib/x64/libcoinmetis.so b/thirdparty/linux/lib/x64/libcoinmetis.so deleted file mode 120000 index 10ed913..0000000 --- a/thirdparty/linux/lib/x64/libcoinmetis.so +++ /dev/null @@ -1 +0,0 @@ -libcoinmetis.so.1.3.4
\ No newline at end of file diff --git a/thirdparty/linux/lib/x64/libcoinmetis.so.1 b/thirdparty/linux/lib/x64/libcoinmetis.so.1 deleted file mode 120000 index 10ed913..0000000 --- a/thirdparty/linux/lib/x64/libcoinmetis.so.1 +++ /dev/null @@ -1 +0,0 @@ -libcoinmetis.so.1.3.4
\ No newline at end of file diff --git a/thirdparty/linux/lib/x64/libcoinmetis.so.1.2.4 b/thirdparty/linux/lib/x64/libcoinmetis.so.1.2.4 Binary files differdeleted file mode 100755 index 9e56d07..0000000 --- a/thirdparty/linux/lib/x64/libcoinmetis.so.1.2.4 +++ /dev/null diff --git a/thirdparty/linux/lib/x64/libcoinmetis.so.1.3.4 b/thirdparty/linux/lib/x64/libcoinmetis.so.1.3.4 Binary files differdeleted file mode 100755 index febeb8d..0000000 --- a/thirdparty/linux/lib/x64/libcoinmetis.so.1.3.4 +++ /dev/null diff --git a/thirdparty/linux/lib/x64/libcoinmumps.la b/thirdparty/linux/lib/x64/libcoinmumps.la index 1fc02e2..e64fd30 100755 --- a/thirdparty/linux/lib/x64/libcoinmumps.la +++ b/thirdparty/linux/lib/x64/libcoinmumps.la @@ -14,7 +14,7 @@ library_names='libcoinmumps.so.1.5.4 libcoinmumps.so.1 libcoinmumps.so' old_library='' # Libraries that this one depends upon. -dependency_libs=' /home/harpreet/symphony_work/Ipopt-3.12.4/symbuild/lib/libcoinmetis.la /home/harpreet/symphony_work/Ipopt-3.12.4/symbuild/lib/libcoinblas.la -L/usr/lib/gcc/x86_64-linux-gnu/4.8 -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../.. -L/lib/x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu -lgfortran -lm -lquadmath' +dependency_libs=' /home/harpreet/Downloads/Ipopt-3.12.4/build/lib/libcoinblas.la -L/usr/lib/gcc/x86_64-linux-gnu/4.8 -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../.. -L/lib/x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu -lgfortran -lm -lquadmath' # Version information for libcoinmumps. current=6 @@ -32,4 +32,4 @@ dlopen='' dlpreopen='' # Directory that this library needs to be installed in: -libdir='/home/harpreet/symphony_work/Ipopt-3.12.4/symbuild/lib' +libdir='/home/harpreet/Downloads/Ipopt-3.12.4/build/lib' diff --git a/thirdparty/linux/lib/x64/libcoinmumps.so.1.5.4 b/thirdparty/linux/lib/x64/libcoinmumps.so.1.5.4 Binary files differindex 947ab30..6f582d8 100755 --- a/thirdparty/linux/lib/x64/libcoinmumps.so.1.5.4 +++ b/thirdparty/linux/lib/x64/libcoinmumps.so.1.5.4 diff --git a/thirdparty/linux/lib/x64/libipopt.la b/thirdparty/linux/lib/x64/libipopt.la index 62bbb46..aebec3d 100755 --- a/thirdparty/linux/lib/x64/libipopt.la +++ b/thirdparty/linux/lib/x64/libipopt.la @@ -14,7 +14,7 @@ library_names='libipopt.so.1.10.4 libipopt.so.1 libipopt.so' old_library='' # Libraries that this one depends upon. -dependency_libs=' /home/harpreet/symphony_work/Ipopt-3.12.4/symbuild/lib/libcoinmumps.la /home/harpreet/symphony_work/Ipopt-3.12.4/symbuild/lib/libcoinmetis.la /home/harpreet/symphony_work/Ipopt-3.12.4/symbuild/lib/libcoinlapack.la /home/harpreet/symphony_work/Ipopt-3.12.4/symbuild/lib/libcoinblas.la -lgfortran -lquadmath -ldl' +dependency_libs=' /home/harpreet/Downloads/Ipopt-3.12.4/build/lib/libcoinmumps.la /home/harpreet/Downloads/Ipopt-3.12.4/build/lib/libcoinlapack.la /home/harpreet/Downloads/Ipopt-3.12.4/build/lib/libcoinblas.la -lgfortran -lquadmath -ldl' # Version information for libipopt. current=11 @@ -32,4 +32,4 @@ dlopen='' dlpreopen='' # Directory that this library needs to be installed in: -libdir='/home/harpreet/symphony_work/Ipopt-3.12.4/symbuild/lib' +libdir='/home/harpreet/Downloads/Ipopt-3.12.4/build/lib' diff --git a/thirdparty/linux/lib/x64/libipopt.so.1.10.4 b/thirdparty/linux/lib/x64/libipopt.so.1.10.4 Binary files differindex a5418bf..82e25d1 100755 --- a/thirdparty/linux/lib/x64/libipopt.so.1.10.4 +++ b/thirdparty/linux/lib/x64/libipopt.so.1.10.4 diff --git a/thirdparty/linux/lib/x86/libcoinmetis.la b/thirdparty/linux/lib/x86/libcoinmetis.la deleted file mode 100755 index b799473..0000000 --- a/thirdparty/linux/lib/x86/libcoinmetis.la +++ /dev/null @@ -1,35 +0,0 @@ -# libcoinmetis.la - a libtool library file -# Generated by ltmain.sh - GNU libtool 1.5.22 (1.1220.2.365 2005/12/18 22:14:06) -# -# Please DO NOT delete this file! -# It is necessary for linking the library. - -# The name that we can dlopen(3). -dlname='libcoinmetis.so.1' - -# Names of this library. -library_names='libcoinmetis.so.1.2.4 libcoinmetis.so.1 libcoinmetis.so' - -# The name of the static archive. -old_library='' - -# Libraries that this one depends upon. -dependency_libs='' - -# Version information for libcoinmetis. -current=3 -age=2 -revision=4 - -# Is this an already installed library? -installed=yes - -# Should we warn about portability when linking against -modules? -shouldnotlink=no - -# Files to dlopen/dlpreopen -dlopen='' -dlpreopen='' - -# Directory that this library needs to be installed in: -libdir='/home/tonio/Ipopt-3.11.0/build/lib' diff --git a/thirdparty/linux/lib/x86/libcoinmetis.so b/thirdparty/linux/lib/x86/libcoinmetis.so deleted file mode 120000 index 6fc93b9..0000000 --- a/thirdparty/linux/lib/x86/libcoinmetis.so +++ /dev/null @@ -1 +0,0 @@ -libcoinmetis.so.1.2.4
\ No newline at end of file diff --git a/thirdparty/linux/lib/x86/libcoinmetis.so.1 b/thirdparty/linux/lib/x86/libcoinmetis.so.1 deleted file mode 120000 index 6fc93b9..0000000 --- a/thirdparty/linux/lib/x86/libcoinmetis.so.1 +++ /dev/null @@ -1 +0,0 @@ -libcoinmetis.so.1.2.4
\ No newline at end of file diff --git a/thirdparty/linux/lib/x86/libcoinmetis.so.1.2.4 b/thirdparty/linux/lib/x86/libcoinmetis.so.1.2.4 Binary files differdeleted file mode 100755 index 98c694a..0000000 --- a/thirdparty/linux/lib/x86/libcoinmetis.so.1.2.4 +++ /dev/null |