public IHyperCube <double> GenerateRandomWithinHypercube(IHyperCube <double>[] points) { if (points.Length == 0) { return(this.GenerateRandom(points[0])); } else { IHyperCube <double> p = points[0].Clone() as IHyperCube <double>; string[] varNames = p.GetVariableNames(); for (int i = 0; i < varNames.Length; i++) { string v = varNames[i]; double minimum; double maximum; GetSmallestIntervalForValues(points, v, out minimum, out maximum); minimum = Math.Max(minimum, p.GetMinValue(v)); maximum = Math.Min(maximum, p.GetMaxValue(v)); checkFeasibleInterval(minimum, maximum, v); p.SetValue(varNames[i], GetRandomisedValue(minimum, maximum)); } return(p); } }
public static bool CheckInBounds <T>(IHyperCube <T> point) where T : IComparable { foreach (var varName in point.GetVariableNames()) { var min = point.GetMinValue(varName); var max = point.GetMaxValue(varName); var val = point.GetValue(varName); if (!MetaheuristicsHelper.CheckInBounds(val, min, max, throwIfFalse: false)) { return(false); } } return(true); }
public IHyperCube <double> GenerateRandom(IHyperCube <double> point) { string[] varNames = point.GetVariableNames( ); IHyperCube <double> result = point.Clone( ) as IHyperCube <double>; for (int i = 0; i < varNames.Length; i++) { string v = varNames[i]; // We take the bounds of the result point, to cater for cascading parameter constraints. double min = result.GetMinValue(v); double max = result.GetMaxValue(v); checkFeasibleInterval(min, max, v); result.SetValue(varNames[i], GetRandomisedValue(min, max)); } return(result); }
public static HyperCubeInterop ToDataFrame(IHyperCube <double> paramSet) { var names = paramSet.GetVariableNames(); var r = new HyperCubeInterop(names.Length); for (int i = 0; i < names.Length; i++) { var name = names[i]; r.Name[i] = name; r.Description[i] = ""; r.Value[i] = paramSet.GetValue(name); r.Min[i] = paramSet.GetMinValue(name); r.Max[i] = paramSet.GetMaxValue(name); } return(r); }
private bool tryAdd(string varName, IHyperCube <U> sysConfig, double realStepSize) { var min = sysConfig.GetMinValue(varName).ToDouble(null); var max = sysConfig.GetMaxValue(varName).ToDouble(null); var val = sysConfig.GetValue(varName).ToDouble(null); var newval = val + realStepSize; bool result = true; if (newval < min) { newval = min; result = false; } else if (newval > max) { newval = max; result = false; } sysConfig.SetValue(varName, (U)((IConvertible)newval).ToType(typeof(U), CultureInfo.InvariantCulture)); return(result); }
/// <summary> /// populates the internal array of parameters with the relavant pest values. In the /// current version, it considers all parameters to be of the same group (not sure /// if this functionality is required for TIME models) /// </summary> /// <param name="parameters">starting point and range of input parameters </param> public void AddParameterSet(IHyperCube <double> parameters) { List <PESTParameterData> parameterList = new List <PESTParameterData>(); foreach (String paramName in parameters.GetVariableNames()) { PESTParameterData tmpParameter = new PESTParameterData(); tmpParameter.Scale = 1.0; tmpParameter.MaxValue = parameters.GetMaxValue(paramName); tmpParameter.MinValue = parameters.GetMinValue(paramName); tmpParameter.InitialValue = parameters.GetValue(paramName); tmpParameter.ParameterName = paramName; tmpParameter.TransformType = PestConstants.ParameterDataConstants.ParameterTransformationType.noneType; tmpParameter.ChangeLimitedType = PestConstants.ParameterDataConstants.ParameterChangeLimitedType.relativeChange; tmpParameter.ParameterGroup = "param"; parameterList.Add(tmpParameter); } this.Parameters = parameterList.ToArray(); }
public static HyperCubeInterop ToDataFrame(IHyperCube<double> paramSet) { var names = paramSet.GetVariableNames(); var r = new HyperCubeInterop(names.Length); for (int i = 0; i < names.Length; i++) { var name = names[i]; r.Name[i] = name; r.Description[i] = ""; r.Value[i] = paramSet.GetValue(name); r.Min[i] = paramSet.GetMinValue(name); r.Max[i] = paramSet.GetMaxValue(name); } return r; }