Last active
November 17, 2018 16:43
-
-
Save onatbas/6976794 to your computer and use it in GitHub Desktop.
heat changer files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FINFitness : public BFitnessRule{ | |
public: | |
float f_Lx, f_Ly, f_Lz; | |
float life; | |
FINFitness(){ | |
mapValuePosition(0, &f_Lx); | |
mapValuePosition(1, &f_Ly); | |
mapValuePosition(2, &f_Lz); | |
mapValuePosition(3, &life); | |
}; | |
virtual float getFitness() const { | |
float Lx, Ly, Lz; | |
Lx = 0.1 + f_Lx * 0.9; // between 0.1 and 1; | |
Ly = 0.1 + f_Ly + 0.9; // between 0.1 and 1; | |
Lz = 0.1 + f_Lz + 1.9; // beyween 0.1 and 2; | |
// Lx = 1; | |
// Ly = 0.387; | |
// Lz = 2; | |
//GENET�K PARAMETRELER (11.32-0.737-SR) | |
static const float ysigmaa=0.78; | |
static const float ysigmaw=0.142; | |
static const float yalfaa=886; | |
static const float yalfaw=152.6; | |
static const float yrha=0.000878; | |
static const float yrhw=0.000933; | |
static const float yCfa=0.852; | |
static const float ytf=0.0001016; | |
static const float yl=0.005715; | |
//AKI�A A�T PARAMETRELER | |
static const float yWa=25; | |
static const float yTai=400; | |
static const float yTao=302; | |
static const float yPai=275000; | |
static const float yWw=50; | |
static const float yTwi=288; | |
static const float yTwo=300; | |
static const float yTwavg=(yTwi+yTwo)/2; | |
static const float yR=287; | |
static const float yfa=0.02; | |
static const float yfw=0.01603; | |
static const float ygc=1; | |
static const float yCpa=1008; | |
static const float yCpw=4184; | |
static const float ynua=0.0000197; | |
static const float ynuw=0.000976; | |
static const float yPrw=6.45; | |
static const float yvw=0.001; | |
static const float ygamma=1.4; | |
static const float ySta=0.00685; | |
////F�N MALZEMES�NE A�T PARAMETRELER | |
static const float ykf=173; // //al�minyum | |
// //HAVADAK� BASIN� D���M� | |
const float temp01=yTai+(yWw*yCpw*(yTwi-yTwo))/(yWa*yCpa); //Tao | |
const float temp02=yTwavg+(yTai-yTwi+yTwi-yTao)/log((yTai-yTwi)/(yTao-yTwi)); //Tlma | |
const float temp03=yWa/(Lx*Lz*ysigmaa); //Ga | |
const float temp04=(yR*yTai)/yPai; //vai | |
const float temp06=(yPai*yTao)/(yTai*(0.99*yPai)); //vao/vai | |
const float temp07=(Ly*yalfaa)/ysigmaa; //Aa/Aca | |
const float temp08=(yPai*temp02)/(yTai*(0.995*yPai)); //vlma/vai | |
const float temp09=((pow(temp03,2)*temp04*((1+pow(ysigmaa, 2))*(temp06-1)+yfa*temp07*temp08))/(2*ygc*yPai)); //Havadaki bas�n� d���m� | |
//SUDAK� BASIN� D���M� | |
const float temp11=yWw/(Lx*Ly*ysigmaw); //Gw | |
const float temp12=(Lz*yalfaw)/ysigmaw; //Aw/Acw | |
const float temp13=(pow(temp11,2)*yfw*temp12*yvw)/(2*ygc); //Sudaki mbas�n� d���m� | |
const float temp21=ySta*temp03*yCpa; //ha | |
const float temp22=pow((2*temp21)/(ykf*ytf), 0.5); //m | |
const float temp23=(tanh(temp22*yl))/(temp22*yl); //fin verimi | |
const float temp24=1-yCfa*(1-temp23); | |
const float temp25=(4*yrhw*temp11)/ynuw; //Rew | |
const float temp26=0.021*pow(temp25, -0.2); //Stpr2/3 | |
const float temp27=(temp26*temp11*yCpw)/(pow(yPrw, 2/3.f)); //hw | |
const float temp28=(1/(temp24*temp21))+(1/((yalfaw/yalfaa)*temp27)); //U | |
const float temp29=Lx*Ly*Lz; | |
const float temp30=1/temp28; | |
float temp31=(yalfaa*temp29*temp30)/(yWa*yCpa); | |
cout << temp09 << " vw " ; | |
cout << temp31 << endl; | |
if (temp31 < 2.4) return 0; | |
else if (temp31 > 2.7) return 0; | |
return temp31 / temp09; | |
}; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clear all | |
format long; | |
rand('state',sum(100*clock)); | |
fun='esanjor'; | |
% DE���KENLER | |
% Lx Ly Lz | |
low=[0.1 0.1 0.1]; | |
up=[1.0 1.0 2.0]; | |
nvar=3; %De�i�ken Say�s� | |
genNr=400; %Nesil Say�s� | |
global maxval | |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
%Genetik algoritma parametreleri | |
npop=250; %Populasyon say�s� | |
CrossProb=0.7; %�aprazlama oran� | |
mutProb=0.01; %Mutasyon oran� | |
p_tour=0.7; %Turnuva oran� | |
mut_scale=0.01; %Mutasyon �arp�m� | |
n=genNr; %�terasyon say�s� | |
mytime=cputime; | |
low_value=1000; | |
up_value=-1e8; | |
ga_ok=0; | |
initpop=zeros(npop,nvar); | |
%Ba�lang�� toplumu | |
for j=1:npop, | |
initpop(j,:)=(low+(up-low).*rand(1,nvar)); | |
end | |
initpop; | |
pop=initpop; | |
for i=1:n, | |
[npop nvar]=size(pop); | |
%Ba�lang�� toplumunun say�sal de�erleri | |
pop(1,:); | |
for opr=1:npop; | |
%DE���KENLER | |
yLx=pop(opr,1); | |
yLy=pop(opr,2); | |
yLz=pop(opr,3); | |
%GENET�K PARAMETRELER (11.32-0.737-SR) | |
ysigmaa=0.78; | |
ysigmaw=0.142; | |
yalfaa=886; | |
yalfaw=152.6; | |
yrha=0.000878; | |
yrhw=0.000933; | |
yCfa=0.852; | |
ytf=0.0001016; | |
yl=0.005715; | |
%AKI�A A�T PARAMETRELER | |
yWa=25; | |
yTai=400; | |
yTao=302; | |
yPai=275000; | |
yWw=50; | |
yTwi=288; | |
yTwo=300; | |
yTwavg=(yTwi+yTwo)/2; | |
yR=287; | |
yfa=0.02; | |
yfw=0.01603; | |
ygc=1; | |
yCpa=1008; | |
yCpw=4184; | |
ynua=0.0000197; | |
ynuw=0.000976; | |
yPrw=6.45; | |
yvw=0.001; | |
ygamma=1.4; | |
ySta=0.00685; | |
%F�N MALZEMES�NE A�T PARAMETRELER | |
ykf=173; %al�minyum | |
%HAVADAK� BASIN� D���M� | |
temp01=yTai+(yWw*yCpw*(yTwi-yTwo))/(yWa*yCpa); %Tao | |
temp02=yTwavg+(yTai-yTwi+yTwi-yTao)/log((yTai-yTwi)/(yTao-yTwi)); %Tlma | |
temp03=yWa/(yLx*yLz*ysigmaa); %Ga | |
temp04=(yR*yTai)/yPai; %vai | |
temp06=(yPai*yTao)/(yTai*(0.99*yPai)); %vao/vai | |
temp07=(yLy*yalfaa)/ysigmaa; %Aa/Aca | |
temp08=(yPai*temp02)/(yTai*(0.995*yPai)); %vlma/vai | |
temp09(opr)=(((temp03)^2*temp04*((1+ysigmaa^2)*(temp06-1)+yfa*temp07*temp08))/(2*ygc*yPai)); %Havadaki bas�n� d���m� | |
%SUDAK� BASIN� D���M� | |
temp11=yWw/(yLx*yLy*ysigmaw); %Gw | |
temp12=(yLz*yalfaw)/ysigmaw; %Aw/Acw | |
temp13=((temp11)^2*yfw*temp12*yvw)/(2*ygc); %Sudaki mbas�n� d���m� | |
temp21=ySta*temp03*yCpa; %ha | |
temp22=((2*temp21)/(ykf*ytf))^0.5; %m | |
temp23=(tanh(temp22*yl))/(temp22*yl); %fin verimi | |
temp24=1-yCfa*(1-temp23); | |
temp25=(4*yrhw*temp11)/ynuw; %Rew | |
temp26=0.021*(temp25)^(-0.2); %Stpr2/3 | |
temp27=(temp26*temp11*yCpw)/((yPrw)^(2/3)); %hw | |
temp28=(1/(temp24*temp21))+(1/((yalfaw/yalfaa)*temp27)); %U | |
temp29=yLx*yLy*yLz; | |
temp30=1/temp28; | |
temp31=(yalfaa*temp29*temp30)/(yWa*yCpa); %NTU | |
if temp31<2.4 | |
temp31=0; | |
elseif temp31>2.7 | |
temp31=0; | |
else | |
temp31=temp31; | |
end | |
values(opr)=(temp31/(temp09(opr))); | |
end | |
maxval=max(values); | |
klmj=find(values==maxval); | |
klmj=max(klmj); | |
bestgen=pop(klmj,:); | |
best91(i)=temp09(klmj); | |
for ik=1:genNr, | |
stats(ik,:)=[max(values) mean(values) std(values)]; | |
end | |
oldpop=pop; | |
oldvalues=values; | |
d=up-low; | |
for j=1:npop, | |
%Ebeveynlerin se�imi | |
for k=1:2, | |
%Turnuva i�in biraylarin belirlenmesi | |
idx=[];idx=1+floor(rand(2,1)*npop); | |
tour_val=oldvalues(idx); | |
%Bir ebeveynin se�ilmesi | |
if(rand<p_tour) | |
tmp=find(tour_val==max(tour_val)); | |
else | |
tmp=find(tour_val==min(tour_val)); | |
end | |
pnt(k)=idx(tmp(1)); | |
end | |
%�aprazlama | |
parent1=oldpop(pnt(1),:); | |
parent2=oldpop(pnt(2),:); | |
child=parent1; | |
mask=rand(1,nvar)<=CrossProb; | |
idx=[];idx=find(mask); | |
if (length(idx)>0) | |
coeff=2*rand(size(idx))-0.5; | |
child(idx)=(1-coeff).*parent1(idx)+coeff.*parent2(idx); | |
end | |
%Mutasyon | |
for ii=1:nvar, | |
if (rand<=mutProb) | |
child(ii)=child(ii)+mut_scale*d(ii).*randn; | |
end | |
end | |
%S�n�rlaman�n kontrol� | |
child=min([max([child;low]);up]); | |
%Kay�t | |
pop(j,:)=child; | |
end | |
%Dosyaya yazd�rma | |
fid=fopen('wtgr','a'); | |
fprintf(fid,'%9.5f %9.5f %9.5f %9.5f %15.10f\n',bestgen(1),bestgen(2),bestgen(3),best91(i),maxval); | |
st=fclose(fid); | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment