@@ -3,10 +3,10 @@ using Distributions
33
44@kwdef struct LocalSearchDecider <: LocalDecider
55 initial_schedule:: Vector{Float64}
6- corridors:: Vector{Tuple{Float64}}
6+ corridors:: Vector{Tuple{Float64,Float64 }}
77 local_performance:: Function
88 convergence_force_factor:: Float64 = 0.1
9- max_iterations = 10
9+ max_iterations:: Int = 10
1010 sample_size_per_value:: Int = 10
1111 distribution:: Function = (low, up) -> Uniform (low, up)
1212end
@@ -20,18 +20,19 @@ function local_performance_with_global_share(decider::LocalSearchDecider, schedu
2020end
2121
2222function find_new_value (decider:: LocalSearchDecider , current_index:: Int , current_best_schedule:: Vector{Float64} , delta_to_target:: Float64 )
23- possible_values = rand (decider. distribution, decider. sample_size_per_value)
23+ corridor = decider. corridors[current_index]
24+ possible_values = rand (decider. distribution (corridor[1 ], corridor[2 ]), decider. sample_size_per_value)
2425 current_value = current_best_schedule[current_index]
2526 new_value_performance_tuples:: Vector{Tuple{Float64,Float64}} = []
2627 new_value = nothing
2728 iteration = 1
28- while length (possible_values) > 0 || iteration > decider. max_iterations
29+ while length (possible_values) > 0 && iteration <= decider. max_iterations
2930 copy_bs = copy (current_best_schedule)
3031 random_index = ceil (Int, rand () * length (possible_values))
3132 new_value = possible_values[random_index]
3233 copy_bs[current_index] = new_value
3334
34- # we calculate the performance with a variable local performance share and a adaptive global performance share
35+ # we calculate the performance with a variable local performance share and a adaptive global performance share
3536 performance = local_performance_with_global_share (decider, copy_bs, new_value, current_value, delta_to_target)
3637
3738 push! (new_value_performance_tuples, (new_value, performance))
@@ -41,7 +42,7 @@ function find_new_value(decider::LocalSearchDecider, current_index::Int, current
4142 sort! (new_value_performance_tuples)
4243 first = new_value_performance_tuples[1 ][1 ]
4344 second = new_value_performance_tuples[2 ][1 ]
44- third = new_value_performance_tuples[2 ][1 ]
45+ third = new_value_performance_tuples[3 ][1 ]
4546
4647 # cut out undesirable parts of the whole vector
4748 if first > second > third
0 commit comments