When the kmeans algorithm is used to cluster networks, this is not
deterministic by default. The result is that repeated runs of the
`simplify_network` and `cluster_network` rules can and usually do
produce different results that vary somewhat randomly. This makes
results less reproducible when given only a pypsa-eur configuration
file.
The fix is to supply a fixed random state to the k-means algorithm.
Assume you have 10 nodes that need to be distributed between 2 countries.
What can happen with some of the open source solvers is that one country
gets assigned to 9.01 (float) nodes, and the other one to 0.99.
Now using .astype(int) would lead to a node distribution of 0 and 9, as
the `astype(int)` function round down by default (0.99 -> 0). This assigned
zero value breaks the code in case open source solvers are used.
Gurobi somehow does deal with it.
* for now use n.snapshot_weightings.generators
* require pypsa master; use .objective for Nyears
* implement suggestions from code review
* add release note
* add option to use custom clustermaps from data folder
* adapt default config to custom busmap
* input file from Snakefile
* adapt input description
* add option to use custom clustermaps from data folder
* adapt default config to custom busmap
* input file from Snakefile
* adapt input description
* Snakefile: custom_busmap in cluster_network input is now csv
* cluster_network: custom_busmap is now read as csv file, adaptions of description
* simplify_network: adapt descriptions
* configfiles: add cutom_clustermaps switch
* unify clustarmap and busmap names
* unify clustermap and busmap names
* test/config: unify clustermap and busmap names
* cluster_network: make clustering_for_n_clusters compatible with simplify_network
* simplify_network: make compatible with changes in cluster_network.py
* Update scripts/cluster_network.py
* Update scripts/simplify_network.py
* Update scripts/simplify_network.py
* Update scripts/cluster_network.py
* Update scripts/cluster_network.py
* cluster_network: move custom_busmap flag to enable; simplify names
* cluster_network: move custom_busmap flag to enable; simplify names
* custom_busmap: add documentation
* cluster_network: add default for custom_busmap for compatibility with old configs
* cluster_network: add default for custom_busmap for compatibility with old configs
Co-authored-by: martha.frysztacki <eb5194@iai-esm003.iai.kit.edu>
Co-authored-by: Fabian Neumann <fabian.neumann@outlook.de>
* rewrite mocksnakemake for parsing real Snakefile
* continue add function to scripts
* going through all scripts, setting new mocksnakemake
* fix plotting scripts
* fix build_country_flh
* fix build_country_flh II
* adjust config files
* fix make_summary for tutorial network
* create dir also for output
* incorporate suggestions
* consistent import of mocksnakemake
* consistent import of mocksnakemake II
* Update scripts/_helpers.py
Co-Authored-By: euronion <42553970+euronion@users.noreply.github.com>
* Update scripts/_helpers.py
Co-Authored-By: euronion <42553970+euronion@users.noreply.github.com>
* Update scripts/_helpers.py
Co-Authored-By: euronion <42553970+euronion@users.noreply.github.com>
* Update scripts/_helpers.py
Co-Authored-By: euronion <42553970+euronion@users.noreply.github.com>
* Update scripts/plot_network.py
Co-Authored-By: euronion <42553970+euronion@users.noreply.github.com>
* Update scripts/plot_network.py
Co-Authored-By: euronion <42553970+euronion@users.noreply.github.com>
* Update scripts/retrieve_databundle.py
Co-Authored-By: euronion <42553970+euronion@users.noreply.github.com>
* use pathlib for mocksnakemake
* rename mocksnakemake into mock_snakemake
* revert change in data
* Update scripts/_helpers.py
Co-Authored-By: euronion <42553970+euronion@users.noreply.github.com>
* remove setting logfile in mock_snakemake, use Path in configure_logging
* fix fallback path and base_dir
fix return type of make_io_accessable
* reformulate mock_snakemake
* incorporate suggestion, fix typos
* mock_snakemake: apply absolute paths again, add assertion error
*.py: make hard coded io path accessable for mock_snakemake
* retrieve_natura_raster: use snakemake.output for fn_out
* include suggestion
* Apply suggestions from code review
Co-Authored-By: Jonas Hörsch <jonas.hoersch@posteo.de>
* linting, add return ad end of file
* Update scripts/plot_p_nom_max.py
Co-Authored-By: Jonas Hörsch <jonas.hoersch@posteo.de>
* Update scripts/plot_p_nom_max.py
fixes#112
Co-Authored-By: Jonas Hörsch <jonas.hoersch@posteo.de>
* plot_p_nom_max: small correction
* config.tutorial.yaml fix snapshots end
* use techs instead of technology
* revert try out from previous commit, complete replacing
* change clusters -> clusts in plot_p_nom_max due to wildcard constraints of clusters
* change clusters -> clusts in plot_p_nom_max due to wildcard constraints of clusters II
* Add logging to logfiles to all snakemake workflow scripts.
* Fix missing quotation marks in Snakefile.
* Apply suggestions from code review
Co-Authored-By: Fabian Neumann <fabian.neumann@outlook.de>
* Apply suggestions from code review
Co-Authored-By: Fabian Neumann <fabian.neumann@outlook.de>
* doc: fix _ec_ filenames in docs
* Allow logging message format to be specified in config.yaml.
* Add logging for Snakemake rule 'retrieve_databundle '.
* Add limited logging to STDERR only for retrieve_*.py scripts.
* Import progressbar module only on demand.
* Fix logging to file and enable concurrent printing to STDERR for most scripts.
* Add new 'logging_format' option to Travis CI test config.yaml.
* Add missing parenthesis (bug fix) and cross-os compatible paths.
* Fix typos in messages.
* Use correct log files for logging (bug fix).
* doc: fix line references
* config: logging_format in all configs
* doc: add doc for logging_format
* environment: update to powerplantmatching 0.4.3
* doc: update line references for tutorial.rst
* Change logging configuration scheme for config.yaml.
* Add helper function for doing basic logging configuration.
* Add logpath for prepare_links_p_nom rule.
* Outsource basic logging configuration for all scripts to _helper submodule.
* Update documentation for changed config.yaml structure.
Instead of 'logging_level' and 'logging_format', now 'logging' with subcategories is used.
* _helpers: Change configure_logging signature.
- a network name like elec_s1000_ now clusters the network down to 1000 buses in
the simplify step.
- an 'm' after the number of clusters as in elec_s1000_181m_ skips the
aggregation of renewable generators and just moves them to the new clustered
bus in the second clustering step.
- to distribute the number of clusters to countries a small quadratic
optimization is now performed to minimize \sum_i (n_i - L_i/\sum_j L_j N)**2,
where n_i >= 1.