Wiki Link: [discussion:2309]
Code Sample for NPV calculation 

Sep 22 2009 at 8:11 PM
Is there a code sample for using solver to calculate the discount rate for NPV calculation?

Sep 22 2009 at 9:10 PM


quant wrote:
Is there a code sample for using solver to calculate the discount rate for NPV calculation?


As single problem this could be solved with the non-linear solver, but you will need to calculate derivatives as there is no automatic differentation. As part of an LP, MIP or CSP problem this is probably not possible: the problem is nonlinear. With some effort approximations can be developed for these environments. In Excel there is a function IRR to calculate the irr (internal rate of return). You can also use the Excel solver (not solver foundation), which can handle nonlinear problems.

----------------------------------------------------------------
Erwin Kalvelagen
Amsterdam Optimization Modeling Group
erwin@amsterdamoptimization.com
http://amsterdamoptimization.com
----------------------------------------------------------------

Sep 22 2009 at 10:09 PM
I thought solver foundation also handle non-linear programming? Is it not the case? Any plug-in support non-linear solver? I am currently doing this calculation in Excel using Excel solver, but want to do this in .Net c++ program. Appreciate your help.

Sep 23 2009 at 4:47 PM
Solver Foundation can handle unconstrained non-linear problems. This is done with Compact Quasi Newton (CQN) solver which implements an L-BFGS algorithm.
For documentation see Documents\MSF-SolverProgrammingPrimer.docx in your installation directory. There is a C# sample in “User Documents directory\Microsoft Solver Foundation\Samples\Solvers\C#\NLP” - you should be able to adapt it to managed C++ without too much trouble.
There is currently no plug-in support for NLP.

Hope it helped.

-Shahar


Updating...
Page view tracker