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); }
protected void AddRefConstraint(ConstraintRefBase constraint) { ConstraintRefList.Add(constraint); }