mirror of
https://github.com/gsi-upm/soil
synced 2024-12-23 00:28:11 +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']
|
||||
|
||||
def step(self):
|
||||
if self.count_neighboring_agents(state_id=0) == 0:
|
||||
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 )
|
||||
else:
|
||||
civilian_haven = False
|
||||
if self.state['id'] == 0:
|
||||
for neighbour_agent in self.get_neighboring_agents():
|
||||
if isinstance(neighbour_agent, TerroristSpreadModel) and neighbour_agent.state['id'] == 0:
|
||||
civilian_haven = True
|
||||
|
||||
if civilian_haven:
|
||||
self.state['id'] = 0 # Civilian Haven
|
||||
for neighbour in self.get_neighboring_agents():
|
||||
if isinstance(neighbour, TerroristSpreadModel) and neighbour.vulnerability > self.min_vulnerability:
|
||||
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):
|
||||
@ -234,7 +240,7 @@ class TerroristNetworkModel(TerroristSpreadModel):
|
||||
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) )
|
||||
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)
|
||||
break
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
name: TerroristNetworkModel_sim
|
||||
load_module: TerroristNetworkModel
|
||||
max_time: 500
|
||||
max_time: 200
|
||||
num_trials: 1
|
||||
network_params:
|
||||
generator: random_geometric_graph
|
||||
radius: 0.2
|
||||
# generator: geographical_threshold_graph
|
||||
# theta: 20
|
||||
n: 150
|
||||
n: 100
|
||||
network_agents:
|
||||
- agent_type: TerroristNetworkModel
|
||||
weight: 0.8
|
||||
@ -30,7 +30,7 @@ environment_params:
|
||||
# TerroristSpreadModel
|
||||
information_spread_intensity: 0.7
|
||||
terrorist_additional_influence: 0.035
|
||||
max_vulnerability: 0.6
|
||||
max_vulnerability: 0.7
|
||||
prob_interaction: 0.5
|
||||
|
||||
# TrainingAreaModel and HavenModel
|
||||
|
@ -271,7 +271,7 @@ var set_timeline = function(graph) {
|
||||
.attr('width', d3.select('svg #root > image').node().getBBox().width)
|
||||
.attr('height', d3.select('svg #root > image').node().getBBox().height);
|
||||
}
|
||||
}, 500);
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
// 'Speed' slider
|
||||
|
Loading…
Reference in New Issue
Block a user