解决方案
(类来自 pyomo.contrib.alternative_solutions.solution)
- class pyomo.contrib.alternative_solutions.solution.Solution(model, variable_list, include_fixed=True, objective=None)[source]
基础类:
object一个用于存储来自Pyomo模型的解决方案的类。
- variables
Pyomo变量与其解的值之间的映射。
- Type:
- fixed_vars
在解决方案中固定的Pyomo变量集合。
- Type:
- objective
Pyomo目标与其解决方案值之间的映射。
- Type:
- pprint():
打印一个解决方案。
- get_variable_name_values(self, ignore_fixed_vars=False):
获取变量名-变量值对的字典。
- get_fixed_variable_names(self):
获取固定变量名称的列表。
- get_objective_name_values(self):
获取目标名称-目标值对的字典。
- __init__(model, variable_list, include_fixed=True, objective=None)[source]
构建一个Pyomo解决方案对象。
- Parameters:
model (ConcreteModel) – 一个具体的Pyomo模型。
variable_list (一个集合的Pyomo _GenereralVarData 变量) – 将存储解决方案的变量。
include_fixed (boolean) – 布尔值,指示是否应将固定变量添加到解决方案中。
目标 (无 或 Objective) – 要保存其值的目标函数。无表示应使用活动目标,但也可以存储不同的目标。
方法
__init__(model, variable_list[, ...])构建一个Pyomo解决方案对象。
获取固定变量名称的列表。
get_variable_name_values([include_fixed, ...])获取变量名-变量值对的字典。
pprint([round_discrete, sort_keys, indent])打印解决方案变量和目标值。
to_dict([round_discrete])to_string([round_discrete, sort_keys, indent])属性
rtype: 目标函数的值。
成员文档
- get_variable_name_values(include_fixed=True, round_discrete=True)[source]
获取变量名-变量值对的字典。
- Parameters:
include_fixed (boolean) – 如果为True,则在字典中包含固定变量。
round_discrete (boolean) – 如果为True,则在字典中对离散变量值进行四舍五入。
- Return type:
字典映射变量名称到变量值。
- pprint(round_discrete=True, sort_keys=True, indent=4)[source]
打印解决方案变量和目标值。
- Parameters:
rounded_discrete (boolean) – 如果为True,则在打印前对离散变量值进行四舍五入。
- property objective_value
rtype: 目标函数的值。