Developing AI System for Microgeneration Management
Microgeneration is solar panels, small wind turbines, and mini-CHP units at consumer premises. In Russia it has been permitted since 2021 (Federal Law 471): excess power can be sold to the grid. AI optimizes use of own generation and manages the grid connection point.
Forecasting Generation and Consumption
Microgeneration task:
Every 15 minutes the system must decide: sell excess to grid or charge BESS; buy from grid or discharge BESS. The decision depends on forecast of:
- Own generation in coming hours (sun/wind)
- Facility consumption in coming hours
- Tariff curve (differential rates: night/day/peak)
import numpy as np
import pandas as pd
from prophet import Prophet
class MicrogenerationForecaster:
"""Forecasting generation and consumption for facility with microgeneration"""
def fit_solar_model(self, historical_generation, capacity_kw):
"""Solar generation forecast using Prophet"""
df = historical_generation.reset_index()
df.columns = ['ds', 'y']
df['y'] = df['y'] / capacity_kw # normalize to capacity → capacity factor
model = Prophet(
changepoint_prior_scale=0.05,
seasonality_mode='multiplicative',
yearly_seasonality=10,
daily_seasonality=True,
weekly_seasonality=False # sun doesn't depend on day of week
)
model.fit(df)
return model
def predict_next_day(self, solar_model, load_model, weather_forecast):
"""Combined forecast for next 24 hours"""
future = solar_model.make_future_dataframe(periods=96, freq='15min')
# Add weather regressor
future = future.merge(weather_forecast[['ds', 'ghi', 'temperature']],
on='ds', how='left')
solar_forecast = solar_model.predict(future)
load_forecast = load_model.predict(future)
return pd.DataFrame({
'timestamp': future['ds'],
'solar_kw': solar_forecast['yhat'].clip(0) * self.capacity_kw,
'load_kw': load_forecast['yhat'].clip(0),
'net_kw': (solar_forecast['yhat'] - load_forecast['yhat']).clip(-self.max_load)
})
Battery Energy Storage Optimization
Charge/discharge strategy:
Stochastic optimization problem with 24–48 hour horizon:
from scipy.optimize import linprog
import numpy as np
def optimize_bess_schedule(
solar_forecast, # kW per hour
load_forecast, # kW per hour
tariff_grid_buy, # rubles/kWh per hour (grid purchase)
tariff_grid_sell, # rubles/kWh per hour (grid sale)
bess_capacity_kwh=10,
bess_max_power_kw=5,
bess_soc_init=0.5,
bess_soc_min=0.1,
bess_soc_max=0.9,
bess_efficiency=0.9
):
"""
BESS schedule optimization.
Variables: [p_charge_t, p_discharge_t, p_grid_buy_t, p_grid_sell_t] × 24h
"""
T = len(solar_forecast)
# Linear programming (LP)
# Simplification: don't account for binary constraints on simultaneous charge/discharge
# Variables: [charge[0..T], discharge[0..T], buy[0..T], sell[0..T], soc[0..T]]
n_vars = T * 4 + T # charge, discharge, buy, sell, SoC
c = np.zeros(n_vars)
# Minimize cost: purchase cost - sales revenue
for t in range(T):
c[2*T + t] = tariff_grid_buy[t] # purchase — expense
c[3*T + t] = -tariff_grid_sell[t] # sale — revenue (negative)
# Constraints (simplified)
# SoC balance, power constraints, SoC bounds
result = linprog(c, method='highs') # HiGHS solver
return result
Zero-Export Control Management
Zero-Export Control:
If grid sell tariff is unprofitable or absent — prevent grid injection:
- Forecast of excess → increase controllable load (water heater, pump, EV charging)
- When unable to absorb → reduce solar inverter power (curtailment)
- Fast control (100ms cycle): current measurement at connection point → PID control of inverter output power
Aggregation for Demand Response Programs
VPP aggregator:
Hundreds of private microgeneration units → aggregator combines into Virtual Power Plant:
- Forecast of total aggregated export
- Participation in balancing market
- Payment distribution among participants by contribution (Shapley Values)
Monitoring and Diagnostics
Panel degradation assessment:
- Monitor Performance Ratio (PR): expected vs. actual generation
- PR decline of 0.5%/year — normal; >1.5%/year — degradation or soiling
- I-V curve analysis: identification of shading, bypass diode failure
Development timeline: 2–4 months for microgeneration management system with forecasting, BESS optimization, and Zero-Export control.







