@Test public void when_runningWith2Threads_expect_2AgentLearnerCreated() { Predicate<AsyncTrainer<Integer>> stoppingCondition = t -> true; AsyncTrainer sut = new AsyncTrainer(agentLearnerBuilderMock, stoppingCondition, 2); sut.train(); verify(agentLearnerBuilderMock, times(2)).build(); }
public void train() { reset(); Thread[] threads = new Thread[numThreads]; for(int i = 0; i < numThreads; ++i) { AgentLearnerThread thread = new AgentLearnerThread(agentLearnerBuilder.build(), i); threads[i] = thread; thread.start(); } for (Thread thread : threads) { try { thread.join(); } catch (InterruptedException e) { } } }
AsyncTrainer implements ITrainer { public void train() { reset(); Thread[] threads = new Thread[numThreads]; for(int i = 0; i < numThreads; ++i) { AgentLearnerThread thread = new AgentLearnerThread(agentLearnerBuilder.build(), i); threads[i] = thread; thread.start(); } for (Thread thread : threads) { try { thread.join(); } catch (InterruptedException e) { } } } }
AsyncTrainer implements ITrainer { public void train() { reset(); Thread[] threads = new Thread[numThreads]; for(int i = 0; i < numThreads; ++i) { AgentLearnerThread thread = new AgentLearnerThread(agentLearnerBuilder.build(), i); threads[i] = thread; thread.start(); } for (Thread thread : threads) { try { thread.join(); } catch (InterruptedException e) { } } } @lombok.Builder  AsyncTrainer(@NonNull Builder<IAgentLearner<ACTION>> agentLearnerBuilder,
                        @NonNull Predicate<AsyncTrainer<ACTION>> stoppingCondition,
                        int numThreads); }
AsyncTrainer implements ITrainer { public void train() { reset(); Thread[] threads = new Thread[numThreads]; for(int i = 0; i < numThreads; ++i) { AgentLearnerThread thread = new AgentLearnerThread(agentLearnerBuilder.build(), i); threads[i] = thread; thread.start(); } for (Thread thread : threads) { try { thread.join(); } catch (InterruptedException e) { } } } @lombok.Builder  AsyncTrainer(@NonNull Builder<IAgentLearner<ACTION>> agentLearnerBuilder,
                        @NonNull Predicate<AsyncTrainer<ACTION>> stoppingCondition,
                        int numThreads); void train(); int getEpisodeCount(); int getStepCount(); }
AsyncTrainer implements ITrainer { public void train() { reset(); Thread[] threads = new Thread[numThreads]; for(int i = 0; i < numThreads; ++i) { AgentLearnerThread thread = new AgentLearnerThread(agentLearnerBuilder.build(), i); threads[i] = thread; thread.start(); } for (Thread thread : threads) { try { thread.join(); } catch (InterruptedException e) { } } } @lombok.Builder  AsyncTrainer(@NonNull Builder<IAgentLearner<ACTION>> agentLearnerBuilder,
                        @NonNull Predicate<AsyncTrainer<ACTION>> stoppingCondition,
                        int numThreads); void train(); int getEpisodeCount(); int getStepCount();  }