⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 route_cost.m

📁 一个模拟退火matlab程序
💻 M
字号:
function Ew = route_cost(X,W)
% Ew = route_cost(X,W)
% Method for tsp example supplied with SA Tools.
% See http://www.frostconcepts.com/software for information on SA Tools.
%
%   Ew = route_cost(X,W) ;
%
%   X = {N, D}
%       N = # of cities.
%       D = distance matrix. D(i,j) = distance from city i to j.
%   W = a route, a permutation of the indicies 1:N
%
%   Ew = energy corresponding to W.
%   Computed by summing the distances along the route.
%
N = X{1} ;
D = X{2} ;
Ew = D(W(N),W(1)) ;
for i=1:(N-1)
    Ew = Ew + D(W(i),W(i+1)) ;
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -