Skip to content

Commit

Permalink
Remove discrete grid converter
Browse files Browse the repository at this point in the history
  • Loading branch information
timmens committed Sep 23, 2024
1 parent 05d1887 commit 420eedd
Show file tree
Hide file tree
Showing 13 changed files with 22 additions and 499 deletions.
5 changes: 1 addition & 4 deletions src/lcm/entry_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ def get_lcm_function(
continuous_choice_grids=continuous_choice_grids,
compute_ccv_functions=compute_ccv_functions,
emax_calculators=emax_calculators,
discrete_grid_converter=_mod.discrete_grid_converter,
logger=logger,
)

Expand All @@ -184,7 +183,6 @@ def get_lcm_function(
compute_ccv_policy_functions=compute_ccv_policy_functions,
model=_mod,
next_state=jax.jit(_next_state_simulate),
discrete_grid_converter=_mod.discrete_grid_converter,
logger=logger,
)

Expand All @@ -195,8 +193,7 @@ def get_lcm_function(
elif targets == "solve_and_simulate":
_target = partial(simulate_model, solve_model=solve_model)

user_params = _mod.discrete_grid_converter.internal_params_to_params(_mod.params)
return cast(Callable, _target), user_params
return cast(Callable, _target), _mod.params


def create_compute_conditional_continuation_value(
Expand Down
3 changes: 1 addition & 2 deletions src/lcm/input_processing/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from .discrete_grid_conversion import DiscreteGridConverter
from .process_model import process_model

__all__ = ["process_model", "DiscreteGridConverter"]
__all__ = ["process_model"]
280 changes: 0 additions & 280 deletions src/lcm/input_processing/discrete_grid_conversion.py

This file was deleted.

20 changes: 7 additions & 13 deletions src/lcm/input_processing/process_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@

from lcm.functools import all_as_args, all_as_kwargs
from lcm.input_processing.create_params_template import create_params_template
from lcm.input_processing.discrete_grid_conversion import (
convert_arbitrary_codes_to_array_indices,
)
from lcm.input_processing.util import (
get_function_info,
get_grids,
Expand Down Expand Up @@ -39,21 +36,18 @@ def process_model(model: Model) -> InternalModel:
The processed model.
"""
tmp_model, converter = convert_arbitrary_codes_to_array_indices(model)

params = create_params_template(tmp_model)
params = create_params_template(model)

return InternalModel(
grids=get_grids(tmp_model),
gridspecs=get_gridspecs(tmp_model),
variable_info=get_variable_info(tmp_model),
functions=_get_internal_functions(tmp_model, params=params),
function_info=get_function_info(tmp_model),
grids=get_grids(model),
gridspecs=get_gridspecs(model),
variable_info=get_variable_info(model),
functions=_get_internal_functions(model, params=params),
function_info=get_function_info(model),
params=params,
discrete_grid_converter=converter,
# currently no additive utility shocks are supported
random_utility_shocks=ShockType.NONE,
n_periods=tmp_model.n_periods,
n_periods=model.n_periods,
)


Expand Down
4 changes: 0 additions & 4 deletions src/lcm/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from jax import Array

from lcm.grids import ContinuousGrid, DiscreteGrid, Grid
from lcm.input_processing import DiscreteGridConverter
from lcm.typing import ParamsDict, ShockType


Expand Down Expand Up @@ -94,8 +93,6 @@ class InternalModel:
True if the function has the corresponding property. The columns are:
is_filter, is_constraint, is_next.
params: Dict of model parameters.
discrete_grid_converter: Helps with converting between internal and external
representations of model variables and associated parameters.
n_periods: Number of periods.
random_utility_shocks: Type of random utility shocks.
Expand All @@ -107,7 +104,6 @@ class InternalModel:
functions: dict[str, Callable]
function_info: pd.DataFrame
params: ParamsDict
discrete_grid_converter: DiscreteGridConverter
n_periods: int
# Not properly processed yet
random_utility_shocks: ShockType
Loading

0 comments on commit 420eedd

Please sign in to comment.