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.

RunExpSrv8b.m 8.6KB

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