static Object perform(SimArgs args) { final Simulator sim = Experiment.init(args.getScenario(), args.getMasConfig(), args.getRandomSeed(), args.isShowGui(), args.getUiCreator()); try { sim.start(); final Object resultObject = args.getPostProcessor().collectResults(sim, args); checkNotNull(resultObject, "PostProcessor may not return null."); return resultObject; } catch (final Exception e) { final FailureStrategy strategy = args.getPostProcessor().handleFailure(e, sim, args); checkNotNull(strategy, "An exception (%s) occured in the simulation but the PostProcessor %s " + "failed to handle the failure.", e.toString(), args.getPostProcessor()); if (strategy == FailureStrategy.INCLUDE) { return args.getPostProcessor().collectResults(sim, args); } else if (strategy == FailureStrategy.ABORT_EXPERIMENT_RUN) { throw new AbortExperimentException("Failed: " + args, e); } return strategy; } }
static Object perform(SimArgs args) { final Simulator sim = Experiment.init(args.getScenario(), args.getMasConfig(), args.getRandomSeed(), args.isShowGui(), args.getUiCreator()); try { sim.start(); final Object resultObject = args.getPostProcessor().collectResults(sim, args); checkNotNull(resultObject, "PostProcessor may not return null."); return resultObject; } catch (final Exception e) { final FailureStrategy strategy = args.getPostProcessor().handleFailure(e, sim, args); checkNotNull(strategy, "An exception (%s) occured in the simulation but the PostProcessor %s " + "failed to handle the failure.", e.toString(), args.getPostProcessor()); if (strategy == FailureStrategy.INCLUDE) { return args.getPostProcessor().collectResults(sim, args); } else if (strategy == FailureStrategy.ABORT_EXPERIMENT_RUN) { throw new AbortExperimentException("Failed: " + args, e); } return strategy; } }