pygsti.algorithms.grasp.neighboring_weight_vectors#
- neighboring_weight_vectors(weights, forced_weights=None, shuffle=False)#
Return the list of weights in the neighborhood of a given weight vector.
A weight vector is in the neighborhood of a given weight vector if it is only a single swap away from the given weight vector. There is an option to use forced_weights to indicate elements you don’t want to swap out.
- Parameters:
weights (numpy.array) – Binary vector to find the neighborhood of.
forced_weights (numpy.array, optional) – Binary vector indicating elements that must be included in all neighboring vectors (these elements are assumed to already be present in weights.
shuffle (bool, optional) – Whether the neighborhood should be presented to the optimizer in a random order (important if the local optimizer updates the solution to the first better solution it finds in the neighborhood instead of exhaustively searching the neighborhood for the best solution).
- Returns:
List of binary vectors corresponding to all the neighbors of weights.
- Return type:
list of numpy.array