Skip to content
This repository has been archived by the owner on Nov 19, 2020. It is now read-only.

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

Open
mahui-cn opened this issue Oct 16, 2020 · 0 comments

Comments

@mahui-cn
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant