private IntermediatePointResult IntermediatePoint(
            MultidimensionalFunctionFDF fdf,
            Vector <double> x,
            Vector <double> p,
            double lambda,
            double pg,
            double stepa,
            double stepc,
            double fa,
            double fc,
            Vector <double> x1,
            Vector <double> dx,
            double step,
            double f)
        {
            double stepb = 0, fb;

Trial:
            {
                double u = Math.Abs(pg * lambda * stepc);
                stepb = 0.5 * stepc * u / ((fc - fa) + u);
            }

            TakeStep(x, p, stepb, lambda, x1, dx);
            if (x.Equals(x1))
            {
                return(new IntermediatePointResult
                {
                    Step = 0,
                    F = fa,
                    Gradient = fdf.DF(x1)
                });
            }

            fb = fdf.F(x1);
            if (fb >= fa && stepb > 0)
            {
                fc    = fb;
                stepc = stepb;
                goto Trial;
            }

            var gradient = fdf.DF(x1);

            return(null);
        }
        public IterationResult Iterate(
            MultidimensionalFunctionFDF fdf,
            double fa,
            Vector <double> gradient,
            Vector <double> x,
            Vector <double> dx)
        {
            var p = State.P;

            if (State.PNorm == 0 || State.G0Norm == 0)
            {
                dx.SetValue(0);
                return(new IterationResult
                {
                    State = IterationResultStates.ERROR
                });
            }

            double pg  = p.Multiply(gradient);
            var    dir = (pg > 0) ? 1 : -1;

            TakeStep(x, p, State.Step, dir / State.PNorm, State.X1, dx);
            double fc = fdf.F(State.X1);

            if (fc < fa)
            {
                State.Step = State.Step * 2;
                State.X1.CopyTo(x);
                return(new IterationResult
                {
                    F = fc,
                    State = IterationResultStates.SUCCESS
                });
            }

            return(null);
        }
Example #3
0
 public MultidimensionalMinimizer(int n, IMultidimensionalIterator iterator, MultidimensionalFunctionFDF fdf)
 {
     Init(n);
     Iterator = iterator;
     FDF      = fdf;
 }