From the mathematical model to the OPL code

The tangency portfolio problem is expressed in OPL (Optimization Programming Language).

Converting the tangency portfolio mathematical model to OPL code is straightforward, and is presented in the files:

<Install_dir>\opl\examples\opl_interfaces\java\ConcurrentProcessing\portfolio.mod

<Install_dir>\opl\examples\opl_interfaces\java\ConcurrentProcessing\portfolio.dat

r(i) is modeled in OPL as:

float Return[Investments] = ...;

COV is defined as:

float Covariance[Investments][Investments] = ...;

ρ is:

float Rho = ...;

X is:

dvar float Allocation[Investments] in FloatRange;

TR and TV are calculated by:

float TotalReturn = sum(i in Investments) Return[i]*Allocation[i];
float TotalVariance = sum(i,j in Investments) Covariance[i][j]*Allocation[i]*Allocation[j];

The file portfolio.dat contains 20 investment assets, for which a vector R and a matrix COV are defined. Rho takes N values from 0 to 1, N being defined by the user.