mirror of
				https://github.com/gsi-upm/soil
				synced 2025-10-30 23:28:17 +00:00 
			
		
		
		
	Removed useless imports
This commit is contained in:
		| @@ -1,74 +0,0 @@ | ||||
| import random | ||||
| import time | ||||
|  | ||||
| settings = { | ||||
|     "empresas": ["BBVA", "Santander"] | ||||
| } | ||||
|  | ||||
| class BaseNetworkAgent: | ||||
|  | ||||
|     def __init__(self, *args, **kwargs): | ||||
|         super().__init__(*args, **kwargs) | ||||
|         self.id = random.random() | ||||
|  | ||||
|     @property | ||||
|     def env(self): | ||||
|         class T(object): | ||||
|             pass | ||||
|  | ||||
|         temp = T() | ||||
|         temp.now = time.time() | ||||
|         return temp | ||||
|  | ||||
|  | ||||
| def agentes_a_json(agentes): | ||||
|     final = {} | ||||
|     for agente in agentes: | ||||
|         for stamp, attrs in self._attrs.items(): | ||||
|             for a in attrs: | ||||
|                 if a not in final: | ||||
|                    final[a] = {} | ||||
|                 final[a][stamp] = attrs[a] | ||||
|     return final | ||||
|  | ||||
| class ComportamientoBase(BaseNetworkAgent): | ||||
|     def __init__(self, *args, **kwargs): | ||||
|         self._attrs = {} | ||||
|  | ||||
|     @property | ||||
|     def attrs(self): | ||||
|         now = self.env.now | ||||
|         if now not in self._attrs: | ||||
|             self._attrs[now] = {} | ||||
|         return self._attrs[now] | ||||
|  | ||||
|     @attrs.setter | ||||
|     def attrs(self, value): | ||||
|         self._attrs[self.env.now] = value | ||||
|  | ||||
|     def run(self): | ||||
|         while True: | ||||
|             self.step(self.env.now) | ||||
|             #yield self.env.timeout(settings.timeout) | ||||
|  | ||||
|     def step(self, now): | ||||
|         pass | ||||
|  | ||||
|     def a_json(self): | ||||
|         final = {} | ||||
|         for stamp, attrs in self._attrs.items(): | ||||
|             for a in attrs: | ||||
|                 if a not in final: | ||||
|                    final[a] = {} | ||||
|                 final[a][stamp] = attrs[a] | ||||
|         return final | ||||
|  | ||||
| class NuevoComportamiento(ComportamientoBase): | ||||
|  | ||||
|     def __init__(self, *args, **kwargs): | ||||
|         super().__init__(*args, **kwargs) | ||||
|         self.empresas = settings["empresas"] | ||||
|  | ||||
|     def step(self, now): | ||||
|         for i in self.empresas: | ||||
|             self.attrs['sentimiento_empresa_%s' % i] = random.random() | ||||
							
								
								
									
										11
									
								
								models.py
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								models.py
									
									
									
									
									
								
							| @@ -1,12 +1,5 @@ | ||||
| from nxsim import NetworkSimulation | ||||
| from nxsim import BaseNetworkAgent | ||||
| from nxsim import BaseLoggingAgent | ||||
| from random import randint | ||||
| from pprint import pprint | ||||
| from matplotlib import pyplot as plt | ||||
| import random | ||||
| import numpy as np | ||||
| import networkx as nx | ||||
| import settings | ||||
|  | ||||
| settings.init() | ||||
| @@ -16,7 +9,7 @@ settings.init() | ||||
| ############################## | ||||
| def init(): | ||||
|     global networkStatus | ||||
|     networkStatus={} # Dict that will contain the status of every agent in the network | ||||
|     networkStatus = {}  # Dict that will contain the status of every agent in the network | ||||
|  | ||||
| sentimentCorrelationNodeArray=[] | ||||
| for x in range(0, settings.number_of_nodes): | ||||
| @@ -223,13 +216,11 @@ class SentimentCorrelationModel(ComportamientoBase): | ||||
|  | ||||
|         if(num<anger_prob): | ||||
|  | ||||
|  | ||||
|             self.state['id'] = 1 | ||||
|             sentimentCorrelationNodeArray[self.id][self.env.now]=1 | ||||
|             self.time_awareness[self.state['id']-1] = self.env.now | ||||
|         elif (num<joy_prob+anger_prob and num>anger_prob): | ||||
|  | ||||
|  | ||||
|             self.state['id'] = 2 | ||||
|             sentimentCorrelationNodeArray[self.id][self.env.now]=2 | ||||
|             self.time_awareness[self.state['id']-1] = self.env.now | ||||
|   | ||||
							
								
								
									
										4
									
								
								soil.py
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								soil.py
									
									
									
									
									
								
							| @@ -1,10 +1,6 @@ | ||||
| #from clase_base import * | ||||
| from models import * | ||||
| from nxsim import NetworkSimulation | ||||
| from nxsim import BaseNetworkAgent | ||||
| from nxsim import BaseLoggingAgent | ||||
| import random | ||||
| import numpy as np | ||||
| import networkx as nx | ||||
| import settings | ||||
| import models | ||||
|   | ||||
							
								
								
									
										
											BIN
										
									
								
								status.png
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								status.png
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							| Before Width: | Height: | Size: 13 KiB | 
		Reference in New Issue
	
	Block a user