logging variables in a while-loop
Hi guys,
I need help again
In a while loop, I use a variable which gets overwritten after every increment of the loop.
The variable needs to be logged in the logfile in every loop. For example:
i=0
while i<3:
var.response_time= i
i=i+1
In this example the var.response_time has three diefferent phases (0,1,2). I want to log all these phases.
The problem is:
With log.write_vars() a lot off unnecessary things get written in the logfile.
i=0
while i<3:
var.response_time= i
log.write_vars()
i=i+1
With log.write(var.response_time) the entrys of every loop is under the other. For this example, this isn't a problem, but in my experiment with parallel loops it is not good when every entry of the diefferent variables in the loop comes after the other.
What I want:
var1 var2 var3
x1 y1 z1
x2 y2 z2
. . .
. . .
What I get with log.write()
x1
y1
x2
z1
y2
x3
.
.
.
I hope you guys can help me
Comments
Hi Flippy,
In your case, you want to change the name of the variable on every iteration of the loop. In other words, the name of the variable is itself variable. You can do this using the
var.set()
function, which takes the name of the variable as the first argument, and the value as the second:This will result in a column-based log file like:
For more information, see:
Does that answer your question?
Cheers,
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!