gtopt::IntegerVariable class

Runtime registry entry for one integer LP column.

Mirrors StateVariable (include/gtopt/state_variable.hpp): inherits LPVariable (LPKey + ColIndex), carries a registry Key, owns the (small) per-block-uid fan-out span by value.

IntegerVariable and StateVariable are orthogonal — an expmod column may be registered as BOTH (integer AND cross-phase state), at the same LPKey and the same ColIndex. Producers that need both call add_integer_variable and add_state_variable independently.

Base classes

struct LPVariable

Public types

struct Key
using LPKey = gtopt::LPKey

Public static functions

template<typename ScenarioLP ScenarioLP, typename StageLP StageLP>
static auto key(const ScenarioLP& scenario, const StageLP& stage, LPClassName class_name, Uid element_uid, std::string_view col_name, IntegerScope scope, GroupUid group_uid = unknown_group) -> Key

Constructors, destructors, conversion operators

IntegerVariable(LPKey lp_key, ColIndex col, IntegerDomain domain, IntegerScope scope, GroupUid group_uid, std::vector<BlockUid> blocks) constexpr noexcept

Public functions

auto blocks() const -> std::optional<std::span<const BlockUid>> noexcept
auto blocks_or_throw() const -> std::span<const BlockUid>
auto col() const -> ColIndex noexcept
auto domain() const -> auto noexcept
auto group_uid() const -> auto noexcept
auto lp_key() const -> const LPKey& noexcept
auto phase_index() const -> PhaseIndex noexcept
auto scene_index() const -> SceneIndex noexcept
auto scope() const -> auto noexcept

Function documentation

template<typename ScenarioLP ScenarioLP, typename StageLP StageLP>
static Key gtopt::IntegerVariable::key(const ScenarioLP& scenario, const StageLP& stage, LPClassName class_name, Uid element_uid, std::string_view col_name, IntegerScope scope, GroupUid group_uid = unknown_group)

Build a Key from concrete (scenario, stage) LP objects. Mirrors StateVariable::key.

gtopt::IntegerVariable::IntegerVariable(LPKey lp_key, ColIndex col, IntegerDomain domain, IntegerScope scope, GroupUid group_uid, std::vector<BlockUid> blocks) constexpr noexcept

Construct from key + col + domain/scope. blocks is moved in; span accessors return views into the stored vector.

std::optional<std::span<const BlockUid>> gtopt::IntegerVariable::blocks() const noexcept

Per-block fan-out of this column.

  • Block → single-element span containing the one block uid.
  • Group → every block in the group.
  • Stage → every block in the stage.
  • Phase → std::nullopt — callers must check the optional before iterating. Returning an empty span instead of nullopt was rejected at design time because it turns a forgotten scope check into a silent no-op.

std::span<const BlockUid> gtopt::IntegerVariable::blocks_or_throw() const

Strict accessor: returns the per-block span unconditionally, or throws on Phase scope. Use at sites that KNOW the scope is chronological — CommitmentLP after the layout resolver has refused Phase-scope bindings, for example.

ColIndex gtopt::IntegerVariable::col() const noexcept

const LPKey& gtopt::IntegerVariable::lp_key() const noexcept

PhaseIndex gtopt::IntegerVariable::phase_index() const noexcept

SceneIndex gtopt::IntegerVariable::scene_index() const noexcept