FICO
FICO Xpress Optimization Examples Repository
FICO Optimization Community FICO Xpress Optimization Home
Back to examples browserPrevious exampleNext example

Economics and finance

Description
Problem name and type, featuresDifficulty
H‑1 Choice of loans *
calculation of net present value
H‑2 Publicity campaign *
forall-do
H‑3 Portfolio selection **
sets of integers, second formulation with semi-continuous, parameters
H‑4 Financing an early retirement scheme **
inline if, selection with `|'
H‑5 Family budget **
formulation of monthly balance constraints including different payment frequencies; as, mod, inline if, selection with `|'
H‑6 Choice of expansion projects **
experiment with solutions: solve LP problem explicitly, ``round'' some almost integer variable and re-solve
H‑7 Mean variance portfolio selection: Quadratic Programming problem ***
parameters, forall-do, min, max, loop over problem solving


Further explanation of this example: 'Applications of optimization with Xpress-MP', Chapter 13: Economics and finance problems

mosel_app_8.zip[download all files]

Source Files

Data Files





h4retire.mos

(!******************************************************
   Mosel Example Problems
   ======================

   file h4retire.mos
   `````````````````
   Financing an early retirement scheme
   
   (c) 2008 Fair Isaac Corporation
       author: S. Heipcke, Mar. 2002
*******************************************************!)

model "H-4 Retirement"
 uses "mmxprs"

 declarations
  BONDS = {"SNCF","Fujitsu","Treasury"}  ! Set of bonds
  NT = 7                              ! Length of planning period
  YEARS = 1..NT
  
  DEM: array(YEARS) of integer        ! Annual payments for retirement
  VALUE: array(BONDS) of real         ! Unit price of bonds
  RATE: array(BONDS) of real          ! Remuneration rates paid by bonds
  RET: array(BONDS) of real           ! Unit annual interest of bonds
  DUR: array(BONDS) of real           ! Duration of loans
  INTEREST: real                      ! Interest for other secure investment
  
  buy: array(BONDS) of mpvar          ! Number of bonds acquired
  invest: array(YEARS) of mpvar       ! Other annual investment
  capital: mpvar                      ! Total capital required
 end-declarations

 initializations from 'h4retire.dat'
  DEM VALUE RATE DUR INTEREST
 end-initializations

 forall(b in BONDS) RET(b):= VALUE(b)*RATE(b)/100

! Annual balances
 capital - sum(b in BONDS) VALUE(b)*buy(b) - invest(1) = DEM(1)

 forall(t in 2..NT)
  sum(b in BONDS | DUR(b)+1>=t) (RET(b)*buy(b) + 
                                 if(DUR(b)+1=t, VALUE(b)*buy(b), 0)) +
   (1+INTEREST/100)*invest(t-1) - if(t<NT, invest(t), 0) = DEM(t)

 forall(b in BONDS) buy(b) is_integer

! Solve the problem: minimize invested capital
 minimize(capital)
 
! Solution printing
 writeln("Total capital: ", getobjval)
 writeln("Number of bonds to buy:")
 forall(b in BONDS) write(b, ": ", getsol(buy(b)), 
                          " (price: ", VALUE(b)*getsol(buy(b)), ") ")
 writeln("\nOther investment:") 
 forall(t in 1..NT-1) write("   year ", t)
 writeln
 forall(t in 1..NT-1) write(strfmt(getsol(invest(t)),9,3))
 writeln 
 
end-model

Back to examples browserPrevious exampleNext example