diff --git a/.gitignore b/.gitignore index ab0ce1b7f21fa8cb5051bf05d0240277c4f35ca0..1c4034cfee8d840b1acb941b6e423dd55e175c27 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ test_tmp* ackley_mc ackley_mc.exe - diff --git a/Makefile b/Makefile index eb745ace29ba0103dbde02e9aff4f37882d16ef1..e3b5e3f5e95eb79b86a8d89953419b4b4ba4859f 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,6 @@ # Use the normal go build system for everything, but we want to automate some simple # commands. -# The annoying syntax for debugging is, -# dlv debug --build-flags -tags=no_gfx -- examples/example1 .POSIX: GO=go diff --git a/README_version b/docs/README_version similarity index 100% rename from README_version rename to docs/README_version diff --git a/docs/build_notes b/docs/build_notes new file mode 100644 index 0000000000000000000000000000000000000000..4bd422201ae57b8e891563708f33c0a99bd2764e --- /dev/null +++ b/docs/build_notes @@ -0,0 +1,6 @@ +We only have one build tag. + -tags no_gfx +turns off graphics. You need this if you want to cross compile for macs or windows. + +The annoying syntax for debugging this version is + dlv debug --build-flags -tags=no_gfx -- examples/example1 diff --git a/docs/doc.go b/docs/doc.go index dc60785ed5bd5a8ac6a2c1bd75dfb98237c67128..9ca73c14d55523a8c5af3d11993d42b4fcb68c38 100644 --- a/docs/doc.go +++ b/docs/doc.go @@ -13,8 +13,8 @@ If compiled with the graphical interface, it will run the program, load some def Input parameters These are defined in rdprm.go. The defaults look like - ini_temp 20 - final_temp 1 + ini_temp 1 + final_temp "" n_step 1000 n_equil 0 n_run 1 @@ -39,10 +39,11 @@ and they have the meaning 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 a final_temp is not specified, set the final temp to be the same as the initial temperature and do a run at constant temperature. If final_temp is lower than initial temperature, we will do simulated annealing. +Adaptive step sizes have been removed. They might come back later, but they made the main loop hard to read and the aim is just to provide a model for teaching. */ package ackley_doc diff --git a/docs/uebung_ackley.docx b/docs/uebung_ackley.docx index f90b40cf1d35f149a1637193abcd42112f50055d..b782f3021c4297a6f75fc4d4bb9cbeed630f07b5 100644 Binary files a/docs/uebung_ackley.docx and b/docs/uebung_ackley.docx differ diff --git a/examples/example1 b/examples/example1 index 8ebf08963f1a22d37fa9e74fed933f18866399c9..752d27d77c7b10ac51b7f47250c7c3e3e832b8e7 100644 --- a/examples/example1 +++ b/examples/example1 @@ -4,5 +4,5 @@ final_temp 0.1 n_step 100000 x_ini -1.5,0.5,1 x_delta 0.5 -seed 1637 +seed 1699 foutname ex1.csv # This will store all the information from a run. \ No newline at end of file diff --git a/examples/example2 b/examples/example2 index f24c2db6f16f66a448597f0b3483f186b3b3287e..c444546d04ebc5af7d38aa1378b9ae83722e8bf9 100644 --- a/examples/example2 +++ b/examples/example2 @@ -4,5 +4,5 @@ final_temp 1.1 n_step 5000000 x_ini 4,4 x_delta 0.5 -seed 1637 +seed 1699 foutname ex2.csv # This will store all the information from a run. \ No newline at end of file diff --git a/examples/nofinal_temp b/examples/nofinal_temp new file mode 100644 index 0000000000000000000000000000000000000000..63414be43ec3a24a47a0a0ee99978e5e289832a2 --- /dev/null +++ b/examples/nofinal_temp @@ -0,0 +1,8 @@ +# This should do reasonable sampling of the minimum near zero +ini_temp 0.1 +n_step 100000 +x_ini -1.5,0.5,1 +x_delta 0.5 +seed 1699 +foutname ex1.csv # This will store all the information from a run. +verbose woooo \ No newline at end of file diff --git a/mc_work/dorun.go b/mc_work/dorun.go index 044b4d1022b8d532663c6e35ed994bd1e517b2bb..3ae3121fc990139b0bd50d9742bb36a59bd71bef 100644 --- a/mc_work/dorun.go +++ b/mc_work/dorun.go @@ -185,7 +185,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, 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) // and again } if cprm.xplotWrt != nil { // The trajectory cprm.plotXtrj = append(cprm.plotXtrj, xprev...) diff --git a/mc_work/plot.go b/mc_work/plot.go index d9cf7de8d6c1d21dd048105c14191b99305ecc1c..c775d44c6cec58567fac83e3314d5dcabfd3c219 100644 --- a/mc_work/plot.go +++ b/mc_work/plot.go @@ -5,7 +5,7 @@ // What I have learnt about the go-chart package... // - The default tick positions are terrible. // - If I give it a slice of ticks, it works fine for the main axis, but -// something terrible happens to the scaling of the axes. I could get +// something terrible happens to the scaling of the axes. I did get // it to work by: Make a child type from continuousRange. For this type, // define the GetTicks function. go-chart then calls this function, at // apparently the right place, and the tick marks come out nicely. @@ -61,7 +61,7 @@ type range2 struct { // GetTicks is called by go-chart. It has to be a method that acts on a range. // This means we define a range2 type and define this method on range2. We -// do not actually use the arguments that go-charts offers (style, formatter, ..) +// do not use the arguments that go-charts offers (style, formatter, ..) func (rng *range2) GetTicks(r chart.Renderer, cs chart.Style, vf chart.ValueFormatter) []chart.Tick { tmp := []float64{rng.Min, rng.Max} if a, err := axticks.Tickpos(tmp); err != nil { diff --git a/mc_work/rdprm.go b/mc_work/rdprm.go index 1be0d54bbb1753bd1d0f55a3e535285727a62a1c..a74e1a572de1897981ee2bb7dc045e4aadec5599 100644 --- a/mc_work/rdprm.go +++ b/mc_work/rdprm.go @@ -20,7 +20,7 @@ var cmdDflt = []struct { v string }{ {"ini_temp", "20"}, - {"final_temp", "1"}, + {"final_temp", ""}, // no default. Use ini_temp if not set {"n_step", "1000"}, {"n_equil", "0"}, {"n_run", "1"}, @@ -84,7 +84,8 @@ func digest(prmMap map[string]string, mcPrm *McPrm) error { mcPrm.xPltName = prmMap["xpltname"] Seed = geti(prmMap["seed"]) if err != nil { // Only returns the first error encountered - return err + e := errors.New("Parsing input parameters gave: " + err.Error()) + return e } if prmMap["verbose"] != "" { mcPrm.verbose = true @@ -138,6 +139,12 @@ func RdPrm(fp io.Reader, mcPrm *McPrm) error { prmMap[key] = ss[1] } } + if prmMap["final_temp"] == "" { + prmMap["final_temp"] = prmMap["ini_temp"] + if prmMap["verbose"] != "" { + fmt.Println ("setting final temp to ini_temp") + } + } if err := scn.Err(); err != nil { return errors.New(spew()) }