-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtestlogic.m
executable file
·50 lines (41 loc) · 1.11 KB
/
testlogic.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
%%
% clear all, clc, close all
global ROUTE
global cityCell
global COST
global topFlag
cityCell={};
ROUTE = [];
COST = 0;
topFlag=1;
NUM_TYPES = 4;
scale = 5; pm = 10; genrd = 30;
swarm = genData(genrd, scale, pm);
% swarm = 100*rand(nSizeIn, 2);
swarm = [swarm, (1:length(swarm))']; % this is the original ids
swarm = ja9847;
% viewSwarm(swarm(:, 1), swarm(:, 2), lbl)
layer = swarm;
tmpCenters = zeros(length(layer), 1);
% calc a list centers of all the subsets, for linprog of current
% layer
if iscell(layer)
for k = 1:numel(layer)
tmpCenters(k) = [mean(layer{k}(:, 1:2)), layer{k}(:, 3)]; % layer{k} must be col vector
end
else % input data, as a single vector
tmpCenters = layer;
end
[nxtIdx, Centr] = kmeans(tmpCenters(:, 1:2), NUM_TYPES, 'Distance','sqeuclidean',...
'Replicates',10,'Options',statset('Display','final'));
%%
logicImp(swarm, NUM_TYPES,100);
%%
figure(221)
route = [];
for i =1:length(cityCell)
route=[route;cityCell{i}];
end
MarkSwarm(route(:, 1:2), Centr, nxtIdx, 'k', 'v', 8)
hold on;
plot(route(:, 1), route(:, 2))