Changeset 37 for liacs/nc/laser-pulse-shaping
- Timestamp:
- Dec 16, 2009, 5:06:53 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
liacs/nc/laser-pulse-shaping/pso.m
r36 r37 48 48 49 49 idle_counter = 0; 50 start_time = time();50 tic(); 51 51 52 52 % Code not optimised for performance, but for readablility … … 84 84 % Stop conditions 85 85 if idle_counter == iteration_break 86 printf("Caught by idle_counter\n");87 break;86 fprintf('Caught by idle_counter\n'); 87 return; 88 88 end 89 if t ime - start_time> max_time90 printf("Caught by max_time used \n");91 break;89 if toc > max_time 90 fprintf('Caught by max_time used \n'); 91 return; 92 92 end 93 93 94 94 95 printf("%i : %.15f\n", i, g_fitness);95 fprintf('%i : %.15f\n', i, g_fitness); 96 96 fitness_iterations = [fitness_iterations, i]; 97 97 fitness_history = [fitness_history, g_fitness]; … … 104 104 for s = 1:local_swarms 105 105 for p = 1:local_swarm_size 106 flock_v(:,p,s) = flock_v(:,p,s) * wander ;107 flock_v(:,p,s) = flock_v(:,p,s) + (g_best - flock_p(:,p,s)) * (c_cognitive * r_cognitive);108 flock_v(:,p,s) = flock_v(:,p,s) + (n_best(:,s) - flock_p(:,p,s)) * (c_social * r_social);109 flock_v(:,p,s) = flock_v(:,p,s) +(l_best(:,p,s) - flock_p(:,p,s)) * (c_ego * r_ego);106 flock_v(:,p,s) = flock_v(:,p,s) * wander + ... 107 (g_best - flock_p(:,p,s)) * (c_cognitive * r_cognitive) + ... 108 (n_best(:,s) - flock_p(:,p,s)) * (c_social * r_social) + ... 109 (l_best(:,p,s) - flock_p(:,p,s)) * (c_ego * r_ego); 110 110 flock_p(:,p,s) = flock_p(:,p,s) + flock_v(:,p,s); 111 111 end … … 120 120 grid on; 121 121 legend(sprintf('Parameters %i',parameters)); 122 print("pso-fitness.eps","-depsc2"); 123 122 print('pso-fitness.eps','-depsc2');
Note:
See TracChangeset
for help on using the changeset viewer.