public override IOperation Apply()
        {
            var  state     = State;
            bool @continue = alglib.minlbfgs.minlbfgsiteration(state.State);

            TerminationCriterionParameter.ActualValue = new BoolValue(!@continue);
            if (@continue)
            {
                PointParameter.ActualValue = new RealVector(state.State.x);
            }
            else
            {
                double[] x = new double[state.State.x.Length];
                alglib.minlbfgs.minlbfgsreport rep = new alglib.minlbfgs.minlbfgsreport();
                alglib.minlbfgs.minlbfgsresults(state.State, ref x, rep);
                if (rep.terminationtype < 0)
                {
                    if (rep.terminationtype == -1)
                    {
                        throw new OperatorExecutionException(this, "Incorrect parameters were specified.");
                    }
                    else if (rep.terminationtype == -2)
                    {
                        throw new OperatorExecutionException(this, "Rounding errors prevent further improvement.");
                    }
                    else if (rep.terminationtype == -7)
                    {
                        throw new OperatorExecutionException(this, "Gradient verification failed.");
                    }
                }
                PointParameter.ActualValue = new RealVector(x);
            }
            return(base.Apply());
        }
 public override IOperation Apply() {
   var state = State;
   bool @continue = alglib.minlbfgs.minlbfgsiteration(state.State);
   TerminationCriterionParameter.ActualValue = new BoolValue(!@continue);
   if (@continue) {
     PointParameter.ActualValue = new RealVector(state.State.x);
   } else {
     double[] x = new double[state.State.x.Length];
     alglib.minlbfgs.minlbfgsreport rep = new alglib.minlbfgs.minlbfgsreport();
     alglib.minlbfgs.minlbfgsresults(state.State, ref x, rep);
     if (rep.terminationtype < 0) {
       if (rep.terminationtype == -1)
         throw new OperatorExecutionException(this, "Incorrect parameters were specified.");
       else if (rep.terminationtype == -2)
         throw new OperatorExecutionException(this, "Rounding errors prevent further improvement.");
       else if (rep.terminationtype == -7)
         throw new OperatorExecutionException(this, "Gradient verification failed.");
     }
     PointParameter.ActualValue = new RealVector(x);
   }
   return base.Apply();
 }