Question: Minimize VaR with LP

I want to minimze VaR (the 5th percentile for the return distribution) with LP.
However, the way I have specified the problem does not work for some reason, why?


restart:
with(Optimization):
with(LinearAlgebra):

nstock := 20:
n := 15:

R := RandomMatrix(n, nstock, generator = -15 .. 15, outputoptions = [datatype = float[8]]):
W := Matrix(nstock, 1, [seq(w[i], i = 1 .. nstock)]):
data1 := Array(Multiply(R, W));

LPSolve(Percentile(data1, 5), {seq(w[i] >= 0, i = 1 .. nstock), seq(w[i] <= 1, i = 1 .. nstock)})


Error, (in Optimization:-LPSolve) objective function must be specified as a linear polynomial or Vector

Please Wait...