Tabnine Logo
Node.getReactions
Code IndexAdd Tabnine to your IDE (free)

How to use
getReactions
method
in
it.unibo.alchemist.model.interfaces.Node

Best Java code snippets using it.unibo.alchemist.model.interfaces.Node.getReactions (Showing top 11 results out of 315)

origin: it.unibo.alchemist/alchemist-incarnation-protelis

@Override
public ComputationalRoundComplete cloneCondition(final Node<Object> n, final Reaction<Object> r) {
  final List<RunProtelisProgram> possibleRefs = n.getReactions().stream()
      .map(Reaction::getActions)
      .flatMap(List::stream)
      .filter(a -> a instanceof RunProtelisProgram)
      .map(a -> (RunProtelisProgram) a)
      .collect(Collectors.toList());
  if (possibleRefs.size() == 1) {
    return new ComputationalRoundComplete((ProtelisNode) n, possibleRefs.get(0));
  }
  throw new IllegalStateException("There must be one and one only unconfigured " + RunProtelisProgram.class.getSimpleName());
}
origin: it.unibo.alchemist/alchemist-incarnation-protelis

@Override
public SendToNeighbor cloneAction(final Node<Object> n, final Reaction<Object> r) {
  final List<RunProtelisProgram> possibleRefs = n.getReactions().stream()
      .map(Reaction::getActions)
      .flatMap(List::stream)
      .filter(a -> a instanceof RunProtelisProgram)
      .map(a -> (RunProtelisProgram) a)
      .collect(Collectors.toList());
  if (possibleRefs.size() == 1) {
    return new SendToNeighbor((ProtelisNode) n, reaction, possibleRefs.get(0));
  }
  throw new IllegalStateException("There must be one and one only unconfigured " + RunProtelisProgram.class.getSimpleName());
}
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

private void finalizeConstructor() {
  for (final Node<T> n : env.getNodes()) {
    for (final Reaction<T> r : n.getReactions()) {
      scheduleReaction(r);
    }
  }
}
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-swingui

  @Override
  public void stepDone(final Environment<T> env, final Reaction<T> exec, final Time time, final long step) {
    if (exec == null || exec.getNode().equals(n)) {
      final StringBuilder sb = new StringBuilder(stringLength);
      sb.append(POSITION);
      sb.append('\n');
      sb.append(env.getPosition(n));
      sb.append("\n\n\n");
      sb.append(CONTENT);
      sb.append('\n');
      sb.append(n.getContents().entrySet().stream()
        .map(e -> e.getKey().getName() + " > " + e.getValue() + '\n')
        .sorted()
        .collect(Collectors.joining())
      );
      sb.append("\n\n\n");
      sb.append(PROGRAM);
      sb.append("\n\n");
      for (final Reaction<T> r : n.getReactions()) {
        sb.append(r.toString());
        sb.append("\n\n");
      }
      stringLength = sb.length() + MARGIN;
      SwingUtilities.invokeLater(() -> {
        txt.setText(sb.toString());
      });
    }
  }
}
origin: it.unibo.alchemist/alchemist-engine

private void updateNeighborhood(final Node<T> n) {
  for (final Reaction<T> r : n.getReactions()) {
    if (r.getInputContext().equals(Context.NEIGHBORHOOD)) {
      updateReaction(handlers.get(r));
    }
  }
}
origin: it.unibo.alchemist/alchemist-engine

  @Override
  public void removeNeighbor(final Node<T> n1, final Node<T> n2) {
    DependencyHandler<T> rh1, rh2;
    for (final Reaction<T> r1 : n1.getReactions()) {
      rh1 = hndlrs.get(r1);
      for (final Reaction<T> r2 : n2.getReactions()) {
        rh2 = hndlrs.get(r2);
        if (!mayInfluence(r2, r1)) {
          rh1.removeInDependency(rh2);
          rh2.removeOutDependency(rh1);
          /*
           * Dependencies addition or removal should not influence the
           * next scheduled execution time.
           */
        }
        if (!mayInfluence(r1, r2)) {
          rh2.removeInDependency(rh1);
          rh1.removeOutDependency(rh2);
          /*
           * Dependencies addition or removal should not influence the
           * next scheduled execution time.
           */
        }
      }
    }
  }
}
origin: it.unibo.alchemist/alchemist-engine

private void updateDependenciesForOperationOnNode(final Neighborhood<T> oldNeighborhood) {
  /*
   * A reaction in the neighborhood may have changed due to the content of
   * this new node. Must check.
   */
  for (final Node<T> n : oldNeighborhood) {
    for (final Reaction<T> r : n.getReactions()) {
      if (r.getInputContext().equals(Context.NEIGHBORHOOD)) {
        updateReaction(handlers.get(r));
      }
    }
  }
  /*
   * It is possible that some global reaction is changed due to the
   * creation of a new node. Checking.
   */
  for (final Node<T> n : env) {
    for (final Reaction<T> r : n.getReactions()) {
      if (r.getInputContext().equals(Context.GLOBAL)) {
        updateReaction(handlers.get(r));
      }
    }
  }
}
origin: it.unibo.alchemist/alchemist-engine

@Override
public void addNeighbor(final Node<T> n1, final Node<T> n2) {
  DependencyHandler<T> rh1, rh2;
  for (final Reaction<T> r1 : n1.getReactions()) {
    rh1 = hndlrs.get(r1);
    for (int j = 0; j < n2.getReactions().size(); j++) {
      final Reaction<T> r2 = n2.getReactions().get(j);
      if (mayInfluence(r2, r1) && influences(r2, r1.getInfluencingMolecules())) {
        rh2 = hndlrs.get(r2);
        if (!rh1.isInfluenced().contains(rh2)) {
          rh1.addInDependency(rh2);
        }
        if (!rh2.influences().contains(rh1)) {
          rh2.addOutDependency(rh1);
        }
      }
      if (mayInfluence(r1, r2) && influences(r1, r2.getInfluencingMolecules())) {
        rh2 = hndlrs.get(r2);
        if (!rh2.isInfluenced().contains(rh1)) {
          rh2.addInDependency(rh1);
        }
        if (!rh1.influences().contains(rh2)) {
          rh1.addOutDependency(rh2);
        }
      }
    }
  }
}
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));
  }
}
it.unibo.alchemist.model.interfacesNodegetReactions

Popular methods of Node

  • contains
  • getId
  • getConcentration
  • setConcentration
  • compareTo
  • getContents
  • hashCode

Popular in Java

  • Running tasks concurrently on multiple threads
  • compareTo (BigDecimal)
  • setRequestProperty (URLConnection)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • URLConnection (java.net)
    A connection to a URL for reading or writing. For HTTP connections, see HttpURLConnection for docume
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • DataSource (javax.sql)
    An interface for the creation of Connection objects which represent a connection to a database. This
  • JOptionPane (javax.swing)
  • LogFactory (org.apache.commons.logging)
    Factory for creating Log instances, with discovery and configuration features similar to that employ
  • CodeWhisperer alternatives
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