<p>The obvious algorithm is to use binary search.</p>

<p>You'll need $\lg n$ iterations of binary search, where $n$ = the number of convex sets in your sequence.  (If you have an infinite family of convex sets, $\lg(|f(x)|/\epsilon)$ iterations are enough to approximate $f(x)$ to within $\epsilon$.)  In each iteration, for some value of $\lambda$, you test whether $x \in C_\lambda$.  You haven't specified the representation of the family of convex sets, but for typical representations, testing whether $x \in C_\lambda$ can be done in polynomial time.  So, the total running time will be polynomial.</p>

<p>To do better than this, I suspect the algorithm will need to depend upon how the sequence of convex sets $C$ is represented.  (Do you have a requirement for it to be represented in a particular way, or are you OK with any reasonable representation?  You might want to edit the question accordingly.  You might also want to specify whether this is a finite sequence or an infinite sequence, and how the sets are related.)</p>

<hr>

<p>For instance, here's a special case where the problem is easier.  Suppose that the sequence of sets is represented as follows: you have a set of linear inequalities on $x_1,x_2,\dots,x_d,\lambda$, with constants $c_0,c_1,\dots,c_d$, so that each linear inequality has this form:</p>

<p>$$c_0 \lambda + c_1 x_1 + c_2 x_2 + \dots + c_d x_d \le 0.$$</p>

<p>Now suppose that the convex set $C_\lambda$ is defined as the set of points $(x_1,\dots,x_d)$ that satisfy all of these linear inequalities (notice the very specific kind of dependence on $\lambda$), and suppose that the linear inequalities are chosen so $C_{\lambda_1} \subset C_{\lambda_2}$ whenever $\lambda_1 &gt; \lambda_2$.  Then you compute $f(x)$ efficiently using a very simple algorithm: you plug in $x$ into each of the linear inequalities, leaving $\lambda$ as the only unknown in each case, and find the largest value of $\lambda$ so that all of those inequalities are satisfied.  This only works if your sets have a certain form and are represented in a certain special way, which is why I say that your problem will probably depend upon how the sets are represented and what structure they might have.</p>

CC BY-SA 3.0
2013-09-06T22:50:43.600Z
You could use doubling search too, if the sizes of the convex sets increase with $\lambda$: test the convex sets $1$,$2$,$4$,$8$,... till you find one that contains $x$, then binary search in the last interval you found.
J.y B.y
CC BY-SA 3.0
2013-09-06T22:58:06.217Z
@Jeremy, yup!  That was implicitly what I had in mind for the case where we have an infinite family of convex sets.  (That's where the dependence on $|f(x)|$ comes from, in my answer.)
D.W.
CC BY-SA 3.0
2013-09-09T21:15:22.617Z
D.W. and Jeremy : Yes, the binary search is the first thing that came to my mind too. Was wondering if one can do any better. As for the representation of the set - I have some flexibility: if any particular representation would lead to a significantly better algorithm I would prefer that; in fact that is an interesting question in itself I guess. And it is an infinite sequence.
Kcafe
CC BY-SA 3.0
2013-09-09T21:33:54.687Z
@Krishna, I encourage you to edit the question to clarify all of those points; that will increase the exposure your question gets.  On this site, the expectation is that people should be able to understand your question and all of your requirements just by reading the main body of the question, without reading the comment thread.  You can do that by clicking the "edit" link underneath your question. (Given that it's an infinite sequence, it also might not hurt to describe how you are *currently* representing the sets, as I'm still not clear on the structure of your infinite sequence of sets.)
D.W.
CC BY-SA 3.0
2013-09-06T05:59:31.407Z
2013-09-09T21:41:28.933Z
2013-09-09T21:41:28.933Z
D.W.
<p>I have a sequence of convex sets $C_\lambda$ for $\lambda \in \mathbb{R}$ such that for $\lambda_1 &gt; \lambda_2$, we have $C_{\lambda_1} \subset C_{\lambda_2}$ (essentially a nested sequence of convex sets in $d$ dimensions). For a given point $x \in \mathbb{R}^d$, define: 
\begin{align*}
f(x) = \sup \{ \lambda: x \in C_{\lambda} \} 
\end{align*} </p>

<p>Is there an efficient algorithm for computing $f(x)$ given $x$. </p>

CC BY-SA 3.0
2013-09-06T22:48:18.167Z
Do you have any information about the size of each convex set?
J.y B.y
<ds.algorithms><convex-geometry>
Algorithm for testing if a point belongs to a sequence of convex set or not
Kcafe
# Algorithm for testing if a point belongs to a sequence of convex set or not

(Asked by: username_0 on 2013-09-06)

I have a sequence of convex sets $C\_\lambda$ for $\lambda \in \mathbb{R}$ such that for $\lambda\_1 > \lambda\_2$, we have $C\_{\lambda\_1} \subset C\_{\lambda\_2}$ (essentially a nested sequence of convex sets in $d$ dimensions). For a given point $x \in \mathbb{R}^d$, define:
\begin{align\*}
f(x) = \sup \{ \lambda: x \in C\_{\lambda} \}
\end{align\*}

Is there an efficient algorithm for computing $f(x)$ given $x$.

**Tags:** ds.algorithms, convex-geometry
> **Comments:**
> **username_1**: Do you have any information about the size of each convex set?  

---

## 1 answers

### Answer by username_2 on 2013-09-06. Score: 1

The obvious algorithm is to use binary search.

You'll need $\lg n$ iterations of binary search, where $n$ = the number of convex sets in your sequence. (If you have an infinite family of convex sets, $\lg(|f(x)|/\epsilon)$ iterations are enough to approximate $f(x)$ to within $\epsilon$.) In each iteration, for some value of $\lambda$, you test whether $x \in C\_\lambda$. You haven't specified the representation of the family of convex sets, but for typical representations, testing whether $x \in C\_\lambda$ can be done in polynomial time. So, the total running time will be polynomial.

To do better than this, I suspect the algorithm will need to depend upon how the sequence of convex sets $C$ is represented. (Do you have a requirement for it to be represented in a particular way, or are you OK with any reasonable representation? You might want to edit the question accordingly. You might also want to specify whether this is a finite sequence or an infinite sequence, and how the sets are related.)

---

For instance, here's a special case where the problem is easier. Suppose that the sequence of sets is represented as follows: you have a set of linear inequalities on $x\_1,x\_2,\dots,x\_d,\lambda$, with constants $c\_0,c\_1,\dots,c\_d$, so that each linear inequality has this form:

$$c\_0 \lambda + c\_1 x\_1 + c\_2 x\_2 + \dots + c\_d x\_d \le 0.$$

Now suppose that the convex set $C\_\lambda$ is defined as the set of points $(x\_1,\dots,x\_d)$ that satisfy all of these linear inequalities (notice the very specific kind of dependence on $\lambda$), and suppose that the linear inequalities are chosen so $C\_{\lambda\_1} \subset C\_{\lambda\_2}$ whenever $\lambda\_1 > \lambda\_2$. Then you compute $f(x)$ efficiently using a very simple algorithm: you plug in $x$ into each of the linear inequalities, leaving $\lambda$ as the only unknown in each case, and find the largest value of $\lambda$ so that all of those inequalities are satisfied. This only works if your sets have a certain form and are represented in a certain special way, which is why I say that your problem will probably depend upon how the sets are represented and what structure they might have.

> **Comments:**
> **username_1**: You could use doubling search too, if the sizes of the convex sets increase with $\lambda$: test the convex sets $1$,$2$,$4$,$8$,... till you find one that contains $x$, then binary search in the last interval you found.  
> **username_2**: @Jeremy, yup!  That was implicitly what I had in mind for the case where we have an infinite family of convex sets.  (That's where the dependence on $|f(x)|$ comes from, in my answer.)  
> **username_0**: D.W. and Jeremy : Yes, the binary search is the first thing that came to my mind too. Was wondering if one can do any better. As for the representation of the set - I have some flexibility: if any particular representation would lead to a significantly better algorithm I would prefer that; in fact that is an interesting question in itself I guess. And it is an infinite sequence.  
> **username_2**: @Krishna, I encourage you to edit the question to clarify all of those points; that will increase the exposure your question gets.  On this site, the expectation is that people should be able to understand your question and all of your requirements just by reading the main body of the question, without reading the comment thread.  You can do that by clicking the "edit" link underneath your question. (Given that it's an infinite sequence, it also might not hurt to describe how you are *currently* representing the sets, as I'm still not clear on the structure of your infinite sequence of sets.)  

---

