diff --git a/algo/randomSearch.go b/algo/randomSearch.go index 7840868..e12fa5c 100644 --- a/algo/randomSearch.go +++ b/algo/randomSearch.go @@ -7,9 +7,11 @@ "fmt" "log" "os" + "time" "git.dotya.ml/wanderer/math-optim/bench" "git.dotya.ml/wanderer/math-optim/stats" + "golang.org/x/exp/rand" "gonum.org/v1/gonum/stat/distuv" ) @@ -52,7 +54,11 @@ func singleRandomSearch(dimens uint, f func([]float64) float64, min, max float64 vals := make([]float64, dimens) // create a continuous uniform distribution representation within min/max bounds - uniformDist := distuv.Uniform{Min: min, Max: max} + uniformDist := distuv.Uniform{ + Min: min, + Max: max, + Src: rand.NewSource(uint64(time.Now().UnixNano())), + } genValsRandomSearch(dimens, vals, &uniformDist) diff --git a/go.mod b/go.mod index 62c0339..d7ae6cb 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module git.dotya.ml/wanderer/math-optim go 1.18 require ( + golang.org/x/exp v0.0.0-20191002040644-a1355ae1e2c3 gonum.org/v1/gonum v0.11.0 gonum.org/v1/plot v0.10.1 ) @@ -14,7 +15,6 @@ require ( github.com/go-latex/latex v0.0.0-20210823091927-c0d11ff05a81 // indirect github.com/go-pdf/fpdf v0.6.0 // indirect github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect - golang.org/x/exp v0.0.0-20191002040644-a1355ae1e2c3 // indirect golang.org/x/image v0.0.0-20220302094943-723b81ca9867 // indirect golang.org/x/text v0.3.7 // indirect )