summaryrefslogtreecommitdiff
path: root/fitness.m
diff options
context:
space:
mode:
Diffstat (limited to 'fitness.m')
-rw-r--r--fitness.m24
1 files changed, 14 insertions, 10 deletions
diff --git a/fitness.m b/fitness.m
index 752e748..55f9d76 100644
--- a/fitness.m
+++ b/fitness.m
@@ -1,9 +1,17 @@
function [Energy, Waist, Penalty] = fitness( q_0, q_final, x_final, optics_positions, optics_focal_length, lambda )
-%FITNESS Summary of this function goes here
-% Detailed explanation goes here
+%Outputs fitness of suggested solution
x0 = 0;
- Np=20;
- x=linspace(x0,x_final,Np);
+ Np=20; % # of pts between start position and second lens
+ N_collimated = 10; % # of pts between second lens and third lens to be collimated region
+
+ x1=optics_positions(1);
+ x2=optics_positions(2);
+ x3=optics_positions(3);
+
+ x_array1=linspace(x0,x2,Np);
+ x_array2=linspace(x2, x3, N_collimated);
+ x = cat(2,x_array1,x_array2);
+
q_f_trial_forward = gbeam_propagation(x,q_0,x0,optics_placer(optics_positions, optics_focal_length));
[Waist_trial_forward, Radius_trial_forward] = q2wr(q_f_trial_forward, lambda);
q_f_trial_backward = gbeam_propagation(x,q_final,x_final,optics_placer(optics_positions, optics_focal_length));
@@ -18,9 +26,7 @@ function [Energy, Waist, Penalty] = fitness( q_0, q_final, x_final, optics_posit
% do not put lenses too close to each other and end positions
lens_size=0.03;
- x1=optics_positions(1);
- x2=optics_positions(2);
- x3=optics_positions(3);
+
d(1)=abs(x1-x2);
d(2)=abs(x2-x3);
@@ -53,9 +59,7 @@ function [Energy, Waist, Penalty] = fitness( q_0, q_final, x_final, optics_posit
% make collimated region between 2nd and 3rd lens
%intialize intermediate points between lenses
- intermediate_positions = linspace(optics_positions(2), optics_positions(3),10);
- f_q_x = @(x) gbeam_propagation(x,q_0,x0,optics_placer(optics_positions, optics_focal_length));
- q_intermediate = arrayfun(f_q_x,intermediate_positions);
+ q_intermediate = q_f_trial_forward((x2<x) & (x<x3));
lambda_over_waist_sq = (-imag(1./q_intermediate)); %with numerical factor
coef = 1e-3;