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

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

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

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

@Override
public double getProperty(final Node<Double> node, final Molecule mol, final String prop) {
  return node.getConcentration(mol);
}
origin: it.unibo.alchemist/alchemist-incarnation-biochemistry

/**
 * @return true if the concentration of the molecule is higher or equal the
 *         value.
 */
@Override
public boolean isValid() {
  return getNode().getConcentration(molecule).doubleValue() >= qty
      .doubleValue();
}
origin: it.unibo.alchemist/alchemist-incarnation-biochemistry

@Override
public Map<Node<Double>, Double> getValidNeighbors(final Collection<? extends Node<Double>> neighborhood) {
  propensity = 0;
  neigh = neighborhood.stream()
      .filter(n -> n instanceof CellNode && n.getConcentration(mol) >= conc)
      .collect(Collectors.<Node<Double>, Node<Double>, Double>toMap(
          n -> n,
          n -> CombinatoricsUtils.binomialCoefficientDouble(n.getConcentration(mol).intValue(), conc.intValue())));
  if (!neigh.isEmpty()) {
    propensity = neigh.values().stream().max((d1, d2) -> d1.compareTo(d2)).get();
  }
  return new LinkedHashMap<>(neigh);
}
origin: it.unibo.alchemist/alchemist-incarnation-biochemistry

@Override
public void execute(final Node<Double> targetNode) {
  targetNode.setConcentration(mol, targetNode.getConcentration(mol) + delta);
}
origin: it.unibo.alchemist/alchemist-incarnation-biochemistry

@Override
public boolean isValid() {
  if (neigh.isEmpty()) {
    return false;
  } else {
    final Neighborhood<Double> neighborhood = environment.getNeighborhood(getNode());
    return neigh.entrySet().stream()
        .filter(n -> n.getKey() instanceof CellNode)
        .allMatch(n -> neighborhood.contains(n.getKey()) 
            && n.getKey().getConcentration(mol) >=  conc);
  }
}
origin: it.unibo.alchemist/alchemist-incarnation-protelis

  public Object runCycle() {
    final Node<Object> node = key.node.get();
    if (node == null) {
      throw new IllegalStateException("The node should never be null");
    }
    if (vm.isPresent()) {
      final ProtelisVM myVM = vm.get();
      mutex.acquireUninterruptibly();
      myVM.runCycle();
      mutex.release();
      return myVM.getCurrentValue();
    }
    if (node instanceof NoNode) {
      return key.property;
    }
    return node.getConcentration(key.molecule);
  }
}
origin: it.unibo.alchemist/alchemist-incarnation-biochemistry

/**
 * @return the propensity influence computed as max(0, T-[M]), where T is
 *         the threshold chosen and [M] is the current concentration of the
 *         molecule
 */
@Override
public double getPropensityConditioning() {
  final double qty = getQuantity().doubleValue();
  final double c = getNode().getConcentration(getMolecule())
      .doubleValue();
  return Math.max(0, qty - c);
}
origin: it.unibo.alchemist/alchemist-incarnation-biochemistry

/**
 * @return true if the concentration of the molecule is lower the value.
 */
@Override
public boolean isValid() {
  return getNode().getConcentration(getMolecule()).doubleValue() < getQuantity().doubleValue();
}
origin: it.unibo.alchemist/alchemist-incarnation-biochemistry

/**
 * Propensity influence is computed through the binomial coefficient. See
 * Bernardo, Degano, Zavattaro - Formal Methods for Computational Systems
 * Biology for the formulae.
 * 
 * @return the propensity influence
 */
@Override
public double getPropensityConditioning() {
  final int n = getNode().getConcentration(molecule).intValue();
  final int k = qty.intValue();
  if (k > n) {
    return 0;
  }
  return CombinatoricsUtils.binomialCoefficientDouble(n, k);
}
origin: it.unibo.alchemist/alchemist-incarnation-protelis

@Override
public Object get(final String id) {
  return shadow.get(id, node.getConcentration(new SimpleMolecule(id)));
}
@Override
origin: it.unibo.alchemist/alchemist-incarnation-biochemistry

private double getTotalQuantity() {
  double quantityInEnvNodes = 0;
  if (!getEnviromentNodesSurrounding().isEmpty()) {
    quantityInEnvNodes = getEnviromentNodesSurrounding().stream()
        .parallel()
        .mapToDouble(n -> n.getConcentration(getBiomolecule()))
        .sum();
  }
  double quantityInLayers = 0;
  final Optional<Layer<Double>> layer = environment.getLayer(getBiomolecule());
  if (layer.isPresent()) {
    quantityInLayers = layer.get().getValue(environment.getPosition(getNode()));
  }
  return quantityInEnvNodes + quantityInLayers;
}
origin: it.unibo.alchemist/alchemist-incarnation-biochemistry

@Override
public void execute() {
  final Neighborhood<Double> neighborhood = env.getNeighborhood(getNode());
  final List<Integer> validTargetsIds = new ArrayList<>();
  if (delta < 0) {
    neighborhood.getNeighbors().stream()
    .filter(n -> n instanceof CellNode && n.getConcentration(mol) >= delta)
    .mapToInt(n -> n.getId())
    .forEach(i -> validTargetsIds.add(i));
  } else {
    neighborhood.getNeighbors().stream()
    .filter(n -> n instanceof CellNode && n.getConcentration(mol) >= delta)
    .mapToInt(n -> n.getId())
    .forEach(i -> validTargetsIds.add(i));
  }
  if (!validTargetsIds.isEmpty()) {
    final int targetId = validTargetsIds.get(getRandomGenerator().nextInt(validTargetsIds.size()));
    execute(neighborhood.getNeighborByNumber(targetId));
  }
}
origin: it.unibo.alchemist/alchemist-incarnation-biochemistry

  private void changeConcentrationInRandomNodes(final List<EnvironmentNode> envNodesSurrounding) {
    if (delta < 0) {
      double deltaTemp = delta;
      while (deltaTemp < 0) {
        final int index = getRandomGenerator().nextInt(envNodesSurrounding.size());
        final EnvironmentNode pickedNode = envNodesSurrounding.get(index);
        final double nodeConcentration = pickedNode.getConcentration(biomolecule);
        // if nodeConcentration >= |deltaTemp|, remove the a delta quantity of the biomol only from this node
        if (nodeConcentration >= FastMath.abs(deltaTemp)) {
          pickedNode.setConcentration(biomolecule, nodeConcentration + deltaTemp);
          break;
          // else, remove all molecule of that species from that node and go on till deltaTemp is smaller than nodeConcetration
        } else {
          deltaTemp = deltaTemp + nodeConcentration;
          pickedNode.removeConcentration(biomolecule);
        }
        envNodesSurrounding.remove(index);
      }
    } else {
      // if delta > 0, simply add delta to the first node of the list (which has been sorted randomly)
      final Node<Double> target = envNodesSurrounding.get(getRandomGenerator().nextInt(envNodesSurrounding.size()));
      target.setConcentration(biomolecule, target.getConcentration(biomolecule) + delta);
    }
  }
}
origin: it.unibo.alchemist/alchemist-incarnation-biochemistry

private void changeConcentrationInSortedNodes(final List<EnvironmentNode> envNodesSurrounding) {
  if (delta < 0) {
    double deltaTemp = delta;
    for (final EnvironmentNode n : envNodesSurrounding) {
      final double nodeConcentration = n.getConcentration(biomolecule);
      // if nodeConcentration >= |deltaTemp|, remove the a delta quantity of the biomol only from this node
      if (nodeConcentration >= FastMath.abs(deltaTemp)) {
        n.setConcentration(biomolecule, nodeConcentration + deltaTemp);
        break;
        // else, remove all molecule of that species from that node and go on till deltaTemp is smaller than nodeConcetration
      } else {
        deltaTemp = deltaTemp + nodeConcentration;
        n.removeConcentration(biomolecule);
      }
    }
  } else {
    // if delta > 0, simply add delta to the first node of the list (which has been sorted randomly)
    final Node<Double> target = envNodesSurrounding.get(0);
    target.setConcentration(biomolecule, target.getConcentration(biomolecule) + delta);
  }
}
origin: it.unibo.alchemist/alchemist-incarnation-biochemistry

@Override
public void execute() {
  super.getNode().setConcentration(getMolecule(), super.getNode().getConcentration(getMolecule()) + deltaC);
}
origin: it.unibo.alchemist/alchemist-incarnation-biochemistry

} else {
  final boolean isNodeOnMaxConc = env.getPosition(l.stream()
      .max((n1, n2) -> Double.compare(n1.getConcentration(biomol), n2.getConcentration(biomol)))
      .get()).equals(env.getPosition(thisNode));
  if (isNodeOnMaxConc) {
origin: it.unibo.alchemist/alchemist-incarnation-biochemistry

private Position weightedAverageVectors(final List<Node<Double>> list, final CellNode thisNode) {
  Position res = new Continuous2DEuclidean(0, 0);
  final Position thisNodePos = env.getPosition(thisNode);
  for (final Node<Double> n : list) {
    final Position nPos = env.getPosition(n);
    Position vecTemp = new Continuous2DEuclidean(
        nPos.getCoordinate(0) - thisNodePos.getCoordinate(0),
        nPos.getCoordinate(1) - thisNodePos.getCoordinate(1));
    final double vecTempModule = FastMath.sqrt(FastMath.pow(vecTemp.getCoordinate(0), 2) + FastMath.pow(vecTemp.getCoordinate(1), 2));
    vecTemp = new Continuous2DEuclidean(
        n.getConcentration(biomol) * (vecTemp.getCoordinate(0) / vecTempModule), 
        n.getConcentration(biomol) * (vecTemp.getCoordinate(1) / vecTempModule));
    res = new Continuous2DEuclidean(
        res.getCoordinate(0) + vecTemp.getCoordinate(0),
        res.getCoordinate(1) + vecTemp.getCoordinate(1));
  }
  return res;
}
it.unibo.alchemist.model.interfacesNodegetConcentration

Popular methods of Node

  • contains
  • getId
  • getReactions
  • setConcentration
  • compareTo
  • getContents
  • hashCode

Popular in Java

  • Making http requests using okhttp
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • getSystemService (Context)
  • setRequestProperty (URLConnection)
  • ObjectMapper (com.fasterxml.jackson.databind)
    ObjectMapper provides functionality for reading and writing JSON, either to and from basic POJOs (Pl
  • FileInputStream (java.io)
    An input stream that reads bytes from a file. File file = ...finally if (in != null) in.clos
  • Thread (java.lang)
    A thread is a thread of execution in a program. The Java Virtual Machine allows an application to ha
  • TimeZone (java.util)
    TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
  • BoxLayout (javax.swing)
  • JTextField (javax.swing)
  • Top plugins for WebStorm
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