Beispiel #1
0
def yfile_to_yvector(name, yvec_run, modelo, ins_run, zvec_run):
    vec = []

    # Zero à esquerda
    yvec_run = int_to_str(yvec_run)
    zvec_run = int_to_str(zvec_run)
    ins_run = int_to_str(ins_run)

    path = "Datasets/" + name + "/Respostas/Y-m" + str(modelo) + "|Z#" + zvec_run + "|ins#" + ins_run + "|beta#" + beta_run + "|#" + yvec_run + ".txt"
    tf = open(path, "r")

    # Lê o arquivo
    for i in tf:
        vec.append(np.float64(i))
    tf.close()
    return(vec)
Beispiel #2
0
def yvector_to_yfile(vec, modelo, name, ins_run, zvec_run, beta_run):
    N = len(vec)
    path = "Datasets/" + name + "/Respostas/"
    zvec_run = int_to_str(zvec_run)
    ins_run = int_to_str(ins_run)
    beta_run = int_to_str(beta_run)

    run = len([ x for x in listdir(path) if ("m" +  str(modelo)) in x
    and ("Z#" + zvec_run) in x and ("ins#" + ins_run) in x]) + 1

    run = int_to_str(run)

    path += "Y-m" + str(modelo) + "|Z#" + zvec_run + "|ins#" + ins_run + "|beta#" + beta_run + "|#" + run + ".txt"
    arq = open(path, "w")

    # Escreve no arquivo
    for i in range(N):
        arq.write("{}\n".format(vec[i]))
    arq.close()

    return(int(run))
Beispiel #3
0
def beta_vector_to_file(beta_vector, name, model):
    N = len(beta_vector)
    path = "Datasets/" + name + "/Betas/"
    run = len([ x for x in listdir(path) if ("m" +  str(model)) in x ]) + 1

    # Zero à esquerda
    run = int_to_str(run)

    path += "Beta-m" + str(model) + "|#" + run + ".txt"
    arq = open(path, "w")

    # Escreve no arquivo
    for i in range(N):
        arq.write("{}\n".format(beta_vector[i]))
    arq.close()

    return(int(run))
Beispiel #4
0
def zvector_to_zfile(vec, name):
    N = len(vec)
    path = "Datasets/" + name + "/Tratamentos/"
    run = len(listdir(path)) + 1

    # Zero à esquerda
    run = int_to_str(run)

    path += "Z-#" + run + ".txt"
    arq = open(path, "w")

    # Escreve no arquivo
    for i in range(N):
        arq.write("{}\n".format(vec[i]))
    arq.close()

    return(int(run))
Beispiel #5
0
def ins_to_file(ins, name, model):
    if model == 1:
        return(-1)

    N = len(ins)
    path = "Datasets/" + name + "/Ins/"
    run = len([ x for x in listdir(path) if ("m" +  str(model)) in x ]) + 1

    # Zero à esquerda
    run = int_to_str(run)

    path += "ins-m" + str(model) + "|#" + run + ".txt"
    arq = open(path, "w")

    # Escreve no arquivo
    for i in range(N):
        arq.write("{}\n".format(ins[i]))
    arq.close()

    return(int(run))
Beispiel #6
0
def file_to_ins(name, model, run):
    ins = []

    # Zero à esquerda
    run = int_to_str(run)

    path = "Datasets/" + name + "/Ins/ins-m" + str(model) + "|#" + run + ".txt"
    tf = open(path, "r")

    # Lê o arquivo
    for i in tf:
        if i[0] is "T":
            ins.append(bool(1))
        elif i[0] is "F":
            ins.append(bool(0))
        elif model is 4 and "." not in i:
            ins.append(int(i))
        else:
            ins.append(np.float64(i))
    tf.close()

    return(ins)
Beispiel #7
0
def file_to_beta_vector(name, model, run):
    beta_vector = []

    # Zero à esquerda
    run = int_to_str(run)

    path = "Datasets/" + name + "/Betas/Beta-m" + str(model) + "|#" + run + ".txt"
    tf = open(path, "r")

    # Lê o arquivo
    for i in tf:
        if i[0] is "T":
            beta_vector.append(bool(1))
        elif i[0] is "F":
            beta_vector.append(bool(0))
        elif model is 4 and "." not in i:
            beta_vector.append(int(i))
        else:
            beta_vector.append(np.float64(i))
    tf.close()

    return(beta_vector)
Beispiel #8
0
def zfile_to_zvector(name, run):
    treatment = []

    # Zero à esquerda
    run = int_to_str(run)