Simulation Approach Required


#1

Hey There! I'm a senior high school student and I'm trying to write a program which runs a computational simulation for the no. of ways of performing a particular task and then compares them all to find the most efficient solution.
The idea is similar to that of a Generative AI, although I don't have any idea on how to write a code for an AI so I'm trying to work with the vanilla python environment.

As you can see in the pic below, on running the simulation, the raw data from each steps would look something like that. I've used black scribble lines instead of variables because the data generated in STEP - N depends on the input from the STEP - N-1.
So, the possible actions per step differ on the basis of the previous actions.
Also, the number of steps per processed set is also unknow.

What I'm trying to achieve?
I'm trying to make a ProcessedData Dictionary containing all the possible arrangements of actions that can be performed using the initial conditions provided by the user.
i.e.-

Procedure_1 = { "Step 1" : [#1st Scribbled Line/raw data], "Step 2" : [#1st Scribbled Line/raw data], "Step 3" : [#1st Scribbled Line/raw data] }

Procedure_2 = { "Step 1" : [#1st Scribbled Line/raw data], "Step 2" : [#1st Scribbled Line/raw data], "Step 3" : [#2nd Scribbled Line/raw data] }

Procedure_3 = { "Step 1" : [#1st Scribbled Line/raw data], "Step 2" : [#1st Scribbled Line/raw data], "Step 3" : [#3rd Scribbled Line/raw data] }

Procedure_4 = { "Step 1" : [#1st Scribbled Line/raw data], "Step 2" : [#1st Scribbled Line/raw data], "Step 3" : [#4th Scribbled Line/raw data] }

Procedure_5 = { "Step 1" : [#1st Scribbled Line/raw data], "Step 2" : [#1st Scribbled Line/raw data], "Step 3" : [#5th Scribbled Line/raw data] }

Procedure_6 = { "Step 1" : [#1st Scribbled Line/raw data], "Step 2" : [#1st Scribbled Line/raw data], "Step 3" : [#6th Scribbled Line/raw data] }

Procedure_7 = { "Step 1" : [#1st Scribbled Line/raw data], "Step 2" : [#1st Scribbled Line/raw data], "Step 3" : [#7th Scribbled Line/raw data] }

Procedure_8 = { "Step 1" : [#1st Scribbled Line/raw data], "Step 2" : [#1st Scribbled Line/raw data], "Step 3" : [#8th Scribbled Line/raw data] }

Procedure_9 = { "Step 1" : [#1st Scribbled Line/raw data], "Step 2" : [#1st Scribbled Line/raw data], "Step 3" : [#9th Scribbled Line/raw data] }

Procedure_10 = { "Step 1" : [#1st Scribbled Line/raw data], "Step 2" : [#2nd Scribbled Line/raw data], "Step 3" : [#1st Scribbled Line/raw data] }

Procedure_11 = { "Step 1" : [#1st Scribbled Line/raw data], "Step 2" : [#2nd Scribbled Line/raw data], "Step 3" : [#2nd Scribbled Line/raw data] }

Procedure_12 = { "Step 1" : [#1st Scribbled Line/raw data], "Step 2" : [#2nd Scribbled Line/raw data], "Step 3" : [#3rd Scribbled Line/raw data] }

Procedure_13 = { "Step 1" : [#1st Scribbled Line/raw data], "Step 2" : [#2nd Scribbled Line/raw data], "Step 3" : [#4th Scribbled Line/raw data] }

Procedure_14 = { "Step 1" : [#1st Scribbled Line/raw data], "Step 2" : [#2nd Scribbled Line/raw data], "Step 3" : [#5th Scribbled Line/raw data] }

Procedure_15 = { "Step 1" : [#1st Scribbled Line/raw data], "Step 2" : [#2nd Scribbled Line/raw data], "Step 3" : [#6th Scribbled Line/raw data] }

Procedure_16 = { "Step 1" : [#1st Scribbled Line/raw data], "Step 2" : [#2nd Scribbled Line/raw data], "Step 3" : [#7th Scribbled Line/raw data] }

And So on

So it's pretty straightforward that in an ideal condition where we know the no. of Steps (n) that will be required and we already have a table of the raw data (like in the pic above), which is independent of the previous step's actions. A nested loop structure till n loops would be the best solution!

But neither do we know the number of steps nor do we have the raw data as independent data.
So, I'm just really confused at this point on whether if I even need a nested loop system or not because right now I'm trying to make a nested loop system that writes itself until the simulation ends from a particular set of actions or for a Procedure_n = {} dictionary.
Please Help :smiley:


#2

You seem to count upwards starting from 111 with a number system that only has numbers 1 2 3 4 5 6 7 8 9
You only need two loops for that, one to increment, and one for the carry, same as "normal" counting
That behavior is already implemented by itertools.product though
https://docs.python.org/library/itertools.html#itertools.product