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, featuresDifficultyRelated examples
H‑1 Choice of loans *
calculation of net present value
H‑2 Publicity campaign *
forall-do
H‑3 Portfolio selection ** h7qportf.mos
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 ** capbgt_graph.mos
experiment with solutions: solve LP problem explicitly, ``round'' some almost integer variable and re-solve
H‑7 Mean variance portfolio selection: Quadratic Programming problem *** folioqp_graph.mos
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





h3portf.mos

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

   file h3portf.mos
   ````````````````
   Composition of an investment portfolio

   A financial consultant aims to determine in which shares
   to invest given an investment budget and the estimated 
   return on investment. There are minimum and maximum 
   investments for different subsets of shares. How much 
   money should be invested in each share to obtain the
   highest expected ROI?

   The model and its implementation present the use of subsets.
   A new condition is introduced, instead of investing between
   a minimum (VMIN) and maximum (VMAX) amount into *every* 
   share, the invested amount for each share must be within
   [VMIN,VMAX] or take the value 0. In this case, the decision 
   variable is known as semi-continuous variable so, the 
   implementation presents the possible use of 'is_semcont'.
   Limit values are defined as runtime parameters fr which new
   values can be stated when executing the model without having
   to edit the model source.
   
   (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

Back to examples browserPrevious exampleNext example