Add EV Adoption Model examples #227
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip CodeRabbit can approve the review once all CodeRabbit's comments are resolved.Enable the |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #227 +/- ##
==========================================
+ Coverage 87.61% 90.67% +3.05%
==========================================
Files 19 19
Lines 1405 1555 +150
==========================================
+ Hits 1231 1410 +179
+ Misses 174 145 -29 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 74727fa3ec
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| @@ -0,0 +1,2 @@ | |||
| import examples.migration_model.tools | |||
There was a problem hiding this comment.
Remove import of nonexistent migration tools module
Importing examples.migration_model now raises ModuleNotFoundError because __init__.py unconditionally imports examples.migration_model.tools, but this commit does not add any tools module under examples/migration_model (repo search only finds __init__.py). Any code that imports this package will fail at import time.
Useful? React with 👍 / 👎.
| self.calculate_ice_cost() | ||
| self.calculate_ev_cost() | ||
| self.compute_utility() | ||
| self.make_decision() |
There was a problem hiding this comment.
Drain EV battery in the household step loop
The step loop never calls drive(), which is the only method that decreases battery_level; as a result EV households keep a full battery indefinitely and the charge_ev behavior (triggered only when battery is low) never activates in normal runs. This breaks the charging/infrastructure dynamics described by the model.
Useful? React with 👍 / 👎.
| energy = agent.battery_capacity - agent.battery_level | ||
| cost = energy * station.price_per_kwh | ||
|
|
||
| agent.battery_level = agent.battery_capacity |
There was a problem hiding this comment.
Update station utilization when charging succeeds
A successful charge_ev call refills the battery but never modifies station.utilization_rate; since utilization is initialized to 0 and never changed elsewhere in this model, station-capacity checks and congestion effects stay effectively disabled. This makes both station.utilization_rate >= station.capacity and infrastructure congestion modeling inaccurate.
Useful? React with 👍 / 👎.
| if len(neighbors) == 0: | ||
| return 0 | ||
|
|
||
| return ev_neighbors / len(neighbors) |
There was a problem hiding this comment.
Compute social influence over household neighbors only
The EV-neighbor count is filtered to HouseholdAgent, but the denominator uses len(neighbors) for all nearby agents. When charging stations (or any non-household agents) are adjacent, social influence is artificially diluted even if all neighboring households are EV adopters, which contradicts the documented definition of social influence.
Useful? React with 👍 / 👎.
|
Hi @colinfrisch , @sanika-n I've added a new example model called the EV adoption model. I would really appreciate any feedback or suggestions for improving the model. Thank You! |
for more information, see https://pre-commit.ci
Added logic to occupy and release charger in charging process.
This PR introduces a new example model demonstrating EV adoption dynamics
using mesa-llm agents.
The model simulates how households decide whether to adopt an electric
vehicle (EV) or continue using an internal combustion engine (ICE)
vehicle. Each household agent evaluates a utility-based decision model
that incorporates financial costs, environmental awareness, and charging
infrastructure availability.
Agents use LLM-based reasoning (ReAct) to explain their decisions and
select actions via tools.
Key features of the model:
• Household agents evaluating EV vs ICE utilities
• ChargingStation agents representing EV infrastructure
• Utility-based adoption decision model
• LLM-driven reasoning and tool execution
• Solara-based interactive visualization
• Data collection for EV and ICE adoption trends
Households can perform the following actions:
• buy_ev – purchase an electric vehicle
• buy_ice – purchase an internal combustion vehicle
• charge_ev – charge an EV at a charging station