How to write matlab code for optimization of this equation ?
이전 댓글 표시
Hello, I want to optimize the following equation with particle swarm optimization algorithm.
margin(d)=-13.4-(8.686.*((d/0.5).^2))+30 ;
where range of d is (0.1, 3) and range of margin is (6,20). Need optimum margin with optimum value of d within those boundary value.
답변 (1개)
Walter Roberson
2017년 10월 9일
margin = @(d) -13.4-(8.686.*((d/0.5).^2))+30;
A = []; b = [];
Aeq = []; beq = [];
lb = 0.1; ub = 3;
mlb = 6; mub = 20;
nonlcon = @(d) deal([mlb - margin(d), margin(d)-mub], []);
d_min_margin = ga(margin, 1, A, b, Aeq, beq, lb, ub, nonlcon);
d_max_margin = ga(@(d) -margin(d), 1, A, b, Aeq, beq, lb, ub, nonlcon);
It was not clear from your "optimum" whether you were looking to minimize or maximize, so I show both.
However, there is really no point in using genetic algorithms for this function. The function is quadratic, so you can solve directly. Expand the function and you will find it is 16.6 - 34.744*d^2 . So you can
t = roots([-34.744, 0, 16.6-mlb]);
t(imag(g) == 0 & t>0)
to solve for the exact point at which margin(d) = mlb, and the location of the 0 is going to be sqrt(16.6/34.744)
카테고리
도움말 센터 및 File Exchange에서 Systems of Nonlinear Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!