Skip to content

Add EV Adoption Model examples #227

Open
niteshver wants to merge 14 commits into
mesa:mainfrom
niteshver:ev_model
Open

Add EV Adoption Model examples #227
niteshver wants to merge 14 commits into
mesa:mainfrom
niteshver:ev_model

Conversation

@niteshver

Copy link
Copy Markdown
Contributor

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

Screenshot 2026-03-15 at 8 14 51 PM Screenshot 2026-03-15 at 7 58 23 PM

@coderabbitai

coderabbitai Bot commented Mar 15, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b3096185-c8a4-458f-ad6a-5e4b50a94308

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can approve the review once all CodeRabbit's comments are resolved.

Enable the reviews.request_changes_workflow setting to automatically approve the review once all CodeRabbit's comments are resolved.

@codecov

codecov Bot commented Mar 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.67%. Comparing base (379c4d8) to head (748526d).
⚠️ Report is 117 commits behind head on main.

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.
📢 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread examples/migration_model/__init__.py Outdated
@@ -0,0 +1,2 @@
import examples.migration_model.tools

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment on lines +377 to +380
self.calculate_ice_cost()
self.calculate_ev_cost()
self.compute_utility()
self.make_decision()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment on lines +93 to +96
energy = agent.battery_capacity - agent.battery_level
cost = energy * station.price_per_kwh

agent.battery_level = agent.battery_capacity

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment thread examples/ev_model/agent.py Outdated
Comment on lines +268 to +271
if len(neighbors) == 0:
return 0

return ev_neighbors / len(neighbors)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@niteshver

Copy link
Copy Markdown
Contributor Author

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!

@wang-boyu wang-boyu added the example Release notes label label Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

example Release notes label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants