aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugeniy Mikhailov <evgmik@gmail.com>2012-09-25 17:38:04 -0400
committerEugeniy Mikhailov <evgmik@gmail.com>2012-09-25 17:38:04 -0400
commit9773dd0f1a6f9941a9a3ec5308bd3845d77bcf52 (patch)
tree4faae2b8a8a1afd80dd3c5d79699fa26b546e3b6
parent67fa755e143a0529d960d1a6fbd358b2a19f3d7d (diff)
downloadmode_match-9773dd0f1a6f9941a9a3ec5308bd3845d77bcf52.tar.gz
mode_match-9773dd0f1a6f9941a9a3ec5308bd3845d77bcf52.zip
added function to return fitness of the solution
-rw-r--r--fitness.m47
-rw-r--r--optics_placer.m15
2 files changed, 62 insertions, 0 deletions
diff --git a/fitness.m b/fitness.m
new file mode 100644
index 0000000..285cf12
--- /dev/null
+++ b/fitness.m
@@ -0,0 +1,47 @@
+function Energy = fitness( q_0, q_final, x_final, optics_positions )
+%FITNESS Summary of this function goes here
+% Detailed explanation goes here
+ x0 = 0;
+ q_f_trial = gbeam_propagation(x_final,q_0,x0,optics_placer(optics_positions));
+
+ Energy = abs(q_final-q_f_trial);
+
+ % penalty calculation
+ % 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);
+ d(3)=abs(x1-x3);
+
+ d_from_start=abs(x0-optics_positions);
+ d_from_end=abs(x_final-optics_positions);
+
+
+
+ d=cat(2, d, d_from_start, d_from_end);
+
+ coef = 1e-1;
+
+ penalty=coef*sum( exp(-(d/lens_size).^2) );
+
+ Energy = Energy + penalty;
+
+ % make sure that lenses are between ends
+ d_from_start=(x0-optics_positions);
+ d_from_end=(optics_positions-x_final);
+
+ d = cat(2, d_from_start, d_from_end);
+
+ coef = 1e-1;
+
+ penalty = coef * sum(1 + tanh(d.^2));
+
+ Energy = Energy + penalty;
+
+end
+
diff --git a/optics_placer.m b/optics_placer.m
new file mode 100644
index 0000000..ec08ab2
--- /dev/null
+++ b/optics_placer.m
@@ -0,0 +1,15 @@
+function optics = optics_placer( x )
+ x1=x(1);
+ x2=x(2);
+ x3=x(3);
+
+ lns1.abcd=abcd_lens( 0.075 ) ;
+ lns1.x= x1 ;
+ lns2.abcd=abcd_lens( 0.075 ) ;
+ lns2.x= x2 ;
+ lns3.abcd=abcd_lens( 0.203 ) ;
+ lns3.x= x3 ;
+ optics={lns1,lns2,lns3};
+
+end
+