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
c7f23622
Commit
c7f23622
authored
3 years ago
by
Andrew E. Torda
Browse files
Options
Downloads
Patches
Plain Diff
Simplifying main loop - moved print statements to their own function.
parent
efbd0c80
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
+13
-7
13 additions, 7 deletions
ackwork/dorun.go
with
13 additions
and
7 deletions
ackwork/dorun.go
+
13
−
7
View file @
c7f23622
...
@@ -134,6 +134,16 @@ func nRunAdj(mcPrm *mcPrm, runAcc float64, xDlta float32) float32 {
...
@@ -134,6 +134,16 @@ func nRunAdj(mcPrm *mcPrm, runAcc float64, xDlta float32) float32 {
return
xDlta
return
xDlta
}
}
// printfVal is just the loop to print out the function value and coordinates
// probably for later plotting.
func
printfVal
(
fOut
io
.
Writer
,
x
[]
float32
,
n
uint32
,
tmprtr
float64
,
fOld
float64
)
{
fmt
.
Fprintf
(
fOut
,
"%d,%.4g,%.5g"
,
n
,
tmprtr
,
fOld
)
for
_
,
xx
:=
range
x
{
fmt
.
Fprintf
(
fOut
,
",%.2g"
,
xx
)
}
fmt
.
Fprintln
(
fOut
)
}
// doRun does a Monte Carlo run. Although single precision is fine for the
// doRun does a Monte Carlo run. Although single precision is fine for the
// coordinates and function, we use double precision for the temperature.
// coordinates and function, we use double precision for the temperature.
func
doRun
(
mcPrm
*
mcPrm
)
error
{
func
doRun
(
mcPrm
*
mcPrm
)
error
{
...
@@ -166,16 +176,12 @@ func doRun(mcPrm *mcPrm) error {
...
@@ -166,16 +176,12 @@ func doRun(mcPrm *mcPrm) error {
var
acc
bool
var
acc
bool
nout
--
nout
--
if
nout
==
0
{
// Do we want to print out results on this step ?
if
nout
==
0
{
// Do we want to print out results on this step ?
fmt
.
Fprintf
(
cprm
.
fOut
,
"%d,%.4g,%.5g"
,
n
,
tmprtr
,
fOld
)
printfVal
(
cprm
.
fOut
,
x
,
n
,
tmprtr
,
fOld
)
for
_
,
xx
:=
range
x
{
fmt
.
Fprintf
(
cprm
.
fOut
,
",%.2g"
,
xx
)
}
fmt
.
Fprintln
(
cprm
.
fOut
)
nout
=
cprm
.
nEvery
nout
=
cprm
.
nEvery
}
}
nRunAcc
--
nRunAcc
--
if
nRunAcc
==
0
{
// Do we want to try adjusting the step size ?
if
nRunAcc
==
0
{
// Do we want to try adjusting the step size ?
xDlta
=
nRunAdj
(
mcPrm
,
runAcc
,
xDlta
)
// mucking about here
xDlta
=
nRunAdj
(
mcPrm
,
runAcc
,
xDlta
)
nRunAcc
=
nRunAccAdj
// Reset the counter
nRunAcc
=
nRunAccAdj
// Reset the counter
}
}
newx
(
x
,
xT
,
cprm
.
rand
,
xDlta
)
newx
(
x
,
xT
,
cprm
.
rand
,
xDlta
)
...
...
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