SumElementRef struct
#include <gtopt/constraint_expr.hpp>
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 list of filters (F4) restricts the sum to elements whose metadata matches every predicate (AND). For backward compatibility, the legacy sum(type(all, type="hydro").attr) syntax is accepted and lowered to a single type == "hydro" predicate in filters.
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" and cap>=50).generation) → {all_elements=true, filters=[{"type", Eq, "hydro"}, {"cap", Ge, 50}]}
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::vector<SumPredicate> filters
- F4 filter predicates (AND).