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

Merge branch 'devel'

parents 2ff8fb48 03db1080
No related branches found
No related tags found
No related merge requests found
# Use the normal go build system for everything, but we want to automate some simple
# commands.
# Use the normal go build system for everything, but we want to automate some
# simple commands. Unlike most makefiles, there are no dependencies for the
# executables. We let go's build commands take care of that.
.POSIX:
GO=go
......@@ -9,12 +9,16 @@ GOFMT=gofmt
# The lint target only makes sense for Andrew's setup.
LINTER=~/go/bin/linux_amd64/golangci-lint
all:
$(GO) build -o bin .
$(GO) build -o bin/ackley_nogfx -tags no_gfx -- .
GOOS=linux GOARCH=amd64 $(GO) build -o bin/ .
GOOS=linux GOARCH=amd64 $(GO) build -o bin/ackley_nogfx -tags no_gfx -- .
GOOS=darwin GOARCH=amd64 $(GO) build -o bin/ackley_darwinamd64_nogfx -tags no_gfx -- .
GOOS=darwin GOARCH=arm64 $(GO) build -o bin/ackley_darwinarm64_nogfx -tags no_gfx -- .
GOOS=windows GOARCH=amd64 $(GO) build -o bin/ackley_win_nogfx -tags no_gfx -- .
GOOS=windows GOARCH=amd64 $(GO) build -o bin/ackley_nogfx.exe -tags no_gfx -- .
win:
GOOS=windows GOARCH=amd64 $(GO) build -o bin -- .
test:
$(GO) test ./...
......@@ -29,6 +33,7 @@ lint:
clean:
$(GO) clean
rm -rf bin/*
rm -rf examples/*.csv
rm -rf */*_delme.*
rm -rf */test_tmp*
rm -rf /tmp/go-build[0-9]*
......
ackley*
// Dec 2021
/*
ackley is for teaching. We use Monte Carlo to sample Ackley's function
ackley_mc is for teaching. We use Monte Carlo to sample Ackley's function
in N dimensions or perhaps with simulated annealing to optimise it.
# Running
To run it
ackley input_file
where input_file contains a set of name-value pairs described below or perhaps
ackley
If compiled with the graphical interface, it will run the program, load some default values and let you play with it.
ackley_mc [ input_file ]
or
ackley_mc input_file
if it was not compiled with the graphical interface. The difference is that the input_file is not optional when there is no graphical interface.
If you are running with the graphical interface, you do not need an input file and some default values will be loaded.
Input parameters
# Input parameters
These are defined in rdprm.go. The defaults look like
ini_temp 1
final_temp ""
n_step 1000
n_equil 0
n_run 1
x_ini 3,4,5
x_delta 0.5
seed 1637
......@@ -29,11 +33,10 @@ These are defined in rdprm.go. The defaults look like
and they have the meaning
ini_temp initial temperature
final_temp final temperature
final_temp final temperature. If this is set, we are doing annealing. If it is not set, it will be the same as ini_temp, and this will be a constant temperature run.
n_step number of steps
n_equil number of steps of equilibration
n_run number of runs. This does not do anything and should be deleted
x_ini 3,4,5 initial values for x. It is a comma separated list with no spaces allowed
n_equil number of steps of equilibration. The Monte Carlo routine is called twice. The first time, with this many steps. The results are then thrown away, since they were only there for equilibration.
x_ini initial values for x. It is a comma separated list with no spaces allowed. It is used to determine the number of dimension. A value like "1" would give you one dimension whose initial value is 1. A value like "-1,0,1,2" would give you a four dimensional system with initial values at -1, 0, 1 and 2.
x_delta 0.5 used to decide on the maximum step size
seed 1637 seed for the random number generator
foutname ""
......@@ -44,6 +47,35 @@ and they have the meaning
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.
<<<<<<< HEAD
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.
=======
foutname is where a csv file will be written with values for plotting.
xpltname is where a png file will be written with a plot of coordinates.
Anything in the file after a hash (#) symbol will be treated as a comment.
Any items which are mis-spelled will provoke an error.
# Output
If you are running with the graphical interface, the emphasis is on quickly playing with parameters. There are buttons which let you dump a plot to a file in .png format.
Running without the graphical interface, you should specify `foutname.csv` and you will get a .csv file that you can feed into almost any plotting program. The format on each line looks like
0,0.1,5.8874,-1.5,0.5,1
1,0.1,5.9918,-1.73,0.5,1
2,0.1,5.9968,-1.73,0.514,1
which is
- step number
- temperature
- function value
- x1, x2, x3, ...
So if you want to plot the function value as a function of step, you would plot column 1 on the x-axis and column 3 on the y-axis. To plot the coordinates in the example above, you would plot columns 4, 5 and 6 on the y-axis.
>>>>>>> devel
*/
package ackley_doc
# For the Uebung
ini_temp 0.1
n_step 500000
x_ini -1.5,0.5,1
x_delta 0.5
seed 1699
foutname q1.csv
vini_temp 0.1
n_step 100000
x_ini -0.5,0.5
x_delta 0.5
seed 1699
foutname q2d.csv
ini_temp 0.1
n_step 100000
x_ini -0.5,0.5
x_delta 2
seed 1699
foutname q2dbigstep.csv
# For the Uebung
ini_temp 0.01
n_step 50000
x_ini -5,-4,-3,-2,-1,0,1,2,3,4,5
x_delta 0.5
seed 1699
foutname q1.csv
ini_temp 0.1
n_step 10000
x_ini -1,1
x_delta 0.5
seed 1699
foutname q_dist.csv
ini_temp 5
n_step 50000
x_ini -1,0,1
x_delta 0.5
seed 1699
foutname q_dist.csv
# For the Uebung
ini_temp 0.1
n_step 5000
x_ini -5,-4,-3,-2,-1,0,1,2,3,4,5
x_delta 0.5
seed 1699
foutname q1.csv
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment