From 80b72a51a3f8f0e33bf79a20a4d5fbaca050d920 Mon Sep 17 00:00:00 2001 From: Matt Argao Date: Thu, 18 Oct 2012 17:42:16 -0400 Subject: Added possible permutations of lens choices --- fitter_check.m | 44 +++++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-) (limited to 'fitter_check.m') diff --git a/fitter_check.m b/fitter_check.m index 1898120..53d3299 100644 --- a/fitter_check.m +++ b/fitter_check.m @@ -6,11 +6,15 @@ Ltot= 1.010675025828971 ; r0= 1.0E+100 ; w0= 2.563E-5 ; x0= 0 ; -lns1.abcd=abcd_lens( 0.075 ) ; +focal_length1 = .075; +focal_length2 = .075; +focal_length3 = .203; + +lns1.abcd=abcd_lens( focal_length1 ) ; lns1.x= 0.21358727296049 ; -lns2.abcd=abcd_lens( 0.075 ) ; +lns2.abcd=abcd_lens( focal_length2 ) ; lns2.x= 0.40361319425309 ; -lns3.abcd=abcd_lens( 0.203 ) ; +lns3.abcd=abcd_lens( focal_length3 ) ; lns3.x= 0.80361319425309 ; wf= 3.709E-5 ; rf= 1.0E+100 ; @@ -32,24 +36,38 @@ sample_energy = []; sample_x = []; lens_size = .03; -for iteration = 1:10 - optics_x_rand = sort(lens_size+(xf-2*lens_size)*rand(1,3)); - - fitness_simplified=@(x) fitness(q0, qf, Ltot, x ); - [x_sol, energy]=fminsearch(fitness_simplified, optics_x_rand, optimset('TolX',1e-8,'TolFun',1e-8,'MaxFunEvals',1e8,'MaxIter',2000)); +%Lens permutations +lens_permutations = perms( [ focal_length1, focal_length2, focal_length3 ]); +n_perms = size(lens_permutations,1); +n_shuffles=10; + +for i = 1:n_perms + + + lenses_choice=lens_permutations(i,:) - sample_energy = [sample_energy; energy]; - sample_x = [sample_x; x_sol]; + for iteration = 1:n_shuffles + optics_x_rand = sort(lens_size+(xf-2*lens_size)*rand(1,3)); + + fitness_simplified=@(x) fitness(q0, qf, Ltot, x, lenses_choice ); + [x_sol, energy]=fminsearch(fitness_simplified, optics_x_rand, optimset('TolX',1e-8,'TolFun',1e-8,'MaxFunEvals',1e8,'MaxIter',2000)); + + sample_energy = [sample_energy; energy]; + sample_x = [sample_x; x_sol]; + + figure(2) + solution_visualization(q0,x0, qf, xf, optics_placer(x_sol, lenses_choice), lambda); + drawnow; + end - figure(2) - solution_visualization(q0,x0, qf, xf, optics_placer(x_sol), lambda); end [energy_min, index_of_energy_min] = min(sample_energy(:)) x_sol = sample_x(index_of_energy_min,:); +lenses_choice=lens_permutations(ceil(index_of_energy_min/n_shuffles),:); figure(2) -w_final_trial = solution_visualization(q0,x0, qf, xf, optics_placer(x_sol), lambda); +w_final_trial = solution_visualization(q0,x0, qf, xf, optics_placer(x_sol, lenses_choice), lambda); title('Optimized made'); w_final_handmade; -- cgit v1.2.3