The loss curves in the scenario calculator are reproducible only by accident

Bug #1361533 reported by Michele Simionato
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenQuake Engine
Fix Released
High
Michele Simionato

Bug Description

Currently the numbers produced by the risk scenario calculator are reproducible, but only because we are reading the ground motion fields in a fixed order. Even simple refactorings of the hazard getters will return the GMFs in a different order and produce different numbers, unless extra care is taken. The extra care consists in keeping the relative order of GMFs and epsilons consistent. The problem is exercised in the following test case in risklib.tests.scientific_test:

 class MeanLossTestCase(unittest.TestCase):
    def test_mean_loss(self):
        vf = scientific.VulnerabilityFunction(
            'PGA', imls=[0.1, 0.2, 0.3, 0.5, 0.7],
            mean_loss_ratios=[0.0035, 0.07, 0.14, 0.28, 0.56],
            covs=[0.1, 0.2, 0.3, 0.4, 0.5])

        epsilons = [0.98982371, 0.2776809, -0.44858935, 0.96196624,
                    -0.82757864, 0.53465707, 1.22838619]
        imls = [0.280357, 0.443609, 0.241845, 0.506982, 0.459758,
                0.456199, 0.38077]
        mean = vf.apply_to([imls], [epsilons])[0].mean()
        aaae(mean, 0.2318058254)

        # if you don't reorder the epsilons, the mean loss depends by
        # the order of the imls!
        reordered_imls = [0.443609, 0.280357, 0.241845, 0.506982, 0.459758,
                          0.456199, 0.38077]
        mean2 = vf.apply_to([reordered_imls], [epsilons])[0].mean()
        aaae(mean2, 0.238145174018)

        # by reordering the epsilons the problem is solved
        reordered_epsilons = [0.2776809, 0.98982371, -0.44858935, 0.96196624,
                              -0.82757864, 0.53465707, 1.22838619]
        mean3 = vf.apply_to([reordered_imls], [reordered_epsilons])[0].mean()
        aaae(mean3, mean)

On the engine side, one must ensure that the epsilons are correctly associated to the GMFs.

Changed in oq-engine:
assignee: nobody → Michele Simionato (michele-simionato)
importance: Undecided → High
milestone: none → 1.0.1
status: New → In Progress
Revision history for this message
Michele Simionato (michele-simionato) wrote :
summary: - The loss curves in the scenario calculator are reproducible by accident
+ The loss curves in the scenario calculator are reproducible only by
+ accident
Revision history for this message
Michele Simionato (michele-simionato) wrote :
Changed in oq-engine:
status: In Progress → Fix Committed
Changed in oq-engine:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.