Hi,
I have this code at the moment that loops through a list of values (customer demands from 2 customers being merged) from top to bottom and sums the values into an accumulated sum, breaks the accumulated sum when a specific threshold is reached (37) and then starts over the accumulated sum from the next number in the list. For example, the list of 14 14 12 12 6 6 12 12 20 is becoming 14 28 [break] 12 24 30 36 [break] 12 24 [break] 20 [break].
x = Sum_efterfr_SavingList_kol6; % the list of values
threshold = 37; index=1;while 1 xc = cumsum(x(index:end)); m = find(xc > thresh,1,'first'); if isempty(m) break end x(m) = x(m)-xc(m-1); Loopdata{m}=xc; % this is not saving the values that i want, only where in the list that the cumsum is starting over
end
My first problem is partly that I want to save each accumulated sum into individual arrays instead of a long list, for example I want A = (14 28), B = (12 24 30 36) and so on, but I can't get it to work properly.
But I also can't figure out how (and where in the while loop) to implement that I only want to use the cumsum on the values of customers that isn't already part of a saved array, because I aim to eventually execute the Clarke & Wright algoritm with merging customers in tours (the saved arrays will eventually be the tours) and the list with cumsums will not loop from top to bottom.
Would really appreciate some help!
Best Answer