Examples of ISimulationRun


Examples of org.jamesii.core.simulationrun.ISimulationRun

  @Override
  public IProcessor create(IModel model, IComputationTask computationTask,
      Partition partition, ParameterBlock parameters, Context context) {

    ISimulationRun simulation = (ISimulationRun) computationTask;

    ParameterBlock ef = null;

    // new ParameterBlock(
    // simulation.getParameters()
    // .getEventforwarding());

    ExternalEventForwardingHandlerFactory f =
        SimSystem.getRegistry().getFactory(
            AbstractExternalEventForwardingHandlerFactory.class, ef);
    ExternalEventForwardingHandler eefh = f.create(null, SimSystem.getRegistry().createContext());

    SimSystem.report(Level.CONFIG, "Using " + eefh.getClass().getName()
        + " as external event forwarding mechanism.");

    ParameterBlock eqfp = parameters.getSubBlock("eventqueue");

    // (IEventQueue<IBasicDEVSModel>)
    FlatSequentialProcessor p =
        new FlatSequentialProcessor(model, SimSystem.getRegistry().getFactory(
            AbstractEventQueueFactory.class, eqfp), eefh);

    // ExternalEventForwardingHandlerFactory.getHandler(simulation
    // .getParameters(), ef));

    // IAbstractSequentialProcessor aproc;

    p.init(simulation.getStartTime());

    simulation.setProcessorInfo(new ProcessorInformation(p));

    return p;
  }
View Full Code Here

Examples of org.jamesii.core.simulationrun.ISimulationRun

  @SuppressWarnings("unchecked")
  @Override
  public IProcessor create(IModel model, IComputationTask computationTask,
      Partition partition, ParameterBlock parameters, Context context) {

    ISimulationRun simulation = (ISimulationRun) computationTask;

    RootCoordinator p = new RootCoordinator(model);

    IAbstractSequentialProcessor aproc;

    // AbstractEventQueueFactory.getEventQueueFactory((IBasicDEVSModel)model,
    // simulation.getParameters()

    ParameterBlock aeqp = parameters.getSubBlock("eventqueue");

    if (model instanceof ICoupledModel) {
      aproc =
          new Coordinator((ICoupledModel) model, SimSystem.getRegistry()
              .getFactory(AbstractEventQueueFactory.class, aeqp));
    } else {
      if (model instanceof IAtomicModel) {
        aproc = new Simulator((IAtomicModel<? extends AbstractState>) model);
      } else {
        throw new InvalidModelException(
            "Cannot create an abstract sequential simulator for non-valid DEVS models!");
      }
    }
    aproc.init(simulation.getStartTime());

    p.init(aproc, simulation.getStartTime());

    simulation.setProcessorInfo(new ProcessorInformation(p));

    return p;
  }
View Full Code Here

Examples of org.jamesii.core.simulationrun.ISimulationRun

  @Override
  public IComputationTaskStopPolicy<IComputationTask> create(
      ParameterBlock paramBlock, Context context) {
    ComputationTaskStopPolicyFactory<IComputationTask> policyFactory =
        ParameterBlocks.getSubBlockValue(paramBlock, POLICY);
    ISimulationRun run = ParameterBlocks.getSubBlockValue(paramBlock, COMPTASK);
    ParameterBlock innerParams =
        paramBlock.getSubBlock(POLICY_PARAMS).getCopy();
    innerParams.addSubBl(COMPTASK, run);
    IComputationTaskStopPolicy<IComputationTask> policy =
        policyFactory.create(innerParams, SimSystem.getRegistry().createContext());
View Full Code Here

Examples of org.jamesii.core.simulationrun.ISimulationRun

    // parallel performance as this method might be executed in parallel

    ExecutionMeasurements execMeasures = new ExecutionMeasurements(info);

    // Instantiate model and simulation
    ISimulationRun simulation = null;

    try {
      IModel model =
          createModel((SimulationRunConfiguration) computationTaskConfig,
              modelReader, execMeasures);
View Full Code Here

Examples of org.jamesii.core.simulationrun.ISimulationRun

   */
  protected static ISimulationRun createSimulation(
      SimulationRunConfiguration simRunConfig,
      List<ISimulationServer> resources, ExecutionMeasurements execMeasures,
      IModel model) {
    ISimulationRun simulation;
    execMeasures.startComputationTaskCreation();
    simulation = new SimulationRun("SimRun", model, simRunConfig, resources);
    execMeasures.stopComputationTaskCreation();
    return simulation;
  }
View Full Code Here

Examples of org.jamesii.core.simulationrun.ISimulationRun

   *
   * @param processor
   *          the processor to be executed
   */
  protected void runProcessor(P processor) {
    ISimulationRun simRun = setSimulationRun(processor);
    ((IRunnable) processor).run(new SimTimeStop(Double.POSITIVE_INFINITY));
  }
View Full Code Here

Examples of org.jamesii.core.simulationrun.ISimulationRun

   *          the processor to which the dummy simulation run shall be attached
   * @return the simulation run associated with the processor
   */
  protected ISimulationRun setSimulationRun(P processor) {
    final P proc = processor;
    ISimulationRun simRun = new DummySimRun() {
      @Override
      public Double getTime() {
        return proc.getTime();
      }
    };
View Full Code Here

Examples of org.jamesii.core.simulationrun.ISimulationRun

          + Runtime.getRuntime().totalMemory() + " : "
          + Runtime.getRuntime().freeMemory());

      println("Simulation started at "
          + new SimpleDateFormat().format(new Date()));
      ISimulationRun simulation = null;
      sw.reset();
      sw.start();
      if (parameters.useMasterServer()) {
        // TODO master server deactivated, January, 2009 - model should be
        // created on the exec. host, not here!
        // System.out.println("The simulation will be executed on the server: "
        // + parameters.getMasterServerName());
        // simulation = parameters.getMasterServer().createSimulation(
        // model,
        // new SimulationConfiguration(1, null, null, parameters
        // .getParameterBlock())).getSimulation();

      } else { // if we don't use a server we create a simulation on our own
        TaskConfiguration config =
            new TaskConfiguration(1, null, null, parameters.getParameterBlock());
        SimulationRunConfiguration srConfig =
            (SimulationRunConfiguration) config
                .newComputationTaskConfiguration(new ComputationTaskIDObject());
        simulation = new SimulationRun("SimRun", model, srConfig, null);
      }
      if (simulation == null) {
        SimSystem.report(Level.SEVERE, "Simulation creation failed!!!");
      }
      sw.stop();
      result.simulationCreation = sw.elapsedSeconds();
      println("Seconds needed for creating the simulation: "
          + sw.elapsedSeconds());
      println("Memory (model + simulation - [total:free]): "
          + Runtime.getRuntime().totalMemory() + " : "
          + Runtime.getRuntime().freeMemory());
      sw.reset();
      sw.start();
      if (parameters.useMasterServer()) {
        int tries = 0;
        boolean retry = true;
        while (retry) {
          retry = false;
          try {
            parameters.getMasterServer().execute(
                simulation.getUniqueIdentifier(), null);
          } catch (Exception e) {
            SimSystem.report(Level.SEVERE,
                "Error occured while trying to launch the model on the server");
            tries++;
            if (tries == 3) {
              SimSystem.report(Level.SEVERE,
                  " - stop retrying ... something seems to be wrong with the server "
                      + parameters.getMasterServerName());
              throw e; // rethrow exception
            }

            retry = true;
            SimSystem.report(Level.INFO,
                " - now retrying ... waiting some seconds ...");
            // parameters.findServer(name); refind the server????
            Thread.sleep(2000); // wait two seconds
            SimSystem.report(Level.INFO,
                "   resetting stopwatch ... restarting simulation ...");
            sw.reset();
            sw.start();
          }
        }
      } else { // if we don't use a server we create a simlation on our own
        simulation.start();
      }
      sw.stop();
      result.simulationRun = sw.elapsedSeconds();
      println("Seconds needed for running the simulation: "
          + sw.elapsedSeconds());
View Full Code Here

Examples of org.jamesii.core.simulationrun.ISimulationRun

  /** The parameter to set the wall-clock time (in milliseconds). */
  public static final String SIMEND = "SIMEND";

  @Override
  public IComputationTaskStopPolicy<ISimulationRun> create(ParameterBlock paramBlock, Context context) {
    ISimulationRun run = ParameterBlocks.getSubBlockValue(paramBlock, COMPTASK);
    Number endTimeDelta = ParameterBlocks.getSubBlockValue(paramBlock, SIMEND);
    if (endTimeDelta == null) {
      endTimeDelta = 1l;
    }
    return new WallClockTimeStop(endTimeDelta.longValue());
View Full Code Here

Examples of org.jamesii.core.simulationrun.ISimulationRun

  private static final long serialVersionUID = -7364245846289653229L;

  @Override
  public IComputationTaskStopPolicy<IComputationTask> create(
      ParameterBlock paramBlock, Context context) {
    ISimulationRun run = ParameterBlocks.getSubBlockValue(paramBlock, COMPTASK);
    List<IComputationTaskStopPolicy<IComputationTask>> policies =
        createSubPolicies(paramBlock);

    return new ConjunctiveSimRunStopPolicy<>(run, policies);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.