Tuesday, July 7, 2009

MS Solver Foundation: Excel interface through COM/C# (2)

This is a follow-up on http://yetanothermathprogrammingconsultant.blogspot.com/2009/07/ms-solver-foundation-excel-interface.html. Here we explore an LP approximation to the QP models used in the original post. In the original model we used

risk = Σ wt2/T

Here we will replace the quadratic expression by an absolute value:

risk ≈ Σ |wt|/T

The big advantage of an LP model is that we can extend this to a MIP for more complicated modeling situations. Although some solvers support MIQP models, the MIQP algorithms are often not as fast as MIP algorithms. (Microsoft Solver Foundation does have a QP algorithm, but as it is based on an interior point algorithm it is not really suited to be used inside a branch-and-bound framework, so there is no standard MIQP capability).

The LP model is included in the DLL code as follows:


lpmodel1

The absolute values are implemented using a standard variable splitting technique: wt = yt+ − yt- with yt+,yt- ≥ 0. Then it follows that |wt| = yt+ + yt-.

Everything else can stay the same. The results are shown in the screen dump below. As you can see the LP offers a reasonable approximation: the portfolios for different trade-offs between risk and return are quite similar. (Click on the picture to enlarge).



This exercise shows that beyond using the MSF Excel plug-in, the .NET API’s in combination with the modeling language OML are a powerful tool to write applications and that these solutions can be easily integrated in an Office Environment (Access, Excel).

2 comments:

  1. Hello Erwin,

    I am so happy that I found you randomly on this blog. I have been having problems with my GAMS code recently, it is a simple thing actually. We are solving a MINLP using Lindoglobal. But the solver gives iteration limit reached result-no solution. I was trying to increase this limit but so far no luck. This is what I have done:

    P1.iterlim=100000000;
    P1.optfile=1 (in the opt file I have: NLP ITRLMT 100000000)

    The result that I got says the iteration limit is set 10000.

    I would be really happy if you could comment on this.

    ReplyDelete
  2. This does not seem very related to this posting. Wrt to your question: check the listing file if the iteration limit was indeed increased. Note: free GAMS support can be had from support@gams.com.

    ReplyDelete