예제 #1
0
def launch_computation(agents_count, agent_population, obj, incoming_problems_feed, distortion_factor):
    base_params = create_base_params()
    specific_params = create_classic_params(agents_count, agent_population, obj["matrix"], incoming_problems_feed, distortion_factor)

    inject.resolve_attr = create_resolver(dict(base_params.items() + specific_params.items()))

    workplace = Workplace()
    workplace.publish()
    while not workplace.stopped:
        workplace.step()
    workplace.unregister()
예제 #2
0
def lunch_computation(config, agents_count, agent_population, stages, obj):
    base_params = create_base_params()
    specific_params = {}
    if config == emas:
        specific_params = create_emas_params(agents_count, agent_population, obj[matrix], stages)
    elif config == classic:
        specific_params = create_classic_params(agents_count, agent_population, obj[matrix], stages)

    inject.resolve_attr = create_resolver(dict(base_params.items() + specific_params.items()))
    inject.Inject.read_config = lambda self, string: None

    workplace = Workplace()
    workplace.publish()
    while not workplace.stopped:
        workplace.step()
    workplace.unregister()
예제 #3
0
from pyage.core.workplace import Workplace

logger = logging.getLogger(__name__)

if __name__ == '__main__':
    start_time = time()
    level = logging.INFO
    if len(sys.argv) >= 3:
        level = getattr(logging, sys.argv[2].upper(), None)
    logging.basicConfig(filename='pyage-' +
                        datetime.now().strftime("%Y%m%d_%H%M%S") + '.log',
                        level=level)
    inject.config = sys.argv[1]
    logging.debug("config: %s", inject.config)
    workplace = Workplace()
    workplace.publish()
    logger.debug(workplace.address)
    if hasattr(workplace, "daemon"):
        thread = threading.Thread(target=workplace.daemon.requestLoop)
        thread.setDaemon(True)
        thread.start()
        import Pyro4
        Pyro4.config.COMMTIMEOUT = 1
    while not workplace.stopped:
        workplace.step()
    time = time() - start_time
    logger.debug("elapsed time: %s seconds", time)
    if hasattr(workplace, "daemon"):
        workplace.daemon.close()
    workplace.unregister()
예제 #4
0
from pyage.core import inject

from pyage.core.workplace import Workplace


logger = logging.getLogger(__name__)

if __name__ == '__main__':
    start_time = time()
    level = logging.INFO
    if len(sys.argv) >= 3:
        level = getattr(logging, sys.argv[2].upper(), None)
    logging.basicConfig(filename='pyage-' + datetime.now().strftime("%Y%m%d_%H%M%S") + '.log', level=level)
    inject.config = sys.argv[1]
    logging.debug("config: %s", inject.config)
    workplace = Workplace()
    workplace.publish()
    logger.debug(workplace.address)
    if hasattr(workplace, "daemon"):
        thread = threading.Thread(target=workplace.daemon.requestLoop)
        thread.setDaemon(True)
        thread.start()
        import Pyro4
        Pyro4.config.COMMTIMEOUT = 1
    while not workplace.stopped:
        workplace.step()
    time = time() - start_time
    logger.debug("elapsed time: %s seconds", time)
    if hasattr(workplace, "daemon"):
        workplace.daemon.close()
    workplace.unregister()
예제 #5
0
파일: bootstrap.py 프로젝트: mknapik/pyage
import logging
import threading
from time import sleep, time
import Pyro4
import sys
from pyage.core import inject
from pyage.core.workplace import Workplace

logger = logging.getLogger(__name__)

if __name__ == '__main__':
    start_time = time()
    logging.basicConfig(filename='pyage-' + str(datetime.now()) + '.log', level=logging.INFO)
    inject.config = sys.argv[1]
    logging.debug("config: %s", inject.config)
    workspace = Workplace()
    workspace.publish()
    workspace.publish_agents()
    logger.debug(workspace.address)
    if hasattr(workspace, "daemon"):
        thread = threading.Thread(target=workspace.daemon.requestLoop)
        thread.setDaemon(True)
        thread.start()
    Pyro4.config.COMMTIMEOUT = 1
    while not workspace.stopped:
        workspace.step()
    time = time() - start_time
    logger.debug("elapsed time: %s seconds", time)
    if hasattr(workspace, "daemon"):
        workspace.daemon.close()
    workspace.unregister_agents()