From a8c9a7bbeeb09dabc4196d76cf3c9004eb5f65a3 Mon Sep 17 00:00:00 2001 From: Matt Argao Date: Tue, 23 Oct 2012 16:49:58 -0400 Subject: Optimized collimation penalty and returns penalties --- fitness.m | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'fitness.m') 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 -- cgit v1.2.3