HILS + Multi-Agent + Hybrid AI + MCP Runtime based Energy Management Visualization Demo
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
smartEMS/
├── 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)
cd smartEMS
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 / 상용 시스템 개발