diff --git a/README.md b/README.md index 00a1e15a5bbbfc9a2473b22afd386822a09ccd47..9bcc9bfa4b1f26509a289e524c0c6f3582afc7b3 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 4db3ff09e27faeeb3f7e89025b3bb70366288202..dc60785ed5bd5a8ac6a2c1bd75dfb98237c67128 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 65cdcfb7b34b368b001b9def8eb4d8079bb1767e..044b4d1022b8d532663c6e35ed994bd1e517b2bb 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 101b5eb678c194afade698e80092552cf2a0c47a..64b074a9af302ac24a92cd1412067ae0f71261a3 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 44a16203e621542c5911cc2a7d3bb1402665e1a5..ef47670d879441c68e960df8d7a4577483bab314 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) }