gtopt::VariableScale struct

Scale definition for an LP variable.

Convention: physical_value = LP_value × scale.

When uid is set, the scale applies only to the element with that UID. When uid is absent, the scale applies to all elements of the given class.

Public variables

std::string class_name
std::string name
Element name (informational).
Real scale
physical = LP × scale
Uid uid
Element UID (unknown_uid = all elements).
std::string variable
Variable name (e.g. "theta", "energy").

Variable documentation

std::string gtopt::VariableScale::class_name

Element class (e.g. "Bus", "Reservoir"). Owning std::string: JSON deserialisation binds these zero-copy into the transient parse buffer that parse_planning_json frees on return, so a std::string_view here dangled — a heap-use-after-free later read by auto_scale_reservoirs (found by ThreadSanitizer). Owning the string is correct and cheap; the programmatic call sites just build a small string from a constexpr full_name(). VariableScaleMap still holds string_view keys into these strings — the source must outlive the map (contract unchanged).