You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

RunExpSrv8s.m 9.5KB

5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. function [] = RunExpSrv8s(iterStartStr, iterEndStr, netSizeStr, addAttPercStr)
  2. %function [] = RunExpSrv8s(iterStartStr, iterEndStr, netSizeStr, normF1, normF2, normF3, addAttPercStr)
  3. %affinity calculation types
  4. % affinity_calculation_shortest_path = 0;
  5. % affinity_calculation_euclid = 1;
  6. % affinity_calculation_common_friends = 2;
  7. % affinity_calculation_random_clustering = 3;
  8. % affinity_calculation_adamic_adar = 4;
  9. % affinity_calculation_katz_beta_0_5 = 5;
  10. % affinity_calculation_katz_beta_0_05 = 6;
  11. % affinity_calculation_katz_beta_0_005 = 7;
  12. % affinity_calculation_boost = 9; % sigal 12.3.13 add BOOST option
  13. expParams = 3;
  14. if nargin < expParams
  15. usageStr = 'Usage: RunExperimentSrv <iterStart> <iterEnd> <netSize> [<addAttPerc>]\n';
  16. % usageStr = 'Usage: RunExperimentSrv <iterStart> <iterEnd> <netSize> <f1> <f2> <f3> [<addAttPerc>]\n';
  17. fprintf('RunExpSrv8s:Invalid usage: expected at least %d parameters.\n%s', expParams, usageStr);
  18. return;
  19. end
  20. % input_iter = input('iteration number:');
  21. iterStart = str2num(iterStartStr);
  22. iterEnd = str2num(iterEndStr);
  23. % input_factors
  24. f1 = 9; %str2num(normF1);
  25. f2 = 2; %str2num(normF2);
  26. f3 = 2; %str2num(normF3);
  27. normFactorVec = [f1 f2 f3];
  28. % input addAttPerc;
  29. addAttPerc = 1; %[1 0.7];
  30. if nargin > expParams
  31. addAttPerc = str2double(addAttPercStr);
  32. if addAttPerc > 1
  33. addAttPerc = 1;
  34. elseif addAttPerc < 0
  35. addAttPerc = 0;
  36. end
  37. end
  38. affinities = [2,4,3,9]; %[2,3,9]; %[2,4,3,9]; %,6]; %3,4]; %,6];
  39. %num_missing_nodes_arr = [10 30 50 100 150 200]; %%[11 21 31 41 50]; %%5:5:30; %10:10:50; %%[11 21 31 41 50]; %10:10:50;
  40. percentKnownPHsVec = 1;
  41. % ds_10k = [2000 5000 10000];
  42. % ds_10km = [10001];
  43. % ds_32k = [2048 4096 8192 16384 32768];
  44. % ds_100k = [20000 25000 50000 75000 100000];
  45. % ds_100km = [100001];
  46. % ds_Train = [2001 2049];
  47. ds_GridTrain = [45];
  48. % input netSize
  49. netSize = str2num(netSizeStr);
  50. % if find(ds_10k==netSize)
  51. % ds_str = 'Datasets_10K/';
  52. % num_missing_nodes_arr = [10 20 30 50 70 100];%[10 100 150];
  53. % elseif find(ds_10km==netSize)
  54. % ds_str = 'Datasets_10K/';
  55. % netSize = netSize-1;
  56. % num_missing_nodes_arr = [50 100 150 200 250]; %[10 100 150];
  57. % elseif find(ds_32k==netSize)
  58. % ds_str = 'Datasets_32K/'; %'Train/'; %
  59. % num_missing_nodes_arr = [11 21 31 41 50]; % 100]; %Train
  60. % elseif find(ds_100k==netSize)
  61. % ds_str = 'Datasets_100K/';
  62. % num_missing_nodes_arr = [50 100 200 300 500];
  63. % elseif find(ds_100km==netSize)
  64. % ds_str = 'Datasets_100K/';
  65. % netSize = netSize-1;
  66. % num_missing_nodes_arr = [200 400 600 800 1000];
  67. % elseif find(ds_Train==netSize)
  68. % ds_str = 'Train/';
  69. % netSize = netSize-1;
  70. % num_missing_nodes_arr = [10 30 50 70 100 150]; %[11 21 31 41 50 100 150];
  71. % elseif find(ds_GridTrain==netSize)
  72. % ds_str = 'graph_production/produced_graphs/';
  73. % num_missing_nodes_arr = [10 30 50 70];
  74. % else
  75. % fprintf('RunExpSrv8s:Invalid netSize %d.\n',netSize);
  76. % return;
  77. % end
  78. ds_str = 'graph_production/produced_graphs/';
  79. num_missing_nodes_arr = [1];
  80. fprintf('RunExpSrv8s: netSize %d, dataset %s\n',netSize,ds_str);
  81. rootDir = '../';
  82. %rootDir = '/Users/armin/Desktop/DML/projects/graphgenproj/'; %Facebook/';
  83. %rootDir = 'D:/__SN_Jan14_FF75/'; %Facebook/';
  84. filePrefix = 'testgraph_*'; % 'facebook_sparse_'; %
  85. netSizes = netSize; %%[2048 4096 5000 8192 10000 16384 32768];
  86. %Sigal - 13.2.14 - images data
  87. imagesDir = strcat(rootDir,'Images/');
  88. imagesFile = 'ImagesMatchA.csv';
  89. imagesCount = 200000;
  90. imagesData = []; % LoadAsciiImagesMatch(imagesDir, imagesFile, imagesCount, debugFlag); %[]; %
  91. numImagesProfiles = 200; % 50; %
  92. imgMissProb = 0; %0.2; %%no images
  93. imgSimProbDiff = 0.1; %%0.2;
  94. imgSimType = 1; %% 0=realData, 1=rand(uniform distribution), 2=randn(normal distribution)
  95. datasetDir = strcat(rootDir,ds_str); %'Datasets_10K/'); %'Facebook/Datasets_10K/'); %'Traing_16K/'); %% TODO sigal - change rootDir path before EXE build
  96. factor_str = sprintf('F%d%d%d_',normFactorVec);
  97. images_str = sprintf('I%dP%dM%d_',imgSimType,imgSimProbDiff*10,imgMissProb*10);
  98. results_dir = strcat(datasetDir,'testImg_noTh_',netSizeStr,'/',factor_str,images_str,'Iter_',iterStartStr,iterEndStr,'/');
  99. fprintf('RunExpSrv8b: results_dir %s\n',results_dir);
  100. runAlgFlag = 1;
  101. debugFlag = 0;
  102. dumpKronEM = 1;
  103. dumpGED = 0;
  104. numThreshold = 0;
  105. maxAttStat = 1.35; %1.20; % population threshold - use this attribute only if it appears less than this percentage
  106. numAttrCols = 60; %21; %%50; %%11; %40; %%50;
  107. attSelected = ones(1,numAttrCols);
  108. attWeight = [0.3]; %[0.2 0.3 0.4 0.5 0.6 0.7 0.8]; %%0.3;
  109. addMissingAtt = addAttPerc;
  110. attAffinityThreshold = 0.15; % noise threshold
  111. % skipAtt = [6 2 20 26 22 17 8 14 3 1]; % top 10 PercC
  112. % attSelected(skipAtt) = 0;
  113. date_now = clock;
  114. randSeed = round((date_now(5)+date_now(6)*11)*iterStart+31);
  115. rand(1,randSeed);
  116. date_now = strcat(num2str(date_now(1)),'_',num2str(date_now(2)),'_', num2str(date_now(3)),'_', num2str(date_now(4)), num2str(date_now(5)),'_', num2str(date_now(6)));
  117. LogMsg(sprintf('%s Start RunExpSrv8s RunExperiment (random %d, addMissingAtt %.2f)...',date_now,randSeed,addMissingAtt));
  118. % attSelected = zeros(1,numAttrCols);
  119. % % for i = [1:4,6:8,12:20,22,24,26:30] %% top 23 threshold
  120. % % for i = [1,3,17,14,8,26,22,18,6,16] %% top 5/10 sum
  121. % % for i = [1,14,3,8,22,26,17,19,18,20] %% top 5/10 one
  122. % for i = [1,3,17,14,18,8,6,16,26,10] %% top 5/10 two
  123. % attSelected(i) = 1;
  124. % end
  125. % LogMsg(sprintf('Select %d attributes out of %d ...', sum(attSelected), size(attSelected,2)));
  126. for nodes = netSizes
  127. fprintf('----------!!!!%d---------', nodes);
  128. if size(strfind(filePrefix, 'facebook'),1)>0
  129. prefix = sprintf('%s%s%d_%s',datasetDir,filePrefix,nodes,'*.mat'); % '0*.txt.mat');
  130. else
  131. prefix = sprintf('%s%s%d_%s',datasetDir,filePrefix,nodes,'*.txt.mat'); % '0*.txt.mat');
  132. end
  133. files = dir(prefix);
  134. firstIter = 1;
  135. for iter = iterStart:iterEnd % loop over same network with different missing nodes
  136. if size(files,1) == 0
  137. fprintf('*** ERROR: RunExpSrv8b no file were found (prefix %s)\n',prefix);
  138. end
  139. for i = 1:size(files,1) % loop over the list of networks
  140. file = files(i).name;
  141. if size(strfind(filePrefix, 'facebook'),1)>0
  142. LogMsg(sprintf('facebook netwrok, skipping attributes ...'));
  143. attributes = [];
  144. attUpperRange = [];
  145. else
  146. % sigal 12/6/13 - use binary attribute mat file
  147. attFile = strrep(file, '.txt.mat', '.usr.mat');
  148. [attributes, attUpperRange, attSelected, attStat] = PrepareAttributes5(datasetDir, attFile, nodes, numAttrCols, maxAttStat, attSelected);
  149. LogMsg(sprintf('Select %d attributes out of %d ...', sum(attSelected), size(attSelected,2)));
  150. end
  151. if runAlgFlag == 1
  152. date_now = clock;
  153. date_now = strcat(num2str(date_now(1)),'_',num2str(date_now(2)),'_', num2str(date_now(3)),'_', num2str(date_now(4)), num2str(date_now(5)),'_', num2str(date_now(6)));
  154. % make sure dump & results directories exist
  155. if (firstIter == 1 && i == 1)
  156. firstIter = 0;
  157. if isdir(results_dir) == 0
  158. mkdir(results_dir);
  159. end
  160. dumpFilePath = sprintf('%sdumpKronEM_%s/', results_dir, date_now);
  161. if (dumpKronEM == 1)
  162. mkdir(dumpFilePath);
  163. end
  164. dump_data_dir = sprintf('%sdumpData_%s/', results_dir, date_now);
  165. if dumpGED == 1 && isdir(dump_data_dir) == 0
  166. mkdir(dump_data_dir)
  167. end
  168. end
  169. % run algorithm (file load is done internaly)
  170. [rand_score,purity,p_triads,missing_nodes_mapping,removed_nodes] = MissingNodes_S8b(datasetDir, file, ...
  171. attributes, attUpperRange, attWeight, addMissingAtt, normFactorVec, affinities, num_missing_nodes_arr, attAffinityThreshold, ...
  172. imagesData, numImagesProfiles, imgMissProb, imgSimType, imgSimProbDiff, percentKnownPHsVec, dumpGED, dump_data_dir, iter);
  173. %[rand_score,purity,p_triads,missing_nodes_mapping,removed_nodes] = MissingNodes_Sparse(datasetDir, file, affinities, 1);
  174. % dump graph data for KronEM runs
  175. if dumpKronEM == 1
  176. DumpDataset(datasetDir, file, iter, removed_nodes, dumpFilePath);
  177. end
  178. % save results
  179. out_file = sprintf('%sres_%s_%s.mat', results_dir, file, date_now);
  180. save(out_file);
  181. file_name = sprintf('%s%s','D:\Uni\sharif\Project\SAMI\Code\SAMI\output\mine\',file);
  182. if(iter == 1)
  183. copyfile('D:\Uni\sharif\Project\SAMI\Code\SAMI\output\graphed_1.mat',file_name);
  184. end
  185. LogMsg(sprintf('Results for file %s,iter %d at %s',file,iter,out_file));
  186. %fprintf('Completed RunExperiment cycle - results at %s.\n',out_file);
  187. end
  188. % beep;
  189. end
  190. end
  191. end
  192. date_now = clock;
  193. date_now = strcat(num2str(date_now(1)),'_',num2str(date_now(2)),'_', num2str(date_now(3)),'_', num2str(date_now(4)), num2str(date_now(5)),'_', num2str(date_now(6)));
  194. LogMsg(sprintf('%s Completed RunExpSrv8s RunExperiment (random %d).',date_now,randSeed));
  195. end