Пример #1
0
    def __init__(self,
                 name='platform',
                 maxTask=1,
                 synchronous=False,
                 queueSystem=None,
                 settings=None,
                 logHandlers=[],
                 **kwargs):
        # A platform can contains many queues
        if queueSystem is None:
            self.queue_system = QueueSystem()
        else:
            self.queue_system = queueSystem
        self.settings = {'MAX_TASK':maxTask,
                         'SYNCHRONOUS':synchronous,
                         'OPTIONS':None}
        if settings is not None:
            self.settings.update(settings)
        self.settings.update(kwargs)

        # Running information
        self.running = {}
        self.task_id = 0
        Agent.__init__(self, name=name, logHandlers=logHandlers)
        self.message_handlers['inform-task-finish'] = self.finalize_task
        self.message_handlers['cfp-cancel-queue'] = self.cancel_queue
        return
Пример #2
0
    def __init__(self,
                 name=None,
                 taskId=None,
                 command=None,
                 sessionTag=None,
                 input=None,
                 output='/dev/null',
                 logHandlers=[]):
        '''

        Each task object correspond to an application of the target
        algorithm on a test problem.

        '''
        self.task_id = taskId # task_id is assigned by platform
        self.command = command
        self.output = output
        if name is None:
            Agent.__init__(self, name=command, logHandlers=logHandlers)
        else:
            Agent.__init__(self, name=name, logHandlers=logHandlers)
        if sessionTag is None:
            self.session_tag = self.name
        else:
            self.session_tag = sessionTag
        return
Пример #3
0
    def __init__(self,
                 name='platform',
                 maxTask=1,
                 synchronous=False,
                 queueSystem=None,
                 settings=None,
                 logHandlers=[],
                 **kwargs):
        # A platform can contains many queues
        if queueSystem is None:
            self.queue_system = QueueSystem()
        else:
            self.queue_system = queueSystem
        self.settings = {
            'MAX_TASK': maxTask,
            'SYNCHRONOUS': synchronous,
            'OPTIONS': None
        }
        if settings is not None:
            self.settings.update(settings)
        self.settings.update(kwargs)

        # Running information
        self.running = {}
        self.task_id = 0
        Agent.__init__(self, name=name, logHandlers=logHandlers)
        self.message_handlers['inform-task-finish'] = self.finalize_task
        self.message_handlers['cfp-cancel-queue'] = self.cancel_queue
        return
Пример #4
0
    def __init__(self,
                 name=None,
                 taskId=None,
                 command=None,
                 sessionTag=None,
                 input=None,
                 output='/dev/null',
                 logHandlers=[]):
        '''

        Each task object correspond to an application of the target 
        algorithm on a test problem.

        '''
        self.task_id = taskId  # task_id is assigned by platform
        self.command = command
        self.output = output
        if name is None:
            Agent.__init__(self, name=command, logHandlers=logHandlers)
        else:
            Agent.__init__(self, name=name, logHandlers=logHandlers)
        if sessionTag is None:
            self.session_tag = self.name
        else:
            self.session_tag = sessionTag
        return
Пример #5
0
    def __init__(self,
                 name='function evaluator',
                 function=None,
                 functionFile=None,
                 logHandlers=[],
                 **kwargs):
        Agent.__init__(self,
                       name=name,
                       logHandlers=logHandlers)
        if function is None:
            if functionFile is not None:
                # The model is loaded by pickling
                # Be able to be serialized is a requirement for
                # a model object
                f = open(functionFile)
                function = pickle.load(f)
                f.close()
        if function is None:
            raise Exception("Error in creating an evaluator")
        
        self.function = function

        self.message_handlers['cfp-evaluate-point'] =  self.evaluate
                                                        
        return
Пример #6
0
def test_multi_agent_framework():
    from mafrw import Agent
    from mafrw import Environment

    agent = Agent()
    env = Environment()

    agent.register(env)
Пример #7
0
def test_multi_agent_framework():
    from mafrw import Agent
    from mafrw import Environment

    agent = Agent()
    env = Environment()
    
    agent.register(env)
Пример #8
0
 def __init__(self,
              name='data manager',
              rows=None,
              columns=None,
              storage=None,
              logHandlers=[]):
     self.file_name = 'data_storage.txt'
     Agent.__init__(self, name=name, logHandlers=logHandlers)
     self.message_handlers['inform-measure-values'] = self.add_data
     self.message_handlers['cfp-collect'] = self.collect_data
     return
Пример #9
0
 def __init__(self, 
              name='data manager',
              rows=None,
              columns=None,
              storage=None,
              logHandlers=[]):
     self.file_name = 'data_storage.txt'
     Agent.__init__(self, name=name, logHandlers=logHandlers)
     self.message_handlers['inform-measure-values'] = self.add_data
     self.message_handlers['cfp-collect'] = self.collect_data
     return
Пример #10
0
 def __init__(self,
              name='structure evaluator',
              structure=None,
              problems=None,
              measures=None,
              logHandlers=[],
              **kwargs):
     Agent.__init__(self,
                    name=name,
                    logHandlers=logHandlers)
     self.structure = structure
     
     # Data cache is a map from a parameter tag with an ExperimentResult
     # object
     self.data_cache = DataCache(name='data-cache',
                                 problems=problems,
                                 measures=measures)
     self.message_handlers['inform-measure-values'] = self.evaluate
     self.message_handlers['cfp-evaluate-parameter'] =
     self.create_cache_entry
     return
Пример #11
0
    def __init__(self,
                 name='structure evaluator',
                 structure=None,
                 problems=None,
                 measures=None,
                 logHandlers=[],
                 **kwargs):
        Agent.__init__(self,
                       name=name,
                       logHandlers=logHandlers)
        self.structure = structure
        
        # Data cache is a map from a parameter tag with an ExperimentResult
        # object
        self.data_cache = DataCache(name='data-cache',
                                    problems=problems,
                                    measures=measures)
        

        self.message_handlers['inform-measure-values'] = self.evaluate
        self.message_handlers['cfp-evaluate-parameter'] = \
                                                        self.create_cache_entry
        return