function [c, ceq]=constraint(x) global B; global NumOfvisit m = size(B, 1); % row number of B if m <= NumOfvisit c=zeros(m, 1); for j= 1:m c(j) = (x(2) + B(j, 1))*log(x(1)*x(2)*x(4)) - B(j, 2)*x(1)*x(2) - ... (x(2) + B(j, 1))*log(x(3)*(x(2) + B(j, 1))) + 10^(-6); end else new_m = NumOfvisit; c=zeros(new_m, 1); for j= 1:new_m c(j)= (x(2) + B(j, 1))*log(x(1)*x(2)*x(4)) - B(j, 2)*x(1)*x(2) - ... (x(2) + B(j, 1))*log(x(3)*(x(2) + B(j, 1))) + 10^(-6); end end ceq = x(1) - B(1, 3) * (x(3) - x(1)*x(4)); return