mirror of
https://github.com/gonum/gonum.git
synced 2025-10-04 06:46:29 +08:00

* optimize: remove Local implementation and replace with a call to Global This PR starts the process described in #482. It removes the existing Local implementation, replacing with a function that wraps Method to act as a GlobalMethod. This PR also adds a hack to fix an inconsistency with FunctionConverge between Global and Local (and a TODO to make it not a hack in the future)
36 lines
831 B
Go
36 lines
831 B
Go
// Copyright ©2016 The Gonum Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package optimize
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"gonum.org/v1/gonum/mat"
|
|
"gonum.org/v1/gonum/optimize/functions"
|
|
"gonum.org/v1/gonum/stat/distmv"
|
|
)
|
|
|
|
func TestGuessAndCheck(t *testing.T) {
|
|
dim := 30
|
|
problem := Problem{
|
|
Func: functions.ExtendedRosenbrock{}.Func,
|
|
}
|
|
mu := make([]float64, dim)
|
|
sigma := mat.NewSymDense(dim, nil)
|
|
for i := 0; i < dim; i++ {
|
|
sigma.SetSym(i, i, 1)
|
|
}
|
|
d, ok := distmv.NewNormal(mu, sigma, nil)
|
|
if !ok {
|
|
panic("bad test")
|
|
}
|
|
Global(problem, dim, nil, &GuessAndCheck{Rander: d})
|
|
|
|
settings := DefaultSettingsGlobal()
|
|
settings.Concurrent = 5
|
|
settings.MajorIterations = 15
|
|
Global(problem, dim, settings, &GuessAndCheck{Rander: d})
|
|
}
|