Hello all,
My aim is to solve for complicated non linear system of equations defined as follows:
Unknown variables: epsi, da, dr, phi1, Jr, Ja
Known variables: alpha= 40 deg, Z=16, Kn=4.5080*10(^5), Fr=Fa=17800
Equations are defined as follows:
epsi = 0.5 * (1 + da*tan(alpha) / dr)
phi1 = cosinv (-da*tan(alpha) / dr)
Jr=integration from -phi1 to phi1 of (1/(2*pi)) * (1 - (0.5/epsi) * (1-cos(theta) ) )^(1.5) * cos(theta)
Ja=integration from -phi1 to phi1 of (1/(2*pi)) * (1-(0.5/epsi) * (1-cos(theta) ) )^(1.5)
Fr / Fa = (Jr * cos(alpha)) / (Ja * sin(alpha))
To solve for these system of equations I am using fmincon function available in matlab..
My Matlab code is as follows:
Z=16, KN1=4.5080e5; Fr=Fa=17800; alpha=40;
%optimization for load distribution
%KN1=Kn(5);
%for i=1:1:length(Kn)
[dr, Epsi]=opt();
function [dopt,EPSI] = opt()
dr0=[0.08; 0.1];
lb=[0, 0];
ub=[1, 1];
Options=optimset('Algorithm','active-set','Display','Iter');
dopt=fmincon(@myfun,dr0,[],[],[],[],lb,ub,@mycon,Options);
EPSI=myfun(dopt);
end
function epsi=myfun(dr)
epsi=0.5*(1+dr(1)*tand(alpha)/(dr(2)));
end
function [c,ceq]=mycon(dr)
c=abs(-dr(1)*tand(alpha)/dr(2))-1;
phi1=acos(-dr(1)*tand(alpha)/dr(2));
epsi=0.5*(1+(dr(1)*tand(alpha)/dr(2)));
c=-1+(0.5/epsi).*(1-cos(phi1));
funr=@(theta)(1/(2*pi)).*(1-(0.5/epsi).*(1-cos(theta))).^(1.5).*cos(theta);
Jr=quad(funr,-phi1,phi1);
funa=@(beta)(1/(2*pi)).*(1-(0.5/epsi).*(1-cos(beta))).^(1.5);
Ja=quad(funa,-phi1,phi1);
ceq=real(Jr)*cosd(alpha)/(real(Ja)*sind(alpha))-Fr/Fa;
%c=[];
end
When I run this code, I am getting the optimized value of dr as [-0.0001, 0.0011]. This value is clearly beyond limiting values of dr. I am specifying lower bound of dr as [0,0]. I am unable to understand why Matlab is not considering specified boundaries. As well, my final answer is dependent on initial guess. If I change my initial guess then my final answer changes. Can somebody please help to resolve these issues??
Thanks in advance,
Nikhil

답변 (1개)

Amit
Amit 2013년 12월 29일

0 개 추천

what's the exitflag?

댓글 수: 7

Nikhil
Nikhil 2013년 12월 29일
Hey,
Exit flag for this case is negative. It is coming out to be -2. How should I go about this?
Thanks, Nikhil
Amit
Amit 2013년 12월 29일
편집: Amit 2013년 12월 29일
no feasible solution found with exitflag -2. play around with other solvers and options ..
I also want to add that matlab sin, tan etc use radians and not degree
Nikhil
Nikhil 2013년 12월 30일
Yes, I have ensured that degrees and radians will not be an issue. For certain values of the initial guess, I am getting correct optimized result. But I want to know why am I not getting correct answers for other cases? This means that if I run this code for different values of input parameters then each time I will need to change my initial guess in the fmincon function. I want to avoid this so that my code can run for all the cases..
Amit
Amit 2013년 12월 30일
first of all, looking at the conditions, I think your overall set of eqn can be further simplified .. Fr/Fa = 1 and thus you dont have to compute Jr and Ja .. Also, fmincon is a minimizing algorithm .. it seems that you are minimizing epsi and not solving it. can you check that?
try different algorithm and see if that helps. Also, sometimes using a global minimization algorithm (like simulated annealing) can be ised to find initial guesses.
Amit
Amit 2013년 12월 31일
편집: Amit 2013년 12월 31일
I finally got a hold of my computer to run Matlab to test it. First of all, if the equations mentioned here are valid, this becomes a nonlinear equation (without constrains) and you dont have to use fmincon at all to solve it. From you equation, I get this function:
function F = func(dr)
alpha = 40*pi()/180;
epsi = 0.5*(1+dr(1)*(tan(alpha))/dr(1));
phi1 = acos(-dr(1)*(tan(alpha))/dr(1));
funr=@(theta)(1/(2*pi)).*(1-(0.5/epsi).*(1-cos(theta))).^(1.5).*cos(theta);
funa=@(beta)(1/(2*pi)).*(1-(0.5/epsi).*(1-cos(beta))).^(1.5);
Jr=quad(funr,-phi1,phi1);
Ja=quad(funa,-phi1,phi1);
F = Jr*cos(alpha)-Ja*sin(alpha);
end
Here you are solving for F and can use fsolve instead of fmincon. Now, when I try to solve it, it gives me different solution each time depending on the initial guess. This might be due to these set of equations have multiple solutions. Are you sure the equations given here are correct? I dont see the use of variable like Z, Kn anywhere which you suggested as known variable.
Nikhil
Nikhil 2014년 1월 4일
Hey,
Sorry for getting back to you so late. Before using fmincon, I tried with fsolve. In this case the problem is in funr and funa terms. 1-(0.5/epsi)*(1-cos(theta or beta)) term can become negative. In this case then -ve term raise to odd power can give imaginary results. Hence I need to impose constraints at each iteration, to check whether above mentioned term is positive.
Nikhil
Nikhil 2014년 1월 4일
more over when I analyzed my error, I am getting following information:
fmincon stopped because the predicted change in the objective function is less than the default value of the function tolerance but constraints are not satisfied to within the default value of the constraint tolerance.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Systems of Nonlinear Equations에 대해 자세히 알아보기

질문:

2013년 12월 29일

편집:

2014년 1월 4일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by