Tuesday, September 30, 2008

Microsoft Solver Foundation

.NET based solvers:
  • Simplex solver (LP,MIP)
  • Interior Point solver (LP,QP)
  • Constraint solver (CSP)
  • Unconstrained non-linear solver (NLP)

Can be used as library via any .NET language, or input can be specified as MPS and a simple equation oriented format called OML. In addition, Excel bindings are available.


After downloading, documentation and samples are available in My Documents\Microsoft Solver Foundation.


  1. Sounds interesting.

    Do you know if it's portable to VBA in Excel 2003 and before?


  2. I have seen code to call .NET from a win32 DLL. Then you could call the DLL from VBA.

    There is much better support for Excel 2007 however. It installs into Excel with a ribbon to express the model. Looks pretty cool.

  3. I am not sure if the solver functionality is complete.

    For example if I am minimzing the variance of a portfolio of stocks, then of course it's simple to implement.

    What if...I want to implement

    Stock A -- Regress with (Basket of stocks)

    And solver should minimize the error (residuals square) for regression between Stock A and Basket of Stocks...and give out the appropriate weights for basket of stocks.

    This can't be expressed as one simlpe equation. I guess Microsoft Solver Foundation can't solve this case. or maybe I am missing something?

  4. Yes, regression can be written as an optimization problem. Essentially, Minimize ||e||, s.t. y=Xb+e. It can also be formulated as a system of linear equations (via so-called normal equations, but note that these can introduce numerical instability). For more information see http://www.amsterdamoptimization.com/pdf/ols.pdf (largely focused on GAMS, but many concepts can be translated directly to MSF).

  5. I understand regression can be modeled. But here the simple case in excel can't be replicated in .NET Solver. Since for each regression one of my variables (say Basket of Stocks) will change for different weights.

    X -> Basket of stocks (W1*StockB+W2*StockC+W3*StockD

    Stock B * W1
    Stock C * W2
    Stock D * W3

    Regressing this Basket Value against another stock means running the regression again and again so that residuals are minimized. So in this case both Y and X in the regression are not constant. Y is constant but X Changes depending on the weights. This is very easy to represent in Excel via simple formulas.

    In Solver, since it accepts a single mathematical formula not a summation, it's I believe not possible. Any Suggestions?

  6. I think you are using the Excel Solver's nonlinear programming solver using Excel's regression procedure as constraints. MSF has no solver for constrained nonlinear programming.

    Having said this, sometimes it is possible to reformulate problems. I don't understand your description enough to be able to write down the mathematical model, so you may want to sit down with a statistician to help you with this.