获取模型变量
(函数来自 pyomo.contrib.alternative_solutions.aos_utils)
- pyomo.contrib.alternative_solutions.aos_utils.get_model_variables(model, components=None, include_continuous=True, include_binary=True, include_integer=True, include_fixed=False)[source]
收集并返回来自Pyomo模型的所有变量或变量子集。
- Parameters:
model (ConcreteModel) – 一个具体的Pyomo模型。
components (None 或 一个集合 的 Pyomo 组件) – 从中收集变量的组件。None 表示将包含所有变量。或者,可以提供一个 Pyomo 块、约束或变量(索引或 非索引)的集合,从中收集变量。 如果提供了一个块,将返回与该块及其子块中的约束 相关的所有变量。要排除 子块,可以使用格式为 (Block, False) 的元组元素。
include_continuous (boolean) – 布尔值,表示是否应包含连续变量。
include_binary (boolean) – 布尔值,指示是否应包含二进制变量。
include_integer (boolean) – 布尔值,指示是否应包含整数变量。
include_fixed (boolean) – 布尔值,指示是否应包含固定变量。
- Returns:
一个包含 _GeneralVarData 变量的 Pyomo ComponentSet。
- Return type:
variable_set