1
0
mirror of https://github.com/newnius/YAO-scheduler.git synced 2025-06-06 22:01:55 +00:00
This commit is contained in:
Newnius 2020-06-15 15:04:08 +08:00
parent cbd9e3af89
commit e89f7ca164

View File

@ -136,6 +136,15 @@ func (X Allocation) Mutate(rng *rand.Rand) {
// Crossover a Vector with another Vector by applying uniform crossover.
func (X Allocation) Crossover(Y eaopt.Genome, rng *rand.Rand) {
// make sure n > 0 && round > 0
cnt := 0
for _, tasks := range X.TasksOnNode {
for _ := range tasks {
cnt++
}
}
if cnt != len(X.Tasks) && X.Flags["valid"] {
log.Warn("1:", cnt, len(X.Tasks))
}
round := rng.Intn(1+len(X.Nodes)/100)%10 + 1
for i := 0; i < round; i++ {
if !Y.(Allocation).Flags["valid"] || !X.Flags["valid"] {
@ -245,6 +254,15 @@ func (X Allocation) Crossover(Y eaopt.Genome, rng *rand.Rand) {
}
}
}
cnt = 0
for _, tasks := range X.TasksOnNode {
for _ := range tasks {
cnt++
}
}
if cnt != len(X.Tasks) && X.Flags["valid"] {
log.Warn("1:", cnt, len(X.Tasks))
}
//fmt.Println()
//fmt.Println("crossover", X.TasksOnNode)
}