The code below finds an maximum independent set of the graph whose adjacency matrix is A. I would like to pass an option to intlinprog that says stop and return an answer if you get an objective value of -5 or less (meaning an independent set of size 5 or more has been found). This should be much more efficient than finding an independent set of maximum size.
If there is no option to pass to intlinprog that can accomplish my goal, then is there another approach that will?
n = 20;A = rand(n, n) < 0.1;A = A | A.';[r, c] = find(A);m = numel(r);B = zeros(m, n);for eI = 1 : mB(eI, [r(eI), c(eI)]) = 1;endb = ones(m, 1);c = -ones(n, 1);% min cost.' * x subject to A * x <= b, x(i) is 0 or 1 for all i.
lb = zeros(n, 1);ub = lb + 1;intvars = 1 : n;options = optimoptions('intlinprog','Display','off');[x, fval, exitflag, output] = intlinprog(c, intvars, B, b, [], [], lb, ub, options);
Best Answer