Tabnine Logo
Engine
Code IndexAdd Tabnine to your IDE (free)

How to use
Engine
in
it.unibo.alchemist.core.implementations

Best Java code snippets using it.unibo.alchemist.core.implementations.Engine (Showing top 17 results out of 315)

origin: it.unibo.alchemist/alchemist-engine

@Override
public void nodeAdded(final Node<T> node) {
  checkCaller();
  if (status != Status.INIT) {
    for (final Reaction<T> r : node.getReactions()) {
      scheduleReaction(r);
    }
    updateDependenciesForOperationOnNode(env.getNeighborhood(node));
  }
}
origin: it.unibo.alchemist/alchemist-engine

private void newStatus(final Status s) {
  if (this.compareStatuses(s) > 0) {
    L.error("Attempt to enter in an illegal status: " + s);
  } else {
    schedule(() -> {
      statusLock.lock(); 
      try {
        this.status = s;
        statusCondition.signalAll();
      } finally {
        statusLock.unlock();
      }
    });
  }
}
origin: it.unibo.alchemist/alchemist-engine

private void runUntil(final BooleanSupplier condition) {
  play();
  schedule(() -> {
    try { 
      while (status == Status.RUNNING && condition.getAsBoolean()) {
        doStep();
      }
    } catch (ExecutionException | InterruptedException e) {
      terminate();
      error = Optional.of(e);
    }
  });
  pause();
}
origin: it.unibo.alchemist/alchemist-engine

@Override
public synchronized void goToStep(final long step) {
  runUntil(() -> getStep() < step);
}
origin: it.unibo.alchemist/alchemist-engine

@Override
public void neighborAdded(final Node<T> node, final Node<T> n) {
  checkCaller();
  dg.addNeighbor(node, n);
  updateNeighborhood(node);
  /*
   * This is necessary, see bug #43
   */
  updateNeighborhood(n);
}
origin: it.unibo.alchemist/alchemist-engine

@Override
public void run() {
  synchronized (env) {
    finalizeConstructor();
    status = Status.READY;
    final long currentThread = Thread.currentThread().getId();
    try {
      while (status.equals(Status.READY)) {
        idleProcessSingleCommand();
          doStep();
          idleProcessSingleCommand();
origin: it.unibo.alchemist/alchemist-enginedependentmodel

private Queue<Operation> recursiveOperation(final Node<T> origin, final Node<T> destination, final boolean isAdd) {
  if (isAdd) {
    Engine.neighborAdded(this, origin, destination);
  } else {
    Engine.neighborRemoved(this, origin, destination);
  }
  final Neighborhood<T> newNeighborhood = rule.computeNeighborhood(Objects.requireNonNull(destination), this);
  final Neighborhood<T> oldNeighborhood = neighCache.put(destination.getId(), newNeighborhood);
  return toQueue(destination, oldNeighborhood, newNeighborhood);
}
origin: it.unibo.alchemist/alchemist-runner

.map(vars -> () -> {
  final Environment<T> env = loader.getWith(vars);
  final Simulation<T> sim = new Engine<>(env, endStep, endTime);
  outputMonitors.stream().map(Supplier::get).forEach(sim::addOutputMonitor);
  if (exportFileRoot.isPresent()) {
origin: it.unibo.alchemist/alchemist-engine

@Override
public String toString() {
  return getClass().getSimpleName() + " t: " + getTime() + ", s: " + getStep();
}
origin: it.unibo.alchemist/alchemist-engine

@Override
public void nodeRemoved(final Node<T> node, final Neighborhood<T> oldNeighborhood) {
  checkCaller();
  for (final Reaction<T> r : node.getReactions()) {
    removeReaction(r);
  }
}
origin: it.unibo.alchemist/alchemist-engine

@Override
public synchronized void goToTime(final Time t) {
  runUntil(() -> getTime().compareTo(t) < 0);
}
origin: it.unibo.alchemist/alchemist-engine

@Override
public void nodeMoved(final Node<T> node) {
  checkCaller();
  for (final Reaction<T> r : node.getReactions()) {
    updateReaction(handlers.get(r));
  }
}
origin: it.unibo.alchemist/alchemist-engine

@Override
public Status waitFor(final Status s, final long timeout, final TimeUnit tu) {
  if (this.compareStatuses(s) > 0) {
    L.error("Attempt to wait for an illegal status: " + s + " (current state is: " + getStatus() + ")");
  } else {
    statusLock.lock();
    try {
      if (!getStatus().equals(s)) {
        boolean exit = false;
        while (!exit) {
            if (timeout > 0) {
              final boolean isOnTime = statusCondition.await(timeout, tu);
              if (!isOnTime || getStatus().equals(s)) {
                exit = true;
              if (getStatus().equals(s)) {
                exit = true;
  return getStatus();
origin: it.unibo.alchemist/alchemist-engine

@Override
public synchronized void schedule(final CheckedRunnable r) {
  if (getStatus().equals(Status.TERMINATED)) {
    throw new IllegalStateException("This simulation is terminated and can not get resumed.");
  }
  commands.add(r);
}
origin: it.unibo.alchemist/alchemist-engine

@Override
public void neighborRemoved(final Node<T> node, final Node<T> n) {
  checkCaller();
  dg.removeNeighbor(node, n);
  updateNeighborhood(node);
  updateNeighborhood(n);
}
origin: it.unibo.alchemist/alchemist-enginedependentmodel

  final Neighborhood<T> neighborsNeighborhood = neighCache.get(neighbor.getId());
  neighborsNeighborhood.removeNeighbor(node);
  Engine.neighborRemoved(this, node, neighbor);
Engine.neighborAdded(this, node, n);
origin: it.unibo.alchemist/alchemist-grid

final Loader loader = generalConfig.getLoader();
final Environment<T, P> env = loader.getWith(config.getVariables());
final Simulation<T, P> sim = new Engine<>(env, generalConfig.getEndStep(), generalConfig.getEndTime());
final Map<String, Object> defaultVars = loader.getVariables().entrySet().stream()
    .collect(Collectors.toMap(Entry::getKey, e -> e.getValue().getDefault()));
it.unibo.alchemist.core.implementationsEngine

Javadoc

This class implements a simulation. It offers a wide number of static factories to ease the creation process.

Most used methods

  • <init>
    Builds a simulation for a given environment. By default it uses a DependencyGraph and an IndexedPrio
  • checkCaller
  • compareStatuses
  • doStep
  • finalizeConstructor
  • getStatus
  • getStep
  • getTime
  • idleProcessSingleCommand
  • neighborAdded
  • neighborRemoved
  • newStatus
  • neighborRemoved,
  • newStatus,
  • nodeAdded,
  • nodeMoved,
  • nodeRemoved,
  • pause,
  • play,
  • removeReaction,
  • runUntil,
  • schedule

Popular in Java

  • Running tasks concurrently on multiple threads
  • getApplicationContext (Context)
  • findViewById (Activity)
  • onRequestPermissionsResult (Fragment)
  • Permission (java.security)
    Legacy security code; do not use.
  • MessageFormat (java.text)
    Produces concatenated messages in language-neutral way. New code should probably use java.util.Forma
  • Dictionary (java.util)
    Note: Do not use this class since it is obsolete. Please use the Map interface for new implementatio
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registry of org.quartz.Job
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now