Hi.
I can't figure out if it's somehow possible to input/customize the functions to be minimized/optimized at runtime in C#.
Im making an application for economic students with a GUI. A basic thing in economics is the supply and demand curves. The students will for example see two curves and their intersection in a cordinate system. I use lmoptimize to calculate the intersection cordinates.
If the students want to change the demand or supply they can do it on the fly by moving a slider. If the demand curve is 1/x + 15 the student can change the demand by moving the curve upwards or downwards. If the user moves the demand curve upwards for example to 1/x + 17 I need to be able to recalculate the intersection between the supply and demand curve because it has changed. How can I do this on the fly?
In the example from the reference manual (example_minlm_d_v)
http://www.alglib.net/translator/man/ma ... _minlm_d_vthe function structure has to be "there" at compile time. In my program where minlmoptimize is used for calculating intersection it looks like this:
Code:
public static void function1_fvec(double[] x, double[] fi, object obj)
{
fii[0] = (1 / x[0] + 15) - (x[1] - 16);
fii[1] = (x[1] - 16) - (1 / x[0]+15);
}
I would like to be able to change the fi function vector so the new intersection depending on the user input is calculated in real time. So the new functions in from above in this case would look like:
Code:
public static void function1_fvec(double[] x, double[] fi, object obj)
{
fii[0] = (1 / x[0] + 17) - (x[1] - 16);
fii[1] = (x[1] - 16) - (1 / x[0]+17);
}
It would be very nice if you could pass a string (or something) to and call the function1_fvec with the new user function each time he or she changed the slider. Is this possible to do or should I try to use the codedom compiler in C# which I don't have any experience in.
Thank you very much.
Greets
Hans