Skip to content
Snippets Groups Projects
Commit 99064963 authored by Andrew E. Torda's avatar Andrew E. Torda
Browse files

playing

parent 607e1fc0
No related branches found
No related tags found
No related merge requests found
......@@ -175,15 +175,24 @@ func saveBest(x []float32, fTrial float64, n int) {
}
// saveStep is called when we accept a change. It writes or saves for
// later plotting.
// later plotting. The plan, every time we append values, we have to do it twice
// so we get a proper stepped appearance.
func saveStep(cprm *cprm, n int, tmprtr float64, x []float32, fTrial float64) {
saveBest(x, fTrial, n)
cprm.plotnstp = append(cprm.plotnstp, float64(n)) // num steps
if cprm.fplotWrt != nil { // Function values // function values
cprm.plotf = append(cprm.plotf, fTrial)
cprm.plotTmprtr = append(cprm.plotTmprtr, tmprtr)
fprev := fTrial
xprev := x
if n != 0 {
fprev = cprm.plotf[len(cprm.plotf)-1]
xprev = cprm.plotXtrj[len(cprm.plotXtrj)-len(x):]
}
cprm.plotnstp = append(cprm.plotnstp, float64(n), float64(n)) // num steps
if cprm.fplotWrt != nil { // Function values
cprm.plotf = append(cprm.plotf, fprev) // copy the last coordinates
cprm.plotf = append(cprm.plotf, fTrial) // and append them
cprm.plotTmprtr = append(cprm.plotTmprtr, tmprtr) // then the new ones
}
if cprm.xplotWrt != nil { // The trajectory
cprm.plotXtrj = append(cprm.plotXtrj, xprev...)
cprm.plotXtrj = append(cprm.plotXtrj, x...)
}
if cprm.doTxtFval {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment