예제 #1
0
def from_dict(d):
    experiment_logger = logging_utils.get_logger("models.Experiment")
    experiment_logger.log(5, "Reconstructing experiment from dict %d", d)
    name = d["name"]
    param_defs = dict_to_param_defs(d["parameter_definitions"])
    minimization_problem = d["minimization_problem"]
    notes = d["notes"]
    exp_id = d["exp_id"]
    experiment_logger.debug("Reconstructed attributes.")
    cand_dict_finished = d["candidates_finished"]
    cands_finished = []
    for c in cand_dict_finished:
        cands_finished.append(candidate.from_dict(c))
    cand_dict_pending = d["candidates_pending"]
    cands_pending = []
    for c in cand_dict_pending:
        cands_pending.append(candidate.from_dict(c))
    cand_dict_working = d["candidates_working"]
    cands_working = []
    for c in cand_dict_working:
        cands_working.append(candidate.from_dict(c))
    experiment_logger.log(5, "Reconstructed candidates.")
    best_candidate = d["best_candidate"]

    exp = Experiment(name, param_defs, exp_id, notes, minimization_problem)

    exp.candidates_finished = cands_finished
    exp.candidates_pending = cands_pending
    exp.candidates_working = exp.candidates_working
    exp._update_best()
    exp.last_update_time = d.get("last_update_time", time.time())

    experiment_logger.log(5, "Finished reconstruction. Exp is %s.", exp)

    return exp
예제 #2
0
def client_init_experiment():
    """
    This initializes a single experiment.

    The json-data to be sent should be a dictionary of the following format:
    {
    "name": string
        The name of the experiment. Must be unique.
    "optimizer": string
        The optimizer to be used or None to automatically choose one.
    "param_defs": list of ParamDef dicts.
        Each entry of this must be in the following format:
        {
        "type": string
            The type of the parameter definition
        "<parameter_name>": <parameter_type>
            Where each of the necessary parameters for the ParamDef must be
            included.
        }
    "optimizer_arguments": dict
        Dictionary of the arguments of the optimizer, in key-value pairs.
    "minimization": bool, optional
        Whether the problem is one of minimization or maximization. Default
        is minimization.
    }
    """
    data_received = request.get_json()
    data_received = _filter_data(data_received)
    name = data_received.get("name", None)
    exp_id = data_received.get("exp_id", None)
    notes = data_received.get("notes", None)
    if lAss.contains_id(exp_id):
        _logger.warning("%s already in exp_ids. (Exp_ids known are %s). "
                        "Failing the initialization."
                        %(exp_id, lAss.get_ids()))
        return "failed"
    optimizer = data_received.get("optimizer", None)
    optimizer_arguments = data_received.get("optimizer_arguments", None)
    minimization = data_received.get("minimization", True)
    param_defs = data_received.get("param_defs", None)
    param_defs = dict_to_param_defs(param_defs)
    exp_id = lAss.init_experiment(name, optimizer, param_defs,
                              exp_id, notes, optimizer_arguments, minimization)
    print("EXP_ID: " + str(exp_id))
    print(type(exp_id))
    return exp_id
예제 #3
0
 def test_multiple_transform(self):
     pds = {
         "x": MinMaxNumericParamDef(0, 1),
         "y": FixedValueParamDef([0, 1, 2])
     }
     new_pd = dict_to_param_defs(param_defs_to_dict(pds))