I'm trying to 开发者_运维技巧solve some simple equations in .NET. I came across Math.NET and evaluate it.
The Solver()
methods seemed to be what I need but I can't figure out how to use side conditions with this method.
To illustrate my problem I will give you a sample:
Given:
0 <= a_i <= 100
0 <= b <= 100
0 <= c
a_i, b and c are given
x_1, ..., x_n should be optimized
f(x) = x_1*a_1 + x_2*a_2 + ... + x_n*a_n = b
Side conditions:
g(x) = x_1 + x_2 + ... + x_n = c
0 <= x_i
Is it possible to solve such a problem using the solve method or any other component of Math.NET or do you know any (free for commercial use) .NET library that can be used for solving this? I wouldn't like to write an algorithm for such a common problem by myself.
Best regards & thanks in advance
IMHO Microsoft Solver Foundation is the way to go for this. The Express Version is free AFAIK and powerful enough for most smaller applications.
As I see now the Express Version is only indented for exploration - but there is (now?) a Standard-Lib for MSDN subscribers so I don't remove this post yet, as you might have a MSDN subscribtion.
ALGLIB is great for these tasks. Check out their page on constrained optimization.
EDIT: It has both a free license (GPL) and a commercial license starting from $370.
You need an optimizer with constraints like simplex method or Marquardt non-linear optimization.
精彩评论