Skip to content
This repository was 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

@mahui-cn

Description

@mahui-cn

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions