aboutsummaryrefslogtreecommitdiff
path: root/fitter_check.m
diff options
context:
space:
mode:
Diffstat (limited to 'fitter_check.m')
-rw-r--r--fitter_check.m26
1 files changed, 9 insertions, 17 deletions
diff --git a/fitter_check.m b/fitter_check.m
index 0639e10..1898120 100644
--- a/fitter_check.m
+++ b/fitter_check.m
@@ -24,41 +24,33 @@ xf=Ltot;
optics={lns1,lns2,lns3};
figure(1)
w_final_handmade = solution_visualization(q0,x0, qf, xf, optics, lambda);
+title('Hand made');
% ##########################################
%Initialize sample arrays
sample_energy = [];
sample_x = [];
+lens_size = .03;
for iteration = 1:10
- optics_x_rand = sort(rand(1,3));
+ optics_x_rand = sort(lens_size+(xf-2*lens_size)*rand(1,3));
- test_optics_x = optics_x_rand - min(optics_x_rand(:));
- test_optics_x(1) = []; %delete first element in array
-
- %Prevent random placements that are too close
- while any(test_optics_x < .03) == 1
- optics_x_rand = sort(rand(1,3));
- test_optics_x = optics_x_rand - min(optics_x_rand(:));
- test_optics_x(1) = [];
- end
-
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));
sample_energy = [sample_energy; energy];
sample_x = [sample_x; x_sol];
- iteration
-
+ figure(2)
+ solution_visualization(q0,x0, qf, xf, optics_placer(x_sol), lambda);
end
-energy_min = min(sample_energy(:));
-index_of_energy_min = find(sample_energy == energy_min);
+[energy_min, index_of_energy_min] = min(sample_energy(:))
x_sol = sample_x(index_of_energy_min,:);
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), lambda);
+title('Optimized made');
-w_final_handmade
+w_final_handmade;
x_sol