private static LOCATIONTYPE getNodeType (Node n , LOCATIONTYPE defalutValue) { try { return LOCATIONTYPE.valueOf(n.getAttribute(ATTNAME_NODE_INPUT_LOCATIONTYPE)); } catch (Exception e) {return defalutValue; } } private static void setNodeType (Node n , LOCATIONTYPE type) { n.setAttribute(ATTNAME_NODE_INPUT_LOCATIONTYPE , type.name()); }
data[itemId][n + 1] = netPlan.getNodeFromId(nodeId).getAttribute(attribute); if (data[itemId][n + 1] == null) data[itemId][n + 1] = "";
public String getArbitraryParamString () { return getNe().getAttribute(ATTNAMECOMMONPREFIX + ATTNAMESUFFIX_ARBITRARYPARAMSTRING , ""); }
private void checkSolution (NetPlan netPlan) { for (Link e : netPlan.getLinks ()) { final double pThisLink = Double.parseDouble(e.getAttribute("p_e")); if (pThisLink < minLinkPersistenceProb.getDouble() - 1E-3) throw new RuntimeException ("Bad"); } for (Node n : netPlan.getNodes ()) { final double qThisNode = Double.parseDouble(n.getAttribute("q_n")); if (qThisNode < 0) throw new RuntimeException ("Bad"); if (qThisNode > maxNodePersistenceProb.getDouble() +1E-3) throw new RuntimeException ("Bad"); double peAccum = 0; for (Link e : n.getOutgoingLinks()) peAccum += Double.parseDouble(e.getAttribute("p_e")); if (Math.abs(peAccum - qThisNode) > 1E-3) throw new RuntimeException ("Bad"); } } }
private void setNodeTableInfoFromNetPlan(NetPlan netPlan) { int N = netPlan.getNumberOfNodes(); if (N == 0) throw new Net2PlanException("Network structure doesn't contain a physical topology"); maxLevel = 1; Object[][] data = new Object[N][6]; for (Node node : netPlan.getNodes()) { final int n = node.getIndex(); final long nodeId = node.getId(); double population; int level; population = (int) node.getPopulation (); try { level = Integer.parseInt(node.getAttribute("level")); } catch (Exception ex) { level = 1; } data[n][0] = nodeId; data[n][1] = node.getName(); data[n][2] = node.getXYPositionMap().getX(); data[n][3] = node.getXYPositionMap().getY(); data[n][4] = population < 0 ? 0 : population; data[n][5] = level < 1 ? 1 : level; if (level > maxLevel) maxLevel = level; } nodeInfoTableModel.setDataVector(data, nodeInfoTableHeader); ((DefaultTableModel) levelMatrixTableModel).setRowCount(maxLevel); numNodes.setText(Integer.toString(N)); }
private void checkCapacitiesNetPlan () { double [] p_e = new double [E]; for (Link e : currentNetPlan.getLinks ()) { p_e [e.getIndex ()] = Double.parseDouble (e.getAttribute("p_e")); if ((p_e [e.getIndex ()] < control_minLinkPersistenceProb.getDouble() - 1E-3) ||(p_e [e.getIndex ()] > 1E-3 + control_maxNodePersistenceProb.getDouble())) throw new RuntimeException ("Bad"); } double [] q_n = new double [N]; for (Node n : currentNetPlan.getNodes ()) { for (Link e : n.getOutgoingLinks()) q_n [n.getIndex ()] += p_e [e.getIndex ()]; if (Math.abs (q_n [n.getIndex ()] - Double.parseDouble (n.getAttribute("q_n"))) > 1E-3) throw new RuntimeException ("Bad"); if (q_n [n.getIndex ()] > control_maxNodePersistenceProb.getDouble() + 1E-3) throw new RuntimeException ("Bad"); } for (Link e : currentNetPlan.getLinks ()) { final double u_e = e.getCapacity(); double supposedCapacity = control_linkNominalCapacities.get(e.getIndex ()) * control_p_e.get (e.getIndex ()); for (Node n : control_nodesInterfTo_e.get(e)) supposedCapacity *= 1 - q_n [n.getIndex ()]; if (Math.abs (u_e - supposedCapacity) > 1e-3) throw new RuntimeException ("Bad"); } }
final String stClusterId = n.getAttribute("clusterId"); if (stClusterId == null) throw new Net2PlanException("Node " + n + " does not belong to any cluster"); clusterIds.add(stClusterId);
for(Node node : initialNetPlan.getNodes ()) if (node.getAttribute("timezone") == null) continue; double timezone = Double.parseDouble(node.getAttribute("timezone")); if (timezone < -12 || timezone > 12) throw new Net2PlanException(String.format("Timezone for node %d must be in range [-12, 12]", node.getIndex ())); tfSlow_timeZones_n.set(node.getIndex (), timezone);
for(Node node : initialNetPlan.getNodes ()) if (node.getAttribute("timezone") == null) continue; double timezone = Double.parseDouble(node.getAttribute("timezone")); if (timezone < -12 || timezone > 12) throw new Net2PlanException(String.format("Timezone for node %d must be in range [-12, 12]", node.getIndex ())); tfSlow_timeZones_n.set(node.getIndex (), timezone);