From 14bb48043e63f97cdb34e0e42fbe8b05c7c892e2 Mon Sep 17 00:00:00 2001 From: "Andrew E. Torda" <torda@zbh.uni-hamburg.de> Date: Sat, 23 Apr 2022 18:06:30 +0200 Subject: [PATCH] Still cleaning after removing adaptive steps. --- README.md | 2 +- docs/doc.go | 6 +++--- mc_work/dorun.go | 13 ++++--------- ui/input_tab.go | 2 +- ui/output_tab.go | 2 +- 5 files changed, 10 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 00a1e15..9bcc9bf 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ To build without graphics ## Binaries -Where are they ? +If I have built them for linux and windows, they will be linked to from the course moodle page. # Documentation diff --git a/docs/doc.go b/docs/doc.go index 4db3ff0..dc60785 100644 --- a/docs/doc.go +++ b/docs/doc.go @@ -1,6 +1,6 @@ // Dec 2021 -/* +/* ackley is for teaching. We use Monte Carlo to sample Ackley's function in N dimensions or perhaps with simulated annealing to optimise it. To run it @@ -36,13 +36,13 @@ and they have the meaning x_ini 3,4,5 initial values for x. It is a comma separated list with no spaces allowed x_delta 0.5 used to decide on the maximum step size seed 1637 seed for the random number generator - foutname "" + foutname "" fpltname "" xpltname "" adaptstep if empty, do not adjust the step size. If anything is set here, use adaptive step sizes. verbose "" if empty, do not be too verbose -If final_temp is lower than initial temperature, we will do simulated annealing. +If final_temp is lower than initial temperature, we will do simulated annealing. */ package ackley_doc diff --git a/mc_work/dorun.go b/mc_work/dorun.go index 65cdcfb..044b4d1 100644 --- a/mc_work/dorun.go +++ b/mc_work/dorun.go @@ -14,10 +14,6 @@ import ( "example.com/ackley_mc/ackley" ) -const ( - maxxDlta = 2. // max step size -) - var seedLocker sync.Mutex // getSeed returns the random number seed, but we have to put a lock @@ -234,10 +230,9 @@ func singleRun(mcPrm *McPrm) (MCresult, error) { fOld := ackley.Ackley(x) // Initial function value fTrial := fOld tmprtr := float64(mcPrm.IniTmp) - const runMult = 0.99 xDlta := mcPrm.XDlta // Step size which might be adjusted on the fly saveStep(&cprm, 0, tmprtr, x, fOld) - + for n := 0; n < mcPrm.NStep; n++ { var accept bool newx(x, xT, cprm.rand, xDlta) @@ -300,7 +295,7 @@ func singleRun(mcPrm *McPrm) (MCresult, error) { func DoRun(mcPrm *McPrm) (MCresult, error) { var tmpX []float32 if mcPrm.NEquil > 0 { - tmpX = make ([]float32, len(mcPrm.XIni)) + tmpX = make([]float32, len(mcPrm.XIni)) mcEquil := *mcPrm mcEquil.FnlTmp = mcEquil.IniTmp mcEquil.NStep = mcEquil.NEquil @@ -314,9 +309,9 @@ func DoRun(mcPrm *McPrm) (MCresult, error) { copy(mcPrm.XIni, eqResult.LastX) } } - mcResult, err := singleRun (mcPrm) + mcResult, err := singleRun(mcPrm) if tmpX != nil { - copy (mcPrm.XIni, tmpX) + copy(mcPrm.XIni, tmpX) } return mcResult, err } diff --git a/ui/input_tab.go b/ui/input_tab.go index 101b5eb..64b074a 100644 --- a/ui/input_tab.go +++ b/ui/input_tab.go @@ -130,7 +130,7 @@ func paramForm(genParams genParams) *widget.Form { rdfile := func() { rdwork(genParams, reloadPTab) } rdfileBtn := widget.NewButton("get file ", rdfile) rdFileItem := widget.NewFormItem("read from a file", rdfileBtn) - // puke-oh-rama, Can we tidy up the next three lines ? + // puke-oh-rama, Can we tidy up the next three lines ? r := widget.NewForm( // Lays out the items in the form iniTmpItem, fnlTmpItem, xDltaItem, xIniItem, nStepItem, nEqulItem, seedItem, rdFileItem) diff --git a/ui/output_tab.go b/ui/output_tab.go index 44a1620..ef47670 100644 --- a/ui/output_tab.go +++ b/ui/output_tab.go @@ -94,7 +94,7 @@ func leftbar(win fyne.Window, fdata, xdata []byte) *fyne.Container { infobox := widget.NewLabel(leftText) infobox.Alignment = fyne.TextAlignLeading infobox.Wrapping = fyne.TextWrapWord - s := &widget.Separator{} + s := &widget.Separator{} return container.NewVBox(infobox, s, fdataBtn, s, xdataBtn) } -- GitLab