HopkinsIDD/flepiMoP

Mobility model only applied if more than one disease state in `proportional_to`

twallema opened this issue · 1 comments

Description

The mobility "split" of populations listed in proportional_to is only applied if there is more than one value in the proportional_to; using the following transitions,

  transitions:
    - source: ["S"]
      destination: ["I"]
      rate: ["beta * N"]
      proportional_to: [["S"],["I"]]
      proportion_exponent: ["1","1"]      
    - source: ["I"]
      destination: ["R"]
      rate: ["gamma"]
      proportional_to: ["I"]
      proportion_exponent: ["1"]

the mobility matrix is only used on the transition from S --> I, and not on the transition from I --> R.

This has to with the way this is coded in steps_rk4.py,

# Loops over transitions
for transition_index in range(ntransitions):

    # DO STUFF
    # Loops over proportional populations
    for proportion_index in range(
                transitions[transition_proportion_start_col][transition_index],
                transitions[transition_proportion_stop_col][transition_index],
            ):

        # DO MORE STUFF
                # Determines if there is only one population in `is_proportional_to` in config file
                if first_proportion:
                    only_one_proportion = (
                        transitions[transition_proportion_start_col][transition_index] + 1
                    ) == transitions[transition_proportion_stop_col][transition_index]
                    first_proportion = False
                    source_number = relevant_number_in_comp  # does this mean we need the first to be "source" ??? yes !
                    if source_number.max() > 0:
                        total_rate[source_number > 0] *= (
                            source_number[source_number > 0] ** relevant_exponent[source_number > 0]
                            / source_number[source_number > 0]
                        )
                    if only_one_proportion:
                        total_rate *= parameters[transitions[transition_rate_col][transition_index]][today]
                else:
                    # if not the mobility model is applied
                    for spatial_node in range(nspatial_nodes):
                        proportion_keep_compartment = 1 - percent_day_away * proportion_who_move[spatial_node]

The algorithm determines if there is only one proportion in proportional_to (config file), and if there is, the populations are not split over "home" and "away" patches.

This issue is also part of Issue #256, and was moved here for clarity.

Proposed fix

To be brainstormed/discussed.

That's a very good point we have discussed in the past and we need a good way to do this. I also dislike the automatic way of applying mobility if there is more than one proportional_to.

I like what you proposed #256, the idea with the config flag.

To add to the brainstorm:
Among flepimop features this configuration of transition is my least favorite. Yes, it's compact, but it's also confusing. Personally, I miss writing ODE rhs. I see you have expressed that you liked it. And it has it strenghts.

I would be interested in:

  • perspectives about the current implementation, how confusing it is, and all
  • Thoughts about what kind of DSL (domain-specific language) can be used to express transitions in a clear and compact way while keeping it simple (not having folk think about matrix multiplication and all).