Graphical User Interface

python -m shows the simulation results in ./result/*

abcegui.gui(parameters, names=None, title=None, text=None, self_hosted=True, truncate_initial_rounds=0)

gui is a decorator that can be used to add a graphical user interface to your simulation.



a dictionary with the parameter name as key and an example value as value. Instead of the example value you can also put a tuple: (min, default, max)

parameters can be:
  • float:
    {‘exponent’: (0.0, 0.5, 1.1)}
  • int:
    {‘num_firms’: (0, 100, 100000)}
  • dict or list, which should be strings of a dict or a list (see example):
    {‘list_to_edit’: “[‘brd’, ‘mlk’, ‘add’]”}
  • everything else that can be evaluated as a string, see (eval)[]
  • a list of options:
    {‘several_options’: [‘opt_1’, ‘opt_2’, ‘opt_3’]}
  • a string:
    {‘name’: ‘2x2’}
names (optional):
a dictionary with the parameter name as key and an alternative text to be displayed instead.
a string with the name of the simulation.
a description text of the simulation. Can be html.
Does not display the initial x rounds
If you run this on your local machine self_hosted must be True. If used with an uWSGI/Nginx or different web server must be False


simulation_parameters = {'name': 'name',
                     'trade_logging': 'off',
                     'random_seed': None,
                     'num_rounds': 40,
                     'num_firms': (0, 100, 100000),
                     'num_household': (0, 100, 100000),
                     'exponent': (0.0, 0.5, 1.1),
                     'several_options': ['opt_1', 'opt_2', 'opt_3']
                     'list_to_edit': "['brd', 'mlk', 'add']",
                     'dictionary_to_edit': "{'v1': 1, 'v2': 2}"}

names = {'num_firms': 'Number of Firms'}

@gui(parameters, simulation_parameters, names=names)
def main(simulation_parameters):
    w = Simulation(simulation_parameters)
    action_list = [
    ('household', 'sell_labor'),
    ('firm', 'buy_inputs'),
    ('firm', 'production')]

    w.build_agents(Firm, simulation_parameters['num_firms'])
    w.build_agents(Household, simulation_parameters['num_households'])

if __name__ == '__main__':
Simulation.graphs(open=True, new=1)[source]

after the simulation is run, graphs() shows graphs of all data collected in the simulation. Shows the same output as the @gui decorator shows.


open (True/False):
whether to open a new window
If new is 0, the url is opened in the same browser window if possible. If new is 1, a new browser window is opened if possible. If new is 2, a new browser page (tab) is opened if possible.


simulation = Simulation(...)
for r in range(100):


It is possible to add text frames between the simulation results. In order to add a text frame to the simulation output, simply add a text file .txt or .html in either your source code directory or if generated during the simulation in the simulation.path directory (where the .csv are). The first line of the text file is the title the rest the text. The text can be formatted as html, the first line is separate from the rest. In the simulation results all frames are displayed in alphabetical order, the title in the first line of the text-file determines the position where the text frame is displayed. In order to display a text before all graphs, you have to put leading space (‘ ‘) in front of the title.