Say each sample has values ##\vec{x}=x_1, x_2,..., x_n##, and I know the values of ##\vec{x}## for each sample.

Also, if I sum up all of the samples, I get a value, ##Z##, which tells me something about the samples.

Now I want to find a series of parameters, ##a_i, b_i## such that :

$$

(a_1<x_1<b_1),\,\,\,\, (a_2<x_2<b_2)\,\,\,\, ... \,\,\,\,(a_n<x_n<b_n)

$$

These parameters essentially filter out unwanted samples, to affect the value ##Z##. So, for example, sample ##1## has ##x_1=0##, so if I set ##0<x_1<2##, then sample##1## is left out, and only samples with ##x_1 \in (0,2)## are included.

How can I optimize the parameters ##a_i, b_i##, such that I get the best value of ##Z## ?

##Z## is interesting also, I want the highest ##Z## with the largest number of samples ##(N)##, so it's probably better to multiply ##Z*N## and fit for this.

I don't think this is a standard regression type of problem. I tried a brute force solution, but it will take way too long. Can anyone recommend an algorithm, or a new way to represent the problem so that it can be solved by some algorithm?