Skip to content

Commit

Permalink
Merge pull request #27 from invenia/npr/virtuals
Browse files Browse the repository at this point in the history
Add `get_virtuals`
  • Loading branch information
nickrobinson251 authored Jul 25, 2022
2 parents caf14c5 + 8f642b8 commit 4be5b4a
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 13 deletions.
5 changes: 3 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "FullNetworkSystems"
uuid = "877b7152-b508-43dc-81fb-72341a693988"
authors = ["Invenia Technical Computing Corporation"]
version = "1.4.0"
version = "1.5.0"

[deps]
AxisKeys = "94b1ba4f-4ee9-5380-92f1-94cde586c3c5"
Expand All @@ -18,7 +18,8 @@ InlineStrings = "1"
julia = "1.6"

[extras]
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]
test = ["Random", "Test"]
2 changes: 1 addition & 1 deletion src/FullNetworkSystems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export get_regulation_requirements, get_operating_reserve_requirements, get_good
export get_gens_per_bus, get_loads_per_bus, get_incs_per_bus, get_decs_per_bus, get_psls_per_bus
export get_ptdf, get_lodfs
export get_initial_commitment, get_initial_downtime, get_initial_uptime
export get_increments, get_decrements, get_price_sensitive_loads
export get_increments, get_decrements, get_virtuals, get_price_sensitive_loads
export get_availability, get_must_run
export get_initial_generation, get_loads, get_offer_curve
export get_pmin, get_pmax, get_regulation_min, get_regulation_max
Expand Down
2 changes: 2 additions & 0 deletions src/accessors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ get_increments(system::SystemDA) = system.increments
get_decrements(system::SystemDA) = system.decrements
"Returns time series data of price sensitive load bids."
get_price_sensitive_loads(system::SystemDA) = system.price_sensitive_loads
"Returns time series data of both increment bids and decrement bids."
get_virtuals(system::SystemDA) = vcat(system.increments, system.decrements)

"Returns time series data of flags indicating if the generator is available to be committed in each hour"
get_availability(system::SystemDA) = system.generator_status.availability
Expand Down
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ using AxisKeys
using Dates
using Dictionaries
using FullNetworkSystems
using Random: randstring
using Test

@testset "FullNetworkSystems.jl" begin
Expand Down
31 changes: 21 additions & 10 deletions test/system.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
end
generators = Dictionary(gen_ids, gen_types)

bus_names = ["A", "B", "C"]
bus_names = FullNetworkSystems.BusName["A", "B", "C"]
bus_types = map(bus_names) do name
Bus(name, 100.0)
end
Expand All @@ -102,11 +102,14 @@
]
)

# Bid IDs/names should be unique. Here length of IDs is arbitrary.
bid_names(prefix, n) = FullNetworkSystems.BidName.(prefix * "_" * randstring(5) for _ in 1:n)

gens_per_bus = Dictionary(bus_names, rand(gen_ids, 3) for _ in bus_names)
incs_per_bus = Dictionary(bus_names, string.(rand('A':'Z', 3)) for _ in bus_names)
decs_per_bus = Dictionary(bus_names, string.(rand('A':'Z', 3)) for _ in bus_names)
psls_per_bus = Dictionary(bus_names, string.(rand('A':'Z', 3)) for _ in bus_names)
loads_per_bus = Dictionary(bus_names, string.(rand('A':'Z', 3)) for _ in bus_names)
incs_per_bus = Dictionary(bus_names, bid_names("inc", 3) for _ in bus_names)
decs_per_bus = Dictionary(bus_names, bid_names("dec", 3) for _ in bus_names)
psls_per_bus = Dictionary(bus_names, bid_names("psl", 3) for _ in bus_names)
loads_per_bus = Dictionary(bus_names, bid_names("load", 3) for _ in bus_names)

lodfs = Dictionary(
["CONTIN_1"],
Expand All @@ -118,10 +121,9 @@
datetimes = DateTime(2017, 12, 15):Hour(1):DateTime(2017, 12, 15, 23)
time_series(T=Float64) = KeyedArray(rand(T, length(ids), length(datetimes)); ids, datetimes)
services_time_series() = KeyedArray(vcat(rand(length(ids) - 1, length(datetimes)), fill(missing, 1, length(datetimes))); ids, datetimes)
offer_time_series() = KeyedArray(fill([(1.0, 100.0)], length(ids), length(datetimes)); ids, datetimes)

initial_generation = KeyedArray([rand(length(ids) - 2); fill(0.0, 2)]; ids)
offer_curve = offer_time_series()
offer_curve = KeyedArray(fill([(1.0, 100.0)], length(ids), length(datetimes)); ids, datetimes)
regulation_min = time_series()
regulation_max = time_series()
pmin = time_series()
Expand Down Expand Up @@ -152,9 +154,13 @@
da_generator_status = GeneratorStatusDA(; hours_at_status, availability, must_run)

loads = time_series()
increments = offer_time_series()
decrements = offer_time_series()
price_sensitive_loads = offer_time_series()

nbids = 8 # arbitrary
bid_time_series(prefix) = KeyedArray(fill([(1.0, 100.0)], nbids, length(datetimes)); ids=bid_names(prefix, nbids), datetimes)

increments = bid_time_series("inc")
decrements = bid_time_series("dec")
price_sensitive_loads = bid_time_series("psl")
da_system = SystemDA(;
gens_per_bus,
incs_per_bus,
Expand Down Expand Up @@ -292,6 +298,11 @@
@test get_decrements(da_system) == decrements
@test get_price_sensitive_loads(da_system) == price_sensitive_loads

virtuals = get_virtuals(da_system)
@test size(virtuals) == (nbids * 2, length(datetimes))
v_id_prefixes = first.(axiskeys(virtuals, 1), 3)
@test in("inc", v_id_prefixes) && in("dec", v_id_prefixes)

@test get_availability(da_system) == availability
@test get_must_run(da_system) == must_run

Expand Down

2 comments on commit 4be5b4a

@raphaelsaavedra
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/65018

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.5.0 -m "<description of version>" 4be5b4a0c5bba8f9b12f8a92782cce5ad3582107
git push origin v1.5.0

Please sign in to comment.