From: Muhammad on
Hello everybody,

I've been trying to optimize the problem below. I couldn't figure out how to implement cost function to Matlab. Could anybody assist me doing this? Thanks


function TotalCost = costfunction(x)

% Customer locations j = 1..N, c(:,j)
c = [1 1; 2 2; 2 3; 3 3; 4 5; 5 6]';

% Total trips for customers, d(j)
d = [6 3 3 4 2 2];

f = zeros(5,6);
t = zeros(5,6);

% Constraint
sum(t')=d;

for i=1:5
for j=1:6
f(i,j)=t(i,j)*sqrt((x(:,i)-c(:,j))'*(x(:,i)-c(:,j)));
end
end

TotalCost = sum(f(:));


This is that I could somehow write in Matlab/.
From: Sadik on
Hi Muhammad,

Please send me the formula of the cost function at sadik.hava(a)gmail.com

Best.