Пример #1
0
def solve_th(data):
    print("Solving %s" % data)
    model = "models/%s" % data["data"]
    pm = PEPAModel({"file": model, "solver": "sparse"})
    pm.derive()
    pm.steady_state()
    th = pm.get_throughoutput()
    return "ok" if th else "error"
Пример #2
0
def solve_ss(data):
    print("Solving %s" % data)
    model = "models/%s" % data["data"]
    pm = PEPAModel({"file": model, "solver": "sparse"})
    pm.derive()
    pm.steady_state()
    ss = pm.get_steady_state_vector()
    return "ok" if ss else "error"
Пример #3
0
def _job(task, name, queue):
    curproc = multiprocessing.current_process().name
    print("Process %s started" % curproc)
    actionth = task["actionth"]
    rate = task["rate"]
    values = task["values"]
    print("Process %s Calculating %d values " % (curproc, len(values)))
    pargs = {"file": task["model"], "solver": "sparse"}
    pm = PEPAModel(pargs)
    pm.derive()
    result = rate_experiment(rate, values, actionth, pm)
    queue.put(result)
Пример #4
0
def experiment(task, name, queue):
    curproc = multiprocessing.current_process().name
    print("Process %s started" % curproc)
    actionth = task["actionth"]

    model = "models/%s" % data["data"]
    rate = data["rate"]
    action = data["action"]
    values = data["values"]
    print("Experiment %s with %d values" % (model, len(values)))
    if "map" not in data:
        pm = PEPAModel({"file": model, "solver": "sparse"})
        pm.derive()
        result = rate_experiment(rate, values, action, pm)
        # return result
        return "ok"
    else:
        cpus = multiprocessing.cpu_count()
        queue = multiprocessing.Queue()
        tasks = _carousel(values, cpus)
        for t in tasks:
            task = {
                "actionth": action,
                "rate": rate,
                "values": t,
                "model": model
            }
            p = multiprocessing.Process(target=_job,
                                        args=(task, "TASKNAME", queue))
            p.start()
        vals = []
        for i in range(len(tasks)):
            result = queue.get()
            # print(result)
            #vals.append(result)
            vals.append("ok")
        return vals