summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fitness.m19
1 files changed, 10 insertions, 9 deletions
diff --git a/fitness.m b/fitness.m
index c92d734..54060a7 100644
--- a/fitness.m
+++ b/fitness.m
@@ -1,4 +1,4 @@
-function [Energy, Waist] = 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;
@@ -28,9 +28,9 @@ function [Energy, Waist] = fitness( q_0, q_final, x_final, optics_positions, opt
coef = 1;
- penalty=coef*sum( exp(-(d/(lens_size)).^12) );
+ penalty_lenses_too_closely_spaced =coef*sum( exp(-(d/(lens_size)).^12) );
- Energy = Energy + penalty;
+ Energy = Energy + penalty_lenses_too_closely_spaced;
% make sure that lenses are between ends
d_from_start=(x0-optics_positions);
@@ -40,9 +40,9 @@ function [Energy, Waist] = fitness( q_0, q_final, x_final, optics_positions, opt
coef = 1e-2;
- penalty = coef * sum(1 + tanh(10*d));
+ penalty_lenses_outside_optical_path = coef * sum(1 + tanh(10*d));
- Energy = Energy + penalty;
+ Energy = Energy + penalty_lenses_outside_optical_path;
% make collimated region between 2nd and 3rd lens
%intialize intermediate points between lenses
@@ -51,9 +51,10 @@ function [Energy, Waist] = fitness( q_0, q_final, x_final, optics_positions, opt
q_intermediate = arrayfun(f_q_x,intermediate_positions);
lambda_over_waist_sq = (-imag(1./q_intermediate)); %with numerical factor
-
- coef = 1e-2;
- penalty = coef * sum(exp((std(lambda_over_waist_sq)/mean(lambda_over_waist_sq))));
- Energy = Energy + penalty;
+ coef = 1e-3;
+ penalty_not_collimated_beam = coef * sum(exp((std(lambda_over_waist_sq)/mean(lambda_over_waist_sq)/abs(optics_positions(2) - optics_positions(3)))));
+ Energy = Energy + penalty_not_collimated_beam;
+
+ Penalty = [ penalty_lenses_too_closely_spaced; penalty_lenses_too_closely_spaced; penalty_not_collimated_beam];
end