private Charger createCharger(Attributes atts) { Id<Charger> id = Id.create(atts.getValue("id"), Charger.class); Link link = links.get(Id.createLinkId(atts.getValue("link"))); double power_kW = ReaderUtils.getDouble(atts, "power", DEFAULT_CHARGER_POWER_kW); int plugs = ReaderUtils.getInt(atts, "capacity", DEFAULT_CHARGER_CAPACITY); return new ChargerImpl(id, power_kW * EvUnitConversions.W_PER_kW, plugs, link); }
@Override protected void initFlow(HierarchicalConfiguration flowCfg) { // int node = flowCfg.getInt("[@node]"); int inLink = flowCfg.getInt("[@inLink]", -1); int outLink = flowCfg.getInt("[@outLink]", -1); // int next = flowCfg.getInt("[@next]"); int no = flowCfg.getInt("[@no]", 0); Node node; Node next; if (inLink != -1) { Link link = idToLinkMap.get(Id.create(inLink, Link.class)); node = link.getFromNode(); next = link.getToNode(); } else { Link link = idToLinkMap.get(Id.create(outLink, Link.class)); node = link.getToNode(); next = link.getFromNode(); } int nodeId = Integer.parseInt(node.getId().toString()); int nextId = Integer.parseInt(next.getId().toString()); flows[nodeId] = new MATSimFlow(nodeId, inLink, outLink, nextId, no); }
/** * produces a Id whose prefix up to row is identical to this, followed by a digit with value * column, followed by a suffix of digits with value suffixDigits. * * @param row the length of the prefix * @param column the value of the following digit * @param suffixDigit the value of the suffix digits * @param b power of 2 of the base * @return the resulting Id */ public Id getDomainPrefix(int row, int column, int suffixDigit, int b) { Id res = new Id(Id); res.setDigit(row, column, b); for (int i = 0; i < row; i++) { res.setDigit(i, suffixDigit, b); } return build(res.Id); }
/** * Checks if this Id is between two given ids ccw (inclusive) and cw (exclusive) on the circle * * @param ccw the counterclockwise id * @param cw the clockwise id * @return true if this is between ccw (inclusive) and cw (exclusive), false otherwise */ public boolean isBetween(Id ccw, Id cw) { if (ccw.equals(cw)) { return false; } if (ccw.clockwise(cw)) { return this.clockwise(cw) && !this.clockwise(ccw); } else { return !this.clockwise(ccw) || this.clockwise(cw); } }
/** * produces a set of ids (keys) that are evenly distributed around the id ring. One invocation * produces the i-th member of a set of size num. The set is evenly distributed around the ring, * with an offset given by this Id. The set is useful for constructing, for instance, Scribe trees * with disjoint sets of interior nodes. * * @param num the number of Ids in the set (must be <= 2^b) * @param b the routing base (as a power of 2) * @param i the index of the requested member of the set (0<=i<num; the 0-th member is this) * @return the resulting set member, or null in case of illegal arguments */ public Id getAlternateId(int num, int b, int i) { if (num > (1 << b) || i < 0 || i >= num) { return null; } Id res = new Id(Id); int digit = res.getDigit(numDigits(b) - 1, b) + ((1 << b) / num) * i; res.setDigit(numDigits(b) - 1, digit, b); return build(res.Id); }
public static List<ChargerLocation> createLocationsInZones(Iterable<Zone> zones, double power) { List<ChargerLocation> locations = new ArrayList<>(); for (Zone z : zones) { locations.add( new ChargerLocation(Id.create(z.getId(), ChargerLocation.class), z.getCoord(), power)); } return locations; }
/** * Creates a MondrianOlap4jCellSetAxisMetaData. * * @param cellSetMetaData Cell set axis metadata * @param queryAxis Query axis */ MondrianOlap4jCellSetAxisMetaData( MondrianOlap4jCellSetMetaData cellSetMetaData, QueryAxis queryAxis) { if (queryAxis == null) { queryAxis = new QueryAxis( false, null, AxisOrdinal.StandardAxisOrdinal.SLICER, QueryAxis.SubtotalVisibility.Undefined); } this.queryAxis = queryAxis; this.cellSetMetaData = cellSetMetaData; // populate property list for (Id id : queryAxis.getDimensionProperties()) { propertyList.add(Property.StandardMemberProperty.valueOf(id.toStringArray()[0])); } }
public Syntax internalDeepCopy(Token start, Token end) { Syntax copy = new DotMethodCallExp( start, end, (methodName == null ? null : (Id) methodName.internalDeepCopy(start, end)), (subpat == null ? null : (Cmd) subpat.internalDeepCopy(start, end))); return copy; }
public Syntax internalDeepCopy(Token start, Token end) { Syntax copy = new ClsPatDef( start, end, (id == null ? null : (Id) id.internalDeepCopy(start, end)), (List<Id>) (deepCopyList(formals, start, end)), (body == null ? null : (Cmd) body.internalDeepCopy(start, end))); return copy; }
private void prepareMatrices(String statusMatrixFile) { wrs = new WeightedRandomSelection<Id<Zone>>(); Matrix avestatus = MatrixUtils.readMatrices(statusMatrixFile).getMatrix("avg"); for (Map.Entry<String, ArrayList<Entry>> fromLOR : avestatus.getFromLocations().entrySet()) { if (BerlinZoneUtils.isInBerlin(fromLOR.getKey())) { wrs.add( Id.create(fromLOR.getKey(), Zone.class), MatrixUtils.calculateTotalValue(fromLOR.getValue())); } } }
public static void main(String[] args) { String dir = "d:\\PP-rad\\poznan\\"; String networkFile = dir + "network.xml"; String linkStats = dir + "40.linkstats.txt.gz"; String polygonFile = dir + "poznan_polygon\\poznan_city_polygon.shp"; boolean includeBorderLinks = false; String filteredLinkStats = dir + "40.linkstats-filtered.txt.gz"; Geometry polygonGeometry = PolygonBasedFilter.readPolygonGeometry(polygonFile); Predicate<Link> linkInsidePolygonPredicate = PolygonBasedFilter.createLinkInsidePolygonPredicate(polygonGeometry, includeBorderLinks); Scenario scenario = ScenarioUtils.createScenario(VrpConfigUtils.createConfig()); MatsimNetworkReader nr = new MatsimNetworkReader(scenario); nr.readFile(networkFile); Map<Id<Link>, ? extends Link> linkMap = scenario.getNetwork().getLinks(); try (BufferedReader br = IOUtils.getBufferedReader(linkStats); PrintWriter pw = new PrintWriter(IOUtils.getBufferedWriter(filteredLinkStats))) { String header = br.readLine(); pw.println(header); String line; while ((line = br.readLine()) != null) { String linkId = new StringTokenizer(line).nextToken(); // linkId - first column Link link = linkMap.get(Id.create(linkId, Link.class)); if (linkInsidePolygonPredicate.apply(link)) { pw.println(line); } } } catch (IOException e) { throw new RuntimeException(e); } }
// 循环处理每个需要处理的程序对象 public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { // 定义一个文件输出流,用于生成额外的文件 PrintStream ps = null; try { // 遍历每个被@Persistent修饰的class文件 for (Element t : roundEnv.getElementsAnnotatedWith(Persistent.class)) { // 获取正在处理的类名 Name clazzName = t.getSimpleName(); // 获取类定义前的@Persistent Annotation Persistent per = t.getAnnotation(Persistent.class); // 创建文件输出流 ps = new PrintStream(new FileOutputStream(clazzName + ".hbm.xml")); // 执行输出 ps.println("<?xml version=\"1.0\"?>"); ps.println("<!DOCTYPE hibernate-mapping PUBLIC"); ps.println(" \"-//Hibernate/Hibernate " + "Mapping DTD 3.0//EN\""); ps.println(" \"http://www.hibernate.org/dtd/" + "hibernate-mapping-3.0.dtd\">"); ps.println("<hibernate-mapping>"); ps.print(" <class name=\"" + t); // 输出per的table()的值 ps.println("\" table=\"" + per.table() + "\">"); for (Element f : t.getEnclosedElements()) { // 只处理成员变量上的Annotation if (f.getKind() == ElementKind.FIELD) // ① { // 获取成员变量定义前的@Id Annotation Id id = f.getAnnotation(Id.class); // ② // 当@Id Annotation存在时输出<id.../>元素 if (id != null) { ps.println( " <id name=\"" + f.getSimpleName() + "\" column=\"" + id.column() + "\" type=\"" + id.type() + "\">"); ps.println(" <generator class=\"" + id.generator() + "\"/>"); ps.println(" </id>"); } // 获取成员变量定义前的@Property Annotation Property p = f.getAnnotation(Property.class); // ③ // 当@Property Annotation存在时输出<property.../>元素 if (p != null) { ps.println( " <property name=\"" + f.getSimpleName() + "\" column=\"" + p.column() + "\" type=\"" + p.type() + "\"/>"); } } } ps.println(" </class>"); ps.println("</hibernate-mapping>"); } } catch (Exception ex) { ex.printStackTrace(); } finally { if (ps != null) { try { ps.close(); } catch (Exception ex) { ex.printStackTrace(); } } } return true; }
public static ChargerLocation createLocation(long id, double x, double y, double power) { return new ChargerLocation(Id.create(id, ChargerLocation.class), new Coord(x, y), power); }
public String toString() { return id.toString(); }
public String details() { return "<~" + id.toString() + "~>"; }
public Syntax internalDeepCopy(Token start, Token end) { Syntax copy = new PatVar(start, end, (id == null ? null : (Id) id.internalDeepCopy(start, end))); return copy; }