From fe8e071460b983c4eae17f89d28176be25484ca3 Mon Sep 17 00:00:00 2001 From: leo Date: Thu, 19 Jan 2023 21:42:56 +0100 Subject: [PATCH] go(de): add {f,cr}Vect --- algo/de/jDE.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/algo/de/jDE.go b/algo/de/jDE.go index 5d3ed00..92af3d4 100644 --- a/algo/de/jDE.go +++ b/algo/de/jDE.go @@ -23,6 +23,10 @@ type JDE struct { F float64 // CR is the crossover probability constant. CR float64 + // fVect holds the F values in a slice. + fVect []float64 + // crVect holds the CR values in a slice. + crVect []float64 // MutationStrategy selects the mutation strategy, i.e. the variant of the // jDE algorithm (0..17), see mutationStrategies.go for more details. MutationStrategy int @@ -102,6 +106,17 @@ func (j *JDE) Init(generations, mutStrategy, adptScheme, np int, f, cr float64, j.BenchName = bench j.ch = ch + fV := make([]float64, np) + crV := make([]float64, np) + + for i := 0; i < np; i++ { + fV[i] = f + crV[i] = cr + } + + j.fVect = fV + j.crVect = crV + pop := newPopulation(bench, j.NP) pop.Init()