def test_8(self): project, i = Project(1000, 500, 300, 10), EfInt(0.6) x, y = project.cash_flows, link( (project.cash_flows, project.cash_flows)) self.assertAlmostEqual(aw(x, i), aw(y, i))
def test_3(self): i = EfInt(0.05) aw_cr = aw(Project(300000, 14000, 0, 20).cash_flows, i) aw_ed = aw(Project(220000, 21000, 0, 20).cash_flows, i) + aw( (CashFlow(8, 35000), ), i) self.assertAlmostEqual(aw_cr, 38072.77615720737) self.assertAlmostEqual(aw_ed, 42318.6326589209)
def test_2(self): cr = tuple(Project(300000, 14000, 0, 20).cash_flows) ed = tuple(Project(220000, 21000, 0, 20).cash_flows) + (CashFlow( 8, 35000), CashFlow(16, 35000)) i = EfInt(0.05) self.assertAlmostEqual(pw(cr, i), 474470.94479555974) self.assertAlmostEqual(pw(ed, i), 521429.6981340426) self.assertAlmostEqual(aw(cr, i), 38072.77615720737) self.assertAlmostEqual(aw(ed, i), 41840.86801633675) self.assertLess(pw(cr, i), pw(ed, i)) self.assertLess(aw(cr, i), aw(ed, i))
def test_projects(self): self.assertAlmostEqual( pw(Project(-20000, 4000 - 1000, 4000, 10).cash_flows, EfInt(0.05)), 5620.857801717468) self.assertAlmostEqual( aw(Project(-20000, 4000 - 1000, 4000, 10).cash_flows, EfInt(0.05)), 727.9268005526942)
def test_5(self): i = EfInt(0.07) sa = aw( chain((CashFlow(0, 5e6), ), repeated(Project(0, 2e5, 1e6, 6).cash_flows, 25)), i, 25) sb = aw( chain((CashFlow(0, 6e6), ), repeated(Project(0, 1.5e5, 1.1e6, 11).cash_flows, 25)), i, 25) ba = aw( chain((CashFlow(0, 5e6), ), repeated(Project(0, 5e5 - 3e5, 1e6, 14).cash_flows, 25)), i, 25) bb = aw( chain((CashFlow(0, 3e6), ), repeated(Project(0, 3e5, 6e5, 5).cash_flows, 25)), i, 25) self.assertAlmostEqual(sa, 766638.1419621999) self.assertAlmostEqual(sb, 731013.277560719) self.assertAlmostEqual(ba, 662331.3841421161) self.assertAlmostEqual(bb, 661765.9683268208) self.assertAlmostEqual(min(sa + ba, sa + bb, sb + ba, sb + bb), sb + bb)