I made a random data matrix as
data = Table[Random[], {i, 5}, {j, 5}];
In my case it was $$ \left( \begin{array}{ccccc} 0.951203 & 0.546669 & 0.86928 & 0.00281753 & 0.306743 \\ 0.823344 & 0.117588 & 0.530483 & 0.777849 & 0.440718 \\ 0.109126 & 0.0686256 & 0.516334 & 0.460716 & 0.395735 \\ 0.254902 & 0.0376569 & 0.0648415 & 0.699014 & 0.373885 \\ 0.75997 & 0.995759 & 0.923424 & 0.498251 & 0.808767 \\ \end{array} \right)$$
I understand how Mathematica is able to solve the optimization problem below, thanks to the theory behind canonical correlation:
Minimize[
Correlation[Sum[a[i] data[[;; , i]], {i, 1, 4}], data[[;; , -1]]],
Table[a[i], {i, 4}]]
What I am not sure is how is it possible to get an exact solution with Minimize when I add linear/affine constraints
Minimize[{Correlation[Sum[a[i] data[[;; , i]], {i, 1, 4}],
data[[;; , -1]]], a[1] + a[2] + a[3] + a[4] > 0.1, a[2] - a[3] < 1},
Table[a[i], {i, 4}]]
I am interested to learn how Mathematica is doing the optimization under the hood for the constrained problem, because I would like to use the same method in Python for greater speed. Thanks.