workspace.iterate(n) not working

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

workspace.iterate(n) not working

Reza
Hi,
I am trying to run a simulation for a specified number of iterations. I set up my workspace using the GUI and when I open the console and type workspace.iterate(100);
I receive this error:

 workspace.iterate(100);
// Error: EvalError: Error in method invocation: Method iterate( int ) not found in class'org.simbrain.workspace.Workspace' : at Line: 1 : in file: <unknown file> : workspace .iterate ( 100 )

I tried other default simulations of simbrain and I get the same error. Any suggestions?
Reply | Threaded
Open this post in threaded view
|

Re: workspace.iterate(n) not working

jyoshimi
Administrator
Hi good catch thanks.  I should remove that from tips().

There are two workarounds.

One is to just write something inline like

for (int i = 0; i < 100; i++) workspace.iterate();

Another is to use a latch, which is needed if you want the GUI to update properly every iteration

import java.util.concurrent.*;
for (int i = 0; i < 100; i++){
        CountDownLatch latch = new CountDownLatch(1);
        workspace.iterate(latch, 1);
        try {
                latch.await();
        } catch (InterruptedException e) {
                e.printStackTrace();
        }
}
Reply | Threaded
Open this post in threaded view
|

Re: workspace.iterate(n) not working

Reza
Hi,
I tried both solutions and they worked!
Thanks!!