This commit is contained in:
Pedro Romero 2025-03-31 17:05:13 +02:00
commit 95816badc8

View File

@ -54,12 +54,17 @@ def logica_offset(offset, error, errorObjetivo):
limSup = 1 + errorObjetivo
limInf = 1 - errorObjetivo
delta = random.random() * 1e-6
if error <= limSup and error >= limInf: return True, None
if error > 1: offset = offset - delta
elif error < 1: offset = offset + delta
tasa_aprendizaje = 0.001
desviacion = error - 1
delta = abs(tasa_aprendizaje * np.tanh(desviacion))
print(delta)
if error >= limSup: offset -= delta
if error <= limInf: offset += delta
return False, offset
@ -81,24 +86,29 @@ if __name__ == '__main__':
ruta = f'{directorio}{nombre}'
offset = 0
generar_curva(offset,ruta)
E_original = 70
B = 4 * np.pi * 1e-7 * 1000 + offset
# B = 1e-2
# BObjetivo = 2e-2
cte = E_original/B
# errorObjetivo = 0.01
EObjetivo = 175
# flag = False
errorObjetivo = 0.01
# while flag == False:
# os.system('cls')
flag = False
# B = B + offset
while flag == False:
os.system('cls')
# error = B/BObjetivo
B_nuevo = 4 * np.pi * 1e-7 * 1000 + offset
# print(B)
# print(error)
Ecalculado = cte * B_nuevo
# flag, offset = logica_offset(offset, error, errorObjetivo)
error = Ecalculado/EObjetivo
print(Ecalculado)
print(error)
print()
flag, offset = logica_offset(offset, error, errorObjetivo)