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

Behaviour changed. If final_temp is not specified, it is set to the same as...

Behaviour changed. If final_temp is not specified, it is set to the same as ini_temp. This is consistent with the Uebung description.
parent 17403d63
No related branches found
No related tags found
No related merge requests found
test_tmp* test_tmp*
ackley ackley
ackley_mc ackley_mc
*.csv
# Use the normal go build system for everything, but we want to automate some simple # Use the normal go build system for everything, but we want to automate some simple
# commands. # commands.
# The annoying syntax for debugging is,
# dlv debug --build-flags -tags=no_gfx -- examples/example1
.POSIX: .POSIX:
GO=go GO=go
......
File moved
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
...@@ -13,8 +13,8 @@ If compiled with the graphical interface, it will run the program, load some def ...@@ -13,8 +13,8 @@ If compiled with the graphical interface, it will run the program, load some def
Input parameters Input parameters
These are defined in rdprm.go. The defaults look like These are defined in rdprm.go. The defaults look like
ini_temp 20 ini_temp 1
final_temp 1 final_temp ""
n_step 1000 n_step 1000
n_equil 0 n_equil 0
n_run 1 n_run 1
...@@ -39,10 +39,11 @@ and they have the meaning ...@@ -39,10 +39,11 @@ and they have the meaning
foutname "" foutname ""
fpltname "" fpltname ""
xpltname "" 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 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. 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 package ackley_doc
No preview for this file type
...@@ -4,5 +4,5 @@ final_temp 0.1 ...@@ -4,5 +4,5 @@ final_temp 0.1
n_step 100000 n_step 100000
x_ini -1.5,0.5,1 x_ini -1.5,0.5,1
x_delta 0.5 x_delta 0.5
seed 1637 seed 1699
foutname ex1.csv # This will store all the information from a run. foutname ex1.csv # This will store all the information from a run.
\ No newline at end of file
...@@ -4,5 +4,5 @@ final_temp 1.1 ...@@ -4,5 +4,5 @@ final_temp 1.1
n_step 5000000 n_step 5000000
x_ini 4,4 x_ini 4,4
x_delta 0.5 x_delta 0.5
seed 1637 seed 1699
foutname ex2.csv # This will store all the information from a run. foutname ex2.csv # This will store all the information from a run.
\ No newline at end of file
# 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
...@@ -185,7 +185,7 @@ func saveStep(cprm *cprm, n int, tmprtr float64, x []float32, fTrial float64) { ...@@ -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, 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 cprm.plotTmprtr = append(cprm.plotTmprtr, tmprtr) // and again
} }
if cprm.xplotWrt != nil { // The trajectory if cprm.xplotWrt != nil { // The trajectory
cprm.plotXtrj = append(cprm.plotXtrj, xprev...) cprm.plotXtrj = append(cprm.plotXtrj, xprev...)
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
// What I have learnt about the go-chart package... // What I have learnt about the go-chart package...
// - The default tick positions are terrible. // - The default tick positions are terrible.
// - If I give it a slice of ticks, it works fine for the main axis, but // - 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, // it to work by: Make a child type from continuousRange. For this type,
// define the GetTicks function. go-chart then calls this function, at // define the GetTicks function. go-chart then calls this function, at
// apparently the right place, and the tick marks come out nicely. // apparently the right place, and the tick marks come out nicely.
...@@ -61,7 +61,7 @@ type range2 struct { ...@@ -61,7 +61,7 @@ type range2 struct {
// GetTicks is called by go-chart. It has to be a method that acts on a range. // 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 // 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 { func (rng *range2) GetTicks(r chart.Renderer, cs chart.Style, vf chart.ValueFormatter) []chart.Tick {
tmp := []float64{rng.Min, rng.Max} tmp := []float64{rng.Min, rng.Max}
if a, err := axticks.Tickpos(tmp); err != nil { if a, err := axticks.Tickpos(tmp); err != nil {
......
...@@ -20,7 +20,7 @@ var cmdDflt = []struct { ...@@ -20,7 +20,7 @@ var cmdDflt = []struct {
v string v string
}{ }{
{"ini_temp", "20"}, {"ini_temp", "20"},
{"final_temp", "1"}, {"final_temp", ""}, // no default. Use ini_temp if not set
{"n_step", "1000"}, {"n_step", "1000"},
{"n_equil", "0"}, {"n_equil", "0"},
{"n_run", "1"}, {"n_run", "1"},
...@@ -84,7 +84,8 @@ func digest(prmMap map[string]string, mcPrm *McPrm) error { ...@@ -84,7 +84,8 @@ func digest(prmMap map[string]string, mcPrm *McPrm) error {
mcPrm.xPltName = prmMap["xpltname"] mcPrm.xPltName = prmMap["xpltname"]
Seed = geti(prmMap["seed"]) Seed = geti(prmMap["seed"])
if err != nil { // Only returns the first error encountered 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"] != "" { if prmMap["verbose"] != "" {
mcPrm.verbose = true mcPrm.verbose = true
...@@ -138,6 +139,12 @@ func RdPrm(fp io.Reader, mcPrm *McPrm) error { ...@@ -138,6 +139,12 @@ func RdPrm(fp io.Reader, mcPrm *McPrm) error {
prmMap[key] = ss[1] 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 { if err := scn.Err(); err != nil {
return errors.New(spew()) return errors.New(spew())
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment