From b5a877099ba08cadf84b5c1ae7fbe934aa4f6758 Mon Sep 17 00:00:00 2001 From: Matthias Fripp Date: Wed, 10 Apr 2019 14:57:59 -1000 Subject: [PATCH 1/6] Update copyright date to 2019 --- switch_model/__init__.py | 2 +- switch_model/balancing/load_zones.py | 2 +- .../balancing/operating_reserves/areas.py | 2 +- .../operating_reserves/spinning_reserves.py | 2 +- .../spinning_reserves_advanced.py | 2 +- switch_model/balancing/planning_reserves.py | 2 +- .../energy_sources/fuel_costs/markets.py | 2 +- .../energy_sources/fuel_costs/simple.py | 2 +- switch_model/energy_sources/properties.py | 2 +- switch_model/financials.py | 4 +- switch_model/generators/core/build.py | 2 +- switch_model/generators/core/dispatch.py | 2 +- .../generators/core/gen_discrete_build.py | 2 +- switch_model/generators/core/no_commit.py | 2 +- switch_model/hawaii/hi_spinning_reserves.py | 2 +- switch_model/main.py | 2 +- switch_model/policies/carbon_policies.py | 2 +- switch_model/reporting/__init__.py | 2 +- switch_model/reporting/dump.py | 2 +- switch_model/reporting/example_export.py | 2 +- switch_model/solve.py | 2 +- switch_model/solve_scenarios.py | 51 ++++++++++++++++++- switch_model/test.py | 2 +- switch_model/timescales.py | 2 +- switch_model/transmission/local_td.py | 2 +- switch_model/transmission/transport/build.py | 2 +- .../transmission/transport/dispatch.py | 2 +- switch_model/upgrade/__init__.py | 2 +- switch_model/upgrade/manager.py | 2 +- switch_model/upgrade/upgrade_2_0_0b1.py | 2 +- switch_model/upgrade/upgrade_2_0_0b2.py | 2 +- switch_model/upgrade/upgrade_2_0_0b4.py | 2 +- switch_model/upgrade/upgrade_2_0_1.py | 2 +- switch_model/utilities.py | 2 +- switch_model/version.py | 2 +- 35 files changed, 85 insertions(+), 36 deletions(-) diff --git a/switch_model/__init__.py b/switch_model/__init__.py index 888e460a8..965e4ad7e 100644 --- a/switch_model/__init__.py +++ b/switch_model/__init__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2017 The Switch Authors. All rights reserved. +# Copyright (c) 2015-2019 The Switch Authors. All rights reserved. # Licensed under the Apache License, Version 2.0, which is in the LICENSE file. """ diff --git a/switch_model/balancing/load_zones.py b/switch_model/balancing/load_zones.py index ab5f7ac19..908f8b4a7 100644 --- a/switch_model/balancing/load_zones.py +++ b/switch_model/balancing/load_zones.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2017 The Switch Authors. All rights reserved. +# Copyright (c) 2015-2019 The Switch Authors. All rights reserved. # Licensed under the Apache License, Version 2.0, which is in the LICENSE file. """ diff --git a/switch_model/balancing/operating_reserves/areas.py b/switch_model/balancing/operating_reserves/areas.py index 4e408f86d..aa56ee824 100644 --- a/switch_model/balancing/operating_reserves/areas.py +++ b/switch_model/balancing/operating_reserves/areas.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2017 The Switch Authors. All rights reserved. +# Copyright (c) 2015-2019 The Switch Authors. All rights reserved. # Licensed under the Apache License, Version 2.0, which is in the LICENSE file. """ diff --git a/switch_model/balancing/operating_reserves/spinning_reserves.py b/switch_model/balancing/operating_reserves/spinning_reserves.py index b53c83472..c1da30beb 100644 --- a/switch_model/balancing/operating_reserves/spinning_reserves.py +++ b/switch_model/balancing/operating_reserves/spinning_reserves.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2017 The Switch Authors. All rights reserved. +# Copyright (c) 2015-2019 The Switch Authors. All rights reserved. # Licensed under the Apache License, Version 2.0, which is in the LICENSE file. """ A simple and flexible model of spinning reserves that tracks the state of unit diff --git a/switch_model/balancing/operating_reserves/spinning_reserves_advanced.py b/switch_model/balancing/operating_reserves/spinning_reserves_advanced.py index c2c13c0a6..77d8ca11b 100644 --- a/switch_model/balancing/operating_reserves/spinning_reserves_advanced.py +++ b/switch_model/balancing/operating_reserves/spinning_reserves_advanced.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2017 The Switch Authors. All rights reserved. +# Copyright (c) 2015-2019 The Switch Authors. All rights reserved. # Licensed under the Apache License, Version 2.0, which is in the LICENSE file. """ This is an advanced version of the basic spinning_reserves reserves module, and diff --git a/switch_model/balancing/planning_reserves.py b/switch_model/balancing/planning_reserves.py index 7c0f3d463..2ec95b5ee 100644 --- a/switch_model/balancing/planning_reserves.py +++ b/switch_model/balancing/planning_reserves.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2017 The Switch Authors. All rights reserved. +# Copyright (c) 2015-2019 The Switch Authors. All rights reserved. # Licensed under the Apache License, Version 2.0, which is in the LICENSE file. """ This module defines planning reserves margins to support resource adequacy diff --git a/switch_model/energy_sources/fuel_costs/markets.py b/switch_model/energy_sources/fuel_costs/markets.py index 4dc92a022..7a762b4d3 100644 --- a/switch_model/energy_sources/fuel_costs/markets.py +++ b/switch_model/energy_sources/fuel_costs/markets.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2017 The Switch Authors. All rights reserved. +# Copyright (c) 2015-2019 The Switch Authors. All rights reserved. # Licensed under the Apache License, Version 2.0, which is in the LICENSE file. """ diff --git a/switch_model/energy_sources/fuel_costs/simple.py b/switch_model/energy_sources/fuel_costs/simple.py index 27c1d406d..c771a630c 100644 --- a/switch_model/energy_sources/fuel_costs/simple.py +++ b/switch_model/energy_sources/fuel_costs/simple.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2017 The Switch Authors. All rights reserved. +# Copyright (c) 2015-2019 The Switch Authors. All rights reserved. # Licensed under the Apache License, Version 2.0, which is in the LICENSE file. """ diff --git a/switch_model/energy_sources/properties.py b/switch_model/energy_sources/properties.py index 784f99382..6ef7e14ee 100644 --- a/switch_model/energy_sources/properties.py +++ b/switch_model/energy_sources/properties.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2017 The Switch Authors. All rights reserved. +# Copyright (c) 2015-2019 The Switch Authors. All rights reserved. # Licensed under the Apache License, Version 2.0, which is in the LICENSE file. """ diff --git a/switch_model/financials.py b/switch_model/financials.py index 3a13ab4ce..060034026 100644 --- a/switch_model/financials.py +++ b/switch_model/financials.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2017 The Switch Authors. All rights reserved. +# Copyright (c) 2015-2019 The Switch Authors. All rights reserved. # Licensed under the Apache License, Version 2.0, which is in the LICENSE file. """ @@ -289,7 +289,7 @@ def calc_sys_costs_per_period(m, p): mod.SystemCostPerPeriod = Expression( mod.PERIODS, rule=calc_sys_costs_per_period) - # starting with Pyomo 4.2, it is impossible to call Objective.reconstruct() + # starting with Pyomo 4.2, it is impossible to call Objective.reconstruct() # or calculate terms like Objective / , # so it's best to define a separate expression and use that for these purposes. mod.SystemCost = Expression( diff --git a/switch_model/generators/core/build.py b/switch_model/generators/core/build.py index 8dd3209ec..cd09d1a20 100644 --- a/switch_model/generators/core/build.py +++ b/switch_model/generators/core/build.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2017 The Switch Authors. All rights reserved. +# Copyright (c) 2015-2019 The Switch Authors. All rights reserved. # Licensed under the Apache License, Version 2.0, which is in the LICENSE file. """ Defines generation projects build-outs. diff --git a/switch_model/generators/core/dispatch.py b/switch_model/generators/core/dispatch.py index d4b75fc80..c329915b3 100644 --- a/switch_model/generators/core/dispatch.py +++ b/switch_model/generators/core/dispatch.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2017 The Switch Authors. All rights reserved. +# Copyright (c) 2015-2019 The Switch Authors. All rights reserved. # Licensed under the Apache License, Version 2.0, which is in the LICENSE file. """ diff --git a/switch_model/generators/core/gen_discrete_build.py b/switch_model/generators/core/gen_discrete_build.py index d18636740..b57b779cd 100644 --- a/switch_model/generators/core/gen_discrete_build.py +++ b/switch_model/generators/core/gen_discrete_build.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2017 The Switch Authors. All rights reserved. +# Copyright (c) 2015-2019 The Switch Authors. All rights reserved. # Licensed under the Apache License, Version 2.0, which is in the LICENSE file. """ diff --git a/switch_model/generators/core/no_commit.py b/switch_model/generators/core/no_commit.py index d7b6f2217..9f8c7de4a 100644 --- a/switch_model/generators/core/no_commit.py +++ b/switch_model/generators/core/no_commit.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2017 The Switch Authors. All rights reserved. +# Copyright (c) 2015-2019 The Switch Authors. All rights reserved. # Licensed under the Apache License, Version 2.0, which is in the LICENSE file. """ diff --git a/switch_model/hawaii/hi_spinning_reserves.py b/switch_model/hawaii/hi_spinning_reserves.py index 044174609..667d2a4c4 100644 --- a/switch_model/hawaii/hi_spinning_reserves.py +++ b/switch_model/hawaii/hi_spinning_reserves.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2017 The Switch Authors. All rights reserved. +# Copyright (c) 2015-2019 The Switch Authors. All rights reserved. # Licensed under the Apache License, Version 2.0, which is in the LICENSE file. """ This customizes the behavior of balancing.operating_reserves.spinning_reserve diff --git a/switch_model/main.py b/switch_model/main.py index ed59eb91e..dec79b2f6 100644 --- a/switch_model/main.py +++ b/switch_model/main.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2017 The Switch Authors. All rights reserved. +# Copyright (c) 2015-2019 The Switch Authors. All rights reserved. # Licensed under the Apache License, Version 2.0, which is in the LICENSE file. """Script to handle switch calls from the command line.""" diff --git a/switch_model/policies/carbon_policies.py b/switch_model/policies/carbon_policies.py index f57bbe458..80eaf5655 100644 --- a/switch_model/policies/carbon_policies.py +++ b/switch_model/policies/carbon_policies.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2017 The Switch Authors. All rights reserved. +# Copyright (c) 2015-2019 The Switch Authors. All rights reserved. # Licensed under the Apache License, Version 2.0, which is in the LICENSE file. """ Add emission policies to the model, either in the form of an added cost, or of diff --git a/switch_model/reporting/__init__.py b/switch_model/reporting/__init__.py index df97c10b2..f4d1a7a32 100644 --- a/switch_model/reporting/__init__.py +++ b/switch_model/reporting/__init__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2017 The Switch Authors. All rights reserved. +# Copyright (c) 2015-2019 The Switch Authors. All rights reserved. # Licensed under the Apache License, Version 2.0, which is in the LICENSE file. """ diff --git a/switch_model/reporting/dump.py b/switch_model/reporting/dump.py index 8df8220cb..116a2f730 100644 --- a/switch_model/reporting/dump.py +++ b/switch_model/reporting/dump.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2017 The Switch Authors. All rights reserved. +# Copyright (c) 2015-2019 The Switch Authors. All rights reserved. # Licensed under the Apache License, Version 2.0, which is in the LICENSE file. """ diff --git a/switch_model/reporting/example_export.py b/switch_model/reporting/example_export.py index b95cb7a41..d91e86db6 100644 --- a/switch_model/reporting/example_export.py +++ b/switch_model/reporting/example_export.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2017 The Switch Authors. All rights reserved. +# Copyright (c) 2015-2019 The Switch Authors. All rights reserved. # Licensed under the Apache License, Version 2.0, which is in the LICENSE file. """ diff --git a/switch_model/solve.py b/switch_model/solve.py index 68ec410db..44807469e 100755 --- a/switch_model/solve.py +++ b/switch_model/solve.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (c) 2015-2017 The Switch Authors. All rights reserved. +# Copyright (c) 2015-2019 The Switch Authors. All rights reserved. # Licensed under the Apache License, Version 2.0, which is in the LICENSE file. import sys, os, time, shlex, re, inspect, textwrap, types import cPickle as pickle diff --git a/switch_model/solve_scenarios.py b/switch_model/solve_scenarios.py index 394f20c37..8495b4d57 100755 --- a/switch_model/solve_scenarios.py +++ b/switch_model/solve_scenarios.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (c) 2015-2017 The Switch Authors. All rights reserved. +# Copyright (c) 2015-2019 The Switch Authors. All rights reserved. # Licensed under the Apache License, Version 2.0, which is in the LICENSE file. """Scenario management module. @@ -78,6 +78,55 @@ # the same host, so it's safe to requeue any jobs with this id job_id = socket.gethostname() + '_' + str(os.getpid()) +# TODO: other options for requeueing jobs: +# - use file locks on lockfiles: lock a +# lockfile in the scenario queue corresponding to the name of the scenario, then +# run the scenario, then create +# a flag file indicating the scenario has been run, then unlock the scenario. +# (or maybe just update a "completed.txt" file when it's finished, and use locks +# on that to manage contention; but still use a lockfile to identify jobs that +# are currently running). +# This allows robust kill/restart of the scenario solver without needing task IDs, +# and without creating all the scenario subdirs (so scenario queue can be cleaned +# out more easily too). +# The lockfile package might be able to do this (seems to work OK on the UH HPC, +# which uses lustre shared file system), but it uses flock on Linux, which is not +# supposed to work across NFS. A better option could be to use fcntl.lockf(); +# see here for info about unix file locking: +# http://chris.improbable.org/2010/12/16/everything-you-never-wanted-to-know-about-file-locking/ +# *** +# A more robust and platform independent way might be to write a hostname, +# port and key (e.g., creation time) into a lockfile; then listen on that port +# (probably with another subprocess). When another machine wants to run the same +# scenario, it first connects to that host and port and offers the key; if +# if the listening process exists and has ever posted that key, it responds +# affirmatively (that the job is either running or [recently] finished running +# on that host), and the attempter moves on. Otherwise it replaces that file +# with a new one (can that be done atomically? might have to do this with lock dirs). +# This requires a way +# for each host to identify itself in an externally accessible way; we could +# just use the IP address and require all hosts to be on the same subnet. +# There's a little more info here about lockfiles: +# http://dev-random.net/linux-lockfile-explained-how-to-use-them-the-easy-or-hard-way/ +# *** +# Or maybe it's better just to use a job server approach to manage the available +# scenarios, similar to pyro, or even use pyro or mpirun to run parallel jobs +# directly. +# *** +# Or we could use a sqlite database and just require each worker to update the +# fact that it's still running a particular job, at least once per minute (probably +# via a separate subprocess). If another worker finds a job that was last updated +# more than a minute ago, it can take over and solve it. Race conditions would be +# managed via normal database locks. +# update locktable set host=myhost, time=mytime where host=oldhost and time=oldtime" +# then check whether that was successful, or possibly got updated first by a different +# worker, then launch the job. Or do the check and update within a transaction, so +# it's atomic. +# This makes it harder to selectively restart jobs, but that could be resolved by +# creating "scenario_done" files for each finished scenario (and removing it from +# the DB), so users can restart scenarios by deleting the 'done' file. +# But this requires synchronized clocks across workers... + running_scenarios_file = os.path.join(scenario_queue_dir, job_id+"_running.txt") # list of scenarios currently being run by this job (always just one with the current code) diff --git a/switch_model/test.py b/switch_model/test.py index fb7b20ba5..1ea2a5386 100644 --- a/switch_model/test.py +++ b/switch_model/test.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2017 The Switch Authors. All rights reserved. +# Copyright (c) 2015-2019 The Switch Authors. All rights reserved. # Licensed under the Apache License, Version 2.0, which is in the LICENSE file. import sys diff --git a/switch_model/timescales.py b/switch_model/timescales.py index cb863b82f..89f8d0144 100644 --- a/switch_model/timescales.py +++ b/switch_model/timescales.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2017 The Switch Authors. All rights reserved. +# Copyright (c) 2015-2019 The Switch Authors. All rights reserved. # Licensed under the Apache License, Version 2.0, which is in the LICENSE file. """ diff --git a/switch_model/transmission/local_td.py b/switch_model/transmission/local_td.py index d1ebc0f0d..f9240bc82 100644 --- a/switch_model/transmission/local_td.py +++ b/switch_model/transmission/local_td.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2017 The Switch Authors. All rights reserved. +# Copyright (c) 2015-2019 The Switch Authors. All rights reserved. # Licensed under the Apache License, Version 2.0, which is in the LICENSE file. """ diff --git a/switch_model/transmission/transport/build.py b/switch_model/transmission/transport/build.py index e493748fd..d4a46dcc7 100644 --- a/switch_model/transmission/transport/build.py +++ b/switch_model/transmission/transport/build.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2017 The Switch Authors. All rights reserved. +# Copyright (c) 2015-2019 The Switch Authors. All rights reserved. # Licensed under the Apache License, Version 2.0, which is in the LICENSE file. """ diff --git a/switch_model/transmission/transport/dispatch.py b/switch_model/transmission/transport/dispatch.py index 6f5e62ed5..9c1725ec9 100644 --- a/switch_model/transmission/transport/dispatch.py +++ b/switch_model/transmission/transport/dispatch.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2017 The Switch Authors. All rights reserved. +# Copyright (c) 2015-2019 The Switch Authors. All rights reserved. # Licensed under the Apache License, Version 2.0, which is in the LICENSE file. """ diff --git a/switch_model/upgrade/__init__.py b/switch_model/upgrade/__init__.py index f5b91d3b8..3b9a4e211 100644 --- a/switch_model/upgrade/__init__.py +++ b/switch_model/upgrade/__init__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2017 The Switch Authors. All rights reserved. +# Copyright (c) 2015-2019 The Switch Authors. All rights reserved. # Licensed under the Apache License, Version 2.0, which is in the LICENSE file. """ diff --git a/switch_model/upgrade/manager.py b/switch_model/upgrade/manager.py index 2046d32bd..191290f5a 100644 --- a/switch_model/upgrade/manager.py +++ b/switch_model/upgrade/manager.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2017 The Switch Authors. All rights reserved. +# Copyright (c) 2015-2019 The Switch Authors. All rights reserved. # Licensed under the Apache License, Version 2.0, which is in the LICENSE file. from __future__ import print_function diff --git a/switch_model/upgrade/upgrade_2_0_0b1.py b/switch_model/upgrade/upgrade_2_0_0b1.py index 99f45d6bf..80092238a 100644 --- a/switch_model/upgrade/upgrade_2_0_0b1.py +++ b/switch_model/upgrade/upgrade_2_0_0b1.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2017 The Switch Authors. All rights reserved. +# Copyright (c) 2015-2019 The Switch Authors. All rights reserved. # Licensed under the Apache License, Version 2.0, which is in the LICENSE file. """ diff --git a/switch_model/upgrade/upgrade_2_0_0b2.py b/switch_model/upgrade/upgrade_2_0_0b2.py index 90cd2feba..cbcb5b5e7 100644 --- a/switch_model/upgrade/upgrade_2_0_0b2.py +++ b/switch_model/upgrade/upgrade_2_0_0b2.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2017 The Switch Authors. All rights reserved. +# Copyright (c) 2015-2019 The Switch Authors. All rights reserved. # Licensed under the Apache License, Version 2.0, which is in the LICENSE file. """ diff --git a/switch_model/upgrade/upgrade_2_0_0b4.py b/switch_model/upgrade/upgrade_2_0_0b4.py index f3048bac8..78ef48f96 100644 --- a/switch_model/upgrade/upgrade_2_0_0b4.py +++ b/switch_model/upgrade/upgrade_2_0_0b4.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2017 The Switch Authors. All rights reserved. +# Copyright (c) 2015-2019 The Switch Authors. All rights reserved. # Licensed under the Apache License, Version 2.0, which is in the LICENSE file. """ diff --git a/switch_model/upgrade/upgrade_2_0_1.py b/switch_model/upgrade/upgrade_2_0_1.py index 16217200b..af54f0e0e 100644 --- a/switch_model/upgrade/upgrade_2_0_1.py +++ b/switch_model/upgrade/upgrade_2_0_1.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2017 The Switch Authors. All rights reserved. +# Copyright (c) 2015-2019 The Switch Authors. All rights reserved. # Licensed under the Apache License, Version 2.0, which is in the LICENSE file. """ diff --git a/switch_model/utilities.py b/switch_model/utilities.py index 9715b8718..2848e46c2 100644 --- a/switch_model/utilities.py +++ b/switch_model/utilities.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2017 The Switch Authors. All rights reserved. +# Copyright (c) 2015-2019 The Switch Authors. All rights reserved. # Licensed under the Apache License, Version 2.0, which is in the LICENSE file. """ diff --git a/switch_model/version.py b/switch_model/version.py index 292a020e0..894944a45 100644 --- a/switch_model/version.py +++ b/switch_model/version.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2017 The Switch Authors. All rights reserved. +# Copyright (c) 2015-2019 The Switch Authors. All rights reserved. # Licensed under the Apache License, Version 2.0, which is in the LICENSE file. """ This file should only include the version. Do not import any packages or From 30fe2ab68c25a7d64ca668613fc02e258fb80c86 Mon Sep 17 00:00:00 2001 From: Matthias Fripp Date: Wed, 10 Apr 2019 15:45:23 -1000 Subject: [PATCH 2/6] Update version number to 2.0.2 --- examples/3zone_toy/inputs/switch_inputs_version.txt | 2 +- .../3zone_toy_stochastic_PySP/inputs/switch_inputs_version.txt | 2 +- examples/carbon_cap/inputs/switch_inputs_version.txt | 2 +- examples/ccs/inputs/switch_inputs_version.txt | 2 +- examples/copperplate0/inputs/switch_inputs_version.txt | 2 +- examples/copperplate1/inputs/switch_inputs_version.txt | 2 +- examples/custom_extension/inputs/switch_inputs_version.txt | 2 +- .../discrete_and_min_build/inputs/switch_inputs_version.txt | 2 +- examples/discrete_build/inputs/switch_inputs_version.txt | 2 +- examples/dr_simple/inputs/switch_inputs_version.txt | 2 +- examples/hydro_simple/inputs/switch_inputs_version.txt | 2 +- examples/hydro_system/inputs/switch_inputs_version.txt | 2 +- examples/new_builds_only/inputs/switch_inputs_version.txt | 2 +- examples/planning_reserves/inputs/switch_inputs_version.txt | 2 +- .../1plant/inputs/switch_inputs_version.txt | 2 +- .../3plants/inputs/switch_inputs_version.txt | 2 +- .../4plants/inputs/switch_inputs_version.txt | 2 +- .../4plants_with_unserved_load/inputs/switch_inputs_version.txt | 2 +- .../discrete_unit_commit/inputs/switch_inputs_version.txt | 2 +- .../spinning_reserves/inputs/switch_inputs_version.txt | 2 +- .../spinning_reserves_advanced/inputs/switch_inputs_version.txt | 2 +- .../unit_commit/inputs/switch_inputs_version.txt | 2 +- examples/rps_simple/inputs/switch_inputs_version.txt | 2 +- examples/storage/inputs/switch_inputs_version.txt | 2 +- switch_model/version.py | 2 +- 25 files changed, 25 insertions(+), 25 deletions(-) diff --git a/examples/3zone_toy/inputs/switch_inputs_version.txt b/examples/3zone_toy/inputs/switch_inputs_version.txt index 38f77a65b..e9307ca57 100644 --- a/examples/3zone_toy/inputs/switch_inputs_version.txt +++ b/examples/3zone_toy/inputs/switch_inputs_version.txt @@ -1 +1 @@ -2.0.1 +2.0.2 diff --git a/examples/3zone_toy_stochastic_PySP/inputs/switch_inputs_version.txt b/examples/3zone_toy_stochastic_PySP/inputs/switch_inputs_version.txt index 38f77a65b..e9307ca57 100644 --- a/examples/3zone_toy_stochastic_PySP/inputs/switch_inputs_version.txt +++ b/examples/3zone_toy_stochastic_PySP/inputs/switch_inputs_version.txt @@ -1 +1 @@ -2.0.1 +2.0.2 diff --git a/examples/carbon_cap/inputs/switch_inputs_version.txt b/examples/carbon_cap/inputs/switch_inputs_version.txt index 38f77a65b..e9307ca57 100644 --- a/examples/carbon_cap/inputs/switch_inputs_version.txt +++ b/examples/carbon_cap/inputs/switch_inputs_version.txt @@ -1 +1 @@ -2.0.1 +2.0.2 diff --git a/examples/ccs/inputs/switch_inputs_version.txt b/examples/ccs/inputs/switch_inputs_version.txt index 38f77a65b..e9307ca57 100644 --- a/examples/ccs/inputs/switch_inputs_version.txt +++ b/examples/ccs/inputs/switch_inputs_version.txt @@ -1 +1 @@ -2.0.1 +2.0.2 diff --git a/examples/copperplate0/inputs/switch_inputs_version.txt b/examples/copperplate0/inputs/switch_inputs_version.txt index 38f77a65b..e9307ca57 100644 --- a/examples/copperplate0/inputs/switch_inputs_version.txt +++ b/examples/copperplate0/inputs/switch_inputs_version.txt @@ -1 +1 @@ -2.0.1 +2.0.2 diff --git a/examples/copperplate1/inputs/switch_inputs_version.txt b/examples/copperplate1/inputs/switch_inputs_version.txt index 38f77a65b..e9307ca57 100644 --- a/examples/copperplate1/inputs/switch_inputs_version.txt +++ b/examples/copperplate1/inputs/switch_inputs_version.txt @@ -1 +1 @@ -2.0.1 +2.0.2 diff --git a/examples/custom_extension/inputs/switch_inputs_version.txt b/examples/custom_extension/inputs/switch_inputs_version.txt index 38f77a65b..e9307ca57 100644 --- a/examples/custom_extension/inputs/switch_inputs_version.txt +++ b/examples/custom_extension/inputs/switch_inputs_version.txt @@ -1 +1 @@ -2.0.1 +2.0.2 diff --git a/examples/discrete_and_min_build/inputs/switch_inputs_version.txt b/examples/discrete_and_min_build/inputs/switch_inputs_version.txt index 38f77a65b..e9307ca57 100644 --- a/examples/discrete_and_min_build/inputs/switch_inputs_version.txt +++ b/examples/discrete_and_min_build/inputs/switch_inputs_version.txt @@ -1 +1 @@ -2.0.1 +2.0.2 diff --git a/examples/discrete_build/inputs/switch_inputs_version.txt b/examples/discrete_build/inputs/switch_inputs_version.txt index 38f77a65b..e9307ca57 100644 --- a/examples/discrete_build/inputs/switch_inputs_version.txt +++ b/examples/discrete_build/inputs/switch_inputs_version.txt @@ -1 +1 @@ -2.0.1 +2.0.2 diff --git a/examples/dr_simple/inputs/switch_inputs_version.txt b/examples/dr_simple/inputs/switch_inputs_version.txt index 38f77a65b..e9307ca57 100644 --- a/examples/dr_simple/inputs/switch_inputs_version.txt +++ b/examples/dr_simple/inputs/switch_inputs_version.txt @@ -1 +1 @@ -2.0.1 +2.0.2 diff --git a/examples/hydro_simple/inputs/switch_inputs_version.txt b/examples/hydro_simple/inputs/switch_inputs_version.txt index 38f77a65b..e9307ca57 100644 --- a/examples/hydro_simple/inputs/switch_inputs_version.txt +++ b/examples/hydro_simple/inputs/switch_inputs_version.txt @@ -1 +1 @@ -2.0.1 +2.0.2 diff --git a/examples/hydro_system/inputs/switch_inputs_version.txt b/examples/hydro_system/inputs/switch_inputs_version.txt index 38f77a65b..e9307ca57 100644 --- a/examples/hydro_system/inputs/switch_inputs_version.txt +++ b/examples/hydro_system/inputs/switch_inputs_version.txt @@ -1 +1 @@ -2.0.1 +2.0.2 diff --git a/examples/new_builds_only/inputs/switch_inputs_version.txt b/examples/new_builds_only/inputs/switch_inputs_version.txt index 38f77a65b..e9307ca57 100644 --- a/examples/new_builds_only/inputs/switch_inputs_version.txt +++ b/examples/new_builds_only/inputs/switch_inputs_version.txt @@ -1 +1 @@ -2.0.1 +2.0.2 diff --git a/examples/planning_reserves/inputs/switch_inputs_version.txt b/examples/planning_reserves/inputs/switch_inputs_version.txt index 38f77a65b..e9307ca57 100644 --- a/examples/planning_reserves/inputs/switch_inputs_version.txt +++ b/examples/planning_reserves/inputs/switch_inputs_version.txt @@ -1 +1 @@ -2.0.1 +2.0.2 diff --git a/examples/production_cost_models/1plant/inputs/switch_inputs_version.txt b/examples/production_cost_models/1plant/inputs/switch_inputs_version.txt index 38f77a65b..e9307ca57 100644 --- a/examples/production_cost_models/1plant/inputs/switch_inputs_version.txt +++ b/examples/production_cost_models/1plant/inputs/switch_inputs_version.txt @@ -1 +1 @@ -2.0.1 +2.0.2 diff --git a/examples/production_cost_models/3plants/inputs/switch_inputs_version.txt b/examples/production_cost_models/3plants/inputs/switch_inputs_version.txt index 38f77a65b..e9307ca57 100644 --- a/examples/production_cost_models/3plants/inputs/switch_inputs_version.txt +++ b/examples/production_cost_models/3plants/inputs/switch_inputs_version.txt @@ -1 +1 @@ -2.0.1 +2.0.2 diff --git a/examples/production_cost_models/4plants/inputs/switch_inputs_version.txt b/examples/production_cost_models/4plants/inputs/switch_inputs_version.txt index 38f77a65b..e9307ca57 100644 --- a/examples/production_cost_models/4plants/inputs/switch_inputs_version.txt +++ b/examples/production_cost_models/4plants/inputs/switch_inputs_version.txt @@ -1 +1 @@ -2.0.1 +2.0.2 diff --git a/examples/production_cost_models/4plants_with_unserved_load/inputs/switch_inputs_version.txt b/examples/production_cost_models/4plants_with_unserved_load/inputs/switch_inputs_version.txt index 38f77a65b..e9307ca57 100644 --- a/examples/production_cost_models/4plants_with_unserved_load/inputs/switch_inputs_version.txt +++ b/examples/production_cost_models/4plants_with_unserved_load/inputs/switch_inputs_version.txt @@ -1 +1 @@ -2.0.1 +2.0.2 diff --git a/examples/production_cost_models/discrete_unit_commit/inputs/switch_inputs_version.txt b/examples/production_cost_models/discrete_unit_commit/inputs/switch_inputs_version.txt index 38f77a65b..e9307ca57 100644 --- a/examples/production_cost_models/discrete_unit_commit/inputs/switch_inputs_version.txt +++ b/examples/production_cost_models/discrete_unit_commit/inputs/switch_inputs_version.txt @@ -1 +1 @@ -2.0.1 +2.0.2 diff --git a/examples/production_cost_models/spinning_reserves/inputs/switch_inputs_version.txt b/examples/production_cost_models/spinning_reserves/inputs/switch_inputs_version.txt index 38f77a65b..e9307ca57 100644 --- a/examples/production_cost_models/spinning_reserves/inputs/switch_inputs_version.txt +++ b/examples/production_cost_models/spinning_reserves/inputs/switch_inputs_version.txt @@ -1 +1 @@ -2.0.1 +2.0.2 diff --git a/examples/production_cost_models/spinning_reserves_advanced/inputs/switch_inputs_version.txt b/examples/production_cost_models/spinning_reserves_advanced/inputs/switch_inputs_version.txt index 38f77a65b..e9307ca57 100644 --- a/examples/production_cost_models/spinning_reserves_advanced/inputs/switch_inputs_version.txt +++ b/examples/production_cost_models/spinning_reserves_advanced/inputs/switch_inputs_version.txt @@ -1 +1 @@ -2.0.1 +2.0.2 diff --git a/examples/production_cost_models/unit_commit/inputs/switch_inputs_version.txt b/examples/production_cost_models/unit_commit/inputs/switch_inputs_version.txt index 38f77a65b..e9307ca57 100644 --- a/examples/production_cost_models/unit_commit/inputs/switch_inputs_version.txt +++ b/examples/production_cost_models/unit_commit/inputs/switch_inputs_version.txt @@ -1 +1 @@ -2.0.1 +2.0.2 diff --git a/examples/rps_simple/inputs/switch_inputs_version.txt b/examples/rps_simple/inputs/switch_inputs_version.txt index 38f77a65b..e9307ca57 100644 --- a/examples/rps_simple/inputs/switch_inputs_version.txt +++ b/examples/rps_simple/inputs/switch_inputs_version.txt @@ -1 +1 @@ -2.0.1 +2.0.2 diff --git a/examples/storage/inputs/switch_inputs_version.txt b/examples/storage/inputs/switch_inputs_version.txt index 38f77a65b..e9307ca57 100644 --- a/examples/storage/inputs/switch_inputs_version.txt +++ b/examples/storage/inputs/switch_inputs_version.txt @@ -1 +1 @@ -2.0.1 +2.0.2 diff --git a/switch_model/version.py b/switch_model/version.py index 894944a45..c1625cc12 100644 --- a/switch_model/version.py +++ b/switch_model/version.py @@ -6,4 +6,4 @@ installed and executed in environments that don't have any dependencies installed. """ -__version__='2.0.1' +__version__='2.0.2' From 3ad2f4911c0ecc77cd5ea03f14d55f8d0e347d2b Mon Sep 17 00:00:00 2001 From: Matthias Fripp Date: Wed, 10 Apr 2019 15:51:10 -1000 Subject: [PATCH 3/6] Prevent crash when running switch solve --help with hawaii.rps module --- switch_model/hawaii/rps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/switch_model/hawaii/rps.py b/switch_model/hawaii/rps.py index 292043e74..88f87e0cb 100644 --- a/switch_model/hawaii/rps.py +++ b/switch_model/hawaii/rps.py @@ -23,7 +23,7 @@ def define_arguments(argparser): argparser.add_argument('--rps-no-wind', action='store_true', default=False, help="Don't allow any new wind capacity or replacement of existing capacity.") argparser.add_argument('--rps-prefer-dist-pv', action='store_true', default=False, - help="Don't allow any new large solar capacity unless 90% of distributed PV ('*DistPV') capacity has been developed.") + help="Don't allow any new large solar capacity unless 90%% of distributed PV ('*DistPV') capacity has been developed.") argparser.add_argument( '--rps-allocation', default=None, choices=[ From 164290a87163ba983f4987d06d60434ece32d593 Mon Sep 17 00:00:00 2001 From: Matthias Fripp Date: Wed, 10 Apr 2019 15:51:47 -1000 Subject: [PATCH 4/6] Add --assign-current-version flag to `switch upgrade` command --- switch_model/upgrade/manager.py | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/switch_model/upgrade/manager.py b/switch_model/upgrade/manager.py index 191290f5a..ab9b25107 100644 --- a/switch_model/upgrade/manager.py +++ b/switch_model/upgrade/manager.py @@ -32,22 +32,21 @@ upgrade_2_0_1.upgrades_to), ] -# Not every code revision requires an update, so we hard-code the last -# revision that required an update. -last_required_update = '2.0.1' +# Not every code revision requires an update; this is the last revision that did. +last_required_update = upgrade_plugins[-1][-1] code_version = StrictVersion(switch_model.__version__) version_file = 'switch_inputs_version.txt' #verbose = False verbose = True -def scan_and_upgrade(top_dir, inputs_dir_name='inputs', backup=True): +def scan_and_upgrade(top_dir, inputs_dir_name='inputs', backup=True, assign_current_version=False): for dirpath, dirnames, filenames in os.walk(top_dir): for dirname in dirnames: path = os.path.join(dirpath, dirname) if os.path.exists(os.path.join(path, inputs_dir_name, 'modules.txt')): # print_verbose('upgrading {}'.format(os.path.join(path, inputs_dir_name))) - upgrade_inputs(os.path.join(path, inputs_dir_name), backup) + upgrade_inputs(os.path.join(path, inputs_dir_name), backup, assign_current_version) def get_input_version(inputs_dir): @@ -113,8 +112,9 @@ def print_verbose(*args): print(*args) -def upgrade_inputs(inputs_dir, backup=True): +def upgrade_inputs(inputs_dir, backup=True, assign_current_version=False): # This logic will grow over time as complexity evolves.. Don't overengineer + upgraded = False if do_inputs_need_upgrade(inputs_dir): print_verbose('Upgrading ' + inputs_dir) if backup: @@ -128,6 +128,16 @@ def upgrade_inputs(inputs_dir, backup=True): if StrictVersion(v_from) <= inputs_v < StrictVersion(v_to): print_verbose('\tUpgrading from ' + v_from + ' to ' + v_to) upgrader.upgrade_input_dir(inputs_dir) + upgraded = True + + if (StrictVersion(last_required_update) < StrictVersion(switch_model.__version__) + and assign_current_version): + # user requested writing of current version number, even if no upgrade is needed + # (useful for updating examples to track with new release of Switch) + _write_input_version(inputs_dir, switch_model.__version__) + upgraded = True + + if upgraded: print_verbose('\tFinished upgrading ' + inputs_dir + '\n') else: print_verbose('Skipped ' + inputs_dir + '; it does not need upgrade.') @@ -142,12 +152,12 @@ def main(args=None): args = parser.parse_args() set_verbose(args.verbose) if args.recursive: - scan_and_upgrade('.', args.inputs_dir_name, args.backup) + scan_and_upgrade('.', args.inputs_dir_name, args.backup, args.assign_current_version) else: if not os.path.isdir(args.inputs_dir_name): print("Error: Input directory {} does not exist.".format(args.inputs_dir_name)) return -1 - upgrade_inputs(os.path.normpath(args.inputs_dir_name), args.backup) + upgrade_inputs(os.path.normpath(args.inputs_dir_name), args.backup, args.assign_current_version) def set_verbose(verbosity): global verbose @@ -160,6 +170,10 @@ def add_parser_args(parser): help='Make backup of inputs directory before upgrading (set true by default)') parser.add_argument("--no-backup", action='store_false', dest='backup', help='Do not make backup of inputs directory before upgrading') + parser.add_argument("--assign-current-version", dest='assign_current_version', + action='store_true', default=False, + help=('Update version number in inputs directory to match current version' + 'of Switch, even if data does not require an upgrade.')) parser.add_argument("--recursive", dest="recursive", default=False, action='store_true', help=('Recursively scan the provided path for inputs directories ' From 3b4e6d9d37a8312d46c89d5decf5c6016fac8fd4 Mon Sep 17 00:00:00 2001 From: Matthias Fripp Date: Wed, 10 Apr 2019 15:53:40 -1000 Subject: [PATCH 5/6] Minor and cosmetic changes. --- .gitignore | 4 +- CHANGELOG.txt | 4 +- .../hawaii/batteries_fixed_calendar_life.py | 44 +++++++++---------- switch_model/hawaii/kalaeloa.py | 9 +++- switch_model/hawaii/scenario_data.py | 3 +- switch_model/utilities.py | 2 - 6 files changed, 37 insertions(+), 29 deletions(-) diff --git a/.gitignore b/.gitignore index 177181a78..b4ecdf8c0 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,6 @@ gurobi.log switch_model.egg-info/ venv -build/ +build*/ +dist*/ +autodoc* diff --git a/CHANGELOG.txt b/CHANGELOG.txt index c49fb6dd4..08e6a6e41 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -33,8 +33,8 @@ Switch 2.0.1 then re-solves to obtain duals. This flag is not needed with the cplexamp solver. - A new balancing.demand_response.iterative module has been added. This was - formerly in the Hawaii regional package. This moduel performs iterative solutions with any convex demand system, based on a bid-response - process. + formerly in the Hawaii regional package. This module performs iterative + solutions with any convex demand system, based on a bid-response process. - New indexed sets have been added to allow efficient selection of groups of generators that use a particular technology, fuel or non-fuel energy source: GENS_BY_TECHNOLOGY, GENS_BY_FUEL, GENS_BY_NON_FUEL_ENERGY_SOURCE. diff --git a/switch_model/hawaii/batteries_fixed_calendar_life.py b/switch_model/hawaii/batteries_fixed_calendar_life.py index f3387684b..6c34badc3 100644 --- a/switch_model/hawaii/batteries_fixed_calendar_life.py +++ b/switch_model/hawaii/batteries_fixed_calendar_life.py @@ -3,14 +3,14 @@ from switch_model.financials import capital_recovery_factor as crf def define_components(m): - + # TODO: change this to allow multiple storage technologies. # battery capital cost # TODO: accept a single battery_capital_cost_per_mwh_capacity value or the annual values shown here m.BATTERY_CAPITAL_COST_YEARS = Set() # list of all years for which capital costs are available m.battery_capital_cost_per_mwh_capacity_by_year = Param(m.BATTERY_CAPITAL_COST_YEARS) - + # TODO: merge this code with batteries.py and auto-select between fixed calendar life and cycle life # based on whether battery_n_years or battery_n_cycles is provided. (Or find some hybrid that can # handle both well?) @@ -28,7 +28,7 @@ def define_components(m): m.BuildBattery = Var(m.LOAD_ZONES, m.PERIODS, within=NonNegativeReals) m.Battery_Capacity = Expression(m.LOAD_ZONES, m.PERIODS, rule=lambda m, z, p: sum( - m.BuildBattery[z, bld_yr] + m.BuildBattery[z, bld_yr] for bld_yr in m.CURRENT_AND_PRIOR_PERIODS_FOR_PERIOD[p] if bld_yr + m.battery_n_years > p ) ) @@ -43,18 +43,18 @@ def define_components(m): # add storage dispatch to the zonal energy balance m.Zone_Power_Injections.append('DischargeBattery') m.Zone_Power_Withdrawals.append('ChargeBattery') - + # add the batteries to the objective function # cost recovery for any battery capacity currently active m.BatteryAnnualCost = Expression( m.PERIODS, rule=lambda m, p: sum( - m.BuildBattery[z, bld_yr] - * m.battery_capital_cost_per_mwh_capacity_by_year[bld_yr] + m.BuildBattery[z, bld_yr] + * m.battery_capital_cost_per_mwh_capacity_by_year[bld_yr] * crf(m.interest_rate, m.battery_n_years) for bld_yr in m.CURRENT_AND_PRIOR_PERIODS_FOR_PERIOD[p] if bld_yr + m.battery_n_years > p - for z in m.LOAD_ZONES + for z in m.LOAD_ZONES ) ) m.Cost_Components_Per_Period.append('BatteryAnnualCost') @@ -63,31 +63,31 @@ def define_components(m): # NOTE: this is circular for each day # NOTE: the overall level for the day is free, but the levels each timepoint are chained. m.Battery_Level_Calc = Constraint(m.LOAD_ZONES, m.TIMEPOINTS, rule=lambda m, z, t: - m.BatteryLevel[z, t] == + m.BatteryLevel[z, t] == m.BatteryLevel[z, m.tp_previous[t]] + m.tp_duration_hrs[t] * ( - m.battery_efficiency * m.ChargeBattery[z, m.tp_previous[t]] + m.battery_efficiency * m.ChargeBattery[z, m.tp_previous[t]] - m.DischargeBattery[z, m.tp_previous[t]] ) ) - + # limits on storage level - m.Battery_Min_Level = Constraint(m.LOAD_ZONES, m.TIMEPOINTS, rule=lambda m, z, t: + m.Battery_Min_Level = Constraint(m.LOAD_ZONES, m.TIMEPOINTS, rule=lambda m, z, t: (1.0 - m.battery_max_discharge) * m.Battery_Capacity[z, m.tp_period[t]] - <= + <= m.BatteryLevel[z, t] ) - m.Battery_Max_Level = Constraint(m.LOAD_ZONES, m.TIMEPOINTS, rule=lambda m, z, t: + m.Battery_Max_Level = Constraint(m.LOAD_ZONES, m.TIMEPOINTS, rule=lambda m, z, t: m.BatteryLevel[z, t] - <= + <= m.Battery_Capacity[z, m.tp_period[t]] ) m.Battery_Max_Charge_Rate = Constraint(m.LOAD_ZONES, m.TIMEPOINTS, rule=lambda m, z, t: m.ChargeBattery[z, t] <= - # changed 2018-02-20 to allow full discharge in min_discharge_time, - # (previously pegged to battery_max_discharge) + # changed 2018-02-20 to allow full discharge in min_discharge_time, + # (previously pegged to battery_max_discharge) m.Battery_Capacity[z, m.tp_period[t]] / m.battery_min_discharge_time ) m.Battery_Max_Discharge_Rate = Constraint(m.LOAD_ZONES, m.TIMEPOINTS, rule=lambda m, z, t: @@ -112,14 +112,14 @@ def define_components(m): # (this was pegged to battery_max_discharge before 2018-02-20) m.Battery_Cycle_Limit = Constraint(m.LOAD_ZONES, m.PERIODS, rule=lambda m, z, p: sum(m.DischargeBattery[z, tp] * m.tp_duration_hrs[tp] for tp in m.TPS_IN_PERIOD[p]) - <= + <= m.Battery_Capacity[z, p] * m.period_length_hours[p] ) - + # Register with spinning reserves if it is available if 'Spinning_Reserve_Up_Provisions' in dir(m): m.BatterySpinningReserveUp = Expression( - m.BALANCING_AREA_TIMEPOINTS, + m.BALANCING_AREA_TIMEPOINTS, rule=lambda m, b, t: sum(m.BatterySlackUp[z, t] for z in m.ZONES_IN_BALANCING_AREA[b]) @@ -127,9 +127,9 @@ def define_components(m): m.Spinning_Reserve_Up_Provisions.append('BatterySpinningReserveUp') m.BatterySpinningReserveDown = Expression( - m.BALANCING_AREA_TIMEPOINTS, + m.BALANCING_AREA_TIMEPOINTS, rule=lambda m, b, t: \ - sum(m.BatterySlackDown[g, t] + sum(m.BatterySlackDown[z, t] for z in m.ZONES_IN_BALANCING_AREA[b]) ) m.Spinning_Reserve_Down_Provisions.append('BatterySpinningReserveDown') @@ -137,7 +137,7 @@ def define_components(m): def load_inputs(m, switch_data, inputs_dir): """ - Import battery data from .dat and .tab files. + Import battery data from .dat and .tab files. """ switch_data.load(filename=os.path.join(inputs_dir, 'batteries.dat')) switch_data.load_aug( diff --git a/switch_model/hawaii/kalaeloa.py b/switch_model/hawaii/kalaeloa.py index adb0b4e07..74d36a9c6 100644 --- a/switch_model/hawaii/kalaeloa.py +++ b/switch_model/hawaii/kalaeloa.py @@ -3,6 +3,11 @@ import os from pyomo.environ import * +def define_arguments(argparser): + argparser.add_argument("--run-kalaeloa-even-with-high-rps", action='store_true', default=False, + help="Enforce the 75 MW minimum-output rule for Kalaeloa in all years (otherwise relaxed " + "if RPS or EV share >= 75%%). Mimics behavior from switch 2.0.0b2.") + def define_components(m): # force Kalaeloa_CC3 offline unless 1&2 are at max (per John Cole e-mail 9/28/16) @@ -82,7 +87,9 @@ def Kalaeloa_Must_Run_rule(m, tp): ev_share = m.ev_share['Oahu', m.tp_period[tp]] if hasattr(m, 'ev_share') else 0.0 rps_level = m.rps_target_for_period[m.tp_period[tp]] if hasattr(m, 'rps_target_for_period') else 0.0 - if both_units_out or ev_share >= 0.75 or rps_level >= 0.75: + if both_units_out or ( + (ev_share >= 0.75 or rps_level >= 0.75) and not m.options.run_kalaeloa_even_with_high_rps + ): return Constraint.Skip else: return (sum(m.DispatchGen[g, tp] for g in m.KALAELOA_MAIN_UNITS) >= 75.0) diff --git a/switch_model/hawaii/scenario_data.py b/switch_model/hawaii/scenario_data.py index 1f5de82e6..08f2af86c 100644 --- a/switch_model/hawaii/scenario_data.py +++ b/switch_model/hawaii/scenario_data.py @@ -245,7 +245,8 @@ def write_tables(**args): write_table('fuels.tab', """ SELECT DISTINCT replace(c.fuel_type, ' ', '_') AS fuel, co2_intensity, 0.0 AS upstream_co2_intensity, rps_eligible FROM fuel_costs c JOIN energy_source_properties p on (p.energy_source = c.fuel_type) - WHERE load_zone in %(load_zones)s AND fuel_scen_id=%(fuel_scen_id)s; + WHERE load_zone in %(load_zones)s AND fuel_scen_id=%(fuel_scen_id)s + ORDER BY 1; """, args) ######################### diff --git a/switch_model/utilities.py b/switch_model/utilities.py index 2848e46c2..d6d57f6b3 100644 --- a/switch_model/utilities.py +++ b/switch_model/utilities.py @@ -371,11 +371,9 @@ def __str__(self): def load_aug(switch_data, optional=False, auto_select=False, optional_params=[], **kwds): """ - This is a wrapper for the DataPortal object that accepts additional keywords. This currently supports a flag for the file being optional. The name load_aug() is not great and may be changed. - """ # TODO: # Allow user to specify filename when defining parameters and sets. From 48fd260456198be9339e97659ba155334661e050 Mon Sep 17 00:00:00 2001 From: Matthias Fripp Date: Wed, 10 Apr 2019 15:53:57 -1000 Subject: [PATCH 6/6] Update CHANGELOG.txt for 2.0.2 --- CHANGELOG.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 08e6a6e41..5a66d9a66 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,3 +1,15 @@ +------------------------------------------------------------------------------- +Switch 2.0.2 +------------------------------------------------------------------------------- + +- General + - Added --assign-current-version argument to `switch upgrade`. This is + useful for updating version number in example directories to match + current version of Switch, even if the data files don't need an upgrade. + +- Hawaii regional package + - Fixed bug in hawaii.rps that would crash `switch solve --help`. + ------------------------------------------------------------------------------- Switch 2.0.1 -------------------------------------------------------------------------------