def mutation(X, V, pbest, gbest, w, c1, c2, r1, r2, cons):
    """Update position and velocity vectors."""
    V = w * V + c1 * r1 * (pbest - X) + c2 * r2 * (gbest - X)
    X, V = cons(X, V)

    return X, V