Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
QuickStats
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container 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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alkaid Cheng
QuickStats
Commits
9fce1d4f
Commit
9fce1d4f
authored
2 months ago
by
Yizhou Cai
Browse files
Options
Downloads
Patches
Plain Diff
new retry
parent
67b0fe8c
No related branches found
No related tags found
1 merge request
!235
Retry the fit with larger eps when failed
Pipeline
#11852710
passed
2 months ago
Stage: run
Stage: diff
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
quickstats/components/extended_minimizer.py
+44
-26
44 additions, 26 deletions
quickstats/components/extended_minimizer.py
with
44 additions
and
26 deletions
quickstats/components/extended_minimizer.py
+
44
−
26
View file @
9fce1d4f
...
...
@@ -55,6 +55,7 @@ class ExtendedMinimizer(AbstractObject):
'
postfit_hesse
'
:
0
,
'
minuit2_storage_level
'
:
0
,
'
do_prefit
'
:
0
,
'
retry_diff_eps
'
:
0
,
# cms dedicated configs
'
set_zero_point
'
:
1
,
# change the reference point of the NLL to be zero during minimization
# discrete nuisance configs
...
...
@@ -624,8 +625,8 @@ class ExtendedMinimizer(AbstractObject):
self
.
stdout
.
info
(
'
ExtendedMinimizer::minimize(
"
{}
"
) prefit minimization
'
.
format
(
self
.
name
))
# prefit minimization
self
.
minimizer
.
setStrategy
(
0
)
self
.
minimizer
.
setEps
(
self
.
config
[
'
eps
'
]
*
10
)
self
.
robust_minimize
(
cascade
=
cascade
)
self
.
minimizer
.
setEps
(
self
.
config
[
'
eps
'
]
*
10
0
)
self
.
robust_minimize
(
cascade
=
cascade
,
is_prefit
=
True
)
self
.
minimizer
.
setStrategy
(
self
.
config
[
'
strategy
'
])
self
.
minimizer
.
setEps
(
self
.
config
[
'
eps
'
])
...
...
@@ -681,37 +682,54 @@ class ExtendedMinimizer(AbstractObject):
self
.
status
=
status
return
status
def
robust_minimize
(
self
,
cascade
:
bool
=
True
,
fit_from_initial
:
bool
=
Tru
e
):
def
robust_minimize
(
self
,
cascade
:
bool
=
True
,
is_prefit
:
bool
=
Fals
e
):
self
.
stdout
.
debug
(
'
Begin robust minimization.
'
)
strategy
=
self
.
config
[
'
strategy
'
]
retry
=
self
.
config
[
'
retry
'
]
minimizer_type
=
self
.
config
[
'
minimizer_type
'
]
minimizer_algo
=
self
.
config
[
'
minimizer_algo
'
]
if
fit_from_initial
:
variables
=
self
.
pdf
.
getVariables
()
snapshot
=
variables
.
snapshot
()
def
require_cascade
(
fit_status
:
int
):
return
cascade
and
(
fit_status
not
in
[
0
,
1
])
status
=
self
.
single_minimize
(
minimizer_type
,
minimizer_algo
)
# repeat if fit failed or poi(s) at boundary
expanded_pois
=
self
.
expand_poi_bounds
()
def
require_cascade
(
fit_status
:
int
):
return
cascade
and
(
fit_status
not
in
[
0
,
1
])
while
((
require_cascade
(
status
)
or
expanded_pois
)
and
(
retry
>
0
)):
if
(
not
expanded_pois
)
and
(
strategy
<
2
):
strategy
+=
1
retry
-=
1
self
.
stdout
.
error
(
f
'
ExtendedMinimizer::robust_minimize(
"
{
self
.
name
}
"
) fit failed with status
{
status
}
.
'
f
'
Retrying with strategy
{
strategy
}
'
)
self
.
minimizer
.
setStrategy
(
strategy
)
if
fit_from_initial
:
variables
.
__assign__
(
snapshot
)
status
=
self
.
single_minimize
(
minimizer_type
,
minimizer_algo
)
expanded_pois
=
self
.
expand_poi_bounds
()
if
status
not
in
[
0
,
1
]:
self
.
stdout
.
error
(
f
'
ExtendedMinimizer::robust_minimize(
"
{
self
.
name
}
"
) fit failed with status
{
status
}
'
)
self
.
minimizer
.
setStrategy
(
self
.
config
[
'
strategy
'
])
if
self
.
config
[
'
retry_diff_eps
'
]:
eps_init
=
self
.
config
[
'
eps
'
]
*
100
if
is_prefit
else
self
.
config
[
'
eps
'
]
eps
=
eps_init
while
((
require_cascade
(
status
)
or
expanded_pois
)
and
(
retry
>
0
)):
if
(
not
expanded_pois
):
eps
*=
10
retry
-=
1
self
.
stdout
.
error
(
f
'
ExtendedMinimizer::robust_minimize(
"
{
self
.
name
}
"
) fit failed with status
{
status
}
.
'
f
'
Retrying with eps
{
eps
}
'
)
self
.
minimizer
.
setEps
(
eps
)
status
=
self
.
single_minimize
(
minimizer_type
,
minimizer_algo
)
expanded_pois
=
self
.
expand_poi_bounds
()
if
status
not
in
[
0
,
1
]:
self
.
stdout
.
error
(
f
'
ExtendedMinimizer::robust_minimize(
"
{
self
.
name
}
"
) fit failed with status
{
status
}
'
)
self
.
minimizer
.
setEps
(
eps_init
)
else
:
strategy
=
self
.
config
[
'
strategy
'
]
while
((
require_cascade
(
status
)
or
expanded_pois
)
and
(
retry
>
0
)):
if
(
not
expanded_pois
)
and
(
strategy
<
2
):
strategy
+=
1
retry
-=
1
self
.
stdout
.
error
(
f
'
ExtendedMinimizer::robust_minimize(
"
{
self
.
name
}
"
) fit failed with status
{
status
}
.
'
f
'
Retrying with strategy
{
strategy
}
'
)
self
.
minimizer
.
setStrategy
(
strategy
)
status
=
self
.
single_minimize
(
minimizer_type
,
minimizer_algo
)
expanded_pois
=
self
.
expand_poi_bounds
()
if
status
not
in
[
0
,
1
]:
self
.
stdout
.
error
(
f
'
ExtendedMinimizer::robust_minimize(
"
{
self
.
name
}
"
) fit failed with status
{
status
}
'
)
self
.
minimizer
.
setStrategy
(
self
.
config
[
'
strategy
'
])
return
status
...
...
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