get_location_set_map

(function from pyomo.util.slices)

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

Map each value in an index to the set from which it originates

This function iterates over the “subsets” of index_set in the forward direction, assigning sets to each value in index, until it finds a set of dimension None. Then it iterates over the reversed list of subsets, assigning sets, until it encounters the same set of dimension None. All remaining values are assigned to the set of dimension None. If a second such set is found, an error is raised.

Parameters:

index: tuple or hashable scalar

The index whose values will be assigned to sets

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

The index set from which index originates

Returns:

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

from which it originates.