TITLE: Random Sampling a linearly constrained region in n-dimensions...
QUESTION [8 upvotes]: Hi,
So here is my problem:
Given a nonlinear, discontinous, cost function $f(x_1,x_2,..,x_N)$ along with linear constraints $x_n \ge 0, \forall n$
$x_n \le c_n$
 and $\sum_{n=1}^N x_n = 1$ find an optimal (local) solution by randomly sampling the feasible region.  $c_n$ are just constants.
The issue I am having is indexing the space, since it is not a simple n-dimensional cube but rather a polytope(i believe its convex).  Discretizing and enumerating all possible combinations of points to sample is much too hard since N =20.  Approximating the polytope with a n-dimensional cube and sampling from the cube, only about 1% of the samples fall within the feasible region...which is inefficient if I'm trying to generate many samples.
I've tried finding the volume of the space analytically, however the complexity of computing the integral gets overwhelming for many dimensions. 
I was wondering if anyone has come across this type of problem and has any recommendation as to different methods I could try to sample this space.  Essentially, I need a good way to estimate the volume...am I looking at this the correct way?
any help would be greatly appreciated...

REPLY [2 votes]: If the $c_n$ are sufficiently small (say, all smaller than $1/\sqrt{n}$) or sufficiently large (say, all at least $1$) the polytope is a simplex, so estimating the volume and sampling are both easy as pointed out in @Mike's answer. On the other hand, trying to find a local optimum by uniform sampling is doomed in $20$-dimensional space, since the distance between the samples will be very large for any reasonable number of samples. (for example, if your polytope were a cube of side one, generating $2^{40}$ points will have inter point distances around $1/4.$ Needless to say, generating $2^{40}$ points might take a while.