You are here

Model entry

Defining an association using a data file - Model catalogue - Simulistics.com

Search Simulistics Model catalogue Listed by keyword Listed by ID Listed by title Listed by date added

Defining an association using a data file

Model : assoc_from_data1
Simile version : 3.1+
Date added : 2003-06-20
Keywords : Association submodel ;

Description

An association between objects can often be worked out using a formula. For example, you can work out that pairs of grid squares are next to each other (“the 'next-to' association between grid squares”) knowing the row and column of each square. However, sometimes this is difficult or simply impossible. For example, you may want to represent which person is friends with another person: all you can do is provide data on the pairs of people that are friends with each other.

This model shows how to specify such an association. The particular context is that of spatial paches, and the association we are representing is that of one patch being a neighbour of another. However, you should be able to apply the solution to analogous problems, such as the 'friendship' one above, the trade connections between countries, or a network of towns connected by roads.

Note that this model doesn’t actually do anything: it’s only job is to show you how to specify the association from data. In reality, you will probably want to put dynamics into each patch, and to pass information from one patch to its neighbours - there’s no point in representing which are neighbours unless you do this.

This model makes use of two data files. The main one is a CSV (comma-separated value) file, which can either be edited by hand, or exported from a spreadsheet. This contains two columns of data, with headers. The following is an example:

ID1,ID2
1,2
1,4
2,5
3,4
3,5
4,5
       

It would be a good exercise to set this up yourself.

Files

Model file

Click on the icon to download the model file. (You will need Simile to examine and run the model. A free evaluation version is available from the products page.)

Some browsers may attempt to display the model file, rather than open it in Simile; in this case, use the browser back button to return to this page, and use the context menu (invoked by right-clicking on the link) to save the target file to disk.

assoc_from_data1.sml

Diagram

Equations

	Equations in Patch
	ID = index(1)
	
	Equations in Neighbour
	condition = (any(ID1 == [ID1]and ID2 == [ID2]) or any(ID1 == [ID2]and ID2 == [ID1]))
	where:
	  ID1 = Patch/ID (from Patch in role1)
	  ID2 = Patch/ID (from Patch in role2)
	  [ID1] = Neighbour data/ID1
	  [ID2] = Neighbour data/ID2
	
	Equations in Neighbour data
	ID1: read from .csv file
	ID2: read from .csv file