public static double GradApproximation(List <double> parameters, int index, ConstraintRefBase constraint)
        {
            var pert   = 1e-6;
            var temper = parameters[index];

            parameters[index] = temper - pert;
            var first = constraint.Calc(parameters) * constraint.Calc(parameters);

            parameters[index] = temper + pert;
            var second = constraint.Calc(parameters) * constraint.Calc(parameters);

            parameters[index] = temper;
            var grad = .5 * (second - first) / pert;

            return(grad);
        }
Example #2
0
 protected void AddRefConstraint(ConstraintRefBase constraint)
 {
     ConstraintRefList.Add(constraint);
 }