test.gaml 3.12 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
/**
 *  test
 *  Author: Thibaut
 *  Description: 
 */

model test


global {
	
	
	init {
Thibaut Démare's avatar
Thibaut Démare committed
14
		// Clear all previous senders
15 16
		gs_clear_senders;
		
Thibaut Démare's avatar
Thibaut Démare committed
17 18
		// Add a new sender on localhost:2001
		gs_add_sender gs_host:"localhost" gs_port:2001 gs_sender_id:"test1";
19 20
		
		// Create three nodes
Thibaut Démare's avatar
Thibaut Démare committed
21 22 23
		gs_add_node gs_sender_id:"test1" gs_node_id:"node1";
		gs_add_node gs_sender_id:"test1" gs_node_id:"node2";
		gs_add_node gs_sender_id:"test1" gs_node_id:"node3";
24
		
Thibaut Démare's avatar
Thibaut Démare committed
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
		// Create one directed edge and one undirected edge
		gs_add_edge gs_sender_id:"test1" gs_edge_id:"edge1" gs_node_id_from:"node1" gs_node_id_to:"node2" gs_is_directed:true;
		gs_add_edge gs_sender_id:"test1" gs_edge_id:"edge2" gs_node_id_from:"node2" gs_node_id_to:"node3" gs_is_directed:false;
		
		
		// Add attributes on edge
			// A string attribute
		gs_add_edge_attribute gs_sender_id:"test1" gs_edge_id:"edge1" gs_attribute_name:"string" gs_attribute_value:"a string value";
			// A double attribute
		gs_add_edge_attribute gs_sender_id:"test1" gs_edge_id:"edge1" gs_attribute_name:"double" gs_attribute_value:10.0;
			// An integer attribute
		gs_add_edge_attribute gs_sender_id:"test1" gs_edge_id:"edge1" gs_attribute_name:"integer" gs_attribute_value:1;
			// A boolean attribute
		gs_add_edge_attribute gs_sender_id:"test1" gs_edge_id:"edge1" gs_attribute_name:"boolean" gs_attribute_value:true;
			// A list attribute
Thibaut Démare's avatar
Thibaut Démare committed
40
		gs_add_edge_attribute gs_sender_id:"test1" gs_edge_id:"edge1" gs_attribute_name:"list" gs_attribute_value:[1,2,3];
Thibaut Démare's avatar
Thibaut Démare committed
41 42
		
		// Step
Thibaut Démare's avatar
Thibaut Démare committed
43
		gs_step gs_sender_id:"test1" gs_step_number:1;
Thibaut Démare's avatar
Thibaut Démare committed
44
		
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
		// Add attributes on node
			// A string attribute
		gs_add_node_attribute gs_sender_id:"test1" gs_node_id:"node1" gs_attribute_name:"string" gs_attribute_value:"a string value";
			// A double attribute
		gs_add_node_attribute gs_sender_id:"test1" gs_node_id:"node1" gs_attribute_name:"double" gs_attribute_value:10.0;
			// An integer attribute
		gs_add_node_attribute gs_sender_id:"test1" gs_node_id:"node1" gs_attribute_name:"integer" gs_attribute_value:1;
			// A boolean attribute
		gs_add_node_attribute gs_sender_id:"test1" gs_node_id:"node1" gs_attribute_name:"boolean" gs_attribute_value:true;
			// A list attribute
		gs_add_node_attribute gs_sender_id:"test1" gs_node_id:"node1" gs_attribute_name:"list" gs_attribute_value:[1,2,3];
		
		// Step
		gs_step gs_sender_id:"test1" gs_step_number:2;
		
Thibaut Démare's avatar
Thibaut Démare committed
60 61 62 63 64 65
		//Remove edge
		gs_remove_edge gs_sender_id:"test1" gs_edge_id:"edge2";
		
		// Remove node
		gs_remove_node gs_sender_id:"test1" gs_node_id:"node3";
		
66 67 68 69 70 71
		// Remove edge attribute
		gs_remove_edge_attribute gs_sender_id:"test1" gs_edge_id:"edge1" gs_attribute_name:"string";
		
		// Step
		gs_step gs_sender_id:"test1" gs_step_number:3;
		
Thibaut Démare's avatar
Thibaut Démare committed
72
		// Clear
Thibaut Démare's avatar
Thibaut Démare committed
73
		//gs_clear gs_sender_id:"test1";
Thibaut Démare's avatar
Thibaut Démare committed
74 75
		
		// Close
Thibaut Démare's avatar
Thibaut Démare committed
76
		//gs_close gs_sender_id:"test1";
Thibaut Démare's avatar
Thibaut Démare committed
77 78
		
		// If the previous command has worked, the next one should work too
Thibaut Démare's avatar
Thibaut Démare committed
79
		//gs_add_sender gs_host:"localhost" gs_port:2001 gs_sender_id:"test1";
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
	}
}

species Provider {
	
	
	aspect base { 
		draw square(1.5°km) color: rgb([100, 0, 100]) ;
	} 
}

experiment test_gs_extension type: gui {
	output {
		display display_FinalDestinationManager {
			species Provider aspect: base;
		}
	}
}