Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update the documentation content, style and add hypertuning
- Loading branch information
Showing
25 changed files
with
203 additions
and
184 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,25 @@ | ||
# Minimal makefile for Sphinx documentation | ||
# | ||
|
||
# You can set these variables from the command line. | ||
SPHINXOPTS = | ||
SPHINXBUILD = sphinx-build | ||
SPHINXPROJ = tsam | ||
SOURCEDIR = source | ||
BUILDDIR = build | ||
# You can set these variables from the command line, and also | ||
# from the environment for the first two. | ||
SPHINXOPTS ?= | ||
SPHINXBUILD ?= sphinx-build | ||
SOURCEDIR = ./source | ||
BUILDDIR = ./build | ||
|
||
# Put it first so that "make" without argument is like "make help". | ||
help: | ||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) | ||
|
||
.PHONY: help Makefile | ||
|
||
# Build, watch and serve docs with live reload | ||
livehtml: | ||
sphinx-autobuild -b html --host 0.0.0.0 --port 7000 -c $(SOURCEDIR) $(SOURCEDIR) $(BUILDDIR)/html | ||
|
||
|
||
# Catch-all target: route all unknown targets to Sphinx using the new | ||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). | ||
%: Makefile | ||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) | ||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,85 @@ | ||
.. _getting_started: | ||
.. _start: | ||
|
||
############### | ||
******** | ||
Getting started | ||
############### | ||
******** | ||
|
||
In the following, instructions for installing and using the tsam package on Windows are given. The installation | ||
instructions for installing and using tsam on Linux/macOS systems are however quite similar and can be, hopefully | ||
easily, derived from the instructions below. | ||
**Basic Workflow** | ||
|
||
**tsam installation** | ||
A small example how tsam can be used is decribed as follows | ||
|
||
Install via pip by typing | ||
.. code-block:: python | ||
.. code-block:: bash | ||
import pandas as pd | ||
import tsam.timeseriesaggregation as tsam | ||
pip install tsam | ||
Read in the time series data set with pandas | ||
|
||
into the command prompt. Alternatively, download or clone a local copy of the repository to your computer | ||
.. code-block:: python | ||
.. code-block:: bash | ||
raw = pd.read_csv('testdata.csv', index_col = 0) | ||
git clone https://github.com/FZJ-IEK3-VSA/tsam.git | ||
Initialize an aggregation object and define the number of typical periods, the length of a single period, the aggregation method | ||
|
||
and install tsam in the folder where the setup.py is located with | ||
.. code-block:: python | ||
.. code-block:: bash | ||
aggregation = tsam.TimeSeriesAggregation(raw, | ||
noTypicalPeriods = 8, | ||
hoursPerPeriod = 24, | ||
segmentation = True, | ||
noSegments = 8, | ||
representationMethod = "distributionAndMinMaxRepresentation", | ||
distributionPeriodWise = False | ||
clusterMethod = 'hierarchical' | ||
) | ||
pip install -e . | ||
Run the aggregation to typical periods | ||
|
||
or install directly via python as | ||
.. code-block:: python | ||
.. code-block:: bash | ||
typPeriods = aggregation.createTypicalPeriods() | ||
python setup.py install | ||
Store the results as .csv file | ||
|
||
**Installation of an optimization solver** | ||
.. code-block:: python | ||
Some clustering algorithms implemented in tsam are based on Mixed-Integer Linear Programming. Accordingy, an appropriate solver for using these functionalities is required that can be accessed by `Pyomo <https://github.com/Pyomo/pyomo/>`_. In theory many solvers can be used (e.g. `GUROBI <http://www.gurobi.com/>`_ or `cbc <https://sourceforge.net/projects/wincbc/files/latest/download>`_). For the installation of GUROBI, follow the instructions on the solver's website. For installation of cbc, move the downloaded folder to a desired location. Then, manually append the Environment Variable *Path* with the absolute path leading to the folder in which the glpsol.exe is located (c.f. w32/w64 folder, depending on operating system type). | ||
typPeriods.to_csv('typperiods.csv') | ||
**Hypertuned aggregation** | ||
|
||
In case you do not know, which number of segments or typical periods to choose, you should make first a run with the HyperTunedAggregations class. It will find the best combination of typical periods and segments for the aggregation by minimizing the error between the original and the aggregated time series. The following example shows how to use it. | ||
|
||
|
||
Either create or provide a TimeSeriesAggregation object and use it as base case to get tuned by the HyperTunedAggregations class. | ||
|
||
.. code-block:: python | ||
tune_aggregation = tune.HyperTunedAggregations( | ||
tsam.TimeSeriesAggregation( | ||
raw, | ||
hoursPerPeriod=24, | ||
clusterMethod="hierarchical", | ||
representationMethod="distributionRepresentation", | ||
rescaleClusterPeriods=False, | ||
segmentation=True, | ||
) | ||
) | ||
Afterwards, define the aggregation level you want to reach. The following examples shows how to reduce the original time series to 5% of the original data set. | ||
|
||
.. code-block:: python | ||
segments, periods, RMSE = tune_aggregation.identifyOptimalSegmentPeriodCombination( | ||
dataReduction=0.05 | ||
) | ||
Since, it is quite time consuming, I would recommend to just run it once at the beginning for your time series set, save the resulting segment and period number, and use it as fix values for the original TimeSeriesAggregation object in production. | ||
|
||
The scientific documentation of the methodology can be found here: | ||
`The Pareto-Optimal Temporal Aggregation of Energy System Models <https://www.sciencedirect.com/science/article/abs/pii/S0306261922004342>`_ | ||
|
||
**Additional Examples** | ||
|
||
More detailed examples can be found on the `GitHub page of tsam <https://github.com/FZJ-IEK3-VSA/tsam>`_. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
###################### | ||
Hypertuning segment and period selection | ||
###################### | ||
|
||
.. |br| raw:: html | ||
|
||
<br /> | ||
|
||
Descriptions of the basic functions are given below. | ||
|
||
**Function descriptions:** | ||
|
||
.. automodule:: hyperparametertuning | ||
:member-order: bysource | ||
|
||
.. autoclass:: HyperTunedAggregations | ||
:members: | ||
:member-order: bysource | ||
|
||
.. automethod:: __init__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.