Skip to content

Add time varying parameters#282

Open
FlxPo wants to merge 1 commit intomainfrom
parameter-profiles
Open

Add time varying parameters#282
FlxPo wants to merge 1 commit intomainfrom
parameter-profiles

Conversation

@FlxPo
Copy link
Contributor

@FlxPo FlxPo commented Mar 17, 2026

Motivations

This PR adds support for time-varying parameter values, see #281 for details.

Changes

  • Add ParameterProfile and SimulationStep utilities to represent and evaluate iteration-based parameter profiles.
  • Add shared validated scalar aliases in validation_types.py.
  • Allow motive parameters such as value_of_time, value_of_time_stay_home, and radiation_lambda to accept either constant scalar values or ParameterProfile values.
  • Add Motive.get_parameters_at_step(step) to resolve step-varying motive parameters into scalar values for a given simulation step.
  • Update destination sampling to use step-specific motive parameters when computing:
    • destination utilities
    • radiation-model destination probabilities
  • Update state initialization to use the step-specific home parameters when building the initial stay-home state.
  • Update state updates to use step-specific motive parameters when computing:
    • step activity utilities
    • stay-home / home-time utility
    • sink saturation parameters

Examples

The API to get a value of time for the work activity to change from 4 €/h to 8 €/h at time step 3 is :

WorkMotive(
    value_of_time=ParameterProfile(
        mode="step",
        points={ 
            1: 4.0,
            3: 8.0
        }
    )
 )

It's also possible to get a gradual change with linear interpolation, here the value of time will be 4, 6 and 8 at steps 1, 2, 3 :

WorkMotive(
    value_of_time=ParameterProfile(
        mode="linear",
        points={ 
            1: 4.0,
            3: 8.0
        }
    )
 )

The old API still works for constant parameters :

WorkMotive(
    value_of_time=4.0
 )

@FlxPo FlxPo changed the title add time varying parameters Add time varying parameters Mar 17, 2026
@codecov
Copy link

codecov bot commented Mar 17, 2026

Codecov Report

❌ Patch coverage is 80.85106% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.26%. Comparing base (db01023) to head (c2b6cba).

Files with missing lines Patch % Lines
mobility/simulation_profile.py 61.36% 17 Missing ⚠️
mobility/choice_models/population_trips.py 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #282      +/-   ##
==========================================
+ Coverage   59.06%   59.26%   +0.19%     
==========================================
  Files         129      131       +2     
  Lines        6738     6815      +77     
==========================================
+ Hits         3980     4039      +59     
- Misses       2758     2776      +18     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant