A Physics-Informed Foundation Model for Multi-Task Energy Forecasting
See the code
GridFM is a physics-informed foundation model designed for multi-task energy forecasting using real-time data from Independent System Operators (ISOs). It combines pre-trained time series foundation models with domain-specific adaptations that respect power system physics.
GridFM achieves state-of-the-art performance on NYISO, PJM, and CAISO datasets:
| Task | MAPE | Improvement vs. Fine-tuned Baseline |
|---|---|---|
| Load Forecasting | 2.14% Β± 0.05% | 10.1% |
| Price Forecasting | 7.80% Β± 0.31% | 15.9% |
| Emission Prediction | 4.73% Β± 0.18% | 14.3% |
| Renewable Generation | 8.92% Β± 0.42% | 12.7% |
# Clone the repository
git clone https://github.com/GridFM/GridFM.git
cd GridFM
# Create conda environment
conda create -n gridfm python=3.10
conda activate gridfm
# Install dependencies
pip install -r requirements.txt
# Install GridFM
pip install -e .
from gridfm import GridFM
from gridfm.data import NYISODataLoader
# Load pre-trained model
model = GridFM.from_pretrained("gridfm-base-nyiso")
# Load data
dataloader = NYISODataLoader(
start_date="2023-01-01",
end_date="2023-12-31",
zones=["WEST", "CENTRL", "NORTH"]
)
# Generate forecasts
forecasts = model.predict(
dataloader,
horizon=24, # 24 steps ahead (2 hours at 5-min resolution)
tasks=["load", "lbmp", "emissions"]
)
# Access results
print(f"Load MAPE: {forecasts.metrics['load_mape']:.2f}%")
from gridfm import GridFM, GridFMConfig
from gridfm.training import Trainer
# Configure model
config = GridFMConfig(
backbone="moirai-moe-base",
num_zones=11,
hidden_dim=256,
num_freq_components=64,
physics_weight=0.1,
coupling_weight=0.05
)
# Initialize model
model = GridFM(config)
# Train
trainer = Trainer(
model=model,
train_dataloader=train_loader,
val_dataloader=val_loader,
learning_rate=1e-4,
num_epochs=100
)
trainer.train()
GridFM/
βββ gridfm/ # Main package
β βββ models/ # Model architectures
β β βββ gridfm.py # Main GridFM model
β β βββ backbone.py # Foundation model backbone
β β βββ task_heads.py # Task-specific output heads
β βββ layers/ # Custom layers
β β βββ freqmixer.py # FreqMixer adaptation layer
β β βββ gcn.py # Graph convolutional network
β β βββ attention.py # Attention mechanisms
β βββ physics/ # Physics constraints
β β βββ power_balance.py # Power balance equations
β β βββ dc_power_flow.py # DC power flow approximation
β βββ data/ # Data loading utilities
β β βββ nyiso.py # NYISO data loader
β β βββ pjm.py # PJM data loader
β β βββ caiso.py # CAISO data loader
β βββ utils/ # Utility functions
βββ configs/ # Configuration files
βββ scripts/ # Training and evaluation scripts
βββ examples/ # Example notebooks
βββ docs/ # Documentation
βββ paper/ # Paper and supplementary materials
βββ tests/ # Unit tests
GridFM uses YAML configuration files. Example:
# configs/gridfm_nyiso.yaml
model:
backbone: moirai-moe-base
hidden_dim: 256
num_freq_components: 64
freq_delta: 2
physics:
enable_power_balance: true
enable_dc_power_flow: true
physics_weight: 0.1
training:
batch_size: 32
learning_rate: 1e-4
num_epochs: 100
early_stopping_patience: 10
To reproduce the results from our paper:
# Download and preprocess data
python scripts/download_data.py --iso nyiso --start 2019-01-01 --end 2023-12-31
# Train model
python scripts/train.py --config configs/gridfm_nyiso.yaml
# Evaluate
python scripts/evaluate.py --checkpoint checkpoints/best_model.pt --test_year 2023
# Generate figures
python scripts/generate_figures.py --results results/evaluation/
# Run all tests
pytest tests/
# Run specific test module
pytest tests/test_freqmixer.py -v
# Run with coverage
pytest --cov=gridfm tests/
If you use GridFM in your research, please cite our paper:
@article{gridfm2024,
title={GridFM: A Physics-Informed Foundation Model for Multi-Task Energy Forecasting Using Real-Time NYISO Data},
author={Sayghe, Ali},
journal={MDPI Energies},
year={2024}
}
We welcome contributions! Please see our Contributing Guide for details.
git checkout -b feature/amazing-feature)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)This project is licensed under the MIT License - see the LICENSE file for details.
For questions or feedback, please open an issue or contact [[email protected]].
Made with β€οΈ for sustainable energy systems
A Physics-Informed Foundation Model for Multi-Task Energy Forecasting
See the code
GridFM is a physics-informed foundation model designed for multi-task energy forecasting using real-time data from Independent System Operators (ISOs). It combines pre-trained time series foundation models with domain-specific adaptations that respect power system physics.
GridFM achieves state-of-the-art performance on NYISO, PJM, and CAISO datasets:
| Task | MAPE | Improvement vs. Fine-tuned Baseline |
|---|---|---|
| Load Forecasting | 2.14% Β± 0.05% | 10.1% |
| Price Forecasting | 7.80% Β± 0.31% | 15.9% |
| Emission Prediction | 4.73% Β± 0.18% | 14.3% |
| Renewable Generation | 8.92% Β± 0.42% | 12.7% |
# Clone the repository
git clone https://github.com/GridFM/GridFM.git
cd GridFM
# Create conda environment
conda create -n gridfm python=3.10
conda activate gridfm
# Install dependencies
pip install -r requirements.txt
# Install GridFM
pip install -e .
from gridfm import GridFM
from gridfm.data import NYISODataLoader
# Load pre-trained model
model = GridFM.from_pretrained("gridfm-base-nyiso")
# Load data
dataloader = NYISODataLoader(
start_date="2023-01-01",
end_date="2023-12-31",
zones=["WEST", "CENTRL", "NORTH"]
)
# Generate forecasts
forecasts = model.predict(
dataloader,
horizon=24, # 24 steps ahead (2 hours at 5-min resolution)
tasks=["load", "lbmp", "emissions"]
)
# Access results
print(f"Load MAPE: {forecasts.metrics['load_mape']:.2f}%")
from gridfm import GridFM, GridFMConfig
from gridfm.training import Trainer
# Configure model
config = GridFMConfig(
backbone="moirai-moe-base",
num_zones=11,
hidden_dim=256,
num_freq_components=64,
physics_weight=0.1,
coupling_weight=0.05
)
# Initialize model
model = GridFM(config)
# Train
trainer = Trainer(
model=model,
train_dataloader=train_loader,
val_dataloader=val_loader,
learning_rate=1e-4,
num_epochs=100
)
trainer.train()
GridFM/
βββ gridfm/ # Main package
β βββ models/ # Model architectures
β β βββ gridfm.py # Main GridFM model
β β βββ backbone.py # Foundation model backbone
β β βββ task_heads.py # Task-specific output heads
β βββ layers/ # Custom layers
β β βββ freqmixer.py # FreqMixer adaptation layer
β β βββ gcn.py # Graph convolutional network
β β βββ attention.py # Attention mechanisms
β βββ physics/ # Physics constraints
β β βββ power_balance.py # Power balance equations
β β βββ dc_power_flow.py # DC power flow approximation
β βββ data/ # Data loading utilities
β β βββ nyiso.py # NYISO data loader
β β βββ pjm.py # PJM data loader
β β βββ caiso.py # CAISO data loader
β βββ utils/ # Utility functions
βββ configs/ # Configuration files
βββ scripts/ # Training and evaluation scripts
βββ examples/ # Example notebooks
βββ docs/ # Documentation
βββ paper/ # Paper and supplementary materials
βββ tests/ # Unit tests
GridFM uses YAML configuration files. Example:
# configs/gridfm_nyiso.yaml
model:
backbone: moirai-moe-base
hidden_dim: 256
num_freq_components: 64
freq_delta: 2
physics:
enable_power_balance: true
enable_dc_power_flow: true
physics_weight: 0.1
training:
batch_size: 32
learning_rate: 1e-4
num_epochs: 100
early_stopping_patience: 10
To reproduce the results from our paper:
# Download and preprocess data
python scripts/download_data.py --iso nyiso --start 2019-01-01 --end 2023-12-31
# Train model
python scripts/train.py --config configs/gridfm_nyiso.yaml
# Evaluate
python scripts/evaluate.py --checkpoint checkpoints/best_model.pt --test_year 2023
# Generate figures
python scripts/generate_figures.py --results results/evaluation/
# Run all tests
pytest tests/
# Run specific test module
pytest tests/test_freqmixer.py -v
# Run with coverage
pytest --cov=gridfm tests/
If you use GridFM in your research, please cite our paper:
@article{gridfm2024,
title={GridFM: A Physics-Informed Foundation Model for Multi-Task Energy Forecasting Using Real-Time NYISO Data},
author={Sayghe, Ali},
journal={MDPI Energies},
year={2024}
}
We welcome contributions! Please see our Contributing Guide for details.
git checkout -b feature/amazing-feature)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)This project is licensed under the MIT License - see the LICENSE file for details.
For questions or feedback, please open an issue or contact [[email protected]].
Made with β€οΈ for sustainable energy systems