I have an optimization problem with a continuous matrix variable (C), but:
My objective function is not about min/max the entries of C, but to maximize the amounts of 0 in C. My approach to model this, is to translate C to heaviside(C), which would make all non-zero entries equal to 1 and all zero entries stay 0. Then i could minimize the sum of these matrix entries, resulting a maximum of zero entries.
model.set_objective('min', sum(np.heaviside(C[k,j], 0) for k, j in itertools.product(range(M), range(P))))
Here I get errors of cplex, because C does not have defined values at this point. Any kind of casting the values of C to int or float fails as well.
TypeError: ufunc 'heaviside' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
I do not understand, why this is a problem, while e.g.
model.set_objective('min', sum(C[k,j] for k, j in itertools.product(range(M), range(P))))
works fine.