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

When adding steps for plotting, we have to add in every point twice, so we get...

When adding steps for plotting, we have to add in every point twice, so we get a step shape and not interpolation.
parent 99064963
No related branches found
No related tags found
No related merge requests found
...@@ -190,6 +190,7 @@ func saveStep(cprm *cprm, n int, tmprtr float64, x []float32, fTrial float64) { ...@@ -190,6 +190,7 @@ func saveStep(cprm *cprm, n int, tmprtr float64, x []float32, fTrial float64) {
cprm.plotf = append(cprm.plotf, fprev) // copy the last coordinates cprm.plotf = append(cprm.plotf, fprev) // copy the last coordinates
cprm.plotf = append(cprm.plotf, fTrial) // and append them cprm.plotf = append(cprm.plotf, fTrial) // and append them
cprm.plotTmprtr = append(cprm.plotTmprtr, tmprtr) // then the new ones cprm.plotTmprtr = append(cprm.plotTmprtr, tmprtr) // then the new ones
cprm.plotTmprtr = append(cprm.plotTmprtr, tmprtr) // then the new ones
} }
if cprm.xplotWrt != nil { // The trajectory if cprm.xplotWrt != nil { // The trajectory
cprm.plotXtrj = append(cprm.plotXtrj, xprev...) cprm.plotXtrj = append(cprm.plotXtrj, xprev...)
...@@ -299,6 +300,7 @@ func DoRun(mcPrm *McPrm) (MCresult, error) { ...@@ -299,6 +300,7 @@ func DoRun(mcPrm *McPrm) (MCresult, error) {
if fTrial != fOld { // last move was not accepted, so we have to add last step if fTrial != fOld { // last move was not accepted, so we have to add last step
saveStep(&cprm, mcPrm.NStep, tmprtr, x, fOld) saveStep(&cprm, mcPrm.NStep, tmprtr, x, fOld)
} }
defer fmt.Println("n accepted:", nAcc, "of", mcPrm.NStep) defer fmt.Println("n accepted:", nAcc, "of", mcPrm.NStep)
if bestX != nil { if bestX != nil {
defer fmt.Printf("Best function value: %.2f at %.2v\n", bestfval, bestX) defer fmt.Printf("Best function value: %.2f at %.2v\n", bestfval, bestX)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment