fix: clear up Hybrid funcs
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
3933dc608a
commit
138e6f1d0b
@ -81,13 +81,10 @@ func Hybrid1(x []float64) float64 {
|
|||||||
p := []float64{0.3, 0.3, 0.4}
|
p := []float64{0.3, 0.3, 0.4}
|
||||||
gnx := getGnx(p, fnx)
|
gnx := getGnx(p, fnx)
|
||||||
|
|
||||||
z := newOpt(nx)
|
|
||||||
mz := getMz(x, z)
|
|
||||||
|
|
||||||
var sum float64
|
var sum float64
|
||||||
|
|
||||||
for i := range funcs {
|
for i := range funcs {
|
||||||
sum += funcs[i](mz) * gnx[i]
|
sum += funcs[i](x) * gnx[i]
|
||||||
}
|
}
|
||||||
|
|
||||||
return sum
|
return sum
|
||||||
@ -108,13 +105,10 @@ func Hybrid2(x []float64) float64 {
|
|||||||
p := []float64{0.2, 0.2, 0.3, 0.3}
|
p := []float64{0.2, 0.2, 0.3, 0.3}
|
||||||
gnx := getGnx(p, fnx)
|
gnx := getGnx(p, fnx)
|
||||||
|
|
||||||
z := newOpt(nx)
|
|
||||||
mz := getMz(x, z)
|
|
||||||
|
|
||||||
var sum float64
|
var sum float64
|
||||||
|
|
||||||
for i := range funcs {
|
for i := range funcs {
|
||||||
sum += funcs[i](mz) * gnx[i]
|
sum += funcs[i](x) * gnx[i]
|
||||||
}
|
}
|
||||||
|
|
||||||
return sum
|
return sum
|
||||||
@ -136,13 +130,10 @@ func Hybrid3(x []float64) float64 {
|
|||||||
p := []float64{0.1, 0.2, 0.2, 0.2, 0.3}
|
p := []float64{0.1, 0.2, 0.2, 0.2, 0.3}
|
||||||
gnx := getGnx(p, fnx)
|
gnx := getGnx(p, fnx)
|
||||||
|
|
||||||
z := newOpt(nx)
|
|
||||||
mz := getMz(x, z)
|
|
||||||
|
|
||||||
var sum float64
|
var sum float64
|
||||||
|
|
||||||
for i := range funcs {
|
for i := range funcs {
|
||||||
sum += funcs[i](mz) * gnx[i]
|
sum += funcs[i](x) * gnx[i]
|
||||||
}
|
}
|
||||||
|
|
||||||
return sum
|
return sum
|
||||||
|
@ -51,7 +51,7 @@ func TestGriewank(t *testing.T) {
|
|||||||
|
|
||||||
func TestHybrid1(t *testing.T) {
|
func TestHybrid1(t *testing.T) {
|
||||||
in := []float64{-9.2, 10, .7, 3, -80.2843}
|
in := []float64{-9.2, 10, .7, 3, -80.2843}
|
||||||
want := 0.00025455132345086895
|
want := 2.0385039193698734e+08
|
||||||
|
|
||||||
got := Hybrid1(in)
|
got := Hybrid1(in)
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ func TestHybrid1(t *testing.T) {
|
|||||||
|
|
||||||
func TestHybrid2(t *testing.T) {
|
func TestHybrid2(t *testing.T) {
|
||||||
in := []float64{-9.2, 10, .7, 3, -80.2843}
|
in := []float64{-9.2, 10, .7, 3, -80.2843}
|
||||||
want := 25.298615746321026
|
want := 4.6901057350488175e+06
|
||||||
|
|
||||||
got := Hybrid2(in)
|
got := Hybrid2(in)
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ func TestHybrid2(t *testing.T) {
|
|||||||
|
|
||||||
func TestHybrid3(t *testing.T) {
|
func TestHybrid3(t *testing.T) {
|
||||||
in := []float64{-9.2, 10, .7, 3, -80.2843}
|
in := []float64{-9.2, 10, .7, 3, -80.2843}
|
||||||
want := 16.298615746321026
|
want := 2.0618485725498265e+08
|
||||||
|
|
||||||
got := Hybrid3(in)
|
got := Hybrid3(in)
|
||||||
|
|
||||||
|
@ -173,6 +173,7 @@ func getGnx(p []float64, fnx float64) []float64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// getMz calculates Mz.
|
// getMz calculates Mz.
|
||||||
|
// nolint: unused
|
||||||
func getMz(x []float64, z []float64) []float64 {
|
func getMz(x []float64, z []float64) []float64 {
|
||||||
nx := len(x)
|
nx := len(x)
|
||||||
mz := make([]float64, nx)
|
mz := make([]float64, nx)
|
||||||
|
Loading…
Reference in New Issue
Block a user