1
0
mirror of https://github.com/gsi-upm/soil synced 2024-11-14 15:32:29 +00:00
soil/docs/_build/html/usage.html
2017-04-27 13:15:56 +02:00

196 lines
11 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Usage &#8212; Soil 0.1 documentation</title>
<link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '0.1',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt'
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Developing new models" href="models.html" />
<link rel="prev" title="Installation" href="installation.html" />
<link rel="stylesheet" href="_static/custom.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
</head>
<body role="document">
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="usage">
<h1>Usage<a class="headerlink" href="#usage" title="Permalink to this headline"></a></h1>
<p>First of all, you need to install the package. See <a class="reference internal" href="installation.html"><span class="doc">Installation</span></a> for installation instructions.</p>
<div class="section" id="simulation-settings">
<h2>Simulation Settings<a class="headerlink" href="#simulation-settings" title="Permalink to this headline"></a></h2>
<p>Once installed, before running a simulation, you need to configure it.</p>
<ul>
<li><p class="first">In the settings.py file you will find the configuration of the network.</p>
<div class="code python highlight-default"><div class="highlight"><pre><span></span><span class="c1"># Network settings</span>
<span class="n">network_type</span> <span class="o">=</span> <span class="mi">1</span>
<span class="n">number_of_nodes</span> <span class="o">=</span> <span class="mi">1000</span>
<span class="n">max_time</span> <span class="o">=</span> <span class="mi">50</span>
<span class="n">num_trials</span> <span class="o">=</span> <span class="mi">1</span>
<span class="n">timeout</span> <span class="o">=</span> <span class="mi">2</span>
</pre></div>
</div>
</li>
<li><p class="first">In the Simulation Settings JSON file, you will find the configuration of the models.</p>
</li>
</ul>
</div>
<div class="section" id="network-types">
<h2>Network Types<a class="headerlink" href="#network-types" title="Permalink to this headline"></a></h2>
<p>There are three types of network implemented, but you could add more.</p>
<div class="code python highlight-default"><div class="highlight"><pre><span></span><span class="k">if</span> <span class="n">settings</span><span class="o">.</span><span class="n">network_type</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
<span class="n">G</span> <span class="o">=</span> <span class="n">nx</span><span class="o">.</span><span class="n">complete_graph</span><span class="p">(</span><span class="n">settings</span><span class="o">.</span><span class="n">number_of_nodes</span><span class="p">)</span>
<span class="k">if</span> <span class="n">settings</span><span class="o">.</span><span class="n">network_type</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
<span class="n">G</span> <span class="o">=</span> <span class="n">nx</span><span class="o">.</span><span class="n">barabasi_albert_graph</span><span class="p">(</span><span class="n">settings</span><span class="o">.</span><span class="n">number_of_nodes</span><span class="p">,</span> <span class="mi">10</span><span class="p">)</span>
<span class="k">if</span> <span class="n">settings</span><span class="o">.</span><span class="n">network_type</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span>
<span class="n">G</span> <span class="o">=</span> <span class="n">nx</span><span class="o">.</span><span class="n">margulis_gabber_galil_graph</span><span class="p">(</span><span class="n">settings</span><span class="o">.</span><span class="n">number_of_nodes</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
<span class="c1"># More types of networks can be added here</span>
</pre></div>
</div>
</div>
<div class="section" id="models-settings">
<h2>Models Settings<a class="headerlink" href="#models-settings" title="Permalink to this headline"></a></h2>
<p>After having configured the simulation, the next step is setting up the variables of the models.
For this, you will need to modify the Simulation Settings JSON file.</p>
<div class="code json highlight-default"><div class="highlight"><pre><span></span><span class="p">{</span>
<span class="s2">&quot;agent&quot;</span><span class="p">:</span> <span class="p">[</span><span class="s2">&quot;SISaModel&quot;</span><span class="p">,</span><span class="s2">&quot;ControlModelM2&quot;</span><span class="p">],</span>
<span class="s2">&quot;neutral_discontent_spon_prob&quot;</span><span class="p">:</span> <span class="mf">0.04</span><span class="p">,</span>
<span class="s2">&quot;neutral_discontent_infected_prob&quot;</span><span class="p">:</span> <span class="mf">0.04</span><span class="p">,</span>
<span class="s2">&quot;neutral_content_spon_prob&quot;</span><span class="p">:</span> <span class="mf">0.18</span><span class="p">,</span>
<span class="s2">&quot;neutral_content_infected_prob&quot;</span><span class="p">:</span> <span class="mf">0.02</span><span class="p">,</span>
<span class="s2">&quot;discontent_neutral&quot;</span><span class="p">:</span> <span class="mf">0.13</span><span class="p">,</span>
<span class="s2">&quot;discontent_content&quot;</span><span class="p">:</span> <span class="mf">0.07</span><span class="p">,</span>
<span class="s2">&quot;variance_d_c&quot;</span><span class="p">:</span> <span class="mf">0.02</span><span class="p">,</span>
<span class="s2">&quot;content_discontent&quot;</span><span class="p">:</span> <span class="mf">0.009</span><span class="p">,</span>
<span class="s2">&quot;variance_c_d&quot;</span><span class="p">:</span> <span class="mf">0.003</span><span class="p">,</span>
<span class="s2">&quot;content_neutral&quot;</span><span class="p">:</span> <span class="mf">0.088</span><span class="p">,</span>
<span class="s2">&quot;standard_variance&quot;</span><span class="p">:</span> <span class="mf">0.055</span><span class="p">,</span>
<span class="s2">&quot;prob_neutral_making_denier&quot;</span><span class="p">:</span> <span class="mf">0.035</span><span class="p">,</span>
<span class="s2">&quot;prob_infect&quot;</span><span class="p">:</span> <span class="mf">0.075</span><span class="p">,</span>
<span class="s2">&quot;prob_cured_healing_infected&quot;</span><span class="p">:</span> <span class="mf">0.035</span><span class="p">,</span>
<span class="s2">&quot;prob_cured_vaccinate_neutral&quot;</span><span class="p">:</span> <span class="mf">0.035</span><span class="p">,</span>
<span class="s2">&quot;prob_vaccinated_healing_infected&quot;</span><span class="p">:</span> <span class="mf">0.035</span><span class="p">,</span>
<span class="s2">&quot;prob_vaccinated_vaccinate_neutral&quot;</span><span class="p">:</span> <span class="mf">0.035</span><span class="p">,</span>
<span class="s2">&quot;prob_generate_anti_rumor&quot;</span><span class="p">:</span> <span class="mf">0.035</span>
<span class="p">}</span>
</pre></div>
</div>
<p>In this file you will define the different models you are going to simulate. You can simulate as many models
as you want.</p>
<p>After setting up the models, you have to initialize the parameters of each one. You will find the parameters needed
in the documentation of each model.</p>
<p>Parameter validation will fail if a required parameter without a default has not been provided.</p>
</div>
<div class="section" id="running-the-simulation">
<h2>Running the Simulation<a class="headerlink" href="#running-the-simulation" title="Permalink to this headline"></a></h2>
<p>After setting all the configuration, you will be able to run the simulation. All you need to do is execute:</p>
<div class="code bash highlight-default"><div class="highlight"><pre><span></span><span class="n">python</span> <span class="n">soil</span><span class="o">.</span><span class="n">py</span>
</pre></div>
</div>
<p>The simulation will return a dynamic graph .gexf file which could be visualized with
<a class="reference external" href="https://gephi.org/users/download/">Gephi</a>.</p>
<p>It will also return one .png picture for each model simulated.</p>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Usage</a><ul>
<li><a class="reference internal" href="#simulation-settings">Simulation Settings</a></li>
<li><a class="reference internal" href="#network-types">Network Types</a></li>
<li><a class="reference internal" href="#models-settings">Models Settings</a></li>
<li><a class="reference internal" href="#running-the-simulation">Running the Simulation</a></li>
</ul>
</li>
</ul>
<div class="relations">
<h3>Related Topics</h3>
<ul>
<li><a href="index.html">Documentation overview</a><ul>
<li>Previous: <a href="installation.html" title="previous chapter">Installation</a></li>
<li>Next: <a href="models.html" title="next chapter">Developing new models</a></li>
</ul></li>
</ul>
</div>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/usage.rst.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<div><input type="text" name="q" /></div>
<div><input type="submit" value="Go" /></div>
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
&copy;2017, GSI.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 1.5.1</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.9</a>
|
<a href="_sources/usage.rst.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>