Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Need help parallelizing while loop
#1
Hi everyone,

I need some help parallelizing the following:

 
population = []

generations = 100000
generation = 1

while generation < (generations + 1):
        params = {
            'num_char': 100,
            'variables': 'X',
            'constants': 'F+-',
            'axiom': 'FX',
            'rules': {
                'X': {
                    'options': ['+FX', '-FX'],
                    'probabilities': [0.5, 0.5]
                }
            },
            'point': np.array([0, 0]),
            'vector': np.array([0, 1]),
            'length': 1.0,
            'angle': 25  # random
        }

        generation += 1

        population.append(Creature(params).coords) 
I believe joblib's Parallel may be useful but I am unsure of how to feed the params dictionary as well as combining the outputs into a single list

Thank you
Quote

Top Page

Forum Jump:


Users browsing this thread: 1 Guest(s)