示例#1
0
        internal static bool nlopt_stop_time(GeneralConvergence stop)
        {
            var maxtime = stop.MaximumTime;
            var start   = stop.StartTime;

            return(maxtime > TimeSpan.Zero && DateTime.Now - start >= maxtime);
        }
示例#2
0
        internal static bool nlopt_stop_ftol(GeneralConvergence stop, double f, double oldf)
        {
            var ftol_rel = stop.RelativeFunctionTolerance;
            var ftol_abs = stop.AbsoluteFunctionTolerance;

            return(relstop(oldf, f, ftol_rel, ftol_abs));
        }
示例#3
0
        internal static bool nlopt_stop_evals(GeneralConvergence stop)
        {
            var maxeval = stop.MaximumEvaluations;
            var nevals  = stop.Evaluations;

            return(maxeval > 0 && nevals >= maxeval);
        }
示例#4
0
        private void init(int n)
        {
            this.nmax = n;
            this.stop = new GeneralConvergence(nmax);

            pts = new double[n + 1][];
            for (int i = 0; i < pts.Length; i++)
            {
                pts[i] = new double[n];
            }

            val = new double[n + 1];

            c    = new double[n];
            xcur = new double[n];

            xstep = new double[n];
            for (int i = 0; i < xstep.Length; i++)
            {
                xstep[i] = 1e-5;
            }

            lb = new double[n];
            for (int i = 0; i < lb.Length; i++)
            {
                lb[i] = Double.NegativeInfinity;
            }

            ub = new double[n];
            for (int i = 0; i < ub.Length; i++)
            {
                ub[i] = Double.PositiveInfinity;
            }
        }
示例#5
0
        private void init(int n)
        {
            this.n    = n;
            this.stop = new GeneralConvergence(n);

            nelderMead             = new NelderMead(nsmax, subspace_func);
            nelderMead.Convergence = this.stop;

            xstep  = new double[n];
            xstep0 = new double[n];
            for (int i = 0; i < xstep0.Length; i++)
            {
                xstep0[i] = 1e-5;
            }

            p     = new int[n];
            dx    = new double[n];
            xprev = new double[n];
            absdx = new double[n];

            lb = new double[n];
            for (int i = 0; i < lb.Length; i++)
            {
                lb[i] = Double.NegativeInfinity;
            }

            ub = new double[n];
            for (int i = 0; i < ub.Length; i++)
            {
                ub[i] = Double.PositiveInfinity;
            }
        }
示例#6
0
        private void init(int n)
        {
            this.n      = n;
            Convergence = new GeneralConvergence(n);

            nelderMead             = new NelderMead(nsmax, subspace_func);
            nelderMead.Convergence = Convergence;

            xstep    = new double[n];
            StepSize = new double[n];
            for (var i = 0; i < StepSize.Length; i++)
            {
                StepSize[i] = 1e-5;
            }

            p     = new int[n];
            dx    = new double[n];
            xprev = new double[n];
            absdx = new double[n];

            LowerBounds = new double[n];
            for (var i = 0; i < LowerBounds.Length; i++)
            {
                LowerBounds[i] = double.NegativeInfinity;
            }

            UpperBounds = new double[n];
            for (var i = 0; i < UpperBounds.Length; i++)
            {
                UpperBounds[i] = double.PositiveInfinity;
            }
        }
示例#7
0
        internal static bool nlopt_stop_xtol(GeneralConvergence stop, double[] x, double[] oldx, int n)
        {
            var xtol_rel = stop.RelativeParameterTolerance;
            var xtol_abs = stop.AbsoluteParameterTolerance;

            for (int i = 0; i < n; ++i)
            {
                if (!relstop(oldx[i], x[i], xtol_rel, xtol_abs[i]))
                {
                    return(false);
                }
            }

            return(true);
        }
示例#8
0
 internal static bool nlopt_stop_forced(GeneralConvergence stop)
 {
     return(stop.Cancel);
 }