Resource types and function interfaces
GenX.AbstractResource — TypeAn abstract type that should be subtyped for users creating GenX resources.
GenX.default_zero — Constantconst default_zero = 0Default value for resource attributes.
GenX.resource_types — Constantresource_typesName of the type of resources available in the model.
Possible values:
- :Thermal
- :Vre
- :Hydro
- :Storage
- :MustRun
- :FlexDemand
- :VreStorage
- :Electrolyzer
- :AllamCycleLox
Base.findall — Methodfindall(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 — MethodBase.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 — MethodBase.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 — MethodBase.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 — Methodhaskey(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 — Methodpairs(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! — MethodBase.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! — Methodsetproperty!(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! — MethodBase.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.
Base.show — Methodshow(io::IO, r::AbstractResource)Print the attributes of the given resource.
Arguments
io::IO: The IO stream to print to.r::AbstractResource: The resource.
GenX.allam_cycle_lox — Methodallam_cycle_lox(rs::Vector{T}) where T <: AbstractResourceReturns the indices of all ALLAMCYCLELOX resources in the vector rs.
GenX.attributes — Methodattributes(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.elec — Methodelec(rs::Vector{T}) where T <: AbstractResourceReturns the indices of all co-located electrolyzer resources in the vector rs.
GenX.electrolyzer — Methodelectrolyzer(rs::Vector{T}) where T <: AbstractResourceReturns the indices of all electrolyzer resources in the vector rs.
GenX.flex_demand — Methodflex_demand(rs::Vector{T}) where T <: AbstractResourceReturns the indices of all flexible demand resources in the vector rs.
GenX.get_attr — Methodget_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 — Methodget_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 — Methodget_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 — Methodhas_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 — Methodhas_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 — Methodhydro(rs::Vector{T}) where T <: AbstractResourceReturns the indices of all hydro resources in the vector rs.
GenX.ids_with — Methodids_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 — Methodids_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 — Methodids_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 — Methodids_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 — Methodids_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 — Methodids_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 — Methodids_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 — Methodidswithpolicy(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 — Methodids_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 — Methodids_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 — Methodmust_run(rs::Vector{T}) where T <: AbstractResourceReturns the indices of all must-run resources in the vector rs.
GenX.resource_by_name — Methodresource_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 — Methodresources_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 — Methodresources_in_zone_by_rid(rs::Vector{<:AbstractResource}, zone::Int)Find R_ID's of resources in a zone.
GenX.solar — Methodsolar(rs::Vector{T}) where T <: AbstractResourceReturns the indices of all co-located solar resources in the vector rs.
GenX.storage — Methodstorage(rs::Vector{T}) where T <: AbstractResourceReturns the indices of all storage resources in the vector rs.
GenX.storage_ac_charge — Methodstorage_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 — Methodstorage_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 — Methodstorage_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 — Methodstorage_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 — Methodthermal(rs::Vector{T}) where T <: AbstractResourceReturns the indices of all thermal resources in the vector rs.
GenX.validate_boolean_attribute — Methodvalidate_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 — Methodvre(rs::Vector{T}) where T <: AbstractResourceReturns the indices of all Vre resources in the vector rs.
GenX.vre_stor — Methodvre_stor(rs::Vector{T}) where T <: AbstractResourceReturns the indices of all VRE_STOR resources in the vector rs.
GenX.wind — Methodwind(rs::Vector{T}) where T <: AbstractResourceReturns the indices of all co-located wind resources in the vector rs.
GenX.@interface — Macrointerface(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