Ejemplo n.º 1
0
    @Override
    public void run() {
      // gather data from provider
      final DataProvider dataProvider = getDataProvider();
      checkNotNull(
          dataProvider,
          "Probable problem: your MASConfiguration/ObjectiveFunction/"
              + "PostProcessor is not fully serializable.");

      final Supplier<Scenario> scenario = getDataProvider().getParameter(scenarioId);
      final MASConfiguration configuration = getDataProvider().getParameter(configurationId);
      final ObjectiveFunction objectiveFunction =
          getDataProvider().getParameter(objectiveFunctionId);
      final PostProcessor<?> postProcessor = getDataProvider().getParameter(postProcessorId);

      final Scenario s = scenario.get();
      final SimArgs simArgs =
          SimArgs.create(s, configuration, seed, objectiveFunction, false, postProcessor, null);
      final Object simResult = Experiment.perform(simArgs);

      checkArgument(
          simResult instanceof Serializable,
          "Your PostProcessor must generate Serializable objects, found %s.",
          simResult);

      setResult(simResult);
    }
Ejemplo n.º 2
0
  static SimulationResult processResult(
      SimulationTask simTask,
      final Map<String, Scenario> scenariosMap,
      final Map<Task<?>, JPPFJob> jobMap) {
    checkNotNull(simTask);
    if (simTask.getThrowable() != null) {
      throw new IllegalArgumentException(simTask.getThrowable());
    }
    final Object result = simTask.getResult();
    final Scenario scen = scenariosMap.get(simTask.getScenarioId());

    final DataProvider dp = jobMap.get(simTask).getDataProvider();
    final MASConfiguration conf = dp.getParameter(simTask.getConfigurationId());
    final ObjectiveFunction obj = dp.getParameter(simTask.getObjectiveFunctionId());
    final PostProcessor<?> pp = dp.getParameter(simTask.getPostProcessorId());

    final SimArgs args = SimArgs.create(scen, conf, simTask.getSeed(), obj, false, pp, null);
    return SimulationResult.create(args, result);
  }
Ejemplo n.º 3
0
  static void constructTasks(
      Set<SimArgs> inputs,
      List<SimulationTask> tasks,
      IdMap<MASConfiguration> configMap,
      IdMap<ScenarioProvider> scenarioMap,
      IdMap<ObjectiveFunction> objFuncMap,
      IdMap<PostProcessor<?>> ppMap,
      Map<String, Scenario> scenariosMap) {

    for (final SimArgs args : inputs) {
      final String configId = configMap.storeAndGenerateId(args.getMasConfig());
      final String scenId =
          scenarioMap.storeAndGenerateId(
              new ScenarioProvider(
                  ScenarioIO.write(args.getScenario()), args.getScenario().getClass()));
      scenariosMap.put(scenId, args.getScenario());
      final String objFuncId = objFuncMap.storeAndGenerateId(args.getObjectiveFunction());

      final String postProcId = ppMap.storeAndGenerateId(args.getPostProcessor());
      tasks.add(new SimulationTask(args.getRandomSeed(), scenId, configId, objFuncId, postProcId));
    }
  }