Skip to content

Commit

Permalink
differentiate income and income share diffusion
Browse files Browse the repository at this point in the history
  • Loading branch information
gidden committed Sep 6, 2017
1 parent 58649e0 commit 3b01bdd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 14 additions & 1 deletion salamanca/models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,24 @@ def construct(self, diffusion={}, direction={}):
if b:
b = 0.2 if b is True else b
m.i_hi = mo.Constraint(
m.idxs,
rule=lambda m, idx: income_diff_hi_rule(m, idx, b),
doc='income within 20% from past',
)
m.i_lo = mo.Constraint(
m.idxs,
rule=lambda m, idx: income_diff_lo_rule(m, idx, b),
doc='income within 20% from past',
)
b = diffusion.pop('share', False)
if b:
b = 0.2 if b is True else b
m.s_hi = mo.Constraint(
m.idxs,
rule=lambda m, idx: share_diff_hi_rule(m, idx, b),
doc='income share within 20% from past',
)
m.i_lo = mo.Constraint(
m.s_lo = mo.Constraint(
m.idxs,
rule=lambda m, idx: share_diff_lo_rule(m, idx, b),
doc='income share within 20% from past',
Expand Down
2 changes: 1 addition & 1 deletion tests/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def test_Model1_result():
def test_Model1_diffusion_result():
natdata, subdata = data()
model = Model1(natdata, subdata)
diffusion = {'income': True, 'theil': True}
diffusion = {'share': True, 'theil': True}
model.construct(diffusion=diffusion)
model.solve()
df = model.result()
Expand Down

0 comments on commit 3b01bdd

Please sign in to comment.