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: how to plot a function subject to constraints.
Replies: 14   Last Post: Jan 7, 2013 1:15 PM

Advanced Search

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

Posts: 8
Registered: 12/30/12
Re: how to plot a function subject to constraints.
Posted: Jan 7, 2013 9:33 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

TideMan <mulgor@gmail.com> wrote in message <adfc55ca-51c8-4d03-a871-3829fd523c7d@googlegroups.com>...
> On Monday, January 7, 2013 9:25:09 AM UTC+13, Emrah wrote:
> > isn't there anyone to answer this?
>
> Answer what?
> I don't see a question, just a statement of the problem, which looks awfully like homework.
> What have you tried?
> In what way did it not work?
> Show us the code you've developed so far.


ok mate, dont get angry :)
here is the code i have developed so far

function objFuncPlot
[x2, x3] = meshgrid(0.1:.1:10, 0.1:.1:10);
%x1 and x4 is constant
x1=0.1996;
x4=0.2107;
%calculating constraints
[g1,g2,g3,g4,g5,g6,g7]=constraints(x1,x2,x3,x4);
%objective function
f=1.10471.*x1^2.*x2+0.04811.*x3.*x4.*(14.0+x2);
%constraints are applied to f(x) (the problem point)
f=f*mod_neg_step(g1)*mod_neg_step(g2)*mod_neg_step(g3)*mod_neg_step(g4)...
*mod_neg_step(g5)*mod_neg_step(g6)*mod_neg_step(g7);
%plotting surf
surf(x2,x3,f,'LineStyle','none');
view(68,20)
hold on
plot3(4.7550, 9.3584, 1.988,'x','MarkerEdgeColor','b', ...
'MarkerSize',8); % best point
xlabel('x');ylabel('y');zlabel('z');
hold off

%Constraints & Constants & Equations
function [g1,g2,g3,g4,g5,g6,g7]=constraints(x1,x2,x3,x4)
P=6000;
L=14;
E=30.*10^6;
G=12.*10^6;
tau_max=13600;
sigma_max=30000;
delta_max=0.25;
M=P*(14+x2./2);
R=sqrt(x2^2./4+(x1+x3)^2./4);
J=2.*(x1.*x2.*sqrt(2).*(x2^2/12+(x1+x3)^2/4));
tau_one=P./(sqrt(2).*x1.*x2);
tau_two=(M.*R)./J;
tau=sqrt(tau_one^2+2.*tau_one.*tau_two.*x2./(2.*R)+tau_two^2);
sigma=(6.*P.*L)./(x4.*x3^2);
delta=(4.*P.*L^3)./(30.*10^6.*x4.*x3^3);
PcX=4.013.*E./L^2.*sqrt(x3^2.*x4^6./36).*(1-x3.*sqrt(E./(4.*G))./(2.*L));
g1=tau-tau_max;
g2=sigma-sigma_max;
g3=x1-x4;
g4=0.10471.*x1^2+0.04811.*x3.*x4.*(14+x2)-5.0;
g5=0.125-x1;
g6=delta-delta_max;
g7=P-PcX;
function H = mod_neg_step(argument)
H = zeros(size(argument));
H(argument<= 0) = 1;
H(argument> 0) = NaN;

My aim is to determine which type of optimization algorithm i have to use to solve this problem by checking the plot of the f(x) function. (local search or swarm or etc..) the answer is swarm and PSO is the best for this problem. but i have to show to my teacher the way how i discovered.

In my code, the problem is when I apply the penalty function to f(x), the plot returns none. also honestly i dont know if this is the true way. so i need something like a pseucode for the true way and have to know how to read the results.

Thanks in advance...



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.