生成模型图
(函数来自 pyomo.contrib.community_detection.community_graph)
- pyomo.contrib.community_detection.community_graph.generate_model_graph(model, type_of_graph, with_objective=True, weighted_graph=True, use_only_active_components=True)[source]
基于Pyomo优化模型创建节点和边的networkX图
此函数接收一个Pyomo优化模型,然后根据用户确定的图形特定特征创建模型的图形表示(见下面的参数)。
(此函数设计为由 detect_communities 调用,但也可以单独用于创建模型图。)
- Parameters:
model (Block) – 用于社区检测的Pyomo模型或块
type_of_graph (str) – 一个字符串,指定从模型创建的图的类型 ‘constraint’ 创建一个基于约束节点的图, ‘variable’ 创建一个基于变量节点的图, ‘bipartite’ 创建一个基于约束和变量节点的图(二分图)。
with_objective (bool, optional) – 一个布尔参数,用于指定目标函数是否包含在图中;默认值为 True
weighted_graph (bool, optional) – 一个布尔参数,指定是否从Pyomo模型创建加权或未加权的图;默认值为True(type_of_graph=’bipartite’ 无论此参数如何都会创建一个未加权的图)
use_only_active_components (bool, optional) – 一个布尔参数,指定是否在网络X图中包含非活动的约束/目标
- Returns:
bipartite_model_graph/projected_model_graph (nx.Graph) – 一个基于给定Pyomo优化模型的节点和边的NetworkX图
number_component_map (dict) – 一个将数字(确定性)映射到模型中组件的字典
constraint_variable_map (dict) – 一个将编号约束映射到出现在该约束中的(编号)变量列表的字典