1
0
mirror of https://github.com/gsi-upm/soil synced 2024-11-25 20:32:29 +00:00

Fix py3.4 and pypi bugs

This commit is contained in:
J. Fernando Sánchez 2017-10-19 18:28:17 +02:00
parent a7c51742f6
commit a4b32afa2f
5 changed files with 10 additions and 104 deletions

View File

@ -4,3 +4,4 @@ networkx
numpy numpy
matplotlib matplotlib
pyyaml pyyaml
pandas

View File

@ -1,61 +0,0 @@
---
name: ControlModelM2_sim
max_time: 50
num_trials: 1
network_params:
generator: barabasi_albert_graph
n: 100
m: 2
network_agents:
- agent_type: ControlModelM2
weight: 0.1
state:
id: 1
- agent_type: ControlModelM2
weight: 0.9
state:
id: 0
environment_params:
prob_neutral_making_denier: 0.035
prob_infect: 0.075
prob_cured_healing_infected: 0.035
prob_cured_vaccinate_neutral: 0.035
prob_vaccinated_healing_infected: 0.035
prob_vaccinated_vaccinate_neutral: 0.035
prob_generate_anti_rumor: 0.035
standard_variance: 0.055
---
name: SISA_sm
max_time: 50
num_trials: 2
network_params:
generator: erdos_renyi_graph
n: 1000
p: 0.05
#other_agents:
# - agent_type: DrawingAgent
network_agents:
- agent_type: SISaModel
weight: 1
state:
id: content
- agent_type: SISaModel
weight: 1
state:
id: neutral
- agent_type: SISaModel
weight: 1
state:
id: discontent
environment_params:
neutral_discontent_spon_prob: 0.04
neutral_discontent_infected_prob: 0.04
neutral_content_spon_prob: 0.18
neutral_content_infected_prob: 0.02
discontent_neutral: 0.13
discontent_content: 0.07
variance_d_c: 0.02
content_discontent: 0.009
variance_c_d: 0.003
content_neutral: 0.088
standard_variance: 0.055

View File

@ -4,7 +4,7 @@ import os
import pdb import pdb
import logging import logging
__version__ = "0.10" __version__ = "0.10.1"
try: try:
basestring basestring

View File

@ -1,36 +1,4 @@
import importlib from . import main
import sys
import os
import argparse
import logging
from . import simulation
logger = logging.getLogger(__name__)
def main():
parser = argparse.ArgumentParser(description='Run a SOIL simulation')
parser.add_argument('file', type=str,
nargs="?",
default='simulation.yml',
help='python module containing the simulation configuration.')
parser.add_argument('--module', '-m', type=str,
help='file containing the code of any custom agents.')
parser.add_argument('--dry-run', '--dry', action='store_true',
help='Do not store the results of the simulation.')
parser.add_argument('--output', '-o', type=str,
help='folder to write results to. It defaults to the current directory.')
args = parser.parse_args()
if args.module:
sys.path.append(os.getcwd())
importlib.import_module(args.module)
print('Loading config file: {}'.format(args.file, args.output))
simulation.run_from_config(args.file, dump=not args.dry_run, results_dir=args.output)
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View File

@ -145,15 +145,13 @@ class SoilEnvironment(nxsim.NetworkEnvironment):
def __getitem__(self, key): def __getitem__(self, key):
if isinstance(key, tuple): if isinstance(key, tuple):
values = {"agent_id": key[0], values = [("agent_id", key[0]),
"t_step": key[1], ("t_step", key[1]),
"key": key[2], ("key", key[2]),
"value": None, ("value", None),
"value_type": None ("value_type", None)]
} fields = list(k for k, v in values if v is None)
conditions = " and ".join("{}='{}'".format(k, v) for k, v in values if v is not None)
fields = list(k for k, v in values.items() if v is None)
conditions = " and ".join("{}='{}'".format(k, v) for k, v in values.items() if v is not None)
query = """SELECT {fields} from history""".format(fields=",".join(fields)) query = """SELECT {fields} from history""".format(fields=",".join(fields))
if conditions: if conditions: