How can I get binary output instead of fraction from gamultiobj optimization?
Show older comments
I am using the below code to get a binary decision output. Instead I am getting fractions. How can I fix this?
D = [1,2,3,1,2,3,4,1,2,2,1,2,3,4,4,1,2,3,4,3];
F = [4,3,2,4,4,3,2,4,2,2,4,4,4,2,2,5,4,2,2,2];
T = 21;
%H = round(rand(20,20));
H = zeros(20,20);
H(1,2) = 1;
H(1,3) = 1;
H(2,3) = 1;
H(4,5) = 1;
H(4,6) = 1;
H(4,7) = 1;
H(5,6) = 1;
H(5,7) = 1;
H(6,7) = 1;
H(8,9) = 1;
H(8,10) = 1;
H(11,12) = 1;
H(11,13) = 1;
H(12,13) = 1;
H(13,14) = 1;
H(13,15) = 1;
H(16,17) = 1;
H(17,18) = 1;
H(17,19) = 1;
H(17,20) = 1;
fitnessfcn = @(x)[sum(x), -sum(D.*x)];
nvars = 20;
A = -F;
b = -T;
Aeq = [];
Beq = [];
lb = zeros(20,1);
ub = ones(20,1);
[x, fval] = gamultiobj(fitnessfcn, nvars, A, b, Aeq, Beq, lb, ub, @(x) mycon(x, H));
function xsum= constraint2(x,H)
xsum = 0;
for i = 1:length(H)
for j = i+1:length(H)
xsum = xsum + H(i,j) * x(i) * x(j);
end
end
end
function [c,ceq] = mycon(x,H)
c = [];
ceq = constraint2(x,H);
end
Accepted Answer
More Answers (0)
Categories
Find more on Solver Outputs and Iterative Display in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!