private OptSimplexVariable[] GetVariables(double[] variablesArray) { OptSimplexVariable[] vars = new OptSimplexVariable[variablesArray.Length]; for (int i = 0; i < variablesArray.Length; i++) { vars[i] = new OptSimplexVariable(variablesArray[i]); } return(vars); }
private OptSimplexVariable[] GetVariables(OptVariable[] variablesArray) { OptSimplexVariable[] vars = new OptSimplexVariable[variablesArray.Length]; for (int i = 0; i < variablesArray.Length; i++) { OptVariable var = variablesArray[i]; vars[i] = new OptSimplexVariable(var.Name, var.InitialGuess, var.Fixed); } return(vars); }
/// <summary> /// Computes the minimum point of a function of several variables. /// </summary> /// <param name="function">The function to minimize.</param> /// <param name="variables">Array of size N containing the varaibles.</param> /// <returns>Array containing the solution.</returns> public double[] ComputeMin(OptMultivariateFunction function, OptSimplexVariable[] variables) { if (variables == null) return new double[0]; if (variables.Length == 0) return new double[0]; double initialStep = this.GetAutomaticInitialStep(variables); int maxFunc = this._MaxFunEvaluations; return this.GetMinimum(function, variables, initialStep, this._Tolerance, ref maxFunc); }
private OptSimplexVariable[] GetVariables(OptVariable[] variablesArray) { OptSimplexVariable[] vars = new OptSimplexVariable[variablesArray.Length]; for (int i = 0; i < variablesArray.Length; i++) { OptVariable var = variablesArray[i]; vars[i] = new OptSimplexVariable(var.Name, var.InitialGuess, var.Fixed); } return vars; }
private OptSimplexVariable[] GetVariables(double[] variablesArray) { OptSimplexVariable[] vars = new OptSimplexVariable[variablesArray.Length]; for (int i = 0; i < variablesArray.Length; i++) { vars[i] = new OptSimplexVariable(variablesArray[i]); } return vars; }
private int GetNumFreeVariable(OptSimplexVariable[] variables) { int numFreeVariables = 0; foreach (OptSimplexVariable var in variables) { if (var.Fixed == false) numFreeVariables++; } return numFreeVariables; }
private double[] GetMinimum(OptMultivariateFunction function, OptSimplexVariable[] variables, double initialStep, double ftol, ref int nMax) { if (this._AmoebaDirver == null) this._AmoebaDirver = new DownhillDirver(); double[] minimum = this._AmoebaDirver.ComputeMin(function, variables, initialStep, ftol, ref nMax); this.FunEvaluations = nMax; return minimum; }
private double GetAutomaticInitialStep(OptSimplexVariable[] variables) { int numFreeVariables = this.GetNumFreeVariable(variables); if (numFreeVariables == 0) return 1; double step = 0; double sum = 0; foreach (OptSimplexVariable var in variables) { if (var.Fixed == false) { //mod sum += Math.Abs(var.InitialGuess / var.ScaleFactor); } } if (sum != 0) { step = sum / (2.0 * numFreeVariables); } else { step = 1; } return step; }