Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Problem with defining vector x for fmincon
Replies: 2   Last Post: Nov 11, 2012 11:31 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Roshanak Mirmiran

Posts: 4
Registered: 11/8/12
Problem with defining vector x for fmincon
Posted: Nov 8, 2012 3:23 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hi,

I would like to do my optimization with MATLAB FMINCON, and my optimization problem has a nonlinear objective function and nonlinear constraints.
here is my objective function:

for k=1:6;

B(k)=x(2*num+k)*x(fb(k));
C(k)=x(tb(k));
D(k)=2*B(k)*C(k);
g=real(Ybr);

loss(k)=g(fb(k),tb(k))*((B(k)^2)+C(k)^2-D(k)*cos(x(num+fb(k))-x(num+tb(k))));

end

Ploss=sum(loss)


and my constraint:

for i=1:num
P(i)=sym(strcat('p',num2str(i)));
Q(i)=sym(strcat('q',num2str(i)));
end
P(1:num)=0;
Q(1:num)=0;

%% Non Linear Eqaulity Constraints

for i = 1:7
for k = 1:7
P(i) = P(i) + x(i).* x(k).*(g(i,k).*cos(x(num+i)-x(num+k)) +
b(i,k).*sin(x(num+i)-x(num+k)));
Q(i) = Q(i) + x(i).* x(k).*(g(i,k).*sin(x(num+i)-x(num+k)) -
b(i,k).*cos(x(num+i)-x(num+k)));
end
end

for k = 1:6;

N(k)=(x(fb(k))./x(2*num+k))-((xre(k)*(qd(tb(k))-
x(3*num+k)))+r(k)*pd(tb(k)))./((x(2*num+k)^2)*x(tb(k)))-x(tb(k));
end

ceq =[(pg.'-pd.'-P).';(qg.'-qd.'-Q).';N.'];
c=[];

When i run fmincon command i just got different errors such as:

??? Undefined function or method 'max' for input arguments of type 'sym'.

Error in ==> nlconst at 196
mg = max(ga);

I defined my x as:

for i=1:27;
x(i)=sym(strcat('x',num2str(i)));
end

I will highly appreciate if you could give me some hints and help me to do my optimization.



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.