|
1 | 1 | # PandaModelsBackend |
2 | 2 | Provides a high fidelity backend for grid2op that uses PowerModels.jl. It achieves this using pandapower interface that calls PandaModels using PyCall to call julia functions from python. |
3 | 3 |
|
4 | | -## Prerequisites |
5 | | -1. Julia |
6 | | -2. Julia Packages |
7 | | - - PowerModels.jl |
8 | | - - PandaModels.js |
9 | | - - PyCall |
10 | | -3. Configuring PyCall for python |
11 | | - |
12 | 4 | ## Installation |
13 | 5 | ```pip install pandamodelsbackend``` |
14 | 6 |
|
15 | | -## |
| 7 | +## Refer to [tests/test_basic_usage.py]() |
| 8 | + |
| 9 | +``` |
| 10 | +from PandaModelsBackend import PandaModelsBackend |
| 11 | +
|
| 12 | +pp_net = pp.from_json(network_file) # Load PandaPower JSON |
| 13 | +. |
| 14 | +. |
| 15 | +backend = PandaModelsBackend(pp_net) |
| 16 | +env = grid2op.make(env_name, backend=backend) |
| 17 | +. |
| 18 | +``` |
| 19 | + |
| 20 | +## Setting up dev environment |
| 21 | + |
| 22 | +### Using python virtual environment |
| 23 | + |
| 24 | +- Create a python virtual environment |
| 25 | +```python3 -m venv venv``` |
| 26 | + |
| 27 | + - If you don't have virtual env installed refer to this [link](https://www.geeksforgeeks.org/python-virtual-environment/) |
| 28 | + |
| 29 | + - To activate your environment: |
| 30 | + ```source venv/bin/activate``` |
| 31 | + |
| 32 | + - Install grid2op, pandapower |
| 33 | + ```pip install grid2op pandapower``` |
| 34 | + ```pip install julia``` |
| 35 | + |
| 36 | +- Julia Installation refer to [this](https://docs.julialang.org/en/v1/manual/installation/)] |
| 37 | + |
| 38 | + - set your path variable to find Julia e.g., on MAC |
| 39 | + ```export PATH=/Applications/Julia-1.11.app/Contents/Resources/julia/bin:$PATH``` |
| 40 | + |
| 41 | + - Add PowerModels, PandaModels Packages in Julia |
| 42 | + Run Juila on command prompt. Access the package manager in julia by typing ]. Now install the packages: add Ipopt PowerModels. |
| 43 | + |
| 44 | + - Build PyCall: The library PyCall allows to use Python from inside julia. By default, PyCall uses the Conda.jl package to install a Miniconda distribution private to Julia. To use an already installed Python distribution (e.g. Anaconda), set the PYTHON environment variable inside the Julia prompt. |
| 45 | + |
| 46 | + Find path to your python in venv: |
| 47 | + ```which python``` |
| 48 | + e.g., <your python path> - <your venv folder>/bin/python |
| 49 | + |
| 50 | + On MacOS: |
| 51 | + ```ENV["PYTHON"]="<your python path>"``` |
| 52 | + |
| 53 | + Access the package manager again in julia by typing ]. Now install the packages: ```add PyCall```. To pass the python environment variable, running build PyCall inside the julia package manager may be necessary. |
| 54 | + |
| 55 | +### Using Conda |
| 56 | +[TODO] |
| 57 | + |
| 58 | +## Build |
| 59 | +``` |
| 60 | +git clone https://github.com/gt-sse-center/PandaModelsBackend.git |
| 61 | +cd PandaModelBackend.git |
| 62 | +python3 -m build |
| 63 | +pip install -e . |
| 64 | +``` |
| 65 | + |
| 66 | +## Test |
| 67 | +``` |
| 68 | +cd tests |
| 69 | +python test_backend_api.py |
| 70 | +``` |
0 commit comments