diff options
-rw-r--r-- | find_min.m | 8 | ||||
-rw-r--r-- | fitter_check.m | 2 | ||||
-rw-r--r-- | mode_match.m | 22 |
3 files changed, 27 insertions, 5 deletions
diff --git a/find_min.m b/find_min.m new file mode 100644 index 0000000..2c3ae7d --- /dev/null +++ b/find_min.m @@ -0,0 +1,8 @@ +function [ x_sol, energy ] = find_min( index, lens_placement, fitness_simplified, MaxFunEvals, MaxIter ) +%FIND_MIN Summary of this function goes here +% Detailed explanation goes here + + [x_sol, energy] = fminsearch(fitness_simplified, lens_placement(index,:), optimset('TolFun',1e-5,'MaxFunEvals',MaxFunEvals,'MaxIter', MaxIter)); + +end + diff --git a/fitter_check.m b/fitter_check.m index ebb3ad1..9acf990 100644 --- a/fitter_check.m +++ b/fitter_check.m @@ -17,7 +17,7 @@ qf=wr2q(wf,rf,lambda); %End list %Mode match -[ possible_lens_placement, possible_lens_set, possible_sample_energy] = mode_match( q0, qf, Ltot, lambda, lens_permutations ); +[ possible_lens_placement, initial_possible_lens_set, possible_lens_set, possible_sample_energy] = mode_match( q0, qf, Ltot, lambda, lens_permutations ); %Remove similar solutions n_truncate = 3; %number of digits in truncated solution diff --git a/mode_match.m b/mode_match.m index 0a36332..3eed53f 100644 --- a/mode_match.m +++ b/mode_match.m @@ -1,4 +1,4 @@ -function [ possible_lens_placement, possible_lens_set, possible_sample_energy] = mode_match( q0, qf, Ltot, lambda, lens_permutations ) +function [ final_possible_lens_placement, initial_possible_lens_placement, possible_lens_set, possible_sample_energy] = mode_match( q0, qf, Ltot, lambda, lens_permutations ) %Shuffles lenses into random positions and stores possible solutions % Shuffles over entire lens permutation array for n_shuffles times. % Afterwards, solutions are sorted by Energy and truncated to n_truncate @@ -6,6 +6,10 @@ function [ possible_lens_placement, possible_lens_set, possible_sample_energy] = n_perms = size(lens_permutations,1); n_shuffles=20; %number of random placements of lenses +initial_MaxFunEvals = 1e8; +initial_MaxIter = 10; +final_MaxFunEvals = 1e8; +final_MaxIter = 100; %Initialize sample arrays N = n_perms * n_shuffles; @@ -27,12 +31,22 @@ for ip = 1:n_perms end end + + + parfor i = 1:N - fitness_simplified=@(x) fitness(q0, qf, Ltot, x, possible_lens_set(i,:), lambda ); - [x_sol, energy]=fminsearch(fitness_simplified, initial_rand_lens_placement(i,:), optimset('TolFun',1e-5,'MaxFunEvals',1e8,'MaxIter',200)); + [ x_sol, energy ] = find_min(i, initial_rand_lens_placement, fitness_simplified, initial_MaxFunEvals, initial_MaxIter ) + + initial_possible_lens_placement(i,:) =x_sol; - possible_lens_placement(i,:) =x_sol; +end + +parfor i = 1:N + fitness_simplified=@(x) fitness(q0, qf, Ltot, x, possible_lens_set(i,:), lambda ); + [ x_sol, energy ] = find_min(i, initial_possible_lens_placement, fitness_simplified, final_MaxFunEvals, final_MaxIter ) + + final_possible_lens_placement(i,:) =x_sol; possible_sample_energy(i) = energy; end |