i am working on project that it is implementing a one of the non linear optimization algorithm and to achieve that i chose to work with c# and wpf as platform i found how to implement the algorithm and that by using the Accord.net library and that by doing so
// Suppose we would like to minimize the following function:
//
// f(x,y) = min 100(y-x²)²+(1-x)²
//
// Subject to the constraints
//
// x >= 0 (x must be positive)
// y >= 0 (y must be positive)
//
// First, let's declare some symbolic variables
double x = 0, y = 0; // (values do not matter)
// Now, we create an objective function
var f = new NonlinearObjectiveFunction(
// This is the objective function: f(x,y) = min 100(y-x²)²+(1-x)²
function: () => 100 * Math.Pow(y - x * x, 2) + Math.Pow(1 - x, 2),
// And this is the vector gradient for the same function:
gradient: () => new[]
{
2 * (200 * Math.Pow(x, 3) - 200 * x * y + x - 1), // df/dx = 2(200x³-200xy+x-1)
200 * (y - x*x) // df/dy = 200(y-x²)
}
);
and like that i managed my way to make it work i tested it with my teacher equation and everything went good and in goal to make the project a more presentable picture i wanted to create an interface for it to be easy to be used by the end users and at that moment the problem occurs i didn't find a way to parse the given equation dynamically
even that in the library description they mentioned that :
//
// Summary:
// Creates a new objective function specified through a string.
//
// Parameters:
// numberOfVariables:
// The number of parameters in the function.
//
// function:
// A lambda expression defining the objective function.
public NonlinearObjectiveFunction(int numberOfVariables, Func<double[], double> function);
i searched in many resources to achieve that but no clue found all what i found is that i can only create the quadratic equation of the type
ax^2 + bx + c = 0 with the constructor new QuadraticObjectiveFunction("x²+y²+3z+6"); i wish that someone help me find how to achieve the same feature or at least give me a hint to how to reformulate the other non linear objective function types from humain format to C# code
greetings ...
**
Update :
** i was trying to solve the problem with the wrong way the answer is to use R.net or the matlab COM to achieve what i want