Hi piac

Somehow I managed to do it with VolatileData but actually I am working on different small task to learn how to code an optimization algorithm.

As I have understood, in optimization tasks when we change any variable we should run the solution from start so we could get the final answer and load it as cost function. As I read in one of posts, @DavidRutten said that in Galapagos the optimization code runs in another window. I don’t really know how to do this.

To clarify the question I want to have 100 iterations in my optimization code and for each iteration I want to generate 50 different sets of random variables. Each set has for example 3 variables. Each of these random set of variables should be sent to number sliders and the final answer should be received back in the code. I don’t know how to do this so that I don’t have solution problems in my code…

Here I have wrote a simple code so we could speak on this case.

```
import random
def CostFunction(a):
return sum(a)
variables = []
variables_results = []
for i in range(100):
pop = []
pop_results = []
for j in range(50):
set = []
for k in range(3):
set.append(random.randint(0,100))
c_function = CostFunction(set)
pop.append(set)
pop_results.append(c_function)
variables.append(pop)
variables_results.append(pop_results)
```

In the python code I have wrote the CostFunction and it has no problem. But if I want to write the Cost function as a series of grasshopper components (as shown in the image) I face the solution problem. I want to see if there is any ways that I could evaluate different sets of variables and receive the result in my for loop.

simple code.gh (7.7 KB)