mlpy.agents.modules.AgentModuleFactory

class mlpy.agents.modules.AgentModuleFactory[source]

Bases: object

The agent module factory.

An instance of an agent module can be created by passing the agent module type. The module type is the name of the module. The set of agent modules can be extended by inheriting from IAgentModule. However, for the agent module to be registered, the custom module must be imported by the time the agent module factory is called.

Notes

The agent module factory is being called by the Agent during initialization to create the agents controller.

Examples

>>> from mlpy.agents.modules import AgentModuleFactory
>>> AgentModuleFactory.create('learningmodule', 'qlearner', alpha=0.5)

This creates a LearningModule instance performing q-learning with the learning rate alpha set to 0.5.

>>> from mlpy.mdp.discrete import DiscreteModel
>>> from mlpy.planners.discrete import ValueIteration
>>>
>>> planner = ValueIteration(DiscreteModel(['out', 'in', 'kick']))
>>>
>>> AgentModuleFactory().create('learningmodule', 'modelbasedlearner', planner)

This creates a learning module using the ModelBasedLearner. The parameters for the learner are appended to the end of the argument list.

Alternatively non-positional arguments can be used:

>>> AgentModuleFactory().create('learningmodule', 'modelbasedlearner', planner=planner)

Methods

create(_type, *args, **kwargs) Create an agent module of the given type.