The problem is described below:
When m=2 and n=3, it is basically finding the distance between a point and a line segment in $R^3$.
But when both m and n are larger, do I have to use a generic optimizer to solve this, or this problem can be precisely solved with mathematics, like the case when m=2 and n=3?
What I have done for now:
I tried to solve it with Gram–Schmidt process and projection but got stuck.
For example, the following R code:
P <- c(1,1,1,1) m <- rbind(c(1,-1,1,2)*1/3,c(1,2,1,1)*1/5) m2 <- qr.Q(qr(t(m))) P2 <- P%*%m2[,1]*m2[,1]+P%*%m2[,2]*m2[,2]
It does not take into account the restriction $w_1+w_2=1$
Tried to solve it with lagrangian optimization, but also got stuck there.