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์ ๋์ ์๋ฆฌ๋ฅผ ์ง๊ด์ ์ผ๋ก ํ์ธํ ์ ์์ต๋๋ค.
Real-time HILS energy simulation with 6 AI agents status monitoring
ML + Rule-based + LLM three-tier architecture visualization
Multi-agent decision flow and collaboration patterns
Activity distribution across different AI agents
Real-time insights from ML Optimizer, Rule-based Forecaster, and LLM Analyst
Context server data flow showing shared state across agents
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
| Category | Tech | Purpose |
|---|---|---|
| Language | ์ ์ฒด ์์คํ ๊ตฌํ | |
| Web UI | ์ค์๊ฐ ๋์๋ณด๋ | |
| Visualization | ์๋์ง ์ฐจํธ/๊ทธ๋ํ | |
| Optimization | ESS ์ถฉ๋ฐฉ์ MILP ์ต์ ํ | |
| Simulation | SimPy 4.1+ ยท NumPy 1.26+ ยท Pandas 2.2+ | HILS ์๋ฎฌ๋ ์ด์ & ๋ฐ์ดํฐ ์ฒ๋ฆฌ |
| Testing | pytest 7.4+ | ๋จ์ ํ ์คํธ (17๊ฐ, 100% ํต๊ณผ) |
| License | Custom License | ๊ฐ์ธ/๊ต์ก์ฉ ๋ฌด๋ฃ, ์์ ์ฉ ๋ผ์ด์ ์ค ํ์ |
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)[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
- HILS-based Closed-loop Structure: Real-time feedback loop for control algorithm verification
- ML + LLM Hybrid AI Agents: Combination of rule-based + optimization + LLM-style analysis
- Multi-Agent Collaboration: 6 agents collaborating through shared context
- Context Server-based MCP Structure: Platform for sharing state/history between agents
- DER Control Flow: Integrated optimization of PV/ESS/EV
- Extensible Tool Gateway Structure: Support for Modbus/OPC-UA integration (mocked in demo)
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.txtstreamlit run app.pyBrowser will automatically open at http://localhost:8501
python -m pytest tests/test_system.py -vAll tests passing: 17/17 โ
| 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 |
- ML-based: MILP optimization (Optimizer)
- Rule-based: Scheduling, anomaly detection
- LLM-like: MockLLMAgent (strategic analysis)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ 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 โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
- 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
- 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
- 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
- โ All modules/functions have docstrings
- โ Type hints
- โ Detailed comments
- โ Try-except blocks
- โ Logging system
- โ Graceful degradation
- โ 17 unit tests
- โ 100% pass rate
- โ Integration tests
- ESS charge level simulation
- PV output random modeling
- Load modeling
- HILS feedback loop support
- Shared context storage for entire system
- Agent invocation and coordination (
orchestrate()) - MCP-like structure for state sharing between agents
- Implementation of 6 agents
- Hybrid AI structure (ML + Rule + LLM-like)
- Context-based collaboration
- Reusable UI components
- Charts, status cards, logs, metrics
- Hybrid AI architecture visualization
- Multi-agent collaboration timeline
- MCP context flow display
- Log formatting
- Session state management
- Helper functions
pip install pulpstreamlit run app.py --server.port 8502pip install -r requirements.txt --force-reinstall
python -m pytest tests/test_system.py -v- Add new Agent class to
src/agents/agents.py - Inherit from
BaseAgentand implementrun()method - Add to agent dictionary in
app.py - Add tests to
tests/test_system.py
- Create component function in
src/ui/ui_components.pyorsrc/ui/hybrid_ai_ui.py - Import and use in
app.py - Follow existing naming conventions (render_* functions)
src/agents/: All AI agent implementationssrc/core/: Core business logic (simulator, MCP)src/ui/: All UI-related components and utilitiestests/: All test files withtest_prefix- Keep
app.pyas the main entry point, import fromsrc/
- ์ข์ธก ๊ทธ๋ํ:
ui_components.pyโrender_energy_chart() - ์์ด์ ํธ ์นด๋:
ui_components.pyโrender_agent_status_cards() - ๋ก๊ทธ:
ui_components.pyโrender_live_logs()
- README.md ์ฝ๊ธฐ โ ์ ์ฒด ๊ฐ๋ ํ์
- simulator.py ๋ณด๊ธฐ โ HILS ์๋ฎฌ๋ ์ด์ ๋ก์ง
- src/agents/agents.py - Understand each agent's role
- src/core/mcp_core.py - Check MCP orchestration
- app.py - Run and explore UI functionality
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
We provide professional consulting and development services for IoT, AI, and embedded systems projects.
- Email: hyun.lim@okkorea.net
- Homepage: https://www.okkorea.net
- LinkedIn: https://www.linkedin.com/in/aionlabs/
- 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 / ํ๋์จ์ด ํ๋กํ ํ์ดํ
-
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 / ์์ฉ ์์คํ ๊ฐ๋ฐ