gtopt::SumElementRef struct

Aggregation over multiple elements of the same type.

Represents sum(element_type("id1","id2",...).attribute) or sum(element_type(all).attribute) — the AMPL-style sum{g in SET}. An optional type_filter restricts the sum to elements whose type field matches the given string (case-sensitive).

Examples:

  • sum(generator("G1","G2").generation) → {element_type="generator", element_ids={"G1","G2"}, all_elements=false, attribute="generation"}
  • sum(generator(all).generation) → {element_type="generator", element_ids={}, all_elements=true, attribute="generation"}
  • sum(generator(all, type="hydro").generation) → {element_type="generator", element_ids={}, all_elements=true, type_filter="hydro", attribute="generation"}

Public variables

bool all_elements
true = sum over all elements of the type
std::string attribute
LP attribute to aggregate.
std::vector<std::string> element_ids
Element names/UIDs to sum.
std::string element_type
"generator", "demand", "line", etc.
std::optional<std::string> type_filter
Optional type tag filter (matches element.type)