Re: Optimization: Picking random keys from a dictionary and mutating values

2008-05-29 Thread Carl Banks
On May 28, 7:41 pm, blaine <[EMAIL PROTECTED]> wrote: > Hey everyone, > Just a friendly question about an efficient way to do this. Friendly advance reminder: in many optimization problems, the objective function is far more expensive to calculate than the optimizing procedure. Your time is usu

Re: Optimization: Picking random keys from a dictionary and mutating values

2008-05-28 Thread Raymond Hettinger
On May 28, 4:41 pm, blaine <[EMAIL PROTECTED]> wrote: > 1.  Whats a good way to get the keys? I'm using a loop with > random.choice() at the moment. Why not keep a separate list of keys and use random.sample()? Raymond -- http://mail.python.org/mailman/listinfo/python-list

Optimization: Picking random keys from a dictionary and mutating values

2008-05-28 Thread blaine
Hey everyone, Just a friendly question about an efficient way to do this. I have a graph with nodes and edges (networkx is am amazing library, check it out!). I also have a lookup table with weights of each edge. So: weights[(edge1, edge2)] = .12 weights[(edge2, edge5)] = .53 weights[(edge5,