Exemplo n.º 1
0
        private OptVariable[] GetVariables(double[] variablesArray)
        {
            OptVariable[] vars = new OptVariable[variablesArray.Length];

            for (int i = 0; i < variablesArray.Length; i++)
            {
                vars[i] = new OptVariable(variablesArray[i]);
            }

            return(vars);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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;
        }
Exemplo n.º 4
0
        /// <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 initial guess. N is the number of variables.</param>
        /// <param name="initialStep">The initial change of the variables.</param>
        /// <returns>Array containing the solution.</returns>
        public double[] ComputeMin(OptMultivariateFunction function, OptVariable[] variables, double initialStep)
        {
            if (variables == null) return new double[0];
            if (variables.Length == 0) return new double[0];

            OptSimplexVariable[] simplexVariables = this.GetVariables(variables);

            int maxFunc = this._MaxFunEvaluations;

            return this.GetMinimum(function, simplexVariables, initialStep, this._Tolerance, ref maxFunc);
        }
Exemplo n.º 5
0
        private OptVariable[] GetVariables(double[] variablesArray)
        {
            OptVariable[] vars = new OptVariable[variablesArray.Length];

            for (int i = 0; i < variablesArray.Length; i++)
            {
                vars[i] = new OptVariable(variablesArray[i]);
            }

            return vars;
        }
Exemplo n.º 6
0
        /// <summary>
        /// Computes the minimum point of a function of several variables.
        /// </summary>
        /// <param name="function">The function to minimize.</param>
        /// <param name="gradient">A delegate that computes the gradient.</param>
        /// <param name="variables">Array of size N containing the varaibles.</param>
        /// <returns>Array containing the solution.</returns>
        public double[] ComputeMin(OptMultivariateFunction function, OptMultivariateGradient gradient, OptVariable[] variables)
        {
            if (variables == null) return new double[0];
            if (variables.Length == 0) return new double[0];

            int maxFunc = this._MaxFunEvaluations;

            this._TNDriver.ETA = this._SearchSeverity;
            this._TNDriver.STEPMX = this._MaximunStep;

            double[] minimum = this._TNDriver.ComputeMin(function, gradient, variables, this._Tolerance, this._Accuracy, ref maxFunc);
            this._FunEvaluations = maxFunc;
            return minimum;
        }
Exemplo n.º 7
0
        /// <summary>
        /// Computes the minimum point of a function of several variables.
        /// </summary>
        /// <param name="function">The function to minimize.</param>
        /// <param name="gradient">A delegate that computes the gradient.</param>
        /// <param name="variables">Array of size N containing the varaibles.</param>
        /// <returns>Array containing the solution.</returns>
        public double[] ComputeMin(OptMultivariateFunction function, OptMultivariateGradient gradient, OptVariable[] variables)
        {
            if (variables == null) return new double[0];
            if (variables.Length == 0) return new double[0];

            int maxFunc = this._MaxFunEvaluations;

            double[] minimum = this._Driver.ComputeMin(function, gradient, variables, this._Tolerance, this._AccuracyFactor, ref maxFunc);
            this._FunEvaluations = maxFunc;
            return minimum;
        }