예제 #1
0
파일: init.py 프로젝트: csadorf/SignacGA
def main(n, seed):
    project = signac.init_project("HelloWorldGA")
    # create the master job
    goal = 'Hello, World!'
    statepoint = dict(master=True, goal=goal, seed=seed)
    project.open_job(statepoint).init()
    lJob = project.open_job(statepoint)
    lJob.document.generation = 0
    # Test the project document
    # project.document.generation = 0
    lDict = {'n': 0, 'members': None}
    project.document.generation = lDict
    project.document.time = dict()
    project.document.njobs = dict()
    # set the random seed
    np.random.seed(seed=seed)
    for i in range(n):
        # generate a random string
        # a length of 13 is the length of 'Hello, World!'
        length = len(goal)
        lCode = randomString(length)
        # cost of the code can't be part of the statepoint
        # I mean, technically from one point of view it
        # must be, but from another, it can't since it
        # would be part of the operation before creating a
        # new job, and the cost calculation should be part
        # of that process
        # lCost = _calcCost(lCode, goal)
        statepoint = dict(length=length,
                          goal=goal,
                          code=lCode,
                          seed=seed,
                          master=False)
        # create the job
        project.open_job(statepoint).init()
        lJob = project.open_job(statepoint)
        lJob.document.generation = 0
        # lJob.document.eligible = True

    # Use dedicated document for benchmark data
    benchmark_doc = JSONDict(filename='benchmark.json', write_concern=True)
    benchmark_doc.setdefault('time', dict())
    benchmark_doc.setdefault('njobs', dict())
예제 #2
0
파일: project.py 프로젝트: csadorf/SignacGA
    $ python project.py run [job_id [job_id ...]]

See also: $ python src/project.py --help
"""
from signac.core.jsondict import JSONDict
from flow import FlowProject
import util
import numpy as np
import os.path
import time

MAX_NUM_GENERATIONS = 10000


benchmark_doc = JSONDict(filename='benchmark.json', write_concern=True)
benchmark_doc.setdefault('time', dict())
benchmark_doc.setdefault('njobs', dict())


def isMaster(job):
    """
    returns True is job is master; otherwise returns False
    """
    return job.sp.master

def getSimJobs(masterJob, simulated=None):
    """
    Get all the jobs that (don't) need simulated
    """
    # only look for non-master jobs
    filter = dict(master=False)