I'm currently trying to use the GenSA Simulated Annealing package to minimize the function below:
efficientFunction <- function(v) {
t(v) %*% Cov_Mat %*% v
}
Where Cov_Mat is the covariance matrix obtained from 4 assets, and v is the weight vector of dimension 4.
I am trying to solve the Markowitz asset allocation approach this way, and I would like to know how I could introduce a mathematical constraint, such as the sum of all the coefficients should be 1:
sum(v) = 1
Also, since I intend to rely on the GenSA function, I would like to use something like this with a restriction:
v <- c(0.25, 0.25, 0.25, 0.25)
dimension <- 4
lower <- rep(0, dimension)
upper <- rep(1, dimension)
out <- GenSA(v, lower = lower, upper = upper, fn = efficientFunction)
: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.97.6091&rep=rep1&type=pdf
Simulated Annealing Algorithm, , R.
. , SO, , , .