Skip to content

Commit

Permalink
Revert "Add "unit" assumption to (try) to help simplify expressions o…
Browse files Browse the repository at this point in the history
…f the form `x ^(1 - b)`, where 1 - b > 0"

This reverts commit 6481301.
  • Loading branch information
jessegrabowski committed Nov 10, 2024
1 parent 401365b commit c479f96
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 33 deletions.
16 changes: 2 additions & 14 deletions gEconpy/model/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,26 +709,14 @@ def simplify_system_equations(self) -> None:
break

simplified_system = [eq for eq in simplified_system if eq != 0]

self.system_equations = simplified_system
self.eliminated_variables = eliminated_variables

for key, value in self.multipliers.items():
if value in eliminated_variables:
self.multipliers[key] = None

# Simplify expressions further by using the simplify method.
unit_params = [
x for x in self.param_dict.keys() if x._assumptions0.get("unit", False)
]
unit_subs = {
1 - x: sp.Symbol(f"__TEMP_SUB__{i}") for i, x in enumerate(unit_params)
}
r_unit_subs = {v: k for k, v in unit_subs.items()}

simplified_system = [
eq.subs(unit_subs).simplify().subs(r_unit_subs) for eq in simplified_system
]
self.system_equations = simplified_system

def solve_optimization(self, try_simplify: bool = True) -> None:
r"""
Solve the optimization problem implied by the block structure:
Expand Down
2 changes: 1 addition & 1 deletion gEconpy/model/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def compile_to_numpy(
pop_return: bool,
**kwargs,
):
f = sp.lambdify(inputs, outputs, cse=True)
f = sp.lambdify(inputs, outputs)
if stack_return:
f = stack_return_wrapper(f)
if pop_return:
Expand Down
18 changes: 1 addition & 17 deletions gEconpy/model/steady_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,24 +88,8 @@ def make_steady_state_variables(variables):


def system_to_steady_state(system, shocks):
parameters = [
x
for x in set().union(*[eq.free_symbols for eq in system])
if not x.is_number and not isinstance(x, TimeAwareSymbol)
]
shock_dict = make_steady_state_shock_dict(shocks)
# Simplify expressions further by using the simplify method.

unit_params = [x for x in parameters if x._assumptions0.get("unit", False)]
unit_subs = {
1 - x: sp.Symbol(f"__TEMP_SUB__{i}") for i, x in enumerate(unit_params)
}
r_unit_subs = {v: k for k, v in unit_subs.items()}

steady_state_system = [
(eq_to_ss(eq).subs(shock_dict).subs(unit_subs).simplify().subs(r_unit_subs))
for eq in system
]
steady_state_system = [eq_to_ss(eq).subs(shock_dict).simplify() for eq in system]

return steady_state_system

Expand Down
1 change: 0 additions & 1 deletion gEconpy/parser/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
"antihermitian",
"algebraic",
"transcendental",
"unit",
]

DEFAULT_ASSUMPTIONS = {"real": True}

0 comments on commit c479f96

Please sign in to comment.