Finding a maximum using gamultobj tool

Hi, i've written the following script and I'm looking to maximise y(2) using the gamultobj tool. However I can only seem to find the minimum value. How can I find the maximum? (I'm using bounds [ 0 4 0 4 0 4] lower and [20 8 20 8 20 8] upper)
function [y] = totalpowertest(x)
% beta1 x(1) beta3 x(5)
% lamda1 x(2) lamda3 x(6)
% beta2 x(3)
% lamda2 x(4)
rho = 1.225; % density of air kg/m^3
R = 89.15; % radius of turbine m
D = 178.3; % diameter of turbine m
k = 0.04;
xd = 178.3*5; %example value for distance between turbines
u1 = 15; % example value
c1 = 0.5176;
c2 = 116;
c3 = 0.4;
c4 = 5;
c5 = 21;
c6 = 0.0068;
% equation 1 lamdai1
z1 = 1/(x(2) + 0.08*x(1)) - 0.035/((x(1).^3) +1);
lamdai1 =1/z1;
%equation 2 cp1
cp1 = c1*((c2/lamdai1)-c3*x(1)-c4)*exp(-c5/lamdai1)+c6*x(2);
%equation 3 u4 (z3)
Z3 = roots([ 1/(2*u1^3), 1/(2*u1^2), -1/(2*u1), cp1 - 1/2]);
z3 = real(Z3( Z3>0 ));
u4 = z3;
%equation 3ii u2
u2 = 0.5*(u1+u4);
%equation 3iii T
T = rho*pi*(R.^2)*u2*(u1-u4);
%equation 3iv (for second turbine) ct
%u1 istead of u4?
ct = (2*T)/(rho*pi*(R.^2)*(u1.^2));
%equation 4 (for second turbine) vw
vw = u1*(1-((R/(k*xd+R)).^2)*(1-sqrt(1-ct)));
% equation 5i (for first turbine) - maximum 10 MW allowed pout1
a1 = 0.5*cp1*rho*pi*R.^2*u1.^3;
a1(a1>10000000)=10000000;
pout1 = a1;
% equation 1 lamdai2
z3 = 1/(x(4) + 0.08*x(3)) - 0.035/((x(3).^3) +1);
lamdai2 = 1/z3;
%equation 2 cp2
cp2 = c1*((c2/lamdai2)-c3*x(3)-c4)*exp(-c5/lamdai2)+c6*x(4);
% equation 5ii (for second turbine) - maximum 10 MW allowed pout2
a2 = 0.5*cp2*rho*pi*R.^2*vw.^3;
a2(a2>10000000)=10000000;
pout2 = a2;
% equation 6 pout1+pout2
y(1) = pout1 + pout2;
%u1_3 = u4_2; % downstream wind of first turbine to calculate power of second turbine
%u1_3 = y(3); % is equal to incoming windspeed of second turbine to calclate power of third turbine
% equation 1 (for third turbine) lamdai
z4 = 1/(x(6) + 0.08*x(5)) - 0.035/((x(5).^3) +1);
lamdai3 =1/z4;
%equation 2 (for third turbine) cp
cp3 = c1*((c2/lamdai3)-c3*x(5)-c4)*exp(-c5/lamdai3)+c6*x(6);
%equation 3i_3 (for third turbine) u4 (z5?)
Z5 = roots([ 1/(2*u4^3), 1/(2*u4^2), -1/(2*u4), cp2 - 1/2]);
z5 = real(Z5( Z5>0 ));
u4_2=z5;
%
%equation 3ii_3 (for third turbine) u2
u2_2 = 0.5*(u4+u4_2);
%equation 3iii_3 (for third turbine) T
T_2 = rho*pi*(R.^2)*u2_2*(u4-u4_2);
%equation 3iv_3 (for third turbine) ct
ct_2 = (2*T_2)/(rho*pi*(R.^2)*(u4.^2));
%equation 4_2 (for third turbine) vw
vw_2 = u4*(1-((R/(k*xd+R)).^2)*(1-sqrt(1-ct_2)));
% equation 5_3 (for third turbine) - maximum 10 MW allowed pout3
a3 = 0.5*cp3*rho*pi*R.^2*vw_2.^3;
a3(a3>10000000)=10000000;
pout3 = a3;
% equation 6 pout1 + pout2 + pout3
y(2) = pout1 + pout2 + pout3;
end

 采纳的回答

Stephan
Stephan 2019-3-4
编辑:Stephan 2019-3-4
Hi,
all optimizers in Matlab try ti find minimum of functions. If you want to maximize you simply minimize the negative function.
max (f) --> min (-f)
See also here:
Best regards
Stephan

10 个评论

Okay thanks. Though I am confused as to how I would apply it to my script. Any help would be appreciated
Do you want y(1) also to be maximized?
I don't think so. Basically I'm trying to find the maximum amount of power that can be generated by the 3 turbines.
is y(1) a optmization goal? If not life would be easier. Then ga would do the job instead of gamultiobj.
for theoretical reasons y(1) has to be maximized. Since y(2) = y(1) + something to maximize. only if y(1) is a maximum himself, y(2) can be a global maximum. isnt it?
in other words: maximizing y(2) includes maximizing y(1) which means, that you do not have a multiobjective system. or do i miss something here?
I think you're right. So if I remove the initial y(1) from the script and now make y(2) the new y(1) (i.e. y(1) is now y(1) = pout1 + pout2 + pout3) then I can use ga. However this now leads me to another problem as when i run the ga this only produces one result and this uses inputs x(1),x(2)...etc = 20 8 20 8 20 8 i.e my upper bound. Do you know how i can solve this?
This means that you only can achieve more power by setting bounds up. If this is technical possible you shpuld do it. If not you have the maximum possible power when all variables get thei upper bound value.
I've set bounds as [0 4 0 4 0 4] for lower and [20 8 20 8 20 8] for upper. However I know that the maximum power that can be produced from these bounds is not equal to that of my upper bound as it produces a very small result. How would I maximise y(1)?
y = -(pout1 + pout2 + pout3);
for one variable you can write y instead of y(1)
The result should be the negative value of your desired maximum.
Cheers thanks very much! Just one last question. Is there any way to show the values of the other parameters for the maximum result (i.e. cp and u4)?
mmh, one way would be an adapted copy of your function eith the desired outputs. once you have the result you could call this second function with the optimized vector of variables and get the result this way. for a more clever solution i qould have to think a bit longer. but im a bit in hurry currently.
if this answer was useful please accept it.

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Annotations 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by