Compare commits
2 Commits
be65592055
...
50bca88362
Author | SHA1 | Date |
---|---|---|
J. Fernando Sánchez | 50bca88362 | 1 year ago |
J. Fernando Sánchez | cc238d84ec | 1 year ago |
@ -1,7 +1,7 @@
|
|||||||
What are the main changes between version 0.3 and 0.2?
|
What are the main changes in version 1.0?
|
||||||
######################################################
|
#########################################
|
||||||
|
|
||||||
Version 0.3 is a major rewrite of the Soil system, focused on simplifying the API, aligning it with Mesa, and making it easier to use.
|
Version 1.0 is a major rewrite of the Soil system, focused on simplifying the API, aligning it with Mesa, and making it easier to use.
|
||||||
Unfortunately, this comes at the cost of backwards compatibility.
|
Unfortunately, this comes at the cost of backwards compatibility.
|
||||||
|
|
||||||
We drew several lessons from the previous version of Soil, and tried to address them in this version.
|
We drew several lessons from the previous version of Soil, and tried to address them in this version.
|
Before Width: | Height: | Size: 7.0 KiB |
After Width: | Height: | Size: 4.7 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 5.3 KiB |
Before Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 19 KiB |
@ -1,33 +0,0 @@
|
|||||||
---
|
|
||||||
name: quickstart
|
|
||||||
num_trials: 1
|
|
||||||
max_time: 1000
|
|
||||||
model_params:
|
|
||||||
agents:
|
|
||||||
- agent_class: SISaModel
|
|
||||||
topology: true
|
|
||||||
state:
|
|
||||||
id: neutral
|
|
||||||
weight: 1
|
|
||||||
- agent_class: SISaModel
|
|
||||||
topology: true
|
|
||||||
state:
|
|
||||||
id: content
|
|
||||||
weight: 2
|
|
||||||
topology:
|
|
||||||
params:
|
|
||||||
n: 100
|
|
||||||
k: 5
|
|
||||||
p: 0.2
|
|
||||||
generator: newman_watts_strogatz_graph
|
|
||||||
neutral_discontent_spon_prob: 0.05
|
|
||||||
neutral_discontent_infected_prob: 0.1
|
|
||||||
neutral_content_spon_prob: 0.2
|
|
||||||
neutral_content_infected_prob: 0.4
|
|
||||||
discontent_neutral: 0.2
|
|
||||||
discontent_content: 0.05
|
|
||||||
content_discontent: 0.05
|
|
||||||
variance_d_c: 0.05
|
|
||||||
variance_c_d: 0.1
|
|
||||||
content_neutral: 0.1
|
|
||||||
standard_variance: 0.1
|
|
@ -1,7 +1,7 @@
|
|||||||
from soil import Simulation
|
from soil import Simulation
|
||||||
from social_wealth import MoneyEnv, graph_generator
|
from social_wealth import MoneyEnv, graph_generator
|
||||||
|
|
||||||
sim = Simulation(name="mesa_sim", dump=False, max_steps=10, interval=2, model=MoneyEnv, model_params=dict(generator=graph_generator, N=10, width=50, height=50))
|
sim = Simulation(name="mesa_sim", dump=False, max_steps=10, interval=2, model=MoneyEnv, parameters=dict(generator=graph_generator, N=10, width=50, height=50))
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
sim.run()
|
sim.run()
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
[metadata]
|
||||||
|
long_description = file: README.md
|
||||||
|
long_description_content_type = text/markdown
|
||||||
|
|
||||||
[aliases]
|
[aliases]
|
||||||
test=pytest
|
test=pytest
|
||||||
[tool:pytest]
|
[tool:pytest]
|
||||||
|
@ -1 +1 @@
|
|||||||
0.30.0rc4
|
1.0.0rc1
|
@ -0,0 +1,49 @@
|
|||||||
|
import os
|
||||||
|
import sqlalchemy
|
||||||
|
import pandas as pd
|
||||||
|
from collections import namedtuple
|
||||||
|
|
||||||
|
def plot(env, agent_df=None, model_df=None, steps=False, ignore=["agent_count", ]):
|
||||||
|
"""Plot the model dataframe and agent dataframe together."""
|
||||||
|
if agent_df is None:
|
||||||
|
agent_df = env.agent_df()
|
||||||
|
if model_df is None:
|
||||||
|
model_df = env.model_df()
|
||||||
|
ignore = list(ignore)
|
||||||
|
if not steps:
|
||||||
|
ignore.append("step")
|
||||||
|
else:
|
||||||
|
ignore.append("time")
|
||||||
|
|
||||||
|
ax = model_df.drop(ignore, axis='columns').plot();
|
||||||
|
if not agent_df.empty:
|
||||||
|
agent_df.unstack().apply(lambda x: x.value_counts(),
|
||||||
|
axis=1).fillna(0).plot(ax=ax, secondary_y=True);
|
||||||
|
|
||||||
|
Results = namedtuple("Results", ["config", "parameters", "env", "agents"])
|
||||||
|
#TODO implement reading from CSV and SQLITE
|
||||||
|
def read_sql(fpath=None, name=None, include_agents=False):
|
||||||
|
if not (fpath is None) ^ (name is None):
|
||||||
|
raise ValueError("Specify either a path or a simulation name")
|
||||||
|
if name:
|
||||||
|
fpath = os.path.join("soil_output", name, f"{name}.sqlite")
|
||||||
|
fpath = os.path.abspath(fpath)
|
||||||
|
# TODO: improve url parsing. This is a hacky way to check we weren't given a URL
|
||||||
|
if "://" not in fpath:
|
||||||
|
fpath = f"sqlite:///{fpath}"
|
||||||
|
engine = sqlalchemy.create_engine(fpath)
|
||||||
|
with engine.connect() as conn:
|
||||||
|
env = pd.read_sql_table("env", con=conn,
|
||||||
|
index_col="step").reset_index().set_index([
|
||||||
|
"simulation_id", "params_id",
|
||||||
|
"iteration_id", "step"
|
||||||
|
])
|
||||||
|
agents = pd.read_sql_table("agents", con=conn, index_col=["simulation_id", "params_id", "iteration_id", "step", "agent_id"])
|
||||||
|
config = pd.read_sql_table("configuration", con=conn, index_col="simulation_id")
|
||||||
|
parameters = pd.read_sql_table("parameters", con=conn, index_col=["iteration_id", "params_id", "simulation_id"])
|
||||||
|
try:
|
||||||
|
parameters = parameters.pivot(columns="key", values="value")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"warning: coult not pivot parameters: {e}")
|
||||||
|
|
||||||
|
return Results(config, parameters, env, agents)
|
Before Width: | Height: | Size: 1.1 MiB |
Before Width: | Height: | Size: 8.0 MiB |