Initializing help system before first use

H. Economics and finance


Description:

Problem name and type, features Difficulty
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


File(s): h1loan.mos (Mar. 2002), h2publ.mos (Mar. 2002), h3portf.mos (Mar. 2002), h4retire.mos (Mar. 2002), h4retire.mos (Mar. 2002), h6expand.mos (Mar. 2002), h7qportf.mos (Aug. 2002)
Data file(s): h1loan.dat, h2publ.dat, h3portf.dat, h4retire.dat, h4retire.dat, h6expand.dat, h7qportf.dat

h1loan.mos
(!******************************************************
   Mosel Example Problems
   ======================

   file h1loan.mos
   ```````````````
   Choice of loans
   
   (c) 2008 Fair Isaac Corporation
       author: S. Heipcke, Mar. 2002
*******************************************************!)

model "H-1 Loan choice"
 uses "mmxprs"

 declarations
  BANKS = 1..3                         ! Set of banks
  SHOPS = {"London", "Munich", "Rome"} ! Set of shops
  DUR: integer                         ! Duration of loans
  
  PRICE: array(SHOPS) of integer       ! Price of shops
  RATE: array(BANKS,SHOPS) of real     ! Interest rates offered by banks
  VMAX: integer                        ! Maximum loan volume per bank
  
  borrow: array(BANKS,SHOPS) of mpvar  ! Loan taken from banks per project
 end-declarations

 initializations from 'h1loan.dat'
  PRICE RATE VMAX DUR
 end-initializations

! Objective: interest payments
 Interest:= 
  sum(b in BANKS, s in SHOPS) borrow(b,s)*RATE(b,s)/(1-(1+RATE(b,s))^(-DUR))

! Finance all projects
 forall(s in SHOPS) sum(b in BANKS) borrow(b,s) = PRICE(s)
 
! Keep within maximum loan volume per bank
 forall(b in BANKS) sum(s in SHOPS) borrow(b,s) <= VMAX 

! Solve the problem
 minimize(Interest)
 
! Solution printing
 writeln("Total interest: ", getobjval)
 forall(s in SHOPS) do
  write("Shop in ", s, ": ")
  forall(b in BANKS) 
   write( if(getsol(borrow(b,s))>0, 
             " bank " + b + ": " + getsol(borrow(b,s))/1000000 + " million", 
             ""))
  writeln
 end-do  
 
end-model

h2publ.mos
(!******************************************************
   Mosel Example Problems
   ======================

   file h2publ.mos
   ```````````````
   Planning a publicity campaign for a new product
   
   (c) 2008 Fair Isaac Corporation
       author: S. Heipcke, Mar. 2002
*******************************************************!)

model "H-2 Publicity"
 uses "mmxprs"

 declarations
  MEDIA = 1..6                        ! Set of media types
  
  REACH: array(MEDIA) of integer      ! Number of people reached
  COST: array(MEDIA) of integer       ! Unitary cost
  MAXUSE: array(MEDIA) of integer     ! Maximum use
  SCORE: array(MEDIA) of integer      ! Quality rating (best=highest value)
  BUDGET: integer                     ! Available publicity budget
  TARGET: integer                     ! Number of people to be reached
   
  use: array(MEDIA) of mpvar          ! Use made of different media
 end-declarations

 initializations from 'h2publ.dat'
  REACH COST MAXUSE SCORE BUDGET TARGET
 end-initializations

! Objective: quality of perception of the campaign
 Perceive:= sum(m in MEDIA) SCORE(m)*use(m)

! Budgetary limit
 sum(m in MEDIA) COST(m)*use(m) <= BUDGET
 
! Outreach of campaign
 sum(m in MEDIA) REACH(m)*use(m) >= TARGET  

 forall(m in MEDIA) do
  use(m) is_integer
  use(m) <= MAXUSE(m)
 end-do 
 
! Solve the problem
 maximize(Perceive)
 
! Solution printing
 declarations
  NAMES: array(MEDIA) of string
 end-declarations
 
 initializations from 'h2publ.dat'
  NAMES
 end-initializations

 writeln("Perception: ", getobjval, " units (", 
         getsol(sum(m in MEDIA) REACH(m)*use(m)), " people)")
 forall(m in MEDIA) writeln(NAMES(m), ": ", getsol(use(m)))

end-model

h3portf.mos
(!******************************************************
   Mosel Example Problems
   ======================

   file h3portf.mos
   ````````````````
   Composition of an investment portfolio
   
   (c) 2008 Fair Isaac Corporation
       author: S. Heipcke, Mar. 2002
*******************************************************!)

model "H-3 Portfolio"
 uses "mmxprs"

 parameters
  MAXTECH = 0.3                     ! Maximum investment into tech. values
  MINEU = 0.5                       ! Minimum investment into European shares
  VMIN = 5000                       ! Minimum amount for a single value
  VMAX = 40000                      ! Maximum amount for a single value
 end-parameters 

 declarations
  SHARES = 1..6                     ! Set of shares
  
  RET: array(SHARES) of real        ! Estimated return in investment
  CAPITAL: integer                  ! Capital to invest
  EU: set of integer                ! European values among the shares
  TECHNOLOGY: set of integer        ! Technology values among shares
  
  buy: array(SHARES) of mpvar       ! Amount of values taken into portfolio
 end-declarations

 initializations from 'h3portf.dat'
  RET CAPITAL EU TECHNOLOGY
 end-initializations

! Objective: total return
 Return:= sum(s in SHARES) RET(s)/100*buy(s)

! Requirements concerning portfolio composition
 sum(s in TECHNOLOGY) buy(s) <= MAXTECH*CAPITAL
 sum(s in EU) buy(s) >= MINEU*CAPITAL
 
! Total capital to invest
 sum(s in SHARES) buy(s) = CAPITAL
 
 forall(s in SHARES) do
  VMIN <= buy(s); 
!  buy(s) is_semcont(VMIN)
  buy(s) <= VMAX
 end-do   

! Solve the problem
 maximize(Return)
 
! Solution printing
 writeln("Total return: ", getobjval)
 forall(s in SHARES) writeln(s, ": ", getsol(buy(s)))  
 
end-model

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

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

h6expand.mos
(!******************************************************
   Mosel Example Problems
   ======================

   file h6expand.mos
   `````````````````
   Planning the expansion of a company
   
   (c) 2008 Fair Isaac Corporation
       author: S. Heipcke, Mar. 2002
*******************************************************!)

model "H-6 Expansion"
 uses "mmxprs"

 forward procedure print_sol

 declarations
  PROJECTS = 1..5                     ! Set of possible projects
  TIME = 1..5                         ! Planning period
  
  COST: array(PROJECTS,TIME) of real  ! Annual costs of projects
  CAP: array(TIME) of real            ! Annually available capital
  RET: array(PROJECTS) of real        ! Estimated profits
  DESCR: array(PROJECTS) of string    ! Description of projects
   
  choose: array(PROJECTS) of mpvar    ! 1 if project is chosen, 0 otherwise
 end-declarations

 initializations from 'h6expand.dat'
  COST CAP RET DESCR
 end-initializations

! Objective: Total profit
 Profit:= sum(p in PROJECTS) RET(p)*choose(p)
 
! Limit on capital availability
 forall(t in TIME) sum(p  in PROJECTS) COST(p,t)*choose(p) <= CAP(t)  

 forall(p in PROJECTS) choose(p) is_binary 
 
! Solve the problem
 maximize(XPRS_LIN, Profit)
 write("LP solution: ")
 print_sol

 maximize(Profit)
 write("MIP solution: ")
 print_sol
 
! Force acceptance of project 1
 choose(1)=1 

 maximize(Profit)
 write("Forcing project 1 (", DESCR(1), "): ")
 print_sol
 
!-----------------------------------------------------------------

! Solution printing
 procedure print_sol
  writeln("Total profit: ", getobjval)
  forall(p in PROJECTS) 
   if(getsol(choose(p))>0) then
    writeln(" ", DESCR(p), " (", getsol(choose(p)),")")
   end-if
 end-procedure
 
end-model

h7qportf.mos
(!******************************************************
   Mosel Example Problems
   ======================

   file h7qportf.mos
   `````````````````
   Mean-variance portfolio selection
   
   (c) 2008 Fair Isaac Corporation
       author: S. Heipcke, Aug. 2002, rev. Sep. 2017
*******************************************************!)

model "H-7 QP Portfolio"
 uses "mmxprs", "mmnl"

 parameters
  TARGET = 7.0                      ! Minimum target yield
  MAXASSETS = 4                     ! Maximum number of assets in portfolio
 end-parameters 

 declarations
  SECS = 1..4                       ! Set of securities
  
  RET: array(SECS) of real          ! Expected yield of securities
  VAR: array(SECS,SECS) of real     ! Variance/covariance matrix of
                                    ! estimated returns  

  frac: array(SECS) of mpvar        ! Fraction of capital used per security
 end-declarations

 initializations from 'h7qportf.dat'
  RET VAR
 end-initializations

! **** First problem: unlimited number of assets ****

! Objective: mean variance
 Variance:=  sum(s,t in SECS) VAR(s,t)*frac(s)*frac(t)

! Spend all the capital
 sum(s in SECS)  frac(s) = 1
 
! Target yield
 sum(s in SECS) RET(s)*frac(s) >=  TARGET

! Solve the problem
 minimize(Variance)
 
! Solution printing
 declarations
  NAMES: array(SECS) of string
 end-declarations
 
 initializations from 'h7qportf.dat'   ! Get the names of the assets
  NAMES
 end-initializations

 writeln("With a target of ", TARGET, " minimum variance is ", getobjval)
 forall(s in SECS) writeln(NAMES(s), ": ", getsol(frac(s))*100, "%")  

! **** Second problem: limit total number of assets ****
 declarations
  buy: array(SECS) of mpvar         ! 1 if asset is in portfolio, 0 otherwise
 end-declarations

! Limit the total number of assets
 sum(s in SECS) buy(s) <= MAXASSETS

 forall(s in SECS) do
  buy(s) is_binary
  frac(s) <= buy(s)
 end-do
   
! Solve the problem
 minimize(Variance)

 writeln("With a target of ", TARGET," and at most ", MAXASSETS,
          " assets, minimum variance is ", getobjval)
 forall(s in SECS) writeln(NAMES(s), ": ", getsol(frac(s))*100, "%") 

end-model

© 2001-2020 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.