Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions autofit/optimize/grid_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,10 @@ def __init__(
self.paths = paths

self.parallel = parallel
self.number_of_cores = conf.instance.non_linear.get(
"GridSearch", "number_of_cores", int
self.number_of_cores = conf.instance.non_linear.config_for(
"GridSearch"
).get(
"general", "number_of_cores", int
)
self.phase_tag_input = paths.phase_tag

Expand Down
26 changes: 16 additions & 10 deletions autofit/optimize/non_linear/multi_nest.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,14 @@ def __init__(self, paths=None, sigma=3, run=pymultinest.run):
self.log_zero = self.config("log_zero", float)
self.max_iter = self.config("max_iter", int)
self.init_MPI = self.config("init_MPI", bool)
self.terminate_at_acceptance_ratio = conf.instance.non_linear.get(
"MultiNest", "terminate_at_acceptance_ratio", bool
multinest_config = conf.instance.non_linear.config_for(
"MultiNest"
)
self.acceptance_ratio_threshold = conf.instance.non_linear.get(
"MultiNest", "acceptance_ratio_threshold", float
self.terminate_at_acceptance_ratio = multinest_config.get(
"general", "terminate_at_acceptance_ratio", bool
)
self.acceptance_ratio_threshold = multinest_config.get(
"general", "acceptance_ratio_threshold", float
)

self.run = run
Expand Down Expand Up @@ -147,11 +150,14 @@ def prior(cube, ndim, nparams):

return cube

stagger_resampling_likelihood = conf.instance.non_linear.get(
"MultiNest", "stagger_resampling_likelihood", bool
multinest = conf.instance.non_linear.config_for(
"MultiNest"
)
stagger_resampling_likelihood = multinest.get(
"general", "stagger_resampling_likelihood", bool
)
stagger_resampling_value = conf.instance.non_linear.get(
"MultiNest", "stagger_resampling_value", float
stagger_resampling_value = multinest.get(
"general", "stagger_resampling_value", float
)

class Fitness:
Expand All @@ -162,8 +168,8 @@ def __init__(
Fitness function that only handles resampling
"""
self.stagger_accepted_samples = 0
self.resampling_likelihood = conf.instance.non_linear.get(
"MultiNest", "null_log_evidence", float
self.resampling_likelihood = multinest.get(
"general", "null_log_evidence", float
)

def __call__(self, cube, ndim, nparams, lnew):
Expand Down
7 changes: 5 additions & 2 deletions autofit/optimize/non_linear/non_linear.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,11 @@ def config(self, attribute_name, attribute_type=str):
attribute
An attribute for the key with the specified type.
"""
return conf.instance.non_linear.get(
self.__class__.__name__, attribute_name, attribute_type
return conf.instance.non_linear.config_for(
self.__class__.__name__).get(
"general",
attribute_name,
attribute_type
)

def __eq__(self, other):
Expand Down
8 changes: 8 additions & 0 deletions test_autofit/test_files/config/non_linear/DownhillSimplex.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[general]
xtol = 1e-4
ftol = 1e-4
maxiter = None
maxfun = None
full_output = 0
disp = 1
retall = 0
3 changes: 3 additions & 0 deletions test_autofit/test_files/config/non_linear/GridSearch.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[general]
number_of_cores = 3
step_size = 0.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[MultiNest]
[general]
importance_nested_sampling = True
multimodal = True
const_efficiency_mode = False
Expand All @@ -21,17 +21,4 @@ init_MPI = False
stagger_resampling_likelihood = False
stagger_resampling_value = 1000.0
terminate_at_acceptance_ratio = False
acceptance_ratio_threshold = 1.0

[DownhillSimplex]
xtol = 1e-4
ftol = 1e-4
maxiter = None
maxfun = None
full_output = 0
disp = 1
retall = 0

[GridSearch]
number_of_cores = 3
step_size = 0.1
acceptance_ratio_threshold = 1.0