Merge pull request 'betterparallel' (#7) from betterparallel into master
All checks were successful
gitea-physics/deepdog/pipeline/head This commit looks good
All checks were successful
gitea-physics/deepdog/pipeline/head This commit looks good
Reviewed-on: #7
This commit is contained in:
commit
bd0b375751
@ -33,16 +33,24 @@ def get_a_simul_result_using_pairs(input) -> numpy.ndarray:
|
|||||||
nonlocal_lows,
|
nonlocal_lows,
|
||||||
nonlocal_highs,
|
nonlocal_highs,
|
||||||
monte_carlo_count,
|
monte_carlo_count,
|
||||||
|
monte_carlo_cycles,
|
||||||
max_frequency,
|
max_frequency,
|
||||||
seed,
|
seed,
|
||||||
) = input
|
) = input
|
||||||
|
|
||||||
rng = numpy.random.default_rng(seed)
|
rng = numpy.random.default_rng(seed)
|
||||||
|
local_total = 0
|
||||||
|
combined_total = 0
|
||||||
|
|
||||||
sample_dipoles = discretisation.get_model().get_n_single_dipoles(
|
sample_dipoles = discretisation.get_model().get_n_single_dipoles(
|
||||||
monte_carlo_count, max_frequency, rng_to_use=rng
|
monte_carlo_count, max_frequency, rng_to_use=rng
|
||||||
)
|
)
|
||||||
local_vals = pdme.util.fast_v_calc.fast_vs_for_dipoles(dot_inputs, sample_dipoles)
|
local_vals = pdme.util.fast_v_calc.fast_vs_for_dipoles(
|
||||||
local_matches = pdme.util.fast_v_calc.between(local_vals, local_lows, local_highs)
|
dot_inputs, sample_dipoles
|
||||||
|
)
|
||||||
|
local_matches = pdme.util.fast_v_calc.between(
|
||||||
|
local_vals, local_lows, local_highs
|
||||||
|
)
|
||||||
nonlocal_vals = pdme.util.fast_nonlocal_spectrum.fast_s_nonlocal(
|
nonlocal_vals = pdme.util.fast_nonlocal_spectrum.fast_s_nonlocal(
|
||||||
pair_inputs, sample_dipoles
|
pair_inputs, sample_dipoles
|
||||||
)
|
)
|
||||||
@ -50,9 +58,10 @@ def get_a_simul_result_using_pairs(input) -> numpy.ndarray:
|
|||||||
nonlocal_vals, nonlocal_lows, nonlocal_highs
|
nonlocal_vals, nonlocal_lows, nonlocal_highs
|
||||||
)
|
)
|
||||||
combined_matches = numpy.logical_and(local_matches, nonlocal_matches)
|
combined_matches = numpy.logical_and(local_matches, nonlocal_matches)
|
||||||
return numpy.array(
|
|
||||||
[numpy.count_nonzero(local_matches), numpy.count_nonzero(combined_matches)]
|
local_total += numpy.count_nonzero(local_matches)
|
||||||
)
|
combined_total += numpy.count_nonzero(combined_matches)
|
||||||
|
return numpy.array([local_total, combined_total])
|
||||||
|
|
||||||
|
|
||||||
class AltBayesRunSimulPairs:
|
class AltBayesRunSimulPairs:
|
||||||
@ -214,6 +223,7 @@ class AltBayesRunSimulPairs:
|
|||||||
<= self.target_success
|
<= self.target_success
|
||||||
):
|
):
|
||||||
_logger.debug(f"Starting cycle {cycles}")
|
_logger.debug(f"Starting cycle {cycles}")
|
||||||
|
_logger.debug(f"(pair, no_pair) successes are {(cycle_success_pairs, cycle_success_no_pairs)}")
|
||||||
cycles += 1
|
cycles += 1
|
||||||
current_success_pairs = 0
|
current_success_pairs = 0
|
||||||
current_success_no_pairs = 0
|
current_success_no_pairs = 0
|
||||||
@ -223,7 +233,8 @@ class AltBayesRunSimulPairs:
|
|||||||
# note this needs to be inside the loop for monte carlo cycle steps!
|
# note this needs to be inside the loop for monte carlo cycle steps!
|
||||||
# that way we get more stuff.
|
# that way we get more stuff.
|
||||||
|
|
||||||
seeds = seed_sequence.spawn(core_count)
|
seeds = seed_sequence.spawn(self.monte_carlo_cycles)
|
||||||
|
_logger.debug(f"Creating {self.monte_carlo_cycles} seeds")
|
||||||
current_success_both = numpy.array(
|
current_success_both = numpy.array(
|
||||||
sum(
|
sum(
|
||||||
pool.imap_unordered(
|
pool.imap_unordered(
|
||||||
@ -238,6 +249,7 @@ class AltBayesRunSimulPairs:
|
|||||||
pair_lows,
|
pair_lows,
|
||||||
pair_highs,
|
pair_highs,
|
||||||
self.monte_carlo_count,
|
self.monte_carlo_count,
|
||||||
|
self.monte_carlo_cycles,
|
||||||
self.max_frequency,
|
self.max_frequency,
|
||||||
seed,
|
seed,
|
||||||
)
|
)
|
||||||
@ -320,8 +332,8 @@ class AltBayesRunSimulPairs:
|
|||||||
):
|
):
|
||||||
row_pairs[f"{name}_prob"] = probability_pair
|
row_pairs[f"{name}_prob"] = probability_pair
|
||||||
row_no_pairs[f"{name}_prob"] = probability_no_pair
|
row_no_pairs[f"{name}_prob"] = probability_no_pair
|
||||||
_logger.info(row_pairs)
|
_logger.debug(row_pairs)
|
||||||
_logger.info(row_no_pairs)
|
_logger.debug(row_no_pairs)
|
||||||
|
|
||||||
with open(self.filename_pairs, "a", newline="") as outfile:
|
with open(self.filename_pairs, "a", newline="") as outfile:
|
||||||
writer = csv.DictWriter(
|
writer = csv.DictWriter(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user