MATSIM
FacilitiesSummary.java
Go to the documentation of this file.
1 /* *********************************************************************** *
2  * project: org.matsim.*
3  * FacilitiesSummary.java
4  * *
5  * *********************************************************************** *
6  * *
7  * copyright : (C) 2007 by the members listed in the COPYING, *
8  * LICENSE and WARRANTY file. *
9  * email : info at matsim dot org *
10  * *
11  * *********************************************************************** *
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * See also COPYING, LICENSE and WARRANTY file *
18  * *
19  * *********************************************************************** */
20 
21 package org.matsim.facilities.algorithms;
22 
23 import java.util.Iterator;
24 
29 
30 public class FacilitiesSummary {
31 
32  public FacilitiesSummary() {
33  super();
34  }
35 
36  public void run(ActivityFacilities facilities) {
37  System.out.println(" running " + this.getClass().getName() + " algorithm...");
38  int f_cnt = 0;
39  int act_cnt = 0;
40 // Coord min_coord = new Coord(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
41 // Coord max_coord = new Coord(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY);
42  double min_coordX = Double.POSITIVE_INFINITY;
43  double min_coordY = Double.POSITIVE_INFINITY;
44  double max_coordX = Double.NEGATIVE_INFINITY;
45  double max_coordY = Double.NEGATIVE_INFINITY;
46  // home,work,education,shop,leisure
47  int caps[] = {0 , 0, 0, 0, 0};
48  int unlimit_cap_cnt = 0;
49  for (ActivityFacility f : facilities.getFacilities().values()) {
50  f_cnt++;
51  if (f.getCoord().getX() > max_coordX) { max_coordX=f.getCoord().getX(); }
52  if (f.getCoord().getY() > max_coordY) { max_coordY=f.getCoord().getY(); }
53  if (f.getCoord().getX() < min_coordX) { min_coordX=f.getCoord().getX(); }
54  if (f.getCoord().getY() < min_coordY) { min_coordY=f.getCoord().getY(); }
55 
56  Iterator<? extends ActivityOption> a_it = f.getActivityOptions().values().iterator();
57  while (a_it.hasNext()) {
58  ActivityOptionImpl a = (ActivityOptionImpl) a_it.next();
59  act_cnt++;
60  if (a.getCapacity() != Integer.MAX_VALUE) {
61  if (a.getType().equals("home")) {
62  caps[0] += a.getCapacity();
63  }
64  else if (a.getType().equals("work")) {
65  caps[1] += a.getCapacity();
66  }
67  else if (a.getType().equals("education")) {
68  caps[2] += a.getCapacity();
69  }
70  else if (a.getType().equals("shop")) {
71  caps[3] += a.getCapacity();
72  }
73  else if (a.getType().equals("leisure")) {
74  caps[4] += a.getCapacity();
75  }
76  else {
77  throw new RuntimeException("ERROR: in " + this.getClass().getName() +
78  " in run(Facilities facilities):" +
79  " do not know type = " + a.getType());
80  }
81  }
82  else {
83  unlimit_cap_cnt++;
84  }
85  }
86  }
87  System.out.println(" Number of Facilities: " + f_cnt);
88  System.out.println(" Number of Activities: " + act_cnt);
89  System.out.println(" Min Coord: " + min_coordX + " " + min_coordY );
90  System.out.println(" Max Coord: " + max_coordX + " " + max_coordY ) ;
91  System.out.println(" total home cap: " + caps[0]);
92  System.out.println(" total work cap: " + caps[1]);
93  System.out.println(" total education cap: " + caps[2]);
94  System.out.println(" total shop cap: " + caps[3]);
95  System.out.println(" total leisure cap: " + caps[4]);
96  System.out.println(" total acts with unlimited cap: " + unlimit_cap_cnt);
97 
98  System.out.println(" done.");
99  }
100 }
Map< Id< ActivityFacility >, ? extends ActivityFacility > getFacilities()