核数计算

parent 40085732
...@@ -173,8 +173,11 @@ public class ScheduleParams { ...@@ -173,8 +173,11 @@ public class ScheduleParams {
populationSize = (int) Math.max(MIN_POPULATION_SIZE, populationSize = (int) Math.max(MIN_POPULATION_SIZE,
Math.min(MAX_POPULATION_SIZE, MIN_POPULATION_SIZE + totalOps * populationSizeCoeff)); Math.min(MAX_POPULATION_SIZE, MIN_POPULATION_SIZE + totalOps * populationSizeCoeff));
int maxthead= Runtime.getRuntime().availableProcessors() - 1; int maxthead = Math.max(1, Runtime.getRuntime().availableProcessors() - 1);
populationSize= populationSize / maxthead*maxthead; if (populationSize >= maxthead) {
populationSize = populationSize / maxthead * maxthead;
}
populationSize = Math.max(MIN_POPULATION_SIZE, populationSize);
// 确保偶数(方便交叉) // 确保偶数(方便交叉)
// if (populationSize % 2 != 0) { // if (populationSize % 2 != 0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment