How to solve the linear programming problem with DotNumerics?

I am really interested in numerical analysis. I am using the open source DotNumerics app. My linear system:

1 * x + 3 * y <= 150 2 * x + 1 * y <= 100 

where x >= 0, y >= 0

 z = 10 * x + 15 * y 

I am trying to solve z (optimization ...)

I can use the Simplex method to solve the above problem, as shown in this link . I also sent a letter to the author, but he did not reply.

 using DotNumerics.Optimization; using DotNumerics; namespace App.SimplexCalcLinearProgramming { class Program { static void Main(string[] args) { Simplex simplex = new Simplex(); double[] initialGuess = new double[2]; initialGuess[0] = 0.1; initialGuess[1] = 2; double[] minimum = simplex.ComputeMin(AmacFunction, initialGuess); minimum.ToList().ForEach(q => Console.Write(q.ToString() + "\n")); Console.ReadKey(); } static double AmacFunction(double[] x) { /* * 1 * x + 3 * y <= 150 * 2 * x + 1 * y <= 100 * * where x >= 0, y >= 0 * * z = 10 * x + 15 * y * * Solve for z */ double f = 0; f = 10*x[0]+15*x[1]; return f; } } } 
+6
source share
1 answer

I do not think that DotNumerics can solve LP problems on their own. As far as I interpret the documentation, Nelder-Mead (simple spung method) is used only to solve simple problems with minimization, not problems with LP.

The last time I decided to use LP in C #, I used the .net wrapper for LP_Solve .

If you download the lpsolve package, it should come with an example for .net. You can also connect it to the basics of microsoft solution ( see here ), but I think that MSF has some licensing problems and you cannot use it freely for commercial applications. But, nevertheless, MSF can be interesting to check.

Again, you can just use lpsolve without MSF. Lpsolve is a pretty good LP solver if you have no problems with large sizes. Then it can be worth it, at least for alternatives, and compare performance / adaptability to your specific problem.

+7
source

Source: https://habr.com/ru/post/888458/


All Articles