Skip to content

Latest commit

ย 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Simulation-Integrated Multi-AI Agent Energy Platform (Demo)

Python Streamlit Plotly PuLP License

HILS + Multi-Agent + Hybrid AI + MCP Runtime based Energy Management Visualization Demo

๐Ÿ‡ฐ๐Ÿ‡ท ํ”„๋กœ์ ํŠธ ๊ฐœ์š” โ€” HILS(Hardware-in-the-Loop Simulation) ๊ธฐ๋ฐ˜ ๊ฐ€์ƒ EMS ํ™˜๊ฒฝ์—์„œ 6๊ฐœ์˜ AI ์—์ด์ „ํŠธ(Forecaster, Optimizer, Scheduler, FaultDetection, HILSCoach, Orchestrator)๊ฐ€ ๊ณต์œ  ์ปจํ…์ŠคํŠธ(MCP) ์œ„์—์„œ ํ˜‘์—…ํ•˜๋ฉฐ PV/ESS/EV ๋“ฑ ๋ถ„์‚ฐ์ „์›(DER)์„ ์ตœ์  ์šด์˜ํ•˜๋Š” ๊ณผ์ •์„ ์‹œ๊ฐํ™”ํ•˜๋Š” ์—๋„ˆ์ง€ ๊ด€๋ฆฌ ๋ฐ๋ชจ ํ”Œ๋žซํผ์ž…๋‹ˆ๋‹ค. ์‹ค์ œ EMS ์—†์ด๋„ Streamlit ๋Œ€์‹œ๋ณด๋“œ์—์„œ ์—๋„ˆ์ง€ ์ตœ์ ํ™” AI์˜ ๋™์ž‘ ์›๋ฆฌ๋ฅผ ์ง๊ด€์ ์œผ๋กœ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๐Ÿ“ธ Screenshots

Main Dashboard

Main Dashboard Real-time HILS energy simulation with 6 AI agents status monitoring

Hybrid AI Architecture

Hybrid AI Architecture ML + Rule-based + LLM three-tier architecture visualization

Agent Collaboration Timeline

Agent Collaboration Multi-agent decision flow and collaboration patterns

Agent Execution Distribution

Agent Execution Count Activity distribution across different AI agents

Hybrid AI Insights

Hybrid AI Insights Real-time insights from ML Optimizer, Rule-based Forecaster, and LLM Analyst

MCP Context Flow

MCP Context Flow Context server data flow showing shared state across agents


๐ŸŽฏ Project Purpose

This project is a demonstration platform showcasing advanced energy management technologies:

  • HILS (Hardware-in-the-Loop Simulation) based closed-loop simulator
  • ML + LLM Hybrid AI agent architecture
  • Multi-Agent Collaboration framework
  • MCP (Model Context Protocol) based Context server structure
  • DER (PV/ESS/EV) management and optimization workflow visualization
  • Real-time visualization with Streamlit UI

Core Concept: A demo UI that visually demonstrates how energy optimization AI works without requiring an actual EMS system

๐Ÿ› ๏ธ Tech Stack

Category Tech Purpose
Language Python ์ „์ฒด ์‹œ์Šคํ…œ ๊ตฌํ˜„
Web UI Streamlit ์‹ค์‹œ๊ฐ„ ๋Œ€์‹œ๋ณด๋“œ
Visualization Plotly ์—๋„ˆ์ง€ ์ฐจํŠธ/๊ทธ๋ž˜ํ”„
Optimization PuLP ESS ์ถฉ๋ฐฉ์ „ MILP ์ตœ์ ํ™”
Simulation SimPy 4.1+ ยท NumPy 1.26+ ยท Pandas 2.2+ HILS ์‹œ๋ฎฌ๋ ˆ์ด์…˜ & ๋ฐ์ดํ„ฐ ์ฒ˜๋ฆฌ
Testing pytest 7.4+ ๋‹จ์œ„ ํ…Œ์ŠคํŠธ (17๊ฐœ, 100% ํ†ต๊ณผ)
License Custom License ๊ฐœ์ธ/๊ต์œก์šฉ ๋ฌด๋ฃŒ, ์ƒ์—…์šฉ ๋ผ์ด์„ ์Šค ํ•„์š”

๐Ÿ“ Project Structure

smartEMS-MultiAgent-Demo/
โ”œโ”€โ”€ app.py                          # Main Streamlit application entry point
โ”œโ”€โ”€ requirements.txt                # Python dependencies
โ”œโ”€โ”€ README.md                       # Project documentation
โ”‚
โ”œโ”€โ”€ src/                            # Source code directory
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ agents/                     # AI agent modules
โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”‚   โ””โ”€โ”€ agents.py               # All AI agents (Forecaster, Optimizer, etc.)
โ”‚   โ”œโ”€โ”€ core/                       # Core system components
โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”‚   โ”œโ”€โ”€ simulator.py            # HILS-based simulator
โ”‚   โ”‚   โ””โ”€โ”€ mcp_core.py             # MCP Runtime (Context + Orchestration)
โ”‚   โ””โ”€โ”€ ui/                         # UI components
โ”‚       โ”œโ”€โ”€ __init__.py
โ”‚       โ”œโ”€โ”€ ui_components.py        # Reusable UI components (charts, cards, logs)
โ”‚       โ”œโ”€โ”€ hybrid_ai_ui.py         # Hybrid AI + Collaboration visualization
โ”‚       โ””โ”€โ”€ utils.py                # Utility functions (logging, state management)
โ”‚
โ””โ”€โ”€ tests/                          # Test directory
    โ”œโ”€โ”€ __init__.py
    โ””โ”€โ”€ test_system.py              # Unit tests (17 tests, 100% pass rate)

๐Ÿ”„ System Workflow

[HILS Simulator] 
    โ†“ Calculate and generate ESS/PV/Load values
[MCP Runtime]
    โ†“ Update context (time, ess_level, pv_output, load, price, etc.)
[Multi-AI Agents]
    โ”œโ”€ Forecaster: Load/weather prediction
    โ”œโ”€ Optimizer: MILP optimization
    โ”œโ”€ Scheduler: Charge/discharge policy determination
    โ”œโ”€ Fault Detection: Anomaly detection
    โ”œโ”€ Orchestrator: Agent invocation order management
    โ””โ”€ HILS Coach: HILS learning/tuning parameter calculation
[UI / Visualization]
    โ””โ”€ Real-time energy graphs + Agent status dashboard + Log stream

๐Ÿ—๏ธ Core Technology Components

  1. HILS-based Closed-loop Structure: Real-time feedback loop for control algorithm verification
  2. ML + LLM Hybrid AI Agents: Combination of rule-based + optimization + LLM-style analysis
  3. Multi-Agent Collaboration: 6 agents collaborating through shared context
  4. Context Server-based MCP Structure: Platform for sharing state/history between agents
  5. DER Control Flow: Integrated optimization of PV/ESS/EV
  6. Extensible Tool Gateway Structure: Support for Modbus/OPC-UA integration (mocked in demo)

๐Ÿš€ Quick Start

Installation

git clone https://github.com/lhg96/smartEMS-MultiAgent-Demo.git
cd smartEMS-MultiAgent-Demo

# (์„ ํƒ) ๊ฐ€์ƒ ํ™˜๊ฒฝ ์ƒ์„ฑ
python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate

pip install -r requirements.txt

Execution

streamlit run app.py

Browser will automatically open at http://localhost:8501

Testing

python -m pytest tests/test_system.py -v

All tests passing: 17/17 โœ…

๐Ÿค– Agent Architecture

6 Core Agents

Agent Role Technology
ForecasterAgent Load/weather prediction Stochastic modeling
OptimizerAgent ESS charge/discharge optimization MILP (PuLP) / Heuristic fallback
SchedulerAgent Charge/discharge scheduling Rule-based + SoC/ToU
FaultDetectionAgent PV/ESS anomaly detection Threshold-based detection
HILSCoachAgent Learning parameter adjustment Adaptive parameter tuning
OrchestratorAgent Agent invocation management Orchestration pattern

Hybrid AI Structure

  • ML-based: MILP optimization (Optimizer)
  • Rule-based: Scheduling, anomaly detection
  • LLM-like: MockLLMAgent (strategic analysis)

๐ŸŽจ UI Structure

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Sidebar: Simulation Control                    โ”‚
โ”‚  - Scenario selection                           โ”‚
โ”‚  - Step length / speed adjustment               โ”‚
โ”‚  - Start / Stop buttons                         โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Left: HILS Simulation โ”‚  Right Top: Agent Statusโ”‚
โ”‚  - ESS SOC graph       โ”‚  - 6 agent cards        โ”‚
โ”‚  - PV Output           โ”‚  - Status icons         โ”‚
โ”‚  - Load                โ”‚                         โ”‚
โ”‚                        โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                        โ”‚  Right Bottom: Live Logsโ”‚
โ”‚                        โ”‚  - Step-by-step metrics โ”‚
โ”‚                        โ”‚  - CSV download         โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Hybrid AI + Multi-Agent Collaboration Demo     โ”‚
โ”‚  โ”œโ”€ Tab 1: Hybrid AI Architecture               โ”‚
โ”‚  โ”‚   - ML / Rule-based / LLM 3-tier visualizationโ”‚
โ”‚  โ”‚   - Agent Decision Comparison Table          โ”‚
โ”‚  โ”‚   - Hybrid AI Insights Panel                 โ”‚
โ”‚  โ”œโ”€ Tab 2: Agent Collaboration                  โ”‚
โ”‚  โ”‚   - Multi-Agent Decision Timeline Graph      โ”‚
โ”‚  โ”‚   - Agent Activity Distribution Pie Chart    โ”‚
โ”‚  โ””โ”€ Tab 3: MCP Context Flow                     โ”‚
โ”‚      - MCP Context Updates (recent 5 steps)     โ”‚
โ”‚      - Context Server role explanation          โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ“Š Key Features

Simulation Control

  • 3 Scenarios: Baseline / High Price Late Peak / Volatile Market
  • Customization: Step length (5-60), speed (0.2-2.0s), price flip ratio
  • Reproducibility: Fixed seed option

Real-time Monitoring

  • Energy Charts: ESS SOC, PV, Load (Plotly spline curves)
  • Agent Status: Color coding (โœ…๐ŸŸข๐ŸŸกโš ๏ธโŒ)
  • Live Logs: Scrollable + CSV download
  • Metrics: Real-time ESS/PV/Load/Price display

Hybrid AI Demo (New)

  • AI Architecture Visualization: ML/Rule-based/LLM 3-tier structure
  • Agent Decision Comparison: AI type and recent decisions table for each agent
  • Collaboration Timeline: Multi-agent decision flow graph
  • Activity Distribution: Agent call count pie chart
  • MCP Context Flow: Context server data flow visualization
  • Hybrid AI Insights: Recent judgments from ML/Rule/LLM layers

๐Ÿ”ง Code Quality

Documentation

  • โœ… All modules/functions have docstrings
  • โœ… Type hints
  • โœ… Detailed comments

Error Handling

  • โœ… Try-except blocks
  • โœ… Logging system
  • โœ… Graceful degradation

Testing

  • โœ… 17 unit tests
  • โœ… 100% pass rate
  • โœ… Integration tests

๐Ÿ“š Module Roles

src/core/simulator.py

  • ESS charge level simulation
  • PV output random modeling
  • Load modeling
  • HILS feedback loop support

src/core/mcp_core.py

  • Shared context storage for entire system
  • Agent invocation and coordination (orchestrate())
  • MCP-like structure for state sharing between agents

src/agents/agents.py

  • Implementation of 6 agents
  • Hybrid AI structure (ML + Rule + LLM-like)
  • Context-based collaboration

src/ui/ui_components.py

  • Reusable UI components
  • Charts, status cards, logs, metrics

src/ui/hybrid_ai_ui.py

  • Hybrid AI architecture visualization
  • Multi-agent collaboration timeline
  • MCP context flow display

src/ui/utils.py

  • Log formatting
  • Session state management
  • Helper functions

๐Ÿ› Troubleshooting

PuLP Optimization Error

pip install pulp

Streamlit Port Conflict

streamlit run app.py --server.port 8502

Test Failures

pip install -r requirements.txt --force-reinstall
python -m pytest tests/test_system.py -v

๐Ÿ“ Development Guide

Adding a New Agent

  1. Add new Agent class to src/agents/agents.py
  2. Inherit from BaseAgent and implement run() method
  3. Add to agent dictionary in app.py
  4. Add tests to tests/test_system.py

Adding New UI Components

  1. Create component function in src/ui/ui_components.py or src/ui/hybrid_ai_ui.py
  2. Import and use in app.py
  3. Follow existing naming conventions (render_* functions)

Project Structure Guidelines

  • src/agents/: All AI agent implementations
  • src/core/: Core business logic (simulator, MCP)
  • src/ui/: All UI-related components and utilities
  • tests/: All test files with test_ prefix
  • Keep app.py as the main entry point, import from src/

UI ์ˆ˜์ • ์‹œ

  • ์ขŒ์ธก ๊ทธ๋ž˜ํ”„: ui_components.py โ†’ render_energy_chart()
  • ์—์ด์ „ํŠธ ์นด๋“œ: ui_components.py โ†’ render_agent_status_cards()
  • ๋กœ๊ทธ: ui_components.py โ†’ render_live_logs()

๐ŸŽ“ ํ•™์Šต ์ˆœ์„œ

  1. README.md ์ฝ๊ธฐ โ†’ ์ „์ฒด ๊ฐœ๋… ํŒŒ์•…
  2. simulator.py ๋ณด๊ธฐ โ†’ HILS ์‹œ๋ฎฌ๋ ˆ์ด์…˜ ๋กœ์ง
  3. src/agents/agents.py - Understand each agent's role
  4. src/core/mcp_core.py - Check MCP orchestration
  5. app.py - Run and explore UI functionality

๐Ÿ“„ License

Custom License - Free for Personal Use, Commercial License Required

This software is free to use for personal, educational, and non-commercial purposes. Commercial use requires a separate license agreement.

  • โœ… Free: Personal use, education, research
  • โŒ Requires License: Commercial use, production deployment, integration into commercial products

For commercial licensing inquiries, please contact: hyun.lim@okkorea.net


๐Ÿ“ž Contact & Services

Development Consulting & Outsourcing Available

We provide professional consulting and development services for IoT, AI, and embedded systems projects.

๐Ÿ‘จโ€๐Ÿ’ผ Project Manager Contact

๐Ÿ› ๏ธ Technical Expertise / ๊ธฐ์ˆ  ์ „๋ฌธ ๋ถ„์•ผ

  • IoT System Design and Development / IoT ์‹œ์Šคํ…œ ์„ค๊ณ„ ๋ฐ ๊ฐœ๋ฐœ
  • Embedded Software Development / ์ž„๋ฒ ๋””๋“œ ์†Œํ”„ํŠธ์›จ์–ด ๊ฐœ๋ฐœ (Arduino, ESP32)
  • AI Service Development / AI ์„œ๋น„์Šค ๊ฐœ๋ฐœ (LLM, MCP Agent)
  • Cloud Service Architecture / ํด๋ผ์šฐ๋“œ ์„œ๋น„์Šค ๊ตฌ์ถ• (Google Cloud Platform)
  • Hardware Prototyping / ํ•˜๋“œ์›จ์–ด ํ”„๋กœํ† ํƒ€์ดํ•‘

๐Ÿ’ผ Services / ์„œ๋น„์Šค

  • Technical Consulting / ๊ธฐ์ˆ  ์ปจ์„คํŒ…

    • IoT project planning and design consultation / IoT ํ”„๋กœ์ ํŠธ ๊ธฐํš ๋ฐ ์„ค๊ณ„ ์ž๋ฌธ
    • System architecture design / ์‹œ์Šคํ…œ ์•„ํ‚คํ…์ฒ˜ ์„ค๊ณ„
  • Development Outsourcing / ๊ฐœ๋ฐœ ์™ธ์ฃผ

    • Full-stack development from firmware to cloud / ํŽŒ์›จ์–ด๋ถ€ํ„ฐ ํด๋ผ์šฐ๋“œ๊นŒ์ง€ Full-stack ๊ฐœ๋ฐœ
    • Proof of Concept (PoC) development / ๊ฐœ๋… ๊ฒ€์ฆ ๊ฐœ๋ฐœ
    • Production-ready system development / ์ƒ์šฉ ์‹œ์Šคํ…œ ๊ฐœ๋ฐœ

About

Multi-AI Agent Energy Management System with HILS simulation, Hybrid AI (ML+LLM), and MCP Runtime - Real-time visualization demo for smart grid optimization

Topics

Resources

Stars

6 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages