45 lines
887 B
Go
45 lines
887 B
Go
// Copyright 2022 wanderer <a_mirre at utb dot cz>
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
package algo
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
|
|
"git.dotya.ml/wanderer/math-optim/stats"
|
|
"gonum.org/v1/plot"
|
|
"gonum.org/v1/plot/plotter"
|
|
"gonum.org/v1/plot/plotutil"
|
|
"gonum.org/v1/plot/vg"
|
|
)
|
|
|
|
func doCombined30Plot(s *stats.FuncStats, dimens uint, filename string) {
|
|
p := plot.New()
|
|
p.Title.Text = s.BenchName + ", D=" + fmt.Sprint(dimens)
|
|
p.X.Label.Text = "Cost function evaluations"
|
|
p.Y.Label.Text = "CF value"
|
|
|
|
for i, v := range s.Solution {
|
|
pts := make(plotter.XYs, len(s.Solution[i].Results))
|
|
|
|
for j := range pts {
|
|
pts[j].X = float64(j)
|
|
pts[j].Y = v.Results[j]
|
|
}
|
|
|
|
err := plotutil.AddLinePoints(
|
|
p,
|
|
pts,
|
|
)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|
|
|
|
// Save the plot to a PNG file.
|
|
if err := p.Save(8*vg.Inch, 8*vg.Inch, filename); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|