(!******************************************************
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