I want to maximize the number of unique elements I get from the array vector S. while choosing only K of these vectors.

so I wrote this:

`function [x] = linearSolverCVX(actions, S, K) n = length(actions); lowerBound=zeros(n,1); upperBound=ones(n,1); cvx_begin variable x(n) maximize(length(unique(vertcat(S{1,[find(x)]})))) subject to lowerBound <= x <= upperBound sum(x) == K cvx_end disp(x) end`

In my (testing data) I have S containing 14 vectors and in each of these vectors 3 or 4 numbers from 1 to 14.

when I run the code and print x it appears that it selected K indices which means that it did satisfy the second condition and all the value of x are either zero or one which (I think) indicate that the gurobi is working.

However the optimal solution is not correct.