Virtual Map of Manchester – Version 1

Here you will find a virtual map of Manchester and Salford in the in the WKT format showing some bus routes, points of interest, offices, and houses. It's a bit rough around the edges and has a few redundant roads, paths and I've not taken all the rivers and train lines out yet - but it's a good start.

WKT geometries are used throughout GIS applications that implement Open Geospatial Consortium (OGC) specifications. These files were specifically made for the ONE Simulator which can use maps to route agents (in my case people) around an area, but they can be useful as a starting point for any simulation of Manchester, for example - disease propagation. The map contains:

Meeting Points:

Various bars, clubs, parks, etc. Including:

  1. Picadilly Station
  2. Picadilly Gardens
  3. Nother Quarter
  4. The Triangle
  5. Museum of Science and Industry
  6. Town Hall
  7. Hulme Asda
  8. Islington Mill
  9. Zion Arts Center
  10. Arndale center
  11. Whitworth Park
  12. Printworks
  13. Curry Mile
  14. Fallowfield
  15. Withington
  16. West Didsbury
  17. East Didsbury
  18. Pars Wood
  19. Chorlton, 4 banks area
  20. Old Trafford
  21. Levenshulme
  22. Longsite
  23. More music venues such as Sound Control and Ruby Lounge

Bus Routes:

  1. 50
  2. 84
  3. 85
  4. 86
  5. 142
  6. 143
  7. 192
  8. 101
  9. 168
  10. Made up bus route to salford university

Offices:

Various offices around the city with the majority within the town centre. Including:

  1. University of Manchester
  2. University of Salford
  3. MRI

Homes:

Various Homes with the majority in South Manchester area but some in central Manchester and around Salford University.

People in the Simulation

There is a mixture of high-density urban and suburban locations in Manchester. We use the estimation that the population of Manchester is 498,800 and there is an average density of 4,313/km2. Given our map has dimensions of 7,000 x 9,500 meters giving an area of 66.5km2, our map should have a populate of 286,814. If we take the figure of 85% of adults owning a mobile phone then we have a total population for our simulation of 243,791. Our simulation could not handle this. So to counter-act this drawback we say that each device represents a similar pool of 30 devices and populate the simulator with 8,100 mobile nodes.

Screenshot

Screenshot of Virtual Manchester

Screenshot of Virtual Manchester

Download

Released under a GPLv3 license.

  1. Map, bus, house, office, meeting place files
  2. Simple scenario file which uses the maps.
Posted in Manchester Map, ONE Simulator, Social Data Analysis | 3 Comments

How to create a machine readable map of Manchester with bus routes for the ONE Simulator

To create a map of Manchester for my PhD research into movement and wireless communication between people (Pocket Switched Networks if you care to look it up), I used the following software:

1) Get a map from Open Street Map

Go on Open Street Map and export a portion of the map as OpenStreetMap XML Data.

Use osm2wkt to convert OpenStreetMap XML data to WKT format. If you exported a large map then this might take a while. Go make a cup of tea.

2) Get Bus Data

From the http://linkedmanchester.org website you can export bus stop information for a particular bus journey. Thanks to Ric and Bill at Swirll for the following SPARQL for RDF which gives us a list of bus stops for a route.

PREFIX transit: <http://vocab.org/transit/terms/>

SELECT DISTINCT ?stop ?latitude ?longitude WHERE {
GRAPH <http://linkedmanchester.org/id/graph/buses/gmpte> {
?trip transit:route <http://linkedmanchester.org/id/buses/route/101> .
?trip transit:serviceCalendar <http://linkedmanchester.org/id/buses/
                          calendar/101/inbound/weekdays> .
?trip transit:stopTime ?st .
?st transit:stop ?stop .
?stop <http://www.w3.org/2003/01/geo/wgs84_pos#lat> ?latitude .
?stop <http://www.w3.org/2003/01/geo/wgs84_pos#long> ?longitude
}}

This gives you a table of stops for the 101 Bus:

latitude longitude stop
53.4801286865 -2.2371783855 http://transport.data.gov.uk/id/stop-point/1800SB04721
53.4784183311 -2.2384345538 http://transport.data.gov.uk/id/stop-point/1800SB04791
... ... ...

3)Combine Map and Bus Data

We need to convert the bus stop locations for a route into coordinates of our map of Manchester. I had to do it by hand using the links given from the bus stop data above, matching the locations displayed by the links against the map in OpenJUMP. This is because the ONE Simulator needs bus stops to be situated in the road so that the simulator can plot paths for people going to and coming from work.

This is an example of a line-string file which represents the bus route. It's useless to you without the corresponding map of Manchester but is given as an example.

LINESTRING (11719.17 13399.36, 11614.92 13229.12, 11554 13034.1,
11558.6  12859.2, 11396 12780.8, 11422.3 12575.1, 11461.5 12199.8,
11583.8  11968.5, 11745.5 11692.9, 11550.6 11520.5, 11372.3 11423.2,
11191.6  10976.7, 11188.9 10687.5, 11191.5 10456.8, 11197.3 10274,
11224 9858.9,  11239.4 9568.3, 11255.5 9194.8, 11265.5 8898.3,
11217.3 8562.9, 11039.9  8239.6, 10896 8002.7, 10692.5 7629.1,
10639 7454.4, 10313 6953.1,  10210.6 6728.2, 9810.3 5767.6)

Now we have a bus route for Manchester in OpenJUMP. The next picture shows you one I made earlier. With some added houses, offices, and meeting points where people hang out. See if you can spot your local meeting place and let me know if I've not included it.

Map of Manchester in OpenJUMP showing some houses and the 142 bus route.

Map of Manchester in OpenJUMP showing some houses and the 142 bus route.

Repeat for the other buses...

4)Now for the interesting part. Adding people!

The real reason I want to simulate Manchester is to look at what technology we can use to improve mobile data passing but I won't bore you with the specifics of that, I'll save it for my PhD. However, to let you see what is possible with the model we've just made here is a screen shot of some simulated people with mobile phones all running about and catching buses on their way to work. Good eh.

Map of Manchester in ONE Simulator with people moving using the Working Day Model.
Map of Manchester in OpenJUMP showing some houses and the 142 bus route.

If you want to check this map out for yourself you can add the following files to the ONE Simulator. If you use this map in your research it'd be nice if you credited it to me too:

  1. Map files
  2. Simple scenario file which uses the maps.

 

Posted in Manchester Map, ONE Simulator, Simulation, Social Data Analysis | Leave a comment

Message Time To Live in the ONE Simulator and PJ Dillon’s DecisionEngineRouter Class

Just fixed another bug in the ONE Simulator I think. This one is introduced when using PJ Dillon's DecisionEngineRouter in ONE Sim 1.4.1.

When setting Group.msgTtl in your scenario file and when using algorithms provided by PJ Dillon you might notice that there are very few (or zero) messages dropped in many cases. This is because the Message Time To Live isn't being checked in this new router class (which extends ActiveRouter). These are the changes I've had to make to DecisionEngineRouter class to fix the error. Hopefully they don't introduce further bugs.

Recieve Message method changed to:

@Override
 public int receiveMessage(Message m, DTNHost from)
 {
 int recvCheck = checkReceiving(m); 
 if (recvCheck != RCV_OK) {
 return recvCheck;
 }
 if(isDeliveredMessage(m) || (tombstoning && tombstones.contains(m.getId())))
 return DENIED_DELIVERED; 

 return super.receiveMessage(m, from);
 }

Create New Message method changed to:

@Override
 public boolean createNewMessage(Message m)
 {
 if(decider.newMessage(m))
 {
 //if(m.getId().equals("M7"))
 //System.out.println("Host: " + getHost() + " Creating M7");
 makeRoomForNewMessage(m.getSize());
 m.setTtl(this.msgTtl);
 addToMessages(m, true); 

 findConnectionsForNewMessage(m, getHost());
 return true;
 }
 return false;
 }

Update method changed to:

@Override
 public void update()
 {
 super.update();

 /* time to do a TTL check and drop old messages? Only if not sending */
 if (SimClock.getTime() - lastTtlCheck >= TTL_CHECK_INTERVAL && 
 sendingConnections.size() == 0) {
 dropExpiredMessages();
 lastTtlCheck = SimClock.getTime();
 }

 if (!canStartTransfer() || isTransferring()) {
 return; // nothing to transfer or is currently transferring 
 } 

 tryMessagesForConnected(outgoingMessages); 

 for(Iterator<Tuple<Message, Connection>> i = outgoingMessages.iterator(); 
 i.hasNext();)
 {
 Tuple<Message, Connection> t = i.next();
 if(!this.hasMessage(t.getKey().getId()))
 {
 i.remove();
 }
 }
 }

Added the missing variables:

/** how often TTL check (discarding old messages) is performed */
 public static int TTL_CHECK_INTERVAL = 60;
 /** sim time when the last TTL check was done */
 private double lastTtlCheck

 

Posted in ONE Simulator, Simulation, Social Data Analysis | Leave a comment

Scanning Interval Bug In The Opportunistic Network Environment, ONE Simulator 1.4.1

I think I've found a bug in the The Opportunistic Network Environment (ONE) Simulator version 1.4.1. Specifically in the code which checks if a node is scanning in the NetworkInterface class. I've been playing with scanInterval variable and it had no effect on the encounter statistics.

I've discovered that in this constructor:

/**
* copy constructor
*/
public NetworkInterface(NetworkInterface ni) {
this.connections = new ArrayList<Connection>();
this.address = getNextNetAddress();
this.host = ni.host;
this.cListeners = ni.cListeners;
this.interfacetype = ni.interfacetype;
this.transmitRange = ni.transmitRange;
this.transmitSpeed = ni.transmitSpeed;

/* draw lastScanTime of [0 -- scanInterval] */
this.lastScanTime = rng.nextDouble() * scanInterval;
}

The following line is missing:

this.scanInterval = ni.scanInterval;

This meant that isScanning()  would always return true. Adding the missing line to the above constructor appears to have fixed the bug.

Posted in ONE Simulator, Simulation | 3 Comments

Bash is exciting! Trimming a filename to get rid of the extension and a for loop

My girlfriend asked me to write a bash script which copies directories corresponding to a file name.

  1. Folder A contains 100 directories with files
  2. Folder B contains 60 graphml files

For each directory in A that has the same name as a graphml file in B, copy the directory to a new folder. E.g. you end up with 60 directories somewhere that correspond to the 60 graphml files.

Here's the code:

#!/bin/bash
for i in $(ls -d *.graphml); do cp -r /path/to/folderA/${i%.*} /path/to/NewLocation/; done

Save this as script.sh in the directory with the graphml files and remember to chmod +x script.sh to make the bash file executable. Or more likely use this as an example to make your own for loop in bash which loops over filenames.

This script will :

  1. Loop through the files in a directory excluding directories (actually it loops through each file ending in .graphml).
  2. Then trims the names to get rid of the file extension.
  3. Copies the corresponding directory in Folder A to a New Location.

Simple but I thought I'd share. Plus the world needs to know people who know shell scripting can have girlfriends too.

More:

shell scripting

Posted in Programming | Leave a comment