📄 spawner.java
字号:
package chc;import shared.LogOptions;import java.util.*; public class Spawner { private int attrselectionsize; private LogOptions logOptions = new LogOptions("WRAPPER"); private Random rand; public Spawner(int attrselsize) { if (attrselsize < 1) { logOptions.ERR(0, "Atribute attrselectionsize cannot be zero."); } attrselectionsize = attrselsize; rand = new Random(System.currentTimeMillis()); } public Hypothesis[] spawnPopulation(int number, int generation) { logOptions.LOG(3, "Spawning"+CHC.ENDL); Hypothesis[] result = new Hypothesis[number]; for (int i = 0; i < number; i++) { result[i] = newHypo(generation); } return result; } public Hypothesis newHypo(int generation) { int[] newint = new int[attrselectionsize]; for (int j = 0; j < attrselectionsize; j++) { newint[j] = rand.nextInt(2); } Hypothesis newhypo = new Hypothesis(generation, newint); return newhypo; } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -