17 using System.Collections.Generic;
29 private object _locker =
new object();
30 private readonly HashSet<ParameterSet> _runningParameterSet =
new HashSet<ParameterSet>();
31 private int _segmentsAmount = 4;
43 if (stepSettings ==
null)
45 throw new ArgumentNullException(nameof(settings),
46 "EulerSearchOptimizationStrategy.Initialize: Optimizations Strategy settings are required for this strategy");
49 if (stepSettings.DefaultSegmentAmount != 0)
51 _segmentsAmount = stepSettings.DefaultSegmentAmount;
54 base.Initialize(target, constraints, parameters, settings);
65 throw new InvalidOperationException($
"EulerSearchOptimizationStrategy.PushNewResults: strategy has not been initialized yet.");
81 ProcessNewResult(result);
84 if (_runningParameterSet.Count > 0)
94 var boundaries =
new HashSet<OptimizationParameter>();
99 if (optimizationStepParameter !=
null && optimizationStepParameter.Step > optimizationStepParameter.MinStep)
101 var newStep = Math.Max(optimizationStepParameter.MinStep.Value, optimizationStepParameter.Step.Value / _segmentsAmount);
102 var fractal = newStep * ((decimal)_segmentsAmount / 2);
103 var parameter = parameterSet.Value.First(s => s.Key == optimizationParameter.Name);
105 optimizationParameter.Name,
106 Math.Max(optimizationStepParameter.MinValue, parameter.Value.ToDecimal() - fractal),
107 Math.Min(optimizationStepParameter.MaxValue, parameter.Value.ToDecimal() + fractal),
109 optimizationStepParameter.MinStep.Value));
113 boundaries.Add(optimizationParameter);
119 boundaries.Add(staticParam);
142 _runningParameterSet.Add(parameterSet);
143 base.OnNewParameterSet(parameterSet);