コード例 #1
0
        protected void SetValue(string variableName, T value, bool throwOnOutOfBounds)
        {
            checkCorrectArg(variableName);
            T maxValue = GetMaxValue(variableName);
            T minValue = GetMinValue(variableName);

            if (throwOnOutOfBounds)
            {
                MetaheuristicsHelper.CheckInBounds(value, minValue, maxValue, throwOnOutOfBounds);
            }
            this.values[variableName].Val = value;
        }
コード例 #2
0
 protected void performHomoteticTransform(IHyperCube <T> point, T factor, ref HyperCube <T> result)
 {
     foreach (var varName in this.GetVariableNames())
     {
         var min = this.GetMinValue(varName);
         var max = this.GetMaxValue(varName);
         result.SetMinValue(varName, min);
         result.SetMaxValue(varName, max);
         var newVal     = reflect(point.GetValue(varName), this.GetValue(varName), factor);
         var isInBounds = MetaheuristicsHelper.CheckInBounds(newVal, min, max, throwIfFalse: this.ThrowOnOutOfBounds);
         if (!isInBounds)
         {
             result = null;
             break;
         }
         result.SetValue(varName, newVal);
     }
 }