diff options
author | Matt Argao <mcargao@email.wm.edu> | 2012-11-06 17:33:27 -0500 |
---|---|---|
committer | Matt Argao <mcargao@email.wm.edu> | 2012-11-06 17:33:27 -0500 |
commit | 9967bdc8f5c9ab51ea69cacdf694a3ddc5fd233e (patch) | |
tree | 420d433d2b43301d8d01f33c414bf3f08dcff498 /fitness.m | |
parent | 6a755b5f70bc4960e818de260b8b5d057295eb5f (diff) | |
download | mode_match-9967bdc8f5c9ab51ea69cacdf694a3ddc5fd233e.tar.gz mode_match-9967bdc8f5c9ab51ea69cacdf694a3ddc5fd233e.zip |
Assorted code cleanup, addition of mode_match.m
Refinement of fitness function
Diffstat (limited to 'fitness.m')
-rw-r--r-- | fitness.m | 30 |
1 files changed, 17 insertions, 13 deletions
@@ -1,17 +1,21 @@ -function [Energy, Waist_backward, Waist_forward, Penalty] = fitness( q_0, q_final, x_final, optics_positions, optics_focal_length, lambda )
+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
x0 = 0;
- x_forward=linspace(0,x_final,15);
- q_forward = gbeam_propagation(x_forward,q_0,x0,optics_placer(optics_positions, optics_focal_length));
- [Waist_forward, Radius_forward] = q2wr(q_forward, lambda);
-
- x_backward=(x_forward);
- q_backward = gbeam_propagation(x_backward,q_final,x_final,optics_placer(optics_positions, optics_focal_length));
- [Waist_backward, Radius_backward] = q2wr(q_backward, lambda);
-
- Energy = sum((Waist_backward - Waist_forward).^2)/(mean(Waist_backward))^2;
-
+ Np=20;
+ x=linspace(x0,x_final,Np);
+ 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));
+ [Waist_trial_backward, Radius_trial_backward] = q2wr(q_f_trial_backward, lambda);
+
+ Energy = 0;
+ Penalty_waist_mismatch = sum(abs((Waist_trial_forward-Waist_trial_backward)./min(Waist_trial_forward, Waist_trial_backward)))/Np;
+ Penalty_waist_mismatch = 0*Penalty_waist_mismatch + 1e9*sum(abs((Waist_trial_forward-Waist_trial_backward)))/Np;
+ Penalty_radius_mismatch = sum(abs((Radius_trial_forward-Radius_trial_backward)./max(Radius_trial_forward, Radius_trial_backward)))/Np;
+
+ Energy = 0*Penalty_radius_mismatch + Penalty_waist_mismatch;
+
% penalty calculation
% do not put lenses too close to each other and end positions
lens_size=0.03;
@@ -44,8 +48,8 @@ function [Energy, Waist_backward, Waist_forward, Penalty] = fitness( q_0, q_fina d = cat(2, d_from_start, d_from_end);
coef = 1e-2;
-
- penalty_lenses_outside_optical_path = coef * sum(1 + tanh(10*d));
+ distance_scaling=100;
+ penalty_lenses_outside_optical_path = coef * sum(1 + tanh(distance_scaling*d));
Energy = Energy + penalty_lenses_outside_optical_path;
|