把JAVA代码改成C#代码

packagesimpleGa;publicclassPopulation{Individual[]individuals;//创建一个种群publicPopulatio... package simpleGa;

public class Population {
Individual[] individuals;
// 创建一个种群
public Population(int populationSize, boolean initialise) {
individuals = new Individual[populationSize];
// 初始化种群
if (initialise) {
for (int i = 0; i < size(); i++) {
Individual newIndividual = new Individual();
newIndividual.generateIndividual();
saveIndividual(i, newIndividual);
}
}
}

public Individual getIndividual(int index) {
return individuals[index];
}

public Individual getFittest() {
Individual fittest = individuals[0];
// Loop through individuals to find fittest
for (int i = 0; i < size(); i++) {
if (fittest.getFitness() <= getIndividual(i).getFitness()) {
fittest = getIndividual(i);
}
}
return fittest;
}

// Get population size
public int size() {
return individuals.length;
}

// Save individual
public void saveIndividual(int index, Individual indiv) {
individuals[index] = indiv;
}
}
展开
 我来答
tighterman
2015-08-11 · TA获得超过2780个赞
知道答主
回答量:631
采纳率:0%
帮助的人:198万
展开全部
public Individual getIndividual(int index) {
return individuals[index];
}

public Individual getFittest() {
Individual fittest = individuals[0];
// Loop through individuals to find fittest
for (int i = 0; i < size(); i++) {
if (fittest.getFitness() <= getIndividual(i).getFitness()) {
fittest = getIndividual(i);
}
}
return fittest;
}

// Get population size
public int size() {
return individuals.length;
}

// Save individual
public void saveIndividual(int index, Individual indiv) {
individuals[index] = indiv;
}
}
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式