mirror of
https://github.com/gsi-upm/soil
synced 2024-11-22 19:22:29 +00:00
TerroristNetworkModel improved
This commit is contained in:
parent
a26bf637d4
commit
1083112473
@ -186,16 +186,22 @@ class HavenModel(BaseAgent):
|
|||||||
self.max_vulnerability = environment.environment_params['max_vulnerability']
|
self.max_vulnerability = environment.environment_params['max_vulnerability']
|
||||||
|
|
||||||
def step(self):
|
def step(self):
|
||||||
if self.count_neighboring_agents(state_id=0) == 0:
|
civilian_haven = False
|
||||||
self.state['id'] = 1 # Terrorism Haven
|
if self.state['id'] == 0:
|
||||||
for neighbour in self.get_neighboring_agents():
|
for neighbour_agent in self.get_neighboring_agents():
|
||||||
if isinstance(neighbour, TerroristSpreadModel) and neighbour.vulnerability < self.max_vulnerability:
|
if isinstance(neighbour_agent, TerroristSpreadModel) and neighbour_agent.state['id'] == 0:
|
||||||
neighbour.vulnerability = neighbour.vulnerability ** ( 1 - self.haven_influence )
|
civilian_haven = True
|
||||||
else:
|
|
||||||
|
if civilian_haven:
|
||||||
self.state['id'] = 0 # Civilian Haven
|
self.state['id'] = 0 # Civilian Haven
|
||||||
for neighbour in self.get_neighboring_agents():
|
for neighbour in self.get_neighboring_agents():
|
||||||
if isinstance(neighbour, TerroristSpreadModel) and neighbour.vulnerability > self.min_vulnerability:
|
if isinstance(neighbour, TerroristSpreadModel) and neighbour.vulnerability > self.min_vulnerability:
|
||||||
neighbour.vulnerability = neighbour.vulnerability * ( 1 - self.haven_influence )
|
neighbour.vulnerability = neighbour.vulnerability * ( 1 - self.haven_influence )
|
||||||
|
else:
|
||||||
|
self.state['id'] = 1 # Terrorism Haven
|
||||||
|
for neighbour in self.get_neighboring_agents():
|
||||||
|
if isinstance(neighbour, TerroristSpreadModel) and neighbour.vulnerability < self.max_vulnerability:
|
||||||
|
neighbour.vulnerability = neighbour.vulnerability ** ( 1 - self.haven_influence )
|
||||||
|
|
||||||
|
|
||||||
class TerroristNetworkModel(TerroristSpreadModel):
|
class TerroristNetworkModel(TerroristSpreadModel):
|
||||||
@ -234,7 +240,7 @@ class TerroristNetworkModel(TerroristSpreadModel):
|
|||||||
social_distance = 1 / self.shortest_path_length(self.global_topology, self.id, agent.id)
|
social_distance = 1 / self.shortest_path_length(self.global_topology, self.id, agent.id)
|
||||||
spatial_proximity = ( 1 - self.get_distance(self.global_topology, self.id, agent.id) )
|
spatial_proximity = ( 1 - self.get_distance(self.global_topology, self.id, agent.id) )
|
||||||
prob_new_interaction = self.weight_social_distance * social_distance + self.weight_link_distance * spatial_proximity
|
prob_new_interaction = self.weight_social_distance * social_distance + self.weight_link_distance * spatial_proximity
|
||||||
if random.random() < prob_new_interaction:
|
if agent.state['id'] == 0 and random.random() < prob_new_interaction:
|
||||||
self.add_edge(self.global_topology, self, agent)
|
self.add_edge(self.global_topology, self, agent)
|
||||||
break
|
break
|
||||||
|
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
name: TerroristNetworkModel_sim
|
name: TerroristNetworkModel_sim
|
||||||
load_module: TerroristNetworkModel
|
load_module: TerroristNetworkModel
|
||||||
max_time: 500
|
max_time: 200
|
||||||
num_trials: 1
|
num_trials: 1
|
||||||
network_params:
|
network_params:
|
||||||
generator: random_geometric_graph
|
generator: random_geometric_graph
|
||||||
radius: 0.2
|
radius: 0.2
|
||||||
# generator: geographical_threshold_graph
|
# generator: geographical_threshold_graph
|
||||||
# theta: 20
|
# theta: 20
|
||||||
n: 150
|
n: 100
|
||||||
network_agents:
|
network_agents:
|
||||||
- agent_type: TerroristNetworkModel
|
- agent_type: TerroristNetworkModel
|
||||||
weight: 0.8
|
weight: 0.8
|
||||||
@ -30,7 +30,7 @@ environment_params:
|
|||||||
# TerroristSpreadModel
|
# TerroristSpreadModel
|
||||||
information_spread_intensity: 0.7
|
information_spread_intensity: 0.7
|
||||||
terrorist_additional_influence: 0.035
|
terrorist_additional_influence: 0.035
|
||||||
max_vulnerability: 0.6
|
max_vulnerability: 0.7
|
||||||
prob_interaction: 0.5
|
prob_interaction: 0.5
|
||||||
|
|
||||||
# TrainingAreaModel and HavenModel
|
# TrainingAreaModel and HavenModel
|
||||||
|
@ -271,7 +271,7 @@ var set_timeline = function(graph) {
|
|||||||
.attr('width', d3.select('svg #root > image').node().getBBox().width)
|
.attr('width', d3.select('svg #root > image').node().getBBox().width)
|
||||||
.attr('height', d3.select('svg #root > image').node().getBBox().height);
|
.attr('height', d3.select('svg #root > image').node().getBBox().height);
|
||||||
}
|
}
|
||||||
}, 500);
|
}, 1000);
|
||||||
});
|
});
|
||||||
|
|
||||||
// 'Speed' slider
|
// 'Speed' slider
|
||||||
|
Loading…
Reference in New Issue
Block a user