<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/261093</link>
    <title>MATLAB Central Newsreader - nonlinear constraint help</title>
    <description>Feed for thread: nonlinear constraint help</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Thu, 17 Sep 2009 23:13:03 -0400</pubDate>
      <title>nonlinear constraint help</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/261093#680967</link>
      <author>Simone </author>
      <description>Hello to all,&lt;br&gt;
&lt;br&gt;
I have two maybe very dumb questions but I cannot get my head around these: I have a problem subject to 18 linear constraints and 1 nonlinear constraint. In this last one appear in part variables present also in the linear ones and other variables.&lt;br&gt;
&amp;nbsp;Questions: &lt;br&gt;
1. from the nonlinear constraint to recall the variables present in the linear constraints, I'm calling them with x(position), given the example here &lt;a href=&quot;http://www.mathworks.com/access/helpdesk/help/toolbox/optim/index.html?/access/helpdesk/help/toolbox/optim/ug/brhkghv-7.html&amp;http://www.mathworks.com/matlabcentral/newsreader/view_thread/256555&quot;&gt;http://www.mathworks.com/access/helpdesk/help/toolbox/optim/index.html?/access/helpdesk/help/toolbox/optim/ug/brhkghv-7.html&amp;http://www.mathworks.com/matlabcentral/newsreader/view_thread/256555&lt;/a&gt; is this correct? the name of the solution in my function where I call fmincon is x.&lt;br&gt;
&lt;br&gt;
2. the second question is if I can add more variables to be solved for in the nonlinear constraint, but these would be only in this constraint (they are multiplied by the other variables present also in the linear constraints so they should be identified, isn't it?). I have seen the documentation on how to pass parameters in the nonlinear constraints but not variables, is this possible?&lt;br&gt;
&lt;br&gt;
Thanks a lot for your help in advance,&lt;br&gt;
&lt;br&gt;
Best Regards,&lt;br&gt;
&lt;br&gt;
Simone</description>
    </item>
    <item>
      <pubDate>Fri, 18 Sep 2009 12:35:15 -0400</pubDate>
      <title>Re: nonlinear constraint help</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/261093#681101</link>
      <author>Alan Weiss</author>
      <description>I am sorry, I do not understand what you are asking. Perhaps you can &lt;br&gt;
include an example of the type of parameters you would like to include, &lt;br&gt;
and an example of the syntax you use to call your optimization function.&lt;br&gt;
&lt;br&gt;
Alan Weiss&lt;br&gt;
MATLAB mathematical toolbox documentation&lt;br&gt;
&lt;br&gt;
Simone wrote:&lt;br&gt;
&amp;gt; Hello to all,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I have two maybe very dumb questions but I cannot get my head around these: I have a problem subject to 18 linear constraints and 1 nonlinear constraint. In this last one appear in part variables present also in the linear ones and other variables.&lt;br&gt;
&amp;gt;  Questions: &lt;br&gt;
&amp;gt; 1. from the nonlinear constraint to recall the variables present in the linear constraints, I'm calling them with x(position), given the example here &lt;a href=&quot;http://www.mathworks.com/access/helpdesk/help/toolbox/optim/index.html?/access/helpdesk/help/toolbox/optim/ug/brhkghv-7.html&amp;http://www.mathworks.com/matlabcentral/newsreader/view_thread/256555&quot;&gt;http://www.mathworks.com/access/helpdesk/help/toolbox/optim/index.html?/access/helpdesk/help/toolbox/optim/ug/brhkghv-7.html&amp;http://www.mathworks.com/matlabcentral/newsreader/view_thread/256555&lt;/a&gt; is this correct? the name of the solution in my function where I call fmincon is x.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; 2. the second question is if I can add more variables to be solved for in the nonlinear constraint, but these would be only in this constraint (they are multiplied by the other variables present also in the linear constraints so they should be identified, isn't it?). I have seen the documentation on how to pass parameters in the nonlinear constraints but not variables, is this possible?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks a lot for your help in advance,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Best Regards,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Simone</description>
    </item>
    <item>
      <pubDate>Fri, 18 Sep 2009 15:12:02 -0400</pubDate>
      <title>Re: nonlinear constraint help</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/261093#681168</link>
      <author>Matt </author>
      <description>&quot;Simone &quot; &amp;lt;simonematool@gmail.com&amp;gt; wrote in message &amp;lt;h8ufpv$2iq$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hello to all,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I have two maybe very dumb questions but I cannot get my head around these: I have a problem subject to 18 linear constraints and 1 nonlinear constraint. In this last one appear in part variables present also in the linear ones and other variables.&lt;br&gt;
&amp;gt;  Questions: &lt;br&gt;
&amp;gt; 1. from the nonlinear constraint to recall the variables present in the linear constraints, I'm calling them with x(position), given the example here &lt;a href=&quot;http://www.mathworks.com/access/helpdesk/help/toolbox/optim/index.html?/access/helpdesk/help/toolbox/optim/ug/brhkghv-7.html&amp;http://www.mathworks.com/matlabcentral/newsreader/view_thread/256555&quot;&gt;http://www.mathworks.com/access/helpdesk/help/toolbox/optim/index.html?/access/helpdesk/help/toolbox/optim/ug/brhkghv-7.html&amp;http://www.mathworks.com/matlabcentral/newsreader/view_thread/256555&lt;/a&gt; is this correct? &lt;br&gt;
====================&lt;br&gt;
&lt;br&gt;
Yes.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; 2. the second question is if I can add more variables to be solved for in the nonlinear constraint, but these would be only in this constraint&lt;br&gt;
==============&lt;br&gt;
&lt;br&gt;
Yes.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;(they are multiplied by the other variables present also in the linear constraints so they should be identified, isn't it?). I have seen the documentation on how to pass parameters in the nonlinear constraints but not variables, is this possible?&lt;br&gt;
================&lt;br&gt;
&lt;br&gt;
If your variables decompose as [x,y] where x and y are vectors, then neither your objective function f(x,y) nor your constraints Ci(x,y) have to have an explicit dependence on both x and y, even if they both take x and y as input arguments.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
However, if f(x,y) is independent of y, i.e. can theoretically be written f(x), that gives the algorithm more freedom in finding a y that satisfies Ci(x,y)&amp;gt;=0. If it's important to distinguish between more than one possible solution for y, you must of course add more constraints....</description>
    </item>
    <item>
      <pubDate>Fri, 18 Sep 2009 15:29:03 -0400</pubDate>
      <title>Re: nonlinear constraint help</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/261093#681173</link>
      <author>Simone </author>
      <description>Dear Alan and all,&lt;br&gt;
&lt;br&gt;
thanks a lot for the answer and sorry for my little clarity, I am gonna try again.&lt;br&gt;
So the idea is that I have a series of linear constraints called, as usual, with the A= matrix, b=vector, Aeq=matrix and beq= vector. I never specified in my use of MATLAB (which until recently has been mostly with linear programming) the name of the variables that satisfy these constraints, then I have a nonlinear constraint in which are both the variables present in the linear constraints and other objects (that I am interested in as a solution) in something like this:&lt;br&gt;
function [c, ceq] = myconstr(x,l0,l)&lt;br&gt;
c = [l(1,1)./l0.*x(2).*x(2*n+2)+...+l(1,n)./l0.*x(n+1).*x(3*n+1) -x(2*n+2).*x(n+2)-	x(3*n+1).*x(2*n+1) ]&lt;br&gt;
ceq=[]&lt;br&gt;
l0 and l are data given. I assumed that the variables of the system in the linear constraints are all in the vector x as given in the example from the Mathworks website (and I'm calling also my solution x as per below command). In the linear part I have 2*n+1 variables in the constraints so I started calling these new variables I would like to pass onto the system with x(2*n+2) until x(3*n+1), is it possible to do this?&lt;br&gt;
The following is the way I call the optimization function:&lt;br&gt;
[x, fval, exitflag]=fmincon(@myobj,xs,A,b,Aeq,beq,lb,ub,@myconstr);&lt;br&gt;
&lt;br&gt;
Hoping this is clearer and can help you to help me,&lt;br&gt;
&lt;br&gt;
Hoping you have a great weekend,&lt;br&gt;
&lt;br&gt;
Best Regards,&lt;br&gt;
&lt;br&gt;
Simone&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Alan Weiss &amp;lt;aweiss@mathworks.com&amp;gt; wrote in message &amp;lt;h8vuq3$5ng$2@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; I am sorry, I do not understand what you are asking. Perhaps you can &lt;br&gt;
&amp;gt; include an example of the type of parameters you would like to include, &lt;br&gt;
&amp;gt; and an example of the syntax you use to call your optimization function.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Alan Weiss&lt;br&gt;
&amp;gt; MATLAB mathematical toolbox documentation&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Simone wrote:&lt;br&gt;
&amp;gt; &amp;gt; Hello to all,&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; I have two maybe very dumb questions but I cannot get my head around these: I have a problem subject to 18 linear constraints and 1 nonlinear constraint. In this last one appear in part variables present also in the linear ones and other variables.&lt;br&gt;
&amp;gt; &amp;gt;  Questions: &lt;br&gt;
&amp;gt; &amp;gt; 1. from the nonlinear constraint to recall the variables present in the linear constraints, I'm calling them with x(position), given the example here &lt;a href=&quot;http://www.mathworks.com/access/helpdesk/help/toolbox/optim/index.html?/access/helpdesk/help/toolbox/optim/ug/brhkghv-7.html&amp;http://www.mathworks.com/matlabcentral/newsreader/view_thread/256555&quot;&gt;http://www.mathworks.com/access/helpdesk/help/toolbox/optim/index.html?/access/helpdesk/help/toolbox/optim/ug/brhkghv-7.html&amp;http://www.mathworks.com/matlabcentral/newsreader/view_thread/256555&lt;/a&gt; is this correct? the name of the solution in my function where I call fmincon is x.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; 2. the second question is if I can add more variables to be solved for in the nonlinear constraint, but these would be only in this constraint (they are multiplied by the other variables present also in the linear constraints so they should be identified, isn't it?). I have seen the documentation on how to pass parameters in the nonlinear constraints but not variables, is this possible?&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Thanks a lot for your help in advance,&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Best Regards,&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Simone</description>
    </item>
    <item>
      <pubDate>Fri, 18 Sep 2009 16:07:01 -0400</pubDate>
      <title>Re: nonlinear constraint help</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/261093#681185</link>
      <author>Simone </author>
      <description>Thanks a lot Matt for your answer, as you probably saw I was asnswering Alan already so only when I had already posted my reply I saw yours, sorry for the double post but I thank you for your answer, but then, if adding more variables can be done, do you think can it be that MATLAB gives me an error saying that the index exceeds matrix dimension in the nonlinear constraint because I add more variables in the nonlinear constraint or am I doing something else wrong??? Like the number of columns of A should be equal to the total number of variables, does it matter???&lt;br&gt;
&lt;br&gt;
Thanks a lot again,&lt;br&gt;
&lt;br&gt;
Best Regards,&lt;br&gt;
&lt;br&gt;
Simone&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&quot;Matt &quot; &amp;lt;xys@whatever.com&amp;gt; wrote in message &amp;lt;h90802$61u$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;Simone &quot; &amp;lt;simonematool@gmail.com&amp;gt; wrote in message &amp;lt;h8ufpv$2iq$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; Hello to all,&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; I have two maybe very dumb questions but I cannot get my head around these: I have a problem subject to 18 linear constraints and 1 nonlinear constraint. In this last one appear in part variables present also in the linear ones and other variables.&lt;br&gt;
&amp;gt; &amp;gt;  Questions: &lt;br&gt;
&amp;gt; &amp;gt; 1. from the nonlinear constraint to recall the variables present in the linear constraints, I'm calling them with x(position), given the example here &lt;a href=&quot;http://www.mathworks.com/access/helpdesk/help/toolbox/optim/index.html?/access/helpdesk/help/toolbox/optim/ug/brhkghv-7.html&amp;http://www.mathworks.com/matlabcentral/newsreader/view_thread/256555&quot;&gt;http://www.mathworks.com/access/helpdesk/help/toolbox/optim/index.html?/access/helpdesk/help/toolbox/optim/ug/brhkghv-7.html&amp;http://www.mathworks.com/matlabcentral/newsreader/view_thread/256555&lt;/a&gt; is this correct? &lt;br&gt;
&amp;gt; ====================&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Yes.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; 2. the second question is if I can add more variables to be solved for in the nonlinear constraint, but these would be only in this constraint&lt;br&gt;
&amp;gt; ==============&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Yes.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;  (they are multiplied by the other variables present also in the linear constraints so they should be identified, isn't it?). I have seen the documentation on how to pass parameters in the nonlinear constraints but not variables, is this possible?&lt;br&gt;
&amp;gt; ================&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; If your variables decompose as [x,y] where x and y are vectors, then neither your objective function f(x,y) nor your constraints Ci(x,y) have to have an explicit dependence on both x and y, even if they both take x and y as input arguments.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; However, if f(x,y) is independent of y, i.e. can theoretically be written f(x), that gives the algorithm more freedom in finding a y that satisfies Ci(x,y)&amp;gt;=0. If it's important to distinguish between more than one possible solution for y, you must of course add more constraints....</description>
    </item>
    <item>
      <pubDate>Fri, 18 Sep 2009 16:58:13 -0400</pubDate>
      <title>Re: nonlinear constraint help</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/261093#681190</link>
      <author>Alan Weiss</author>
      <description>Simone, I am still not 100% sure I understand you, but I will make a &lt;br&gt;
guess at what you are asking.&lt;br&gt;
&lt;br&gt;
You might be asking how to include the l0 and l matrices in your &lt;br&gt;
constraint function. You should include them exactly as described in the &lt;br&gt;
documentation:&lt;br&gt;
&lt;br&gt;
function [c, ceq] = myconstr(x,l0,l)&lt;br&gt;
c = [l(1,1)./l0.*x(2).*x(2*n+2)+...+l(1,n)./l0.*x(n+1).*x(3*n+1) &lt;br&gt;
-x(2*n+2).*x(n+2)-	x(3*n+1).*x(2*n+1) ]&lt;br&gt;
ceq=[]&lt;br&gt;
&lt;br&gt;
Load l and l0 into your MATLAB workspace, and define&lt;br&gt;
constr = @(x)myconstr(x,l0,l)&lt;br&gt;
&lt;br&gt;
Use constr as follows:&lt;br&gt;
&lt;br&gt;
[x, fval, exitflag]=fmincon(@myobj,xs,A,b,Aeq,beq,lb,ub,constr);&lt;br&gt;
&lt;br&gt;
If this is not what you were asking, please ask again, using more &lt;br&gt;
examples of exactly what you are trying to do and your syntax.&lt;br&gt;
&lt;br&gt;
Alan Weiss&lt;br&gt;
MATLAB mathematical toolbox documentation&lt;br&gt;
&lt;br&gt;
Simone wrote:&lt;br&gt;
&amp;gt; Dear Alan and all,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; thanks a lot for the answer and sorry for my little clarity, I am gonna try again.&lt;br&gt;
&amp;gt; So the idea is that I have a series of linear constraints called, as usual, with the A= matrix, b=vector, Aeq=matrix and beq= vector. I never specified in my use of MATLAB (which until recently has been mostly with linear programming) the name of the variables that satisfy these constraints, then I have a nonlinear constraint in which are both the variables present in the linear constraints and other objects (that I am interested in as a solution) in something like this:&lt;br&gt;
&amp;gt; function [c, ceq] = myconstr(x,l0,l)&lt;br&gt;
&amp;gt; c = [l(1,1)./l0.*x(2).*x(2*n+2)+...+l(1,n)./l0.*x(n+1).*x(3*n+1) -x(2*n+2).*x(n+2)-	x(3*n+1).*x(2*n+1) ]&lt;br&gt;
&amp;gt; ceq=[]&lt;br&gt;
&amp;gt; l0 and l are data given. I assumed that the variables of the system in the linear constraints are all in the vector x as given in the example from the Mathworks website (and I'm calling also my solution x as per below command). In the linear part I have 2*n+1 variables in the constraints so I started calling these new variables I would like to pass onto the system with x(2*n+2) until x(3*n+1), is it possible to do this?&lt;br&gt;
&amp;gt; The following is the way I call the optimization function:&lt;br&gt;
&amp;gt; [x, fval, exitflag]=fmincon(@myobj,xs,A,b,Aeq,beq,lb,ub,@myconstr);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Hoping this is clearer and can help you to help me,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Hoping you have a great weekend,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Best Regards,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Simone&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Alan Weiss &amp;lt;aweiss@mathworks.com&amp;gt; wrote in message &amp;lt;h8vuq3$5ng$2@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt;&amp;gt; I am sorry, I do not understand what you are asking. Perhaps you can &lt;br&gt;
&amp;gt;&amp;gt; include an example of the type of parameters you would like to include, &lt;br&gt;
&amp;gt;&amp;gt; and an example of the syntax you use to call your optimization function.&lt;br&gt;
&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt; Alan Weiss&lt;br&gt;
&amp;gt;&amp;gt; MATLAB mathematical toolbox documentation&lt;br&gt;
&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt; Simone wrote:&lt;br&gt;
&amp;gt;&amp;gt;&amp;gt; Hello to all,&lt;br&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt;&amp;gt; I have two maybe very dumb questions but I cannot get my head around these: I have a problem subject to 18 linear constraints and 1 nonlinear constraint. In this last one appear in part variables present also in the linear ones and other variables.&lt;br&gt;
&amp;gt;&amp;gt;&amp;gt;  Questions: &lt;br&gt;
&amp;gt;&amp;gt;&amp;gt; 1. from the nonlinear constraint to recall the variables present in the linear constraints, I'm calling them with x(position), given the example here &lt;a href=&quot;http://www.mathworks.com/access/helpdesk/help/toolbox/optim/index.html?/access/helpdesk/help/toolbox/optim/ug/brhkghv-7.html&amp;http://www.mathworks.com/matlabcentral/newsreader/view_thread/256555&quot;&gt;http://www.mathworks.com/access/helpdesk/help/toolbox/optim/index.html?/access/helpdesk/help/toolbox/optim/ug/brhkghv-7.html&amp;http://www.mathworks.com/matlabcentral/newsreader/view_thread/256555&lt;/a&gt; is this correct? the name of the solution in my function where I call fmincon is x.&lt;br&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt;&amp;gt; 2. the second question is if I can add more variables to be solved for in the nonlinear constraint, but these would be only in this constraint (they are multiplied by the other variables present also in the linear constraints so they should be identified, isn't it?). I have seen the documentation on how to pass parameters in the nonlinear constraints but not variables, is this possible?&lt;br&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt;&amp;gt; Thanks a lot for your help in advance,&lt;br&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt;&amp;gt; Best Regards,&lt;br&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt;&amp;gt; Simone</description>
    </item>
    <item>
      <pubDate>Fri, 18 Sep 2009 17:49:05 -0400</pubDate>
      <title>Re: nonlinear constraint help</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/261093#681198</link>
      <author>Matt </author>
      <description>&quot;Simone &quot; &amp;lt;simonematool@gmail.com&amp;gt; wrote in message &amp;lt;h908vv$b5f$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Dear Alan and all,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; thanks a lot for the answer and sorry for my little clarity, I am gonna try again.&lt;br&gt;
&amp;gt; So the idea is that I have a series of linear constraints called, as usual, with the A= matrix, b=vector, Aeq=matrix and beq= vector. I never specified in my use of MATLAB (which until recently has been mostly with linear programming) the name of the variables that satisfy these constraints, then I have a nonlinear constraint in which are both the variables present in the linear constraints and other objects (that I am interested in as a solution) in something like this:&lt;br&gt;
&amp;gt; function [c, ceq] = myconstr(x,l0,l)&lt;br&gt;
&amp;gt; c = [l(1,1)./l0.*x(2).*x(2*n+2)+...+l(1,n)./l0.*x(n+1).*x(3*n+1) -x(2*n+2).*x(n+2)-	x(3*n+1).*x(2*n+1) ]&lt;br&gt;
&amp;gt; ceq=[]&lt;br&gt;
&amp;gt; l0 and l are data given. I assumed that the variables of the system in the linear constraints are all in the vector x as given in the example from the Mathworks website (and I'm calling also my solution x as per below command). In the linear part I have 2*n+1 variables in the constraints so I started calling these new variables I would like to pass onto the system with x(2*n+2) until x(3*n+1), is it possible to do this?&lt;br&gt;
=========================&lt;br&gt;
&lt;br&gt;
No. &lt;br&gt;
&lt;br&gt;
You must define both myobj(X) and myconstr(X) so that the input vector X is of length 3*n+1 and contains all variables that ever appear in the problem. It is not necessary that myobj() and myconstr actually use all 3*n+1 components of X. It is okay if they just use the first 2*n+1 of them.&lt;br&gt;
&lt;br&gt;
You must also modify A and Aeq so that they have  3*n+1 columns. The columns 2*n+2 through 3*n+1 should be zero.&lt;br&gt;
&lt;br&gt;
Similarly, you must extend ub and lb to be of length 3*n+1...</description>
    </item>
    <item>
      <pubDate>Fri, 18 Sep 2009 21:05:22 -0400</pubDate>
      <title>Re: nonlinear constraint help</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/261093#681220</link>
      <author>Simone </author>
      <description>Dear Matt,&lt;br&gt;
thanks a lot again, I will try!&lt;br&gt;
Best regards,&lt;br&gt;
Simone&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&quot;Matt &quot; &amp;lt;xys@whatever.com&amp;gt; wrote in message &amp;lt;h90h6h$59s$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;Simone &quot; &amp;lt;simonematool@gmail.com&amp;gt; wrote in message &amp;lt;h908vv$b5f$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; Dear Alan and all,&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; thanks a lot for the answer and sorry for my little clarity, I am gonna try again.&lt;br&gt;
&amp;gt; &amp;gt; So the idea is that I have a series of linear constraints called, as usual, with the A= matrix, b=vector, Aeq=matrix and beq= vector. I never specified in my use of MATLAB (which until recently has been mostly with linear programming) the name of the variables that satisfy these constraints, then I have a nonlinear constraint in which are both the variables present in the linear constraints and other objects (that I am interested in as a solution) in something like this:&lt;br&gt;
&amp;gt; &amp;gt; function [c, ceq] = myconstr(x,l0,l)&lt;br&gt;
&amp;gt; &amp;gt; c = [l(1,1)./l0.*x(2).*x(2*n+2)+...+l(1,n)./l0.*x(n+1).*x(3*n+1) -x(2*n+2).*x(n+2)-	x(3*n+1).*x(2*n+1) ]&lt;br&gt;
&amp;gt; &amp;gt; ceq=[]&lt;br&gt;
&amp;gt; &amp;gt; l0 and l are data given. I assumed that the variables of the system in the linear constraints are all in the vector x as given in the example from the Mathworks website (and I'm calling also my solution x as per below command). In the linear part I have 2*n+1 variables in the constraints so I started calling these new variables I would like to pass onto the system with x(2*n+2) until x(3*n+1), is it possible to do this?&lt;br&gt;
&amp;gt; =========================&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; No. &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; You must define both myobj(X) and myconstr(X) so that the input vector X is of length 3*n+1 and contains all variables that ever appear in the problem. It is not necessary that myobj() and myconstr actually use all 3*n+1 components of X. It is okay if they just use the first 2*n+1 of them.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; You must also modify A and Aeq so that they have  3*n+1 columns. The columns 2*n+2 through 3*n+1 should be zero.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Similarly, you must extend ub and lb to be of length 3*n+1...</description>
    </item>
  </channel>
</rss>

