Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
BornAgain
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mlz
BornAgain
Commits
51e51c28
Commit
51e51c28
authored
6 years ago
by
Pospelov, Gennady
Browse files
Options
Downloads
Patches
Plain Diff
New FitPrintService prints more meaningful info during iterations
parent
61b76530
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Core/Fitting/FitPrintService.cpp
+72
-8
72 additions, 8 deletions
Core/Fitting/FitPrintService.cpp
Core/Fitting/FitPrintService.h
+4
-1
4 additions, 1 deletion
Core/Fitting/FitPrintService.h
with
76 additions
and
9 deletions
Core/Fitting/FitPrintService.cpp
+
72
−
8
View file @
51e51c28
...
@@ -14,33 +14,97 @@
...
@@ -14,33 +14,97 @@
#include
"FitPrintService.h"
#include
"FitPrintService.h"
#include
"FitObjective.h"
#include
"FitObjective.h"
#include
"StringUtils.h"
#include
<iostream>
#include
<iostream>
#include
<iomanip>
#include
<iomanip>
#include
<sstream>
FitPrintService
::
FitPrintService
()
namespace
{
size_t
length_of_longest_name
(
const
Fit
::
Parameters
&
params
)
{
{
size_t
result
(
0
);
for
(
const
auto
&
par
:
params
)
{
if
(
par
.
name
().
size
()
+
result
)
result
=
par
.
name
().
size
();
}
return
result
;
}
}
}
FitPrintService
::
FitPrintService
()
=
default
;
void
FitPrintService
::
print
(
const
FitObjective
&
objective
)
void
FitPrintService
::
print
(
const
FitObjective
&
objective
)
{
{
std
::
ostringstream
ostr
;
if
(
objective
.
iterationCount
()
==
0
)
{
if
(
objective
.
iterationCount
()
==
0
)
{
m_run_time
.
start
();
m_run_time
.
start
();
m_last_call_time
.
start
();
m_last_call_time
.
start
();
}
}
std
::
cout
<<
"FitPrintService::print() "
<<
objective
.
iterationCount
()
<<
std
::
endl
;
ostr
<<
iterationHeaderString
(
objective
);
ostr
<<
wallTimeString
();
ostr
<<
parameterString
(
objective
);
if
(
objective
.
isCompleted
())
if
(
objective
.
isCompleted
())
printFitResults
();
ostr
<<
fitResultString
();
std
::
cout
<<
ostr
.
str
()
<<
"
\n
"
;
}
std
::
string
FitPrintService
::
iterationHeaderString
(
const
FitObjective
&
objective
)
{
std
::
ostringstream
result
;
result
<<
"FitPrintObserver::update() -> Info."
<<
" NCall:"
<<
objective
.
iterationCount
()
<<
" Chi2:"
<<
std
::
scientific
<<
std
::
setprecision
(
8
)
<<
objective
.
iterationInfo
().
chi2
()
<<
"
\n
"
;
return
result
.
str
();
}
std
::
string
FitPrintService
::
wallTimeString
()
{
std
::
ostringstream
result
;
m_last_call_time
.
stop
();
result
<<
"Wall time since last call:"
<<
std
::
fixed
<<
std
::
setprecision
(
2
)
<<
m_last_call_time
.
runTime
()
<<
"
\n
"
;
m_last_call_time
.
start
();
return
result
.
str
();
}
}
void
FitPrintService
::
p
rintFitResults
(
)
std
::
string
FitPrintService
::
p
arameterString
(
const
FitObjective
&
objective
)
{
{
std
::
cout
<<
"This was the last iteration."
<<
std
::
endl
;
std
::
ostringstream
result
;
const
auto
params
=
objective
.
iterationInfo
().
parameters
();
const
auto
length
=
length_of_longest_name
(
params
);
for
(
const
auto
&
par
:
params
)
{
result
<<
StringUtils
::
padRight
(
par
.
name
(),
length
)
<<
std
::
scientific
<<
std
::
setprecision
(
6
)
<<
" "
<<
par
.
startValue
()
<<
" "
<<
par
.
limits
().
toString
()
<<
" "
<<
par
.
value
()
<<
"
\n
"
;
}
return
result
.
str
();
}
std
::
string
FitPrintService
::
fitResultString
()
{
std
::
ostringstream
result
;
m_run_time
.
stop
();
m_run_time
.
stop
();
std
::
cout
<<
"Total time spend: "
<<
std
::
fixed
<<
std
::
setprecision
(
2
)
<<
m_run_time
.
runTime
()
<<
" sec."
<<
std
::
endl
;
result
<<
"This was the last iteration."
<<
std
::
endl
;
std
::
cout
<<
std
::
endl
;
result
<<
"Total time spend: "
<<
std
::
fixed
<<
std
::
setprecision
(
2
)
<<
m_run_time
.
runTime
()
<<
" sec."
<<
"
\n\n
"
;
return
result
.
str
();
}
}
This diff is collapsed.
Click to expand it.
Core/Fitting/FitPrintService.h
+
4
−
1
View file @
51e51c28
...
@@ -30,7 +30,10 @@ public:
...
@@ -30,7 +30,10 @@ public:
void
print
(
const
FitObjective
&
objective
);
void
print
(
const
FitObjective
&
objective
);
private:
private:
void
printFitResults
();
std
::
string
iterationHeaderString
(
const
FitObjective
&
objective
);
std
::
string
wallTimeString
();
std
::
string
parameterString
(
const
FitObjective
&
objective
);
std
::
string
fitResultString
();
TimeInterval
m_run_time
;
TimeInterval
m_run_time
;
TimeInterval
m_last_call_time
;
TimeInterval
m_last_call_time
;
...
...
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