/** * Create the junction that links the target node and the node when this action is executed. */ @Override public void execute(final Node<Double> targetNode) { if (targetNode instanceof CellNode) { ((CellNode) targetNode).addJunction(jun, getNode()); } else { throw new UnsupportedOperationException("Can't add Junction in a node that it's not a CellNode"); } }
@Override public boolean isValid() { return getNode().containsJunction(j); }
@Override public void moveNode(final Node<Double> node, final Position direction) { if (node instanceof CellNode) { super.moveNode(node, direction); final CellNode nodeToMove = (CellNode) node; final Neighborhood<Double> neigh = getNeighborhood(nodeToMove); final Map<Junction, Map<CellNode, Integer>> jun = nodeToMove.getJunctions(); jun.entrySet().stream().forEach(e -> e.getValue().entrySet().forEach(e2 -> { if (!neigh.contains(e2.getKey())) { // there is a junction that links a node which isn't in the neighborhood after the movement for (int i = 0; i < e2.getValue(); i++) { nodeToMove.removeJunction(e.getKey(), e2.getKey()); e2.getKey().removeJunction(e.getKey().reverse(), nodeToMove); } } })); } }
/** * Removes the junction that links the node where this action is executed and the target node. */ @Override public void execute(final Node<Double> targetNode) { if (targetNode instanceof CellNode) { getNode().removeJunction(jun, (CellNode) targetNode); } else { throw new UnsupportedOperationException("Can't remove Junction in a node that it's not a CellNode"); } }
.collect(Collectors.toList()); if (l.isEmpty()) { thisNode.addPolarization(new Continuous2DEuclidean(0, 0)); } else { final boolean isNodeOnMaxConc = env.getPosition(l.stream() .get()).equals(env.getPosition(thisNode)); if (isNodeOnMaxConc) { thisNode.addPolarization(new Continuous2DEuclidean(0, 0)); } else { Position newPolVer = weightedAverageVectors(l, thisNode); ); if (newPolVerModule == 0) { thisNode.addPolarization(newPolVer); } else { newPolVer = new Continuous2DEuclidean(newPolVer.getCoordinate(0) / newPolVerModule, newPolVer.getCoordinate(1) / newPolVerModule); if (ascend) { thisNode.addPolarization(newPolVer); } else { thisNode.addPolarization(new Continuous2DEuclidean( -newPolVer.getCoordinate(0), -newPolVer.getCoordinate(1))
@Override public Map<Node<Double>, Double> getValidNeighbors(final Collection<? extends Node<Double>> neighborhood) { final Set<CellNode> linkedNodes = getNode().getNeighborsLinkWithJunction(j); return neighborhood.stream().filter(n -> linkedNodes.contains(n)) .collect(Collectors.<Node<Double>, Node<Double>, Double>toMap( n -> n, n -> 1.0)); }
@Override public Position getNextPosition() { final CellNode thisNode = getNode(); return new Continuous2DEuclidean( delta * thisNode.getPolarizationVersor().getCoordinate(0), delta * thisNode.getPolarizationVersor().getCoordinate(1) ); }
@Override public void execute() { super.execute(); getNode().setPolarization(new Continuous2DEuclidean(0, 0)); }
@Override public void execute(final Node<Double> targetNode) { if (targetNode instanceof CellNode) { ((CellNode) targetNode).removeJunction(jun, getNode()); } else { throw new UnsupportedOperationException("Can't add Junction in a node that it's not a CellNode"); } }
/** * */ @Override public void execute() { final double x = getRandomGenerator().nextFloat() - 0.5; final double y = getRandomGenerator().nextFloat() - 0.5; Position randomVersor = new Continuous2DEuclidean(x, y); if (x == 0) { randomVersor = new Continuous2DEuclidean(0, 1); } else if (y == 0) { randomVersor = new Continuous2DEuclidean(1, 0); } else { final double module = FastMath.sqrt(FastMath.pow(x, 2) + FastMath.pow(y, 2)); if (module == 0) { randomVersor = new Continuous2DEuclidean(0, 0); } else { randomVersor = new Continuous2DEuclidean(x / module, y / module); } } getNode().addPolarization(randomVersor); }
/** * Create the junction that links the node where this action is executed and the target node. */ @Override public void execute(final Node<Double> targetNode) { if (targetNode instanceof CellNode) { getNode().addJunction(jun, (CellNode) targetNode); } else { throw new UnsupportedOperationException("Can't add Junction in a node that it's not a CellNode"); } }