def create(self, agent_cls=None, n_agents=10, agent_kwargs={},
               env_cls=Environment, env_kwargs={}, callback=None, conns=0,
               log_folder=None):
        """A convenience function to create simple simulations.

        Method first creates environment, then instantiates agents into it
        with give arguments, and finally creates simulation for the
        environment.

        :param agent_cls:
            class for agents, or list of classes. If list, then **n_agents**
            and **agent_kwargs** are expected to be lists also.

        :param n_agents:
            amount of agents for simulation, or list of amounts

        :param agent_kwargs:
            keyword arguments passed to agents at creation time, or list of
            keyword arguments.

        :param env_cls:
            environment class for simulation

        :type env_cls:
            :py:class:`~creamas.core.environment.Environment`

        :param dict env_kwargs:
            keyword arguments passed to environment at creation time

        :param callable callback:
            optional callable to call after each simulation step

        :param conns:
            Create **conns** amount of initial (random) connections for agents
            in the simulation environment.

        :param str log_folder:
            folder for possible logging. This overwrites *log_folder* keyword
            argument from **agent_kwargs** and **env_kwargs**.
        """
        if not issubclass(env_cls, Environment):
            raise TypeError("Environment class must be derived from ({}"
                            .format(Environment.__class__.__name__))
        if callback is not None and not hasattr(callback, '__call__'):
            raise TypeError("Callback must be callable.")

        if hasattr(agent_cls, '__iter__'):
            for e in agent_cls:
                if not issubclass(e, CreativeAgent):
                    raise TypeError("All agent classes must be derived from {}"
                                    .format(CreativeAgent.__class__.__name__))
        else:
            if not issubclass(agent_cls, CreativeAgent):
                raise TypeError("Agent class must be derived from {}"
                                .format(CreativeAgent.__class__.__name__))

        env = env_cls.create(**env_kwargs)

        agents = []
        if hasattr(agent_cls, '__iter__'):
            for i in range(len(n_agents)):
                agent_kwargs[i]['environment'] = env
                agent_kwargs[i]['log_folder'] = log_folder
                agents = agents + [agent_cls[i](**agent_kwargs[i]) for e in
                                   range(n_agents[i])]
        else:
            agent_kwargs['environment'] = env
            agent_kwargs['log_folder'] = log_folder
            agents = [agent_cls(**agent_kwargs) for e in range(n_agents)]

        if conns > 0:
            env.create_random_connections(n=conns)

        return Simulation(env, callback, log_folder)
def create ( self , agent_cls = None , n_agents = 10 , agent_kwargs = { } , env_cls = Environment , env_kwargs = { } , callback = None , conns = 0 , log_folder = None ) : if not issubclass ( env_cls , Environment ) : raise TypeError ( "Environment class must be derived from ({}" . format ( Environment . __class__ . __name__ ) ) if callback is not None and not hasattr ( callback , '__call__' ) : raise TypeError ( "Callback must be callable." ) if hasattr ( agent_cls , '__iter__' ) : for e in agent_cls : if not issubclass ( e , CreativeAgent ) : raise TypeError ( "All agent classes must be derived from {}" . format ( CreativeAgent . __class__ . __name__ ) ) else : if not issubclass ( agent_cls , CreativeAgent ) : raise TypeError ( "Agent class must be derived from {}" . format ( CreativeAgent . __class__ . __name__ ) ) env = env_cls . create ( ** env_kwargs ) agents = [ ] if hasattr ( agent_cls , '__iter__' ) : for i in range ( len ( n_agents ) ) : agent_kwargs [ i ] [ 'environment' ] = env agent_kwargs [ i ] [ 'log_folder' ] = log_folder agents = agents + [ agent_cls [ i ] ( ** agent_kwargs [ i ] ) for e in range ( n_agents [ i ] ) ] else : agent_kwargs [ 'environment' ] = env agent_kwargs [ 'log_folder' ] = log_folder agents = [ agent_cls ( ** agent_kwargs ) for e in range ( n_agents ) ] if conns > 0 : env . create_random_connections ( n = conns ) return Simulation ( env , callback , log_folder )
A convenience function to create simple simulations.

        Method first creates environment, then instantiates agents into it
        with give arguments, and finally creates simulation for the
        environment.

        :param agent_cls:
            class for agents, or list of classes. If list, then **n_agents**
            and **agent_kwargs** are expected to be lists also.

        :param n_agents:
            amount of agents for simulation, or list of amounts

        :param agent_kwargs:
            keyword arguments passed to agents at creation time, or list of
            keyword arguments.

        :param env_cls:
            environment class for simulation

        :type env_cls:
            :py:class:`~creamas.core.environment.Environment`

        :param dict env_kwargs:
            keyword arguments passed to environment at creation time

        :param callable callback:
            optional callable to call after each simulation step

        :param conns:
            Create **conns** amount of initial (random) connections for agents
            in the simulation environment.

        :param str log_folder:
            folder for possible logging. This overwrites *log_folder* keyword
            argument from **agent_kwargs** and **env_kwargs**.