Exemple #1
0
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())
Exemple #2
0
 def get_json_dict(self):
     return JSONDict(filename=self._fn_dict)
Exemple #3
0
 def get_json_dict(self):
     return JSONDict(filename=self._fn_dict, write_concern=True)
Exemple #4
0
 def setUp(self):
     self._tmp_dir = TemporaryDirectory(prefix='signac_')
     self.addCleanup(self._tmp_dir.cleanup)
     self.doc = JSONDict(
         filename=os.path.join(self._tmp_dir.name, 'doc.json'))
Exemple #5
0
 def setUp(self, request):
     self._tmp_dir = TemporaryDirectory(prefix="signac_")
     request.addfinalizer(self._tmp_dir.cleanup)
     self.doc = JSONDict(
         filename=os.path.join(self._tmp_dir.name, "doc.json"))
Exemple #6
0
    $ 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