Editura Sfântul Ierarh Nicolae ISBN 978-606-577-027-0
Editura Sfântul Ierarh Nicolae ISBN 978-606-577-027-0
Editura Sfântul Ierarh Nicolae ISBN 978-606-577-027-0
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
PopulatieNoua[++NrPop]=PopulatieVeche[1+random(MaxPopulatie-<br />
MaxElitism)];<br />
}<br />
void OrdoneazaDupaFitness()<br />
{<br />
int i,sw=1;<br />
TCromozom aux;<br />
while (sw)<br />
{<br />
sw=0;<br />
for(i=1;iPopulatieVeche[i+1].fitness)<br />
{<br />
aux=PopulatieVeche[i];<br />
PopulatieVeche[i]=PopulatieVeche[i+1];<br />
PopulatieVeche[i+1]=aux;<br />
sw=1;<br />
}<br />
}<br />
if (PopulatieVeche[MaxPopulatie].fitness>CelMaiBunCromozom.fitness)<br />
CelMaiBunCromozom=PopulatieVeche[MaxPopulatie];<br />
}<br />
void SelectieParintiAranjata(int &r1, int &r2)<br />
{<br />
int s,r;<br />
s=MaxPopulatie*(MaxPopulatie+1)/2;<br />
r=1+random(s);<br />
r1=0;<br />
while (r>0)<br />
{<br />
r1++;<br />
r-=r1;<br />
}<br />
r=1+random(s);<br />
r2=0;<br />
while (r>0)<br />
{<br />
r2++;<br />
r-=r2;<br />
}<br />
}<br />
void Afiseaza()<br />
{<br />
int i;<br />
cout