feat: add multi run to wrap multi model and repeat runs
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
# serializer version: 1
|
||||
# name: test_subset_simulation_multi_result_coalescing_easy_arithmetic
|
||||
MultiSubsetSimulationResult(child_results=[SubsetSimulationResult(probs_list=(), over_target_cost=1, over_target_likelihood=1, under_target_cost=0.99, under_target_likelihood=0.8, lowest_likelihood=0.5, messages=[]), SubsetSimulationResult(probs_list=(), over_target_cost=1, over_target_likelihood=1, under_target_cost=0.99, under_target_likelihood=0.6, lowest_likelihood=0.01, messages=[])], model_name='test', estimated_likelihood=0.6928203230275509, arithmetic_mean_estimated_likelihood=0.7, num_children=2, num_finished_children=2, clean_estimate=True)
|
||||
# ---
|
||||
# name: test_subset_simulation_multi_result_coalescing_easy_geometric
|
||||
MultiSubsetSimulationResult(child_results=[SubsetSimulationResult(probs_list=(), over_target_cost=1, over_target_likelihood=1, under_target_cost=0.99, under_target_likelihood=0.1, lowest_likelihood=0.5, messages=[]), SubsetSimulationResult(probs_list=(), over_target_cost=1, over_target_likelihood=1, under_target_cost=0.99, under_target_likelihood=0.001, lowest_likelihood=0.01, messages=[])], model_name='test', estimated_likelihood=0.010000000000000004, arithmetic_mean_estimated_likelihood=0.0505, num_children=2, num_finished_children=2, clean_estimate=True)
|
||||
# ---
|
||||
# name: test_subset_simulation_multi_result_coalescing_include_dirty
|
||||
MultiSubsetSimulationResult(child_results=[SubsetSimulationResult(probs_list=(), over_target_cost=1, over_target_likelihood=1, under_target_cost=0.99, under_target_likelihood=0.8, lowest_likelihood=0.5, messages=[]), SubsetSimulationResult(probs_list=(), over_target_cost=1, over_target_likelihood=1, under_target_cost=0.99, under_target_likelihood=0.08, lowest_likelihood=0.01, messages=[]), SubsetSimulationResult(probs_list=(), over_target_cost=None, over_target_likelihood=None, under_target_cost=None, under_target_likelihood=None, lowest_likelihood=0.0001, messages=[])], model_name='test', estimated_likelihood=0.01856635533445112, arithmetic_mean_estimated_likelihood=0.29336666666666666, num_children=3, num_finished_children=2, clean_estimate=False)
|
||||
# ---
|
92
tests/subset_simulation/test_subset_simulation_coalescing.py
Normal file
92
tests/subset_simulation/test_subset_simulation_coalescing.py
Normal file
@@ -0,0 +1,92 @@
|
||||
import deepdog.subset_simulation.subset_simulation_impl as impl
|
||||
import numpy
|
||||
|
||||
|
||||
def test_subset_simulation_multi_result_coalescing_include_dirty(snapshot):
|
||||
res1 = impl.SubsetSimulationResult(
|
||||
probs_list=(),
|
||||
over_target_cost=1,
|
||||
over_target_likelihood=1,
|
||||
under_target_cost=0.99,
|
||||
under_target_likelihood=0.8,
|
||||
lowest_likelihood=0.5,
|
||||
messages=[],
|
||||
)
|
||||
|
||||
res2 = impl.SubsetSimulationResult(
|
||||
probs_list=(),
|
||||
over_target_cost=1,
|
||||
over_target_likelihood=1,
|
||||
under_target_cost=0.99,
|
||||
under_target_likelihood=0.08,
|
||||
lowest_likelihood=0.01,
|
||||
messages=[],
|
||||
)
|
||||
|
||||
res3 = impl.SubsetSimulationResult(
|
||||
probs_list=(),
|
||||
over_target_cost=None,
|
||||
over_target_likelihood=None,
|
||||
under_target_cost=None,
|
||||
under_target_likelihood=None,
|
||||
lowest_likelihood=0.0001,
|
||||
messages=[],
|
||||
)
|
||||
|
||||
combined = impl.coalesce_ss_results("test", [res1, res2, res3])
|
||||
|
||||
assert combined == snapshot
|
||||
|
||||
|
||||
def test_subset_simulation_multi_result_coalescing_easy_arithmetic(snapshot):
|
||||
res1 = impl.SubsetSimulationResult(
|
||||
probs_list=(),
|
||||
over_target_cost=1,
|
||||
over_target_likelihood=1,
|
||||
under_target_cost=0.99,
|
||||
under_target_likelihood=0.8,
|
||||
lowest_likelihood=0.5,
|
||||
messages=[],
|
||||
)
|
||||
|
||||
res2 = impl.SubsetSimulationResult(
|
||||
probs_list=(),
|
||||
over_target_cost=1,
|
||||
over_target_likelihood=1,
|
||||
under_target_cost=0.99,
|
||||
under_target_likelihood=0.6,
|
||||
lowest_likelihood=0.01,
|
||||
messages=[],
|
||||
)
|
||||
|
||||
combined = impl.coalesce_ss_results("test", [res1, res2])
|
||||
|
||||
assert combined.arithmetic_mean_estimated_likelihood == 0.7
|
||||
assert combined == snapshot
|
||||
|
||||
|
||||
def test_subset_simulation_multi_result_coalescing_easy_geometric(snapshot):
|
||||
res1 = impl.SubsetSimulationResult(
|
||||
probs_list=(),
|
||||
over_target_cost=1,
|
||||
over_target_likelihood=1,
|
||||
under_target_cost=0.99,
|
||||
under_target_likelihood=0.1,
|
||||
lowest_likelihood=0.5,
|
||||
messages=[],
|
||||
)
|
||||
|
||||
res2 = impl.SubsetSimulationResult(
|
||||
probs_list=(),
|
||||
over_target_cost=1,
|
||||
over_target_likelihood=1,
|
||||
under_target_cost=0.99,
|
||||
under_target_likelihood=0.001,
|
||||
lowest_likelihood=0.01,
|
||||
messages=[],
|
||||
)
|
||||
|
||||
combined = impl.coalesce_ss_results("test", [res1, res2])
|
||||
|
||||
numpy.testing.assert_allclose(combined.estimated_likelihood, 0.01)
|
||||
assert combined == snapshot
|
Reference in New Issue
Block a user