@@ -91,8 +91,8 @@ public class Trajectory extends Runnable {
9191 "A post-simulation condition." ,
9292 new ArrayList <>());
9393
94- public Input <Integer > maxPostSimConditionRejectsInput =
95- new Input <>("maxPostSimConditionRejects " ,
94+ public Input <Integer > maxConditionRejectsInput =
95+ new Input <>("maxConditionRejects " ,
9696 "Maximum number of post simulation condition failures" +
9797 "before aborting. (Default is no limit.)" );
9898
@@ -167,8 +167,8 @@ public void initAndValidate() {
167167 for (PostSimCondition condition : postSimConditionsInput .get ())
168168 spec .addPostSimCondition (condition );
169169
170- if (maxPostSimConditionRejectsInput .get () != null )
171- spec .setMaxPostSimConditionRejects ( maxPostSimConditionRejectsInput .get ());
170+ if (maxConditionRejectsInput .get () != null )
171+ spec .setMaxConditionRejects ( maxConditionRejectsInput .get ());
172172
173173 // Set seed if provided, otherwise use default BEAST seed:
174174 if (seedInput .get ()!=null )
@@ -188,7 +188,7 @@ public void run() {
188188 try {
189189 simulate ();
190190 } catch (RejectCountExceeded ex ) {
191- System .err .println ("Maximum number of post-simulation condition " +
191+ System .err .println ("Maximum number of condition " +
192192 "rejections exceeded. Aborting." );
193193 System .exit (1 );
194194 }
@@ -233,7 +233,7 @@ private void simulate() throws RejectCountExceeded {
233233
234234 // Loop until any post-simulation rejection conditions fail.
235235 boolean postSimulationReject ;
236- int postSimRejectCount = 0 ;
236+ int rejectCount = 0 ;
237237 do {
238238 sampledStates .clear ();
239239 sampledTimes .clear ();
@@ -282,7 +282,15 @@ private void simulate() throws RejectCountExceeded {
282282 if (endConditionMet .isRejection ()) {
283283 if (spec .verbosity >0 )
284284 System .err .println ("Rejection end condition met "
285- + "at time " + t );
285+ + "at time " + t );
286+
287+ rejectCount += 1 ;
288+
289+ if (spec .getMaxConditionRejects ()>=0 &&
290+ rejectCount > spec .getMaxConditionRejects ()) {
291+ throw new RejectCountExceeded ();
292+ }
293+
286294 currentState = new PopulationState (spec .initPopulationState );
287295 clearSamples ();
288296 sampleState (currentState , 0.0 );
@@ -365,10 +373,10 @@ private void simulate() throws RejectCountExceeded {
365373 if (spec .getVerbosity ()>0 )
366374 System .err .println ("Post-simulation rejection condition met." );
367375
368- postSimRejectCount += 1 ;
376+ rejectCount += 1 ;
369377
370- if (spec .getMaxPostSimConditionRejects ()>=0 &&
371- postSimRejectCount > spec .getMaxPostSimConditionRejects ()) {
378+ if (spec .getMaxConditionRejects ()>=0 &&
379+ rejectCount > spec .getMaxConditionRejects ()) {
372380 throw new RejectCountExceeded ();
373381 }
374382 }
0 commit comments