Resource types and function interfaces
GenX.AbstractResource — Type
An abstract type that should be subtyped for users creating GenX resources.
GenX.default_zero — Constant
const default_zero = 0Default value for resource attributes.
GenX.resource_types — Constant
resource_typesName of the type of resources available in the model.
Possible values:
- :Thermal
- :Vre
- :Hydro
- :Storage
- :MustRun
- :FlexDemand
- :VreStorage
- :Electrolyzer
- :AllamCycleLox
Base.findall — Method
findall(f::Function, rs::Vector{<:AbstractResource})Find all resources in the vector rs that satisfy the condition given by the function f. Return the resource id instead of the vector index.
Arguments
f::Function: The condition function.rs::Vector{<:AbstractResource}: The vector of resources.
Returns
Vector: The vector of resource ids.
Examples
julia> findall(r -> max_cap_mwh(r) != 0, gen.Storage)
3-element Vector{Int64}:
48
49
50Base.get — Method
Base.get(r::AbstractResource, sym::Symbol, default)Retrieves the value of a specific attribute from an AbstractResource object. If the attribute exists, its value is returned; otherwise, the default value is returned.
Arguments:
r::AbstractResource: The resource object.sym::Symbol: The symbol representing the attribute name.default: The default value to return if the attribute does not exist.
Returns:
- The value of the attribute if it exists in the parent object,
defaultotherwise.
Base.getproperty — Method
Base.getproperty(r::AbstractResource, sym::Symbol)Allows to access the attributes of an AbstractResource object using dot syntax. It checks if the attribute exists in the object and returns its value, otherwise it throws an ErrorException indicating that the attribute does not exist.
Arguments:
r::AbstractResource: The resource object.sym::Symbol: The symbol representing the attribute name.
Returns:
- The value of the attribute if it exists in the parent object.
Throws:
ErrorException: If the attribute does not exist in the resource.
Base.getproperty — Method
Base.getproperty(rs::Vector{<:AbstractResource}, sym::Symbol)Allows to return all resources of a given type of a vector of AbstractResource objects using dot syntax.
Arguments:
rs::Vector{<:AbstractResource}: The vector ofAbstractResourceobjects.sym::Symbol: The symbol representing the type fromresource_types.
Returns:
- If
symis an element of theresource_typesconstant, it returns a vector containing all resources of that type.
Examples
julia> vre_gen = gen.Vre; # gen vector of resources
julia> typeof(vre_gen)
Vector{Vre} (alias for Array{Vre, 1})
julia> GenX.zone_id.(vre_gen)Base.haskey — Method
haskey(r::AbstractResource, sym::Symbol)Check if an AbstractResource object has a specific attribute. It returns a boolean value indicating whether the attribute exists in the parent object.
Arguments:
r::AbstractResource: The resource object.sym::Symbol: The symbol representing the attribute name.
Returns:
trueif the attribute exists in the parent object,falseotherwise.
Base.pairs — Method
pairs(r::AbstractResource)Return an iterator of key-value pairs with the attributes of a given resource.
Arguments
r::AbstractResource: The resource.
Returns
Pairs: An iterator of key-value pairs over the attributes.
Base.setindex! — Method
Base.setindex!(rs::Vector{<:AbstractResource}, value::Vector, sym::Symbol)Define dot syntax for setting the attributes specified by sym to the corresponding values in value for a vector of resources.
Arguments
rs::Vector{<:AbstractResource}: The vector of resources.value::Vector: The vector of values to set for the attribute.sym::Symbol: The symbol representing the attribute to set.
Returns
rs::Vector{<:AbstractResource}: The updated vector of resources.
Base.setproperty! — Method
setproperty!(r::AbstractResource, sym::Symbol, value)Allows to set the attribute sym of an AbstractResource object using dot syntax.
Arguments:
r::AbstractResource: The resource object.sym::Symbol: The symbol representing the attribute name.value: The value to set for the attribute.
Base.setproperty! — Method
Base.setproperty!(rs::Vector{<:AbstractResource}, sym::Symbol, value::Vector)Set the attributes specified by sym to the corresponding values in value for a vector of resources.
Arguments
rs::Vector{<:AbstractResource}: The vector of resources.sym::Symbol: The symbol representing the attribute to set.value::Vector: The vector of values to set for the attribute.
Returns
rs::Vector{<:AbstractResource}: The updated vector of resources.
GenX.allam_cycle_lox — Method
allam_cycle_lox(rs::Vector{T}) where T <: AbstractResourceReturns the indices of all ALLAMCYCLELOX resources in the vector rs.
GenX.attributes — Method
attributes(r::AbstractResource)Returns a tuple of the attribute names of the given resource.
Arguments
r::AbstractResource: The resource.
Returns
Tuple: A tuple with symbols representing the attribute names.
GenX.electrolyzer — Method
electrolyzer(rs::Vector{T}) where T <: AbstractResourceReturns the indices of all electrolyzer resources in the vector rs.
GenX.flex_demand — Method
flex_demand(rs::Vector{T}) where T <: AbstractResourceReturns the indices of all flexible demand resources in the vector rs.
GenX.get_attr — Method
get_attr(r::AbstractResource, attr::Symbol, default_value::Real)Function to get attribute attr from a GenX resource r. If the attribute is not found, return default_value.
Arguments
r::AbstractResource: The resource.attr::Symbol: The attribute to get.default_value::Real: The default value to return if the attribute is not found.
Returns
value::Real: The value of the attribute.
GenX.get_attr — Method
get_attr(rs::Vector{<:AbstractResource}, attr::Symbol, default_value::Real)Function to get attribute attr from a vector of GenX resources rs.
Arguments
rs::Vector{<:AbstractResource}: The vector of resources.attr::Symbol: The attribute to get.default_value::Real: The default value to return if the attribute is not found in any of the resources.
Returns
values::Vector{Real}: The vector of values of the attribute.
GenX.get_attr_by_index — Method
get_attr_by_index(rs::Vector{<:AbstractResource}, index::Int64, attr::Symbol, default_value::Real)Function to get attribute attr from a GenX resource r with index rid. Warning: Always double check the index being passed in is correct. The index in the vector rs might be different from the resource ID. See also by_rid_res for getting the attribute by resource ID.
Arguments
rs::Vector{<:AbstractResource}: The vector of resources.index::Int64: The index of the resource.attr::Symbol: The attribute to get.default_value::Real: The default value to return if the attribute is not found in the resource.
Returns
value::Real: The value of the attribute.
GenX.has_all_options_contributing — Method
has_all_options_contributing(retrofit_res::AbstractResource, rs::Vector{T}) where T <: AbstractResourceCheck if all retrofit options in the retrofit cluster of the retrofit resource retrofit_res contribute to min retirement.
Arguments
retrofit_res::AbstractResource: The retrofit resource.rs::Vector{T}: The vector of resources.
Returns
Bool: True if all retrofit options contribute to min retirement, otherwise false.
GenX.has_all_options_not_contributing — Method
has_all_options_not_contributing(retrofit_res::AbstractResource, rs::Vector{T}) where T <: AbstractResourceCheck if all retrofit options in the retrofit cluster of the retrofit resource retrofit_res do not contribute to min retirement.
Arguments
retrofit_res::AbstractResource: The retrofit resource.rs::Vector{T}: The vector of resources.
Returns
Bool: True if all retrofit options do not contribute to min retirement, otherwise false.
GenX.hydro — Method
hydro(rs::Vector{T}) where T <: AbstractResourceReturns the indices of all hydro resources in the vector rs.
GenX.ids_with — Method
ids_with(rs::Vector{T}, f::Function, default=default_zero) where T <: AbstractResourceFunction for finding resources in a vector rs where the attribute specified by f is not equal to default.
Arguments
rs::Vector{<:AbstractResource}: The vector of resources.f::Function: The getter of the attribute.default: The default value of the attribute.
Returns
ids (Vector{Int64}): The vector of resource ids with attribute not equal todefault.
Examples
julia> ids_with(gen.Thermal, existing_cap_mw)
4-element Vector{Int64}:
21
22
23
24
julia> existing_cap_mw(gen[21])
7.0773GenX.ids_with — Method
ids_with(rs::Vector{T}, name::Symbol, default=default_zero) where T <: AbstractResourceFunction for finding resources in a vector rs where the attribute specified by name is not equal to the default value of the attribute.
Arguments
rs::Vector{<:AbstractResource}: The vector of resources.name::Symbol: The name of the attribute.default: The default value of the attribute.
Returns
ids (Vector{Int64}): The vector of resource ids with attribute not equal todefault.
Examples
julia> ids_with(gen.Thermal, :existing_cap_mw)
4-element Vector{Int64}:
21
22
23
24
julia> existing_cap_mw(gen[21])
7.0773GenX.ids_with_all_options_contributing — Method
ids_with_all_options_contributing(rs::Vector{T}) where T <: AbstractResourceFind the resource ids of the retrofit units in the vector rs where all retrofit options contribute to min retirement.
Arguments
rs::Vector{T}: The vector of resources.
Returns
Vector{Int64}: The vector of resource ids.
GenX.ids_with_all_options_not_contributing — Method
ids_with_all_options_not_contributing(rs::Vector{T}) where T <: AbstractResourceFind the resource ids of the retrofit units in the vector rs where all retrofit options do not contribute to min retirement.
Arguments
rs::Vector{T}: The vector of resources.
Returns
Vector{Int64}: The vector of resource ids.
GenX.ids_with_nonneg — Method
ids_with_nonneg(rs::Vector{T}, f::Function) where T <: AbstractResourceFunction for finding resources in a vector rs where the attribute specified by f is non-negative.
Arguments
rs::Vector{<:AbstractResource}: The vector of resources.f::Function: The getter of the attribute.
Returns
ids (Vector{Int64}): The vector of resource ids with non-negative attribute.
Examples
julia> ids_with_nonneg(gen, max_cap_mw)GenX.ids_with_nonneg — Method
ids_with_nonneg(rs::Vector{T}, f::Function) where T <: AbstractResourceFunction for finding resources in a vector rs where the attribute specified by name is non-negative.
Arguments
rs::Vector{<:AbstractResource}: The vector of resources.name::Symbol: The name of the attribute.
Returns
ids (Vector{Int64}): The vector of resource ids with non-negative attribute.
Examples
julia> ids_with_nonneg(gen, max_cap_mw)GenX.ids_with_policy — Method
ids_with_policy(rs::Vector{T}, f::Function; tag::Int64) where T <: AbstractResourceFunction for finding resources in a vector rs where the policy specified by f with tag equal to tag is positive.
Arguments
rs::Vector{<:AbstractResource}: The vector of resources.f::Function: The policy getter function.tag::Int64: The tag of the policy.
Returns
ids (Vector{Int64}): The vector of resource ids with a positive value for policyfand tagtag.
GenX.ids_with_policy — Method
idswithpolicy(rs::Vector{T}, name::Symbol; tag::Int64) where T <: AbstractResource
Function for finding resources in a vector rs where the policy specified by name with tag equal to tag is positive.
Arguments
rs::Vector{<:AbstractResource}: The vector of resources.name::Symbol: The name of the policy.tag::Int64: The tag of the policy.
Returns
ids (Vector{Int64}): The vector of resource ids with a positive value for policynameand tagtag.
GenX.ids_with_positive — Method
ids_with_positive(rs::Vector{T}, f::Function) where T <: AbstractResourceFunction for finding indices of resources in a vector rs where the attribute specified by f is positive.
Arguments
rs::Vector{<:AbstractResource}: The vector of resources.f::Function: The getter of the attribute.
Returns
ids (Vector{Int64}): The vector of resource ids with positive attribute.
Examples
julia> ids_with_positive(gen, max_cap_mw)
3-element Vector{Int64}:
3
4
5
julia> max_cap_mw(gen[3])
4.888236GenX.ids_with_positive — Method
ids_with_positive(rs::Vector{T}, name::Symbol) where T <: AbstractResourceFunction for finding indices of resources in a vector rs where the attribute specified by name is positive.
Arguments
rs::Vector{<:AbstractResource}: The vector of resources.name::Symbol: The name of the attribute.
Returns
Vector{Int64}: The vector of resource ids with positive attribute.
Examples
julia> ids_with_positive(gen, :max_cap_mw)
3-element Vector{Int64}:
3
4
5
julia> max_cap_mw(gen[3])
4.888236GenX.must_run — Method
must_run(rs::Vector{T}) where T <: AbstractResourceReturns the indices of all must-run resources in the vector rs.
GenX.resource_by_name — Method
resource_by_name(rs::Vector{<:AbstractResource}, name::AbstractString)Find the resource with name in the vector rs.
Arguments
rs: A vector of resources.name: The name of the resource.
Returns
AbstractResource: The resource with the namename.
GenX.resources_in_retrofit_cluster_by_rid — Method
resources_in_retrofit_cluster_by_rid(rs::Vector{<:AbstractResource}, cluster_id::String)Find RID's of resources with retrofit cluster id `clusterid`.
Arguments
rs::Vector{<:AbstractResource}: The vector of resources.cluster_id::String: The retrofit cluster id.
Returns
Vector{Int64}: The vector of resource ids in the retrofit cluster.
GenX.resources_in_zone_by_rid — Method
resources_in_zone_by_rid(rs::Vector{<:AbstractResource}, zone::Int)Find R_ID's of resources in a zone.
GenX.solar — Method
solar(rs::Vector{T}) where T <: AbstractResourceReturns the indices of all co-located solar resources in the vector rs.
GenX.storage — Method
storage(rs::Vector{T}) where T <: AbstractResourceReturns the indices of all storage resources in the vector rs.
GenX.storage_ac_charge — Method
storage_ac_charge(rs::Vector{T}) where T <: AbstractResourceReturns the indices of all co-located storage resources in the vector rs that charge AC.
GenX.storage_ac_discharge — Method
storage_ac_discharge(rs::Vector{T}) where T <: AbstractResourceReturns the indices of all co-located storage resources in the vector rs that discharge AC.
GenX.storage_dc_charge — Method
storage_dc_charge(rs::Vector{T}) where T <: AbstractResource
Returns the indices of all co-located storage resources in the vector `rs` that charge DC.GenX.storage_dc_discharge — Method
storage_dc_discharge(rs::Vector{T}) where T <: AbstractResourceReturns the indices of all co-located storage resources in the vector rs that discharge DC.
GenX.thermal — Method
thermal(rs::Vector{T}) where T <: AbstractResourceReturns the indices of all thermal resources in the vector rs.
GenX.validate_boolean_attribute — Method
validate_boolean_attribute(r::AbstractResource, attr::Symbol)Validate that the attribute attr in the resource r is boolean {0, 1}.
Arguments
r::AbstractResource: The resource.attr::Symbol: The name of the attribute.
GenX.vre_stor — Method
vre_stor(rs::Vector{T}) where T <: AbstractResourceReturns the indices of all VRE_STOR resources in the vector rs.
GenX.@interface — Macro
interface(name, default=default_zero, type=AbstractResource)Define a function interface for accessing the attribute specified by name in a resource of type type.
Arguments
name: The name of the attribute.default: The default value to return if the attribute is not found.type: The type of the resource.
Returns
Function: The generated function.
Examples
julia> @interface max_cap_mw 0 Vre
julia> max_cap_mw(gen.Vre[3])
4.888236
julia> max_cap_mw.(gen.Vre) # vectorized
5-element Vector{Float64}:
0.0
0.0
4.888236
20.835569
9.848441999999999