Linear Programming Library for .NET / C #

I need to solve an indefinite linear system of equations and constraints, then find a specific solution that minimizes the cost function. This needs to be done in purely portable managed code that will work in .NET and Mono. What available libraries are available to implement this?

All optimization algorithms provided by free libraries, I found only support interval limits for single variables, for example. 0 < x < 1 , not constraints of type x + 2y < 4 . I also found that often linear equation solvers only support linear systems with one solution.

The closest I have found so far is DotNumerics , which includes decomposing singular values ​​to solve underdetermined linear systems, but its optimization algorithms only support the limitations of one variable (as far as I can tell).

There are a few more questions about linear programming, but my key requirements are variable variables and solutions for underdetermined systems. I have not yet found a free library that supports restrictions with several variables.

+8
c # mono mathematical-optimization linear-programming
source share
4 answers

ALGLIB is a common library for things like linear solvers. I would give a good look before despair.

+5
source share

If you are developing .NET (that is, not the Windows Store, Windows Phone or Silverlight), then I definitely recommend that you take a look at lpsolve , which is suitable for big problems with LP and / or MILP. Download the x86 or x64 development archives that contain the corresponding lpsolve DLL: s, and then download the .NET API archive containing the C # file with P / Invoke calls for all the corresponding functions in the lpsolve API.

Another alternative is to use the CLIN resolver COIN-OR , using CoinMP precompiled binaries. There is a C # DLL wrapper available here .

If you need purely managed code, ALGLIB is probably the best choice (as Mark Gravell suggested above), but keep in mind that the open source ALGLIB license uses the GPL. If you want to use ALGLIB in your own code without disclosing it to the open source community, you will need to purchase a commercial license from ALGLIB.

A quick search on the Internet also shows a clean C # implementation of the Simplex LP algorithm here . I cannot identify the author, and I have no idea whether this implementation is correct or of what quality. The code is really very portable, albeit in terms of the context of the Windows Store, Windows Phone, Silverlight, and Mono.

+8
source share

Linear programming is designed to do exactly what you ask. Constraints with several variables are absolutely normal in linear programming. Find free solvers like lpsolve ( http://sourceforge.net/projects/lpsolve/ ), glpk ( http://www.gnu.org/software/glpk/ ) or CBC ( https: //projects.coin- or.org/Cbc ).

I agree that the above suggestions are not included in C # and are not controlled by .net assemblies out of the box. If this is a deal breaker for you, perhaps you can try to create a version yourself from the source code of one of these libraries. It may take quite a bit of work, although I have not tried it.

It is also not clear from your original question how big or complex the problem you are trying to solve is. If you have variables that must take discrete values, then you need a solver library that will execute a branch that is related or similar, otherwise, if it were purely linear and continuous, then you can simply use the simplex algorithm. Its in many textbooks if you cannot find a pre-built version.

If this is really a tiny problem (dozens of variables and constraints) or just linear and continuous, then you can get away with your own fresh (portable, clean managed code) implementation, but if you have thousands of constraints and variables, you can try your best get the required performance. If you have a big and difficult problem, you might be out of luck, as you may need a commercial solver to get the answers you need.

+4
source share

no one mentioned the crucial foundation . This is a good option.

+1
source share

All Articles