實現了蟻群算法求解TSP問題。注釋詳細 function[R_best,L_best,L_ave,Shortest_Route,Shortest_Length]=ACATSP(C,NC_max,m,Alpha,Beta,Rho,Q) ------------------------------------------------------------------------- 主要符號說明 C n個城市的坐標,n×2的矩陣 NC_max最大迭代次數 m螞蟻個數 Alpha表征信息素重要程度的參數 Beta表征啟發式因子重要程度的參數 Rho信息素蒸發系數 Q信息素增加強度系數 R_best各代最佳路線 L_best各代最佳路線的長度 =========================================================================
標簽: Shortest_Length Shortest_Route function R_best
上傳時間: 2014-01-17
上傳用戶:lunshaomo
Implementation of Edmonds Karp algorithm that calculates maxFlow of graph. Input: For each test case, the first line contains the number of vertices (n) and the number of arcs (m). Then, there exist m lines, one for each arc (source vertex, ending vertex and arc weight, separated by a space). The nodes are numbered from 1 to n. The node 1 and node n should be in different sets. There are no more than 30 arcs and 15 nodes. The arc weights vary between 1 and 1 000 000. Output: The output is a single line for each case, with the corresponding minimum size cut. Example: Input: 7 11 1 2 3 1 4 3 2 3 4 3 1 3 3 4 1 3 5 2 4 6 6 4 5 2 5 2 1 5 7 1 6 7 9 Output: 5
標簽: Implementation calculates algorithm Edmonds
上傳時間: 2014-01-04
上傳用戶:kiklkook
#include <iostream> using namespace std; int main(){ int t; cin>>t; while(t--){ long long n; cin>>n; if(n%2==1) cout<<(n*n-1)/4<<endl; else if (n%4==0) cout <<(n*n)/4-1<<endl; else{ if(n==2) cout<<1<<endl; else{ long long k=n/2-1; cout <<k*k+2*k-3<<endl; } } } return 0; }
標簽: 天津大學acm4022 代碼
上傳時間: 2015-04-20
上傳用戶:nr607
#include <iostream> using namespace std; class Student { public: Student(int, int); int num; int grade; }; Student::Student(int n, int g) { num = n; grade = g; } int maxGradeIndex(Student* s) { int maxGrade, index = 0, i = 0; maxGrade = s[0].grade; for (i = 0; i<5; i++) { if (s[i].grade > maxGrade) { maxGrade = s[i].grade; index = i; } } return index; } int main() { Student a[5] = { Student(1, 86), Student(2, 60), Student(3, 72), Student(4, 95), Student(5, 66) }; int maxGradeStNum = maxGradeIndex(a); cout << "成績最好學生的學號是:" << a[maxGradeStNum].num << endl; cout << "成績最好學生的成績是:" << a[maxGradeStNum].grade << endl; getchar(); return 0; }
上傳時間: 2016-04-23
上傳用戶:burt1025
實驗源代碼 //Warshall.cpp #include<stdio.h> void warshall(int k,int n) { int i , j, t; int temp[20][20]; for(int a=0;a<k;a++) { printf("請輸入矩陣第%d 行元素:",a); for(int b=0;b<n;b++) { scanf ("%d",&temp[a][b]); } } for(i=0;i<k;i++){ for( j=0;j<k;j++){ if(temp[ j][i]==1) { for(t=0;t<n;t++) { temp[ j][t]=temp[i][t]||temp[ j][t]; } } } } printf("可傳遞閉包關系矩陣是:\n"); for(i=0;i<k;i++) { for( j=0;j<n;j++) { printf("%d", temp[i][ j]); } printf("\n"); } } void main() { printf("利用 Warshall 算法求二元關系的可傳遞閉包\n"); void warshall(int,int); int k , n; printf("請輸入矩陣的行數 i: "); scanf("%d",&k); 四川大學實驗報告 printf("請輸入矩陣的列數 j: "); scanf("%d",&n); warshall(k,n); }
上傳時間: 2016-06-27
上傳用戶:梁雪文以
#include "string.h" #include "ctype.h" #include "stdio.h" search(char pd[]) {FILE *fp; int time=0,i=0,j=0,add[80],k=0,m; char *ch, str[900]; m=strlen(pd); if((fp=fopen("haha.txt","r"))==NULL) { printf("Cannot open this file\n"); exit(0); } for(;!feof(fp);i++) { str[i]=fgetc(fp); if(tolower(str[i])==tolower(pd[k])) {k++; if(k==m) if(!isalpha(i-m)&&!isalpha((str[i++]=fgetc(fp)))) { time++; add[j]=i-m+1; j++; k=0; } else k=0; } } if(time) { printf("The time is:%d\n",time); printf("The adders is:\n"); for(i=0;i
標簽: 查詢學會少年宮
上傳時間: 2016-12-29
上傳用戶:767483511
% Computation of ST-ZCR and STE of a speech signal. % % Functions required: zerocross, sgn, winconv. % % Author: Nabin Sharma % Date: 2009/03/15 [x,Fs] = wavread('so.wav'); % word is: so x = x.'; N = length(x); % signal length n = 0:N-1; ts = n*(1/Fs); % time for signal % define the window wintype = 'rectwin'; winlen = 201; winamp = [0.5,1]*(1/winlen);
標簽: 短時過零率和短時能量
上傳時間: 2019-09-23
上傳用戶:minwenji
%========================開始提取加噪信號的各類特征值================================ for n=1:1:50; m=n*Ns; x=(n-1)*Ns; for i=x+1:m; %提取加噪信號'signal_with_noise=y+noise'的前256個元素,抽取50次 y0(i)=signal_with_noise(i); end Y=fft(y0); %對調制信號進行快速傅里葉算法(離散) y1=hilbert(y0) ; %調制信號實部的解析式 factor=0; %開始求零中心歸一化瞬時幅度譜密度的最大值gamma_max for i=x+1:m; factor=factor+y0(i); end ms=factor/(m-x); an_i=y0./ms; acn_i=an_i-1; end gamma_max=max(fft(acn_i.*acn_i))/Ns
上傳時間: 2020-04-07
上傳用戶:如拷貝般復制
%========================開始提取加噪信號的各類特征值================================ for n=1:1:50; m=n*Ns; x=(n-1)*Ns; for i=x+1:m; %提取加噪信號'signal_with_noise=y+noise'的前256個元素,抽取50次 y0(i)=signal_with_noise(i); end Y=fft(y0); %對調制信號進行快速傅里葉算法(離散) y1=hilbert(y0) ; %調制信號實部的解析式 factor=0; %開始求零中心歸一化瞬時幅度譜密度的最大值gamma_max for i=x+1:m; factor=factor+y0(i); end ms=factor/(m-x); an_i=y0./ms; acn_i=an_i-1; end gamma_max=max(fft(acn_i.*acn_i))/Ns
上傳時間: 2020-04-07
上傳用戶:如拷貝般復制
家 庭 總 線 是 智 能 家 居 實 現 的 重 要 基 礎 . 是 住 宅 內 部 的 神 經 系 統 . 其 主 要 作 用 是 連 接 家 中的各 種 電子 、 電氣 設 備 . 負責 將 家 庭 內 的 各 種 通 信 設 備 ( 包 括 安 保 、 電話 、 家 電 、 視 聽 設 備 等 )連 接 在 一 起 . 形 成 一 個 完 整 的家 庭 網 絡 。 日 本 是 較 早 推 動 智 能 家 居 發 展 的 國 家 之 一 , 它 較 早 地 提 出 了 家庭 總線 系統 (H O m e B u S S Y S t e m , 簡稱H B S ) 的概念 . 成 立 了 家庭 總線 (H B S )研 究會 . 并 在 郵政省和 通 產 省 的指 導 下 組 成 了H B S 標 準委 員 會 , 制定 了 日 本 的H B s 標 準 。 按 照 該 標 準 , H B S 系統 由一 條 同 軸 電 纜 和 4 對 雙 絞 線 構 成 , 前 者 用 于 傳 輸 圖 像 信 息 . 后者 用 于 傳輸語 音 、 數據及 控制信 號 。 各 類家用 設 備 與 電氣 設 備 均 按 一 定 方式 與H B S 相 連 , 這 些 電氣設 備 既 可 以在 室 內進 行 控制 . 也 可 在異地 通 過 電話進行 遙 控 。 為適 應 大型 居住社 區 的需 要 , 1 9 8 8 年年初 , 日 本住 宅信息 化推進協會 又 推 出 了 超級 家庭總 線 (S u p e r H0 m e B u s S y s t e m , 簡 稱S - H B S ) , 它適 用 于 更 大 的范 圍 . 因 為一 個S - H B s 系統可 掛接 數千個家庭 內部 網 。 家庭 智能化要 求諸 多家 電和 網絡能夠彼此 相容 . 總線協 議是 其精髓 所 在 , 只 有接 E l 暢通 , 家 電才能 “ 聽懂 ” 人 發 出的指令 , 因此 總線標準 的物理 層 接 口 形 式 是 智能 家居 亟 待解決 的重 要 問題 之 一 。 目前 比 較成型 的總線標 準 協 議 主 要 是 美 國公 司 提 出 的 , 包 括E c h e l o n 公 司 I)~L o n W o r k s 協議 、 電子 工 業 協 會 (E I A ) 的C E 總線協 議 (C EB u S ) 、 S m a r t Ho u s e L P 的智 能屋 協 議 和×一 1 0 公 司 的X 一 1 0 協 議等。 這 些 協 議 各 有 優 劣 。
標簽: 智能家居
上傳時間: 2022-03-11
上傳用戶: