母集団から染色体を削除する方法を書こうとしています。私が書いた方法は以下です。コードを実行すると、範囲外のエラーが発生します。人口は で構築されますArrayList
。このgetChromosomeFitness
メソッドはint
値スコアを返します。誰かが私のエラーを見つけることができますか?
void removeWorst()
{
int worst = population.get(0).getChromosomeFitness();
int temp = 0;
for(int i = 1; i < population.size(); i++)
{
if (population.get(i).getChromosomeFitness() < population.get(worst).getChromosomeFitness())
{
worst = population.get(i).getChromosomeFitness();
temp = i;
}
}
Chromosome x = population.get(temp);
population.remove(x);
}