MATLAB Answers

L Smith

Linear programming and cash flow matching

Asked by L Smith
on 19 Aug 2019
Latest activity Commented on by L Smith
on 27 Aug 2019
I am trying to solve a simple large scale linear /non-linear programming problem to match liability cash flows with asset cash flows. I am thinking between MATLAB and R to solve this problem. I have explained the problem below and I was wondering whether MATLAB can be used to solve this.
Can anyone please let me know if and how MATLAB can be used to solve this problem? If any particular MATLAB optimization toolboxes will be needed then please let me know.
A fixed set of liability cash flows are given, say for the next 20 years. We need to select appropriate bonds to match these liability cash flows, ignoring interest rate risk and other market risks. We are given market value of bonds and their cash flows based on which we need to decide which bonds to select. The objective function is to minimise value of liabilities, which is calculated by discounting liability cash flows at a flat discount rate, say 1% + a spread. This spread depends upon internal rate of return of the assets portfolio, e.g. spread = 50% of internal rate of return on the asset portfolio (the higher the spread, the lower the value of liabilities. Constraints are: weights of bonds can be either zero or 1 (i.e. either we invest in a bond or we don’t) and asset cash flows can be lower than liability cash flows in certain years but cumulatively say at every 3 years asset cash flows should exceed liability cash flows.


Sign in to comment.

1 Answer

Answer by Alan Weiss
on 22 Aug 2019

I don't know for sure, but perhaps this example is relevant.
Alan Weiss
MATLAB mathematical toolbox documentation


Sure, for this problem, going with Solver-based makes sense. There's only one group of variables, bonds, and it is one dimensional. There is only one group of constraints. You can use MATLAB matrix functions to write the constraints.
Problem-based is a win when there are several groups of variables, when the variables are multi-dimensional., or when there are several groups of constraints. For those sorts of problems, Problem-based is easier is easier for me to write the problem and easier for me to remember what I had in mind when I return to it after weeks or months.
Sometimes it is easier to write the expressions using the problem based approach, so that you can write in terms of variable names that are meaningful for you. However the problem based approach is not more powerful than the solver based approach: in most cases they use the same internal logic, sometimes simply converting to solver based internally and using that.
As you have found, the problem based approach is not yet as flexible as the solver based approach.
In setting up systems such as these, often the "better" approach is the one that makes it most likely that what is optimized is what you need to be optimized. The solver based approach is more flexible but it does require a lot of packing and unpacking of variables into a vector of values to be optimized over, and it can be a lot easier in such a way of writing that code to accidentally code values into the wrong place in arrays.
Thank you Mary and Walter much appreciated. I agree with you that it is much easier to apply the problem based approach.

Sign in to comment.