def test_compute_bcr(self): # numbers are proven to be correct eal_orig = 0.00838 eal_retrofitted = 0.00587 retrofitting_cost = 0.1 interest = 0.05 life_expectancy = 40 expected_result = 0.43405 result = bcr(eal_orig, eal_retrofitted, interest, life_expectancy, retrofitting_cost) self.assertAlmostEqual(result, expected_result, delta=2e-5)
def __call__(self, asset, hazard): annual_loss_original = scientific.mean_loss( self.lcc_original(asset, hazard).loss_curve) annual_loss_retrofitted = scientific.mean_loss( self.lcc_retrofitted(asset, hazard).loss_curve) bcr = scientific.bcr( annual_loss_original, annual_loss_retrofitted, self.interest_rate, self.asset_life_expectancy, asset.retrofitting_cost) return scientific.BCROutput( asset, bcr, annual_loss_original, annual_loss_retrofitted)