I have to construct a set of functions that I want to optimize. The set consists of functions with all subsets I can build with p variables. If p is small, that’s easy. For example, with p=2, I can build 2^2-1=3 functions, one for each subset of variables (I excluded the empty subset):
f(x)=2*x^2+1
f(y)=2*y^2+1
f(x)=2*x[1]^2+2*x[2]^2+1
But if I have p=6 variables, how can I construct all the 2^6-1=63 possible functions to optimize without having to create 63 functions? I thought about creating an Array like x=[x[1],x[2],x[3],x[4],x[5],x[6]]
and then building all the functions, setting to 0 all the variables that are not present in the function corresponding to the selected subset.