public static void TestAreEqual(double[] values, IHyperCube <double> point, string[] varNames, double delta = 1e-12) { for (int i = 0; i < varNames.Length; i++) { Assert.AreEqual(values[i], point.GetValue(varNames[i]), delta, "variable " + varNames[i]); } }
private void apply(IHyperCube <double> systemConfiguration, IModelSimulation <double[], double, int> simulation) { var varNames = systemConfiguration.GetVariableNames(); foreach (var varName in varNames) { simulation.SetVariable(varName, systemConfiguration.GetValue(varName)); } }
public static double CalculateParaboloid(IHyperCube <double> sysConfig, double bestParam) { var names = sysConfig.GetVariableNames(); double result = 0; for (int i = 0; i < names.Length; i++) { var name = names[i]; double v = (sysConfig.GetValue(name) - bestParam); result += v * v; } return(result); }
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 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); }
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); } }
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 override string ToString() { StringBuilder output = new StringBuilder(); output.Append("\n--------------------------------------------------------------\n"); for (int i = 0; i < ObjectiveScores.Length; i++) { for (int k = 0; k < ObjectiveScores[i].ObjectiveCount; k++) { output.Append(ObjectiveScores[i].GetObjective(k).GetText() + "\t"); } IHyperCube <double> pSet = (IHyperCube <double>)ObjectiveScores[i].GetSystemConfiguration(); string[] keyNames = pSet.GetVariableNames(); foreach (string key in keyNames) { output.Append("\n" + key + "\t\t" + pSet.GetValue(key)); } output.Append("\n\n"); } return(output.ToString()); }
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; }