framework icon indicating copy to clipboard operation
framework copied to clipboard

Add an Example for NonlinearConstraint Constructor (IObjectiveFunction, Expression(Func(Double[], Boolean)), Func(Double[], Double[]))

Open mahui-cn opened this issue 5 years ago • 0 comments

hi,

When I call new NonlinearConstraint like below:

   var cc = new NonlinearConstraint(objFun, initialGuess => initialGuess.All(x => x <= 1));

Complier throw an error like: System.NullReferenceException

I check the source code of constructor of NonlinearConstraint class:

 public NonlinearConstraint(IObjectiveFunction objective,
           Expression<Func<double[], bool>> constraint,
           Func<double[], double[]> gradient = null)
       {
           Func<double[], double> function;
           ConstraintType shouldBe;
           double value;

           parse(constraint, out function, out shouldBe, out value);

           this.Create(objective.NumberOfVariables, function, shouldBe, value, gradient, DEFAULT_TOL);
       }

** the constraint which I put in should return a result of boolean, but why the constructor call parse to get value of double type?**

Please add an example for NonlinearConstraint Constructor (IObjectiveFunction, Expression(Func(Double[], Boolean)), Func(Double[], Double[])).

TODO (optional): Describe a specific scenario you would like to see addressed.

Help Topic: http://accord-framework.net/docs/html/M_Accord_Math_Optimization_NonlinearConstraint__ctor_3.htm

mahui-cn avatar Oct 16 '20 19:10 mahui-cn