IRT-SystemX / LIPS

Mozilla Public License 2.0
28 stars 8 forks source link

LIPS - Learning Industrial Physical Simulation benchmark suite

This repository implements LIPS benchmarking platform.

Paper: https://openreview.net/pdf?id=ObD_o92z4p

The Readme file is organized as follows:

Introduction

Physical simulations are at the core of many critical industrial systems. However, today's physical simulators have some limitations such as computation time, dealing with missing or uncertain data, or even non-convergence for some feasible cases. Recently, the use of data-driven approaches to learn complex physical simulations has been considered as a promising approach to address those issues. However, this comes often at the cost of some accuracy which may hinder the industrial use.

What is LIPS

To drive the above mentioned new research topic towards a better real-world applicability, we propose a new benchmark suite "Learning Industrial Physical Simulations" (LIPS) to meet the need of developing efficient, industrial application-oriented, augmented simulators. The proposed benchmark suite is a modular and configurable framework that can deal with different physical problems. To do so, as it is depicted in the scheme, the LIPS platform is designed to be modular and includes following modules:

Scheme

Associated results

To demonstrate this ability, we propose in this paper to investigate two distinct use-cases with different physical simulations, namely: Power Grids, Pneumatics and Air Foils. For each use case, several benchmarks (aka tasks or scenarios) may be described and assessed with existing models. In the figure below, we show an example of the results obtained for a specific task associated with each use case. To ease the reading of the numerical comparison table, the performances are reported using three colors computed on the basis of two thresholds. The meaning of colors is described below:

As it can be seen, none of the models perform well under all expected criteria, inviting the community to develop new industry-applicable solutions and possibly showcase their performance publicly upon online LIPS instance on Codabench.

Results

The final score is computed on the basis of the obtained results for each metric (more information concerning the scoring algorithm will be provided).

Usage example

Instantiate a benchmark

The paths should correctly point-out to generated data (DATA_PATH) and benchmark associated config file (CONFIG_PATH). The log path (LOG_PATH) could be set by the user.

from lips.benchmark import PowerGridBenchmark

benchmark1 = PowerGridBenchmark(benchmark_name="Benchmark1",
                                benchmark_path=DATA_PATH,
                                load_data_set=True,
                                log_path=LOG_PATH,
                                config_path=CONFIG_PATH
                               )

Train a simulator

A simulator (based on tensorflow) could be instantiated and trained if required easily as follows:

from lips.augmented_simulators.tensorflow_models import TfFullyConnected
from lips.dataset.scaler import StandardScaler

tf_fc = TfFullyConnected(name="tf_fc",
                         bench_config_name="Benchmark1",
                         scaler=StandardScaler,
                         log_path=LOG_PATH)

tf_fc.train(train_dataset=benchmark1.train_dataset,
            val_dataset=benchmark1.val_dataset,
            epochs=100
           )

For each architecture a config file is attached which are available here for powergrid use case.

Reproducibility and evaluation

The following script show how to use the evaluation capacity of the platform to reproduce the results on all the datasets. A config file (see here for powergrid use case) is associated with this benchmark and all the required evaluation criteria can be set in this configuration file.

tf_fc_metrics = benchmark1.evaluate_simulator(augmented_simulator=tf_fc,
                                              eval_batch_size=128,
                                              dataset="all",
                                              shuffle=False
                                             )

Installation

To be able to run the experiments in this repository, the users should install the last lips package from its github repository. The following steps show how to install this package and its dependencies from source.

Requirements

Setup a Virtualenv (optional)

Create a Conda env (recommended)

conda create -n venv_lips python=3.10
conda activate venv_lips

Create a virtual environment

cd my-project-folder
pip3 install -U virtualenv
python3 -m virtualenv venv_lips

Enter virtual environment

source venv_lips/bin/activate

Install using Python Package Index (PyPI)

pip install "lips-benchmark[recommended]"

Install from source

git clone https://github.com/IRT-SystemX/LIPS.git
cd LIPS
pip3 install -U .[recommended]
cd ..

To contribute

pip3 install -e .[recommended]

Codabench

To see the leaderboard for benchmarking tasks, refer to the codabench page of the framework, accessible from this link.

Getting Started

Some Jupyter notebook are provided as tutorials for LIPS package. They are located in the getting_started directories.

Documentation

The documentation is accessible from here.

To generate locally the documentation:

pip install sphinx
pip install sphinx-rtd-theme
cd docs
make clean
make html

Contribution

FAQ

Pytorch

To be able to use the torch library with GPU, you should consider multiple factors:

torch_sim = TorchSimulator(name="torch_fc", model=TorchFullyConnected, scaler=StandardScaler, device="cuda:0", )


* Otherwise, if you want use only CPU for the training of augmented simulators, you could simply use the version installed following the the requirements and set the device parameter to `cpu` when training as follows:
```python
torch_sim = TorchSimulator(name="torch_fc",
                           model=TorchFullyConnected,
                           scaler=StandardScaler,
                           device="cpu",
                          )

Tensorflow

To be able to use Tensorflow, you should already install a cuda compatible version with your tensorflow package. From Tensorflow 2.4 the cuda version >= 11.0 is required. Once you have get and installed cuda driver (we recommend version 11.5) from here, you should also get corresponding cuDNN package from here and copy the contents in corresponding folders in cuda installation directory. Finally, you should set some environment variables which are discussed in this link for both linux and windows operating systems. For windiows you can do the following in command line:

SET PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\bin;%PATH%
SET PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\extras\CUPTI\lib64;%PATH%
SET PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\include;%PATH%
SET PATH=C:\tools\cuda\bin;%PATH%
SET LD_LIBRARY_PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\lib\x64

However, after setting variables if you encounter some *.dll not found when importing tensorflow library, you could indicating the path to cuda installation in your code before importing tensorflow package as follows:

import os
os.add_dll_directory("C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.5/bin")

And then you can test your installation by running:

import tensorflow as tf
tf.config.list_physical_devices()

Where in its output the GPU device should be appeared as following:

[PhysicalDevice(name='/physical_device:CPU:0', device_type='CPU'),
 PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]

License information

Copyright 2022-2023 IRT SystemX & RTE

IRT SystemX: https://www.irt-systemx.fr/
RTE: https://www.rte-france.com/

This Source Code is subject to the terms of the Mozilla Public License (MPL) v2 also available here

Citation

@article{leyli2022lips,
    title={LIPS-Learning Industrial Physical Simulation benchmark suite},
    author={M. Leyli-Abadi, and A. Marot, Antoine and J. Picault, and D. Danan and M. Yagoubi, B. Donnot, S. Attoui, P. Dimitrov, A. Farjallah, C. Etienam},
    journal={Advances in Neural Information Processing Systems},
    volume={35},
    pages={28095--28109},
    year={2022}
}