# OpenDC EEMM

**OpenDC Extension for Energy Modelling & Management**

![version](https://img.shields.io/badge/version-0.0.1-blue) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![doc](https://readthedocs.org/projects/opendc-eemm/badge/?version=latest)](https://opendc-eemm.readthedocs.io/en/latest/?badge=latest) [![travis](https://img.shields.io/travis/hongyuhe/opendc-eemm.svg)](https://travis-ci.com/hongyuhe/opendc-eemm) [![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://GitHub.com/hongyuhe/opendc-eemm/graphs/commit-activity)[![Percentage of issues still open](http://isitmaintained.com/badge/open/Naereen/badges.svg)](http://isitmaintained.com/project/Naereen/badges "Percentage of issues still open") [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)

<!-- [![made-with-python](https://img.shields.io/badge/Made%20with-Python-1f425f.svg)](https://www.python.org/) -->


![pypi](https://img.shields.io/pypi/v/opendc-eemm/0.0.3.svg)

[![Info](https://img.shields.io/badge/Project-Info-blue?style=flat-square&logo=data:image/svg%2bxml;base64, )](https://opendc-eemm.rtfd.io)

Document: <https://opendc-eemm.rtfd.io>.

---

## Get Started

First, you need to download market data in CSV format from the following offical websites:

* Day-ahead market data: [ENTSO-E](https://transparency.entsoe.eu/dashboard/show)
* Imbance market data: [TenT](https://www.tennet.org/english/operational_management/System_data_relating_processing/settlement_prices/index.aspx#PanelTabTable)

Note that data from ENTSO-E is in CET, whilst data from TenT is in GMT. Please make sure that all market data you selected are of the same period. The `./example/market/` directory contains two such sample datasets. 

Next, to run the example, you also need the simulation results produced by the [OpenDC datacenter simulator](https://opendc.org/). A sample parque file can be found [here](https://drive.google.com/file/d/1o4l8nzcxPXuHuc_qQ23eMiXJypyH4BPF/view?usp=sharing).

## Installation

Please follow the instructions presented [here](https://opendc-eemm.rtfd.io/en/latest/installation.html).

## Usage

### Top-level commands
```shell
usage: opendc-eemm [-v] [-h] -t path [--pue float] {trace,market,decision} ...

CLI of OpenDC Extension for Energy Modelling & Managament.

optional arguments:
  -v, --version         Show version number of the package and exit.
  -h, --help            Show the help messages and exit.
  -t path, --trace path
                        Path to simulation results (expecting a Parque file).
  --pue float           PUE value of the simulatied datacenter.

subcommands:
  Available commands.

  {trace,market,decision}
    trace               Visualize simulation results.
    market              Compare costs in different markets.
    decision            Optimize fine-grained decision-making.
```

### Visualize simulation results

```shell
usage: opendc-eemm trace [-h] -s ['power', 'oc'] [-f float] [-g value]

optional arguments:
  -s ['power', 'oc'], --show ['power', 'oc']
                        Choose 'power' to show power draw; choose 'oc' to show over-commissioned.
  -f float, --frequency float
                        Frequency of simulated machines.
  -g value, --governor value
                        Governor to visualize.
```

### Analyze energy markets

```shell
usage: opendc-eemm market [-h] -s ['load', 'strategy'] -o float -d path -i path

optional arguments:
  -s ['load', 'strategy'], --show ['load', 'strategy']
  -o float, --od_price float
                        On-demand energy price.
  -d path, --dayahead_prices path
                        Path to day-ahead energy prices (expecting a CSV file).
  -i path, --imbalance_prices path
                        Path to imbalance energy prices (expecting a CSV file).
```

### Invoke DVFS scheduler

```shell
usage: opendc-eemm decision [-h] -o ['score', 'schedule'] [-f float] -d path -i path -p path -a ['first', 'last', 'mean'] [-s path]

optional arguments:
  -o ['score', 'schedule'], --option ['score', 'schedule']
                        Choose 'score' to compute the agreement accuracy (AA) sore of the predictions; choose 'schedule' for DVFS
                        scheduling.
  -f float, --factor float
                        Damping factor of the DVFS scheduler.
  -d path, --dayahead_prices path
                        Path to day-ahead energy prices (expecting a CSV file).
  -i path, --imbalance_prices path
                        Path to imbalance energy prices (expecting a CSV file).
  -p path, --predictions path
                        Machine learning predictions (expecting a CSV file).
  -a ['first', 'last', 'mean'], --aggregate ['first', 'last', 'mean']
                        Aggregation method for machine learning predictions.
  -s path, --save_to path
                        Destination path of the DVFS schedule.
```

