Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Sebastian Heimann
grond
Commits
63ab17ee
Commit
63ab17ee
authored
Aug 15, 2017
by
Marius Isken
Browse files
nbootstrap to HighscoreSolver
parent
78ca5053
Changes
6
Show whitespace changes
Inline
Side-by-side
apps/grond
View file @
63ab17ee
...
...
@@ -187,7 +187,6 @@ def command_init(args):
problem_config
=
grond
.
CMTProblemConfig
(
name_template
=
'cmt_%(event_name)s'
,
distance_min
=
2.
*
km
,
nbootstrap
=
100
,
mt_type
=
'deviatoric'
,
ranges
=
dict
(
time
=
Range
(
0
,
10.0
,
relative
=
'add'
),
...
...
src/optimizers/highscore.py
View file @
63ab17ee
...
...
@@ -325,8 +325,6 @@ class BadProblem(GrondError):
pass
def
solve
(
problem
,
phases
,
rundir
=
None
,
...
...
@@ -427,7 +425,6 @@ def solve(problem,
chains
.
insert
(
gbms
,
iiter
)
chains_m
[
0
,
nlinks
]
=
gm
chains_m
[
1
:,
nlinks
]
=
bms
chains_i
[:,
nlinks
]
=
iiter
...
...
@@ -539,13 +536,11 @@ class HighScoreOptimizer(Optimizer):
Optimizer
.
__init__
(
self
)
self
.
_kwargs
=
kwargs
def
solve
(
problem
,
phases
,
rundir
=
None
,
chain_length_factor
=
chain_length_factor
=
8.0
,
standard_deviation_estimator
=
'median_density_single_chain'
,
...
...
@@ -635,6 +630,7 @@ class StandardDeviationEstimatorChoice(StringChoice):
class
HighScoreOptimizerConfig
(
OptimizerConfig
):
nbootstrap
=
Int
.
T
(
default
=
100
)
niter_uniform
=
Int
.
T
(
default
=
1000
)
niter_transition
=
Int
.
T
(
default
=
0
)
niter_explorative
=
Int
.
T
(
default
=
10000
)
...
...
@@ -650,6 +646,7 @@ class HighScoreOptimizerConfig(OptimizerConfig):
def
get_optimizer_kwargs
(
self
):
return
dict
(
nbootstrap
=
self
.
nbootstrap
,
niter_uniform
=
self
.
niter_uniform
,
niter_transition
=
self
.
niter_transition
,
niter_explorative
=
self
.
niter_explorative
,
...
...
src/problems/cmt.py
View file @
63ab17ee
...
...
@@ -3,7 +3,7 @@ import math
import
logging
from
pyrocko
import
gf
,
util
,
moment_tensor
as
mtm
from
pyrocko.guts
import
String
,
Float
,
Dict
,
Int
,
StringChoice
from
pyrocko.guts
import
String
,
Float
,
Dict
,
StringChoice
from
.base
import
Problem
,
ProblemConfig
from
..meta
import
Forbidden
,
expand_template
,
Parameter
...
...
src/problems/double_dc.py
View file @
63ab17ee
...
...
@@ -18,7 +18,6 @@ class DoubleDCProblemConfig(ProblemConfig):
ranges
=
Dict
.
T
(
String
.
T
(),
gf
.
Range
.
T
())
distance_min
=
Float
.
T
(
default
=
0.0
)
nbootstrap
=
Int
.
T
(
default
=
100
)
def
get_problem
(
self
,
event
,
targets
):
if
event
.
depth
is
None
:
...
...
@@ -38,7 +37,6 @@ class DoubleDCProblemConfig(ProblemConfig):
targets
=
targets
,
ranges
=
self
.
ranges
,
distance_min
=
self
.
distance_min
,
nbootstrap
=
self
.
nbootstrap
,
norm_exponent
=
self
.
norm_exponent
)
return
problem
...
...
src/problems/rectangular.py
View file @
63ab17ee
...
...
@@ -18,7 +18,6 @@ class RectangularProblemConfig(ProblemConfig):
ranges
=
Dict
.
T
(
String
.
T
(),
gf
.
Range
.
T
())
apply_balancing_weights
=
Bool
.
T
(
default
=
False
)
decimation_factor
=
Int
.
T
(
default
=
1
)
nbootstrap
=
Int
.
T
(
default
=
10
)
distance_min
=
Float
.
T
(
default
=
0.
)
def
get_problem
(
self
,
event
,
targets
):
...
...
@@ -35,7 +34,6 @@ class RectangularProblemConfig(ProblemConfig):
name
=
expand_template
(
self
.
name_template
,
event
.
name
),
apply_balancing_weights
=
self
.
apply_balancing_weights
,
base_source
=
base_source
,
nbootstrap
=
self
.
nbootstrap
,
distance_min
=
self
.
distance_min
,
targets
=
targets
,
ranges
=
self
.
ranges
,
...
...
src/solvers/highscore.py
View file @
63ab17ee
...
...
@@ -58,6 +58,7 @@ def local_std(xs):
def
solve
(
problem
,
rundir
=
None
,
nbootstrap
=
100
,
niter_uniform
=
1000
,
niter_transition
=
1000
,
niter_explorative
=
10000
,
...
...
@@ -78,8 +79,8 @@ def solve(problem,
npar
=
problem
.
nparameters
nlinks_cap
=
int
(
round
(
chain_length_factor
*
npar
+
1
))
chains_m
=
num
.
zeros
((
1
+
problem
.
nbootstrap
,
nlinks_cap
),
num
.
float
)
chains_i
=
num
.
zeros
((
1
+
problem
.
nbootstrap
,
nlinks_cap
),
num
.
int
)
chains_m
=
num
.
zeros
((
1
+
nbootstrap
,
nlinks_cap
),
num
.
float
)
chains_i
=
num
.
zeros
((
1
+
nbootstrap
,
nlinks_cap
),
num
.
int
)
nlinks
=
0
mbx
=
None
...
...
@@ -98,7 +99,7 @@ def solve(problem,
local_sxs
=
None
xhist
=
num
.
zeros
((
niter
,
npar
))
isbad_mask
=
None
accept_sum
=
num
.
zeros
(
1
+
problem
.
nbootstrap
,
dtype
=
num
.
int
)
accept_sum
=
num
.
zeros
(
1
+
nbootstrap
,
dtype
=
num
.
int
)
accept_hist
=
num
.
zeros
(
niter
,
dtype
=
num
.
int
)
pnames
=
problem
.
parameter_names
...
...
@@ -164,7 +165,7 @@ def solve(problem,
x
=
problem
.
random_uniform
(
xbounds
)
else
:
# ibootstrap_choice = num.random.randint(
# 0, 1 +
problem.
nbootstrap)
# 0, 1 + nbootstrap)
ibootstrap_choice
=
num
.
argmin
(
accept_sum
)
if
phase
in
(
'transition'
,
'explorative'
):
...
...
@@ -309,7 +310,7 @@ def solve(problem,
accept
=
(
chains_i
[:,
nlinks_cap
-
1
]
!=
iiter
).
astype
(
num
.
int
)
nlinks
-=
1
else
:
accept
=
num
.
ones
(
1
+
problem
.
nbootstrap
,
dtype
=
num
.
int
)
accept
=
num
.
ones
(
1
+
nbootstrap
,
dtype
=
num
.
int
)
if
rundir
:
problem
.
dump_problem_data
(
...
...
@@ -342,7 +343,7 @@ def solve(problem,
mxs
=
[]
local_sxs
=
[]
for
i
in
xrange
(
1
+
problem
.
nbootstrap
):
for
i
in
xrange
(
1
+
nbootstrap
):
xs
=
xhist
[
chains_i
[
i
,
:
nlinks
],
:]
mx
=
num
.
mean
(
xs
,
axis
=
0
)
cov
=
num
.
cov
(
xs
.
T
)
...
...
@@ -436,6 +437,7 @@ class StandardDeviationEstimatorChoice(StringChoice):
class
HighScoreSolverConfig
(
SolverConfig
):
nbootstrap
=
Int
.
T
(
default
=
100
)
niter_uniform
=
Int
.
T
(
default
=
1000
)
niter_transition
=
Int
.
T
(
default
=
0
)
niter_explorative
=
Int
.
T
(
default
=
10000
)
...
...
@@ -451,6 +453,7 @@ class HighScoreSolverConfig(SolverConfig):
def
get_solver_kwargs
(
self
):
return
dict
(
nbootstrap
=
self
.
nbootstrap
,
niter_uniform
=
self
.
niter_uniform
,
niter_transition
=
self
.
niter_transition
,
niter_explorative
=
self
.
niter_explorative
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment