Compute Gram matrices a minimal number of times.
The Gram matrix (K_v) computes the "distance" (in a sense that this distance is "weighted" by a kernel) between two constraints, for a set of substrate metabolites described by v. For instance if substrate_metabo = {glucose, thiosulfate, galactose}, v can be {glucose, thiosulfate}. For two constraints c_i, c_j, this matrix writes
(K_v){i,j} = k_v(c_vi, c_vj) = prod(a in v) k{0a} (c_ai, c_aj).
Where c_ai is the real valued constraint for substrate metabolite a
at observation i
. and c_vi is the vector valued constraints for substrate metabolites a in v at observation i
.
See eq 16 from https://arxiv.org/pdf/1905.13695.pdf for a definition of k_0a
.
These matrices must be computed for all subsets of the set of substrate metabolites. For {glucose, thiosulfate, galactose}, there is 7 such subsets.
Currently, 7 Gram matrices are computed each from scratch, whereas one would only need to compute 3: K_{glucose}, K_{galactose}, K_{thiosulfate}, and then obtained the missing ones only with hadamard products, e.g.
K_{glucose, galactose} = K_{glucose} * K_{galactose} where "*" is the term by term matrix product (Hadamard product). We need to modify the code in order to do that.