Decode the weird character.

2 visualizaciones (últimos 30 días)
Steve
Steve el 19 de Nov. de 2011
I have a code here and there are plentiful of the weird character and I wish to decode it into an understandable character. I am new to matlab and trying to study the examples of codes.
Here the codes:
clear;
CityNum=30;
[dislist,Clist]=tsp(CityNum);
Tlist=zeros(CityNum);%½û¼É±í(tabu list)
cl=100;%±£ÁôÇ°cl¸ö×îºÃºòÑ¡½â
bsf=Inf;
tl=50; %½û¼É³¤¶È(tabu length)
l1=200;%ºòÑ¡½â(candidate),²»´óÓÚn*(n-1)/2(È«²¿ÁìÓò½â¸öÊý)
S0=randperm(CityNum);
S=S0;
BSF=S0;
Si=zeros(l1,CityNum);
StopL=2000; %ÖÕÖ¹²½Êý
p=1;
clf;
figure(1);
while (p<StopL+1)
if l1>CityNum*(CityNum)/2
disp('ºòÑ¡½â¸öÊý,²»´óÓÚn*(n-1)/2(È«²¿ÁìÓò½â¸öÊý)£¡ ϵͳ×Ô¶¯Í˳ö£¡');
l1=(CityNum*(CityNum)/2)^.5;
break;
end
ArrS(p)=CalDist(dislist,S);
i=1;
A=zeros(l1,2);
while i<=l1
M=CityNum*rand(1,2);
M=ceil(M);
if M(1)~=M(2)
m1=max(M(1),M(2));m2=min(M(1),M(2));
A(i,1)=m1;A(i,2)=m2;
if i==1
isdel=0;
else
for j=1:i-1
if A(i,1)==A(j,1)&&A(i,2)==A(j,2)
isdel=1;
break;
else
isdel=0;
end
end
end
if ~isdel
i=i+1;
else
i=i;
end
else
i=i;
end
end
for i=1:l1
Si(i,:)=S;
Si(i,[A(i,1),A(i,2)])=S([A(i,2),A(i,1)]);
CCL(i,1)=i;
CCL(i,2)=CalDist(dislist,Si(i,:));
CCL(i,3)=S(A(i,1));
CCL(i,4)=S(A(i,2));
end
[fs fin]=sort(CCL(:,2));
for i=1:cl
CL(i,:)=CCL(fin(i),:);
end
if CL(1,2)<bsf %ÃêÊÓ×¼Ôò(aspiration criterion)
bsf=CL(1,2);
S=Si(CL(1,1),:);
BSF=S;
for m=1:CityNum
for n=1:CityNum
if Tlist(m,n)~=0
Tlist(m,n)=Tlist(m,n)-1;
end
end
end
Tlist(CL(1,3),CL(1,4))=tl;
else
for i=1:cl
if Tlist(CL(i,3),CL(i,4))==0
S=Si(CL(i,1),:);
for m=1:CityNum
for n=1:CityNum
if Tlist(m,n)~=0
Tlist(m,n)=Tlist(m,n)-1;
end
end
end
Tlist(CL(i,3),CL(i,4))=tl;
break;
end
end
end
Arrbsf(p)=bsf;
drawTSP(Clist,BSF,bsf,p,0);
p=p+1;
end
BestShortcut=BSF
theMinDistance=bsf
figure(2);
plot(Arrbsf,'r'); hold on;
plot(ArrS,'b');grid;
title('ËÑË÷¹ý³Ì');
legend('×îÓŽâ','µ±Ç°½â');
Anyway I can get the weird character to be decoded? please advice and guide.

Respuesta aceptada

Walter Roberson
Walter Roberson el 19 de Nov. de 2011
You go back and locate the place you found the code, which is
Select the code you want to translate, and use your browser "Copy" function.
Then you visit Google Translate, such as at <http://translate.google.ca/?hl=en&tab=wT>
You use your browser function to Paste the code to translated into the box on the left hand side, and then you go up to the controls above that box and choose From Chinese in the first control, and To English in the third control. Then you press the Translate button.
The result you will get in this particular case follow:
clear;
CityNum = 30;
[Dislist, Clist] = tsp (CityNum);
Tlist = zeros (CityNum);% taboo table (tabu list)
cl = 100;% to retain the best candidates for a solution before the cl
bsf = Inf;
tl = 50;% taboo length (tabu length)
l1 = 200;% candidate solutions (candidate), not more than n * (n-1) / 2 (the number of solutions of the whole field)
S0 = randperm (CityNum);
S = S0;
BSF = S0;
Si = zeros (l1, CityNum);
StopL = 2000;% termination steps
p = 1;
clf;
figure (1);
while (p <StopL +1)
if l1> CityNum * (CityNum) / 2
disp ('the number of candidate solutions, not more than n * (n-1) / 2 (the number of all solutions of the field)! system will automatically quit!');
l1 = (CityNum * (CityNum) / 2) ^ .5;
break;
end
ArrS (p) = CalDist (dislist, S);
i = 1;
A = zeros (l1, 2);
while i <= l1
M = CityNum * rand (1,2);
M = ceil (M);
if M (1) ~ = M (2)
m1 = max (M (1), M (2)); m2 = min (M (1), M (2));
A (i, 1) = m1; A (i, 2) = m2;
if i == 1
isdel = 0;
else
for j = 1: i-1
if A (i, 1) == A (j, 1) & & A (i, 2) == A (j, 2)
isdel = 1;
break;
else
isdel = 0;
end
end
end
if ~ isdel
i = i +1;
else
i = i;
end
else
i = i;
end
end
for i = 1: l1
Si (i,:) = S;
Si (i, [A (i, 1), A (i, 2)]) = S ([A (i, 2), A (i, 1)]);
CCL (i, 1) = i;
CCL (i, 2) = CalDist (dislist, Si (i ,:));
CCL (i, 3) = S (A (i, 1));
CCL (i, 4) = S (A (i, 2));
end
[Fs fin] = sort (CCL (:, 2));
for i = 1: cl
CL (i,:) = CCL (fin (i ),:);
end
if CL (1,2) <bsf% contempt criteria (aspiration criterion)
bsf = CL (1,2);
S = Si (CL (1,1 ),:);
BSF = S;
for m = 1: CityNum
for n = 1: CityNum
if Tlist (m, n) ~ = 0
Tlist (m, n) = Tlist (m, n) -1;
end
end
end
Tlist (CL (1,3), CL (1,4)) = tl;
else
for i = 1: cl
if Tlist (CL (i, 3), CL (i, 4)) == 0
S = Si (CL (i, 1 ),:);
for m = 1: CityNum
for n = 1: CityNum
if Tlist (m, n) ~ = 0
Tlist (m, n) = Tlist (m, n) -1;
end
end
end
Tlist (CL (i, 3), CL (i, 4)) = tl;
break;
end
end
end
Arrbsf (p) = bsf;
drawTSP (Clist, BSF, bsf, p, 0);
p = p +1;
end
BestShortcut = BSF
theMinDistance = bsf
figure (2);
plot (Arrbsf, 'r'); hold on;
plot (ArrS, 'b'); grid;
title ('search process');
legend ('optimal solution', 'current solution'); ...
  1 comentario
Steve
Steve el 20 de Nov. de 2011
Thanks man, this work great. :)

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Call MATLAB from C en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by