获取位置设置地图

(函数来自 pyomo.util.slices)

pyomo.util.slices.get_location_set_map(index, index_set)[source]

将索引中的每个值映射到它来源的集合

此函数正向遍历index_set的“子集”,将集合分配给index中的每个值,直到找到一个维度为None的集合。然后它反向遍历子集列表,分配集合,直到遇到相同的维度为None的集合。所有剩余的值都被分配给维度为None的集合。如果找到第二个这样的集合,则会引发错误。

参数:

index: tuple or hashable scalar

其值将被分配给集合的索引

index_set: pyomo.core.base.set.SetProduct or pyomo.core.base.set.Set

索引集,从中产生index

返回:

dict: Maps the “locations” (indices) within the index to the set

从其起源的地方。