Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
ackley_mc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Torda, Prof. Dr. Andrew Ernest
ackley_mc
Commits
0bf01ed8
Commit
0bf01ed8
authored
3 years ago
by
Andrew E. Torda
Browse files
Options
Downloads
Patches
Plain Diff
Tidying before the experiment with plotting.
parent
839b0bcd
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
ackwork/dorun.go
+9
-7
9 additions, 7 deletions
ackwork/dorun.go
with
9 additions
and
7 deletions
ackwork/dorun.go
+
9
−
7
View file @
0bf01ed8
...
...
@@ -32,7 +32,7 @@ type cprm struct { // parameters calculated from input
fOut
io
.
WriteCloser
}
// setupRun does things like get the cooling rate
// setupRun does things like get the cooling rate
, seed the random numbers.
func
setupRun
(
mcPrm
*
mcPrm
,
cprm
*
cprm
)
error
{
var
err
error
if
mcPrm
.
dummy
==
true
{
...
...
@@ -40,16 +40,15 @@ func setupRun(mcPrm *mcPrm, cprm *cprm) error {
}
cprm
.
rand
=
rand
.
New
(
rand
.
NewSource
(
getSeed
()))
if
mcPrm
.
iniTmp
!=
mcPrm
.
fnlTmp
{
if
mcPrm
.
iniTmp
!=
mcPrm
.
fnlTmp
{
// cooling or constant temperature ?
var
coolrate
float64
cprm
.
coolme
=
true
if
mcPrm
.
fnlTmp
>
mcPrm
.
iniTmp
{
// would you like to print out a warning ?
return
fmt
.
Errorf
(
"Final temp %g higher than initial temp %g"
,
mcPrm
.
fnlTmp
,
mcPrm
.
iniTmp
)
}
nStep
:=
float64
(
mcPrm
.
nStep
)
fnlTmp
,
iniTmp
:=
float64
(
mcPrm
.
fnlTmp
),
float64
(
mcPrm
.
iniTmp
)
if
fnlTmp
<
0.01
{
breaker
()
if
fnlTmp
==
0
{
fnlTmp
=
math
.
SmallestNonzeroFloat32
}
coolrate
=
-
1
/
nStep
...
...
@@ -67,7 +66,8 @@ func setupRun(mcPrm *mcPrm, cprm *cprm) error {
return
nil
}
// newx gets a candidate x slice
// newx gets a candidate x slice. We have n dimensions, so a candidate
// move is a slice of length n.
func
newx
(
xold
[]
float32
,
xT
[]
float32
,
rand
*
rand
.
Rand
,
xDlta
float32
)
{
for
i
,
x
:=
range
xold
{
t
:=
2.
*
rand
.
Float32
()
-
1
...
...
@@ -76,6 +76,8 @@ func newx(xold []float32, xT []float32, rand *rand.Rand, xDlta float32) {
}
}
func
breaker
()
{}
// doRun does a Monte Carlo run. Although single precision is fine for the
// coordinates and function, we use double precision for the temperature.
func
doRun
(
mcPrm
*
mcPrm
)
error
{
var
cprm
cprm
if
err
:=
setupRun
(
mcPrm
,
&
cprm
);
err
!=
nil
{
...
...
@@ -143,7 +145,7 @@ func doRun(mcPrm *mcPrm) error {
runAcc
=
runMult
*
runAcc
+
(
1.0
-
runMult
)
copy
(
x
,
xT
)
fOld
=
fTrial
}
else
{
}
else
{
// update the running estimate of acceptance
runAcc
=
runMult
*
runAcc
}
if
cprm
.
coolme
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment