Interaction START

In current implementation, interactions are limited to the past. Need to look at how to 
deal with simultaneous arrivals (proably check if that is the case, then trigger an ordering, posibly random
so that it's not always the same user that loses)

Current implementation: interactions are based only on states established in previous time steps.
 TODO: handle simultaneous events where multiple users compete for the same constrained resource, especially simultaneous charging-session starts/arrivals. Detect these before updating individual users and apply an explicit allocation/priority rule. If ordering is required, consider randomized ordering so the same user is not systematically disadvantaged.

One thing I'd keep in mind for later: since reproducibility matters in your model, random ordering should use your existing seeded RandomGenerators setup, rather than an independent/unseeded shuffle.

Your step-by-step approach makes sense. I would not complicate update_tracking() with this yet.


END


Clarify demnded charge. Add network reaction/offered charge
QUeueing with a limit.
All users at the same time (option?)

Documnet random_generators (and their split)
Dashboard
discharge
More run_metrics
Histograms
More vehicles (batched)

peak price per location off peak price per location 
and double slider to set peak (since midnigh crossing is offpeak in principle)

wants to charge combine price and trigger: A trgger any price will do.
At 100% battery, only zero price will do 

(charge level-trigger level) X price <= X 

X is in euros


Do convergence tests. 

How big an issue is convergence right now?

At the current development stage, it is not a major issue, provided you do not interpret the results from 12 users as stable population estimates.

Twelve users are sufficient for:

testing whether the model runs;
debugging user-level behaviour;
checking energy balances and invariants;
examining individual mobility and charging profiles;
detecting obviously implausible results;
comparing outputs when all randomness is deliberately aligned.

Twelve users are not sufficient for:

estimating population-average kilometrage precisely;
evaluating small differences between scenarios;
estimating uncommon behaviour;
establishing stable location-specific charging demand;
drawing policy conclusions from aggregate results.

Your current sample has a standard deviation of roughly 3,400 km and a mean around 12,200 km. For 12 independent users, the standard error of the mean is approximately 1,000 km. Therefore, an average from this user pool can easily move by several hundred or more than 1,000 km merely because of random sampling.

That is not a problem while you are developing the mechanics. It only becomes a problem when you begin interpreting small aggregate differences.

Practical threshold for concern

For now, I would use this rule:

Logic and debugging: 12 users is fine.
Qualitative scenario checks: tens to a few hundred users may be enough.
Quantitative scenario comparison: establish convergence explicitly.
Final reported results: use enough users and runs to meet a chosen precision criterion.

The critical warning sign is when you start saying something like:

Scenario B reduces average kilometrage or charging cost by 2%.

With 12 users, a 2% difference will probably be much smaller than the sampling noise. At that point, convergence testing becomes essential.

Recommended approach

For now:

Keep the changed draw_beta_value.
Use the shorter docstring note.
Start using the two generators you already created:
mobility
charging
Do not add further generator subdivisions yet.
Continue using 12 users for development.
Avoid interpreting the aggregate mean as a converged result.
Add convergence testing once the model structure and principal behavioural rules have stabilized.

So the convergence issue is real, but it is not urgent for implementation work. The random-generator separation is more useful now because it directly improves debugging and controlled scenario comparisons at very little additional complexity.


Recommendation
Keep the modified draw_beta_value that always consumes the beta draw.
Add a regression test confirming that changing a deterministic parameter does not change mobility outputs.
Document that the function intentionally consumes a draw for degenerate ranges to preserve random-stream alignment.
Consider separate generators for activities, distances, user properties, and charging if scenario isolation becomes important.
Do not rely on 12 users for a precise population mean. Use an explicit convergence test based on the standard error across users and across complete Monte Carlo runs.


Test parameters to get to actual kilometrages

Concurrent users thing

Use queue for fast-chargiugn delay (and other things)
   
   
    # Then in mobility matrix put end_base after last steo (or do so also for normal trips)

    # the second pass at trips is only for Trips that are not transition bool

    # This version is actually only for cars and work/leisure (GEneralise???)


    print('[magenta] Document legs and parked times')

print('[magenta]Add repetitions stuff') in Trip.get_leg_info


7. Decide whether the run frequency must divide a day evenly


One conceptual note about week 53


Also issues with multi-year runs

You currently construct:

Python
range(
time_constants.first_week_index,
time_constants.last_week_index,
)

With first_week_index = 1 and last_week_index = 53, this produces weeks 1 through 52 and deliberately excludes week 53. Your comment confirms that this is intentional:

Python
# The last week (53 is only a day or two long)

That is internally consistent.

However, your model can classify dates as ISO week 53 through:

Python
pl.col('date').dt.week()

while no user can ever have week 53 in:

Python
commuting_week_numbers
holiday_trip_week_numbers

That may be intentional if week 53 is treated as a partial boundary week outside the repeating activity schedule. Just ensure get_run_trips() explicitly handles dates in week 53 rather than expecting them in one of these drawn lists.
Implement holiday trips and base shifts in stochastic
Look at notes in Class Trip   BaseTransitions

Use integer second steps to avoid 



Consumpton table first

Track charge: at each time charge = connectivity and bett space (+ space for available)
discharge =consumption

charger efficiency for network demand?


do it per trip
battery level trigger (below this, will charge)

then max power or spread

How to deal with shift to next day? 
Trip of prior day might correlate with next day
    

bank holidays
holiday trips per year?





in requirements.txt
tomli >= 1.1.0 ; python_version < "3.11" 

ESDL compatibility (+ESSIM?)
Chapter on working as a provider/with other models (optimisers, e.g.)
Collection/combination of reference profiles: Can optimiser help choose split?
Jpurnal of software engineering or other?


Advanced CODEC/socio (combine with optimising work?)
Mopo color palette?
Use logos (ChaProEV and Mopo in readme)


Run weather factors in DB (and pickle?)

SOLAR EFFICIENCY !

            print('Do solar panel efficiency')

            print('Avoid swap by arranging before?')
            print('And explain/improve in all hourly')
            print('Clarify what theperature efficiency of vehicles is')
            print('Test leg.electricity_use_kWh')
            print('Implement road and hour in day factors')
            print('Go through class definitions (espcially Trip')
            print('Day start hour in one place?')
            print('Fast/station charging')
            print('Add time fator to location charging price?')
            print('Connectivity can vary with time? (e.g. due to higher occupancy')
            print('Max allowed charging time?')

            PV library Sandia (PV-lib)

https://pvpmc.sandia.gov/applications/pv_lib-toolbox/

Charging point efficiency factor per location and impact on from_grib_to_dataframe

Shading + 890 kWh/kWp in Nll rule of thumb+ Temp (ambient+20)-25 --> 0.5% drop per unit_conversions
Soalr moves: rondomize/spread journeys and such

Where to write computed trip properties (at least non-charge ones, such as location, but maybe also these too)
In scenario_trips, or elsewhere?

Describe connection to optimisation model
Share cookbooj=k with ETS team (focus on some functions, such as SQL query writer)
electricity price: Add (option) for a time correction factor (equal to 1 if not given?)

Density/distribution of building types (houses, work, malls, etc) per zone (e.g.NUTS3)

ESDL in Mopo?

Monte-Carlo/ randomize input (scenarios)
PV from DTU (and other data, see Matti's presentation)

Reference values DB for people to use in other models (SpineOpt, etc): Maybe add reading functions (or structure, matchin SPINE)
Charging costs in aggregates
Have pricing/desirability scaling/flexibility (e.g. charge if need/price reaches a theshold, or use a function, may add desirability to it)

Map plot of kilometrage, charging costs, etc. per country?

Couple to CODEC?


Report to Mikael (and/or run results?) for his student

BAG data

home_home
home_street
other vehicles
output 1/1 to 31/12 (option)
Station users
speed up using day types only (option)
QUantities for optimisers
calendar year (2015 for OPera)
combine with urban strategy
case study
paper
Modulation 
every x days
sun and other prefeence factors for a given day (set in advance?)     

print('Iterate over cases? At least as a separate fucntion')
    # writing.write_scenario_parameters(scenario)
    # weather.setup_weather( scenario)
    # legs, vehicles, legs, trips = define.declare_all_instances(
    #     scenario)

    # run_trip_probabilities = (
    #     mobility.get_run_trip_probabilities(scenario)
    # )
    # Histograms!

    # Spillover at vans too Or maybe the spillover is also for mobility

    print('Match en required fo next and total')
    print('Recap DF')
    print('Sum over locations ofenergy for next?')
    print('Other vehicles')
    print('Trips to keep memory')
    print('Bus percent of time in route at bus stops')
    print('Other quantities')
    # print('Label min and max for btt space and energy fro next leg')
    # print('Aggregates: KMs and cons per trip, day type (?) and total')
    # print(
    #     'Aggregates: Stats (mean, min, max) of Charging power (kW),
    # Driving%, Connected %, Batt space, batt charge level,
    # Maximal delivered power (kW),
    # Percentage of maximal delivered power used (%),
    # Minimal delivered power (kW)'
    # )
    # print(
    #     'Data for Tulipa/COMPETES Connected (%)	Charging Power (kW)
    # Charging Profile	Energy_demand_for_next_leg (kWh)
    # Energy_demand_for_next_leg (as percent of total demand)
    # \Maximal delivered power (kW)
    # Percentage of maximal power used(%)	Minimal deliverd power (kW) '
    # )
    # print(
    #     'Full data too? Or per location, with one table per,
    # and have sumtable 9or sum in Table?'
    # )
    print('Temperature effect')
    print('PVs from PVlib')
    print('Fast chargers')
    print('Speedup per day type (option if using mob module)')
    print('recap DF?')
    print('Check connectivity')
    print('Clarify charge and power! for drawn')
    # print(
    #     'Minimal state of charge = energy for next leg
    # + lowest acceptabl;e level'
    # )
    # print(
    #     'Charging Power and Charge Drawn as separate tables
    # and the in percentage and such'
    # )
    # print(
    #     'Split home an-home and home-street (or have it as
    # separate runs with different powers?)'
    # )
    # print('Other vehicles')
    print('Speed up by using day types only calc as option')
    print('Chargin strategis (basic, adaptive, price (?))')
    print('Every x days')

    print('Add spillover?')
    print('Use departures from and arrivals to for location split')
    print('Difference with zero is % driving')
    print('Station users might be an issue')
    print('Assume evenly distributed and shift proportionally')
    print('Then consumptions (in other module) for both')
    print('One gives demand for next leg, other cosumed energy')
    # NEED percentage driving too! Do it in trip mobility matrix
    # and propagate into future hours if > 1 hour
    # (and maybe use the opportunity to do that too for trips<1 hour
    #  that propagate (but add after check))
    # e.g. 0.25 will be 0.25 for 0.75 and 0.75-x for last 0.25
    # with x going into next hour
    # in mobility: value at
    # [-1] + arrivals(1-travelling) - departures (1-travelling)
    # but then need to add spillover0