#lang racket

(require "Clases-neuron-capa-red.rkt")

;;;;;;;;;;;;;;INSTANCIAS
;;;NEURONAS
(define n_1 (make-object neuron_entrada% 'n_1))
(define n_2 (make-object neuron_entrada% 'n_2))
(define n_3 (make-object neuron_entrada% 'n_3))
(define n_4 (make-object neuron_entrada% 'n_4))
(define n_5 (make-object neuron_entrada% 'n_5))
(define n_6 (make-object neuron_entrada% 'n_6))
(define n_7 (make-object neuron_entrada% 'n_7))
(define n_8 (make-object neuron_entrada% 'n_8))

(define o_1 
  (make-object neurona% 'o_1
    -9 propagacion_lineal lineal escalon_1))
(define o_2 
  (make-object neurona% 'o_2
    -2 propagacion_lineal lineal escalon_1))
(define o_3 
  (make-object neurona% 'o_3
    9 propagacion_lineal lineal escalon_1))
(define o_4 
  (make-object neurona% 'o_4
    4 propagacion_lineal lineal escalon_1))
(define o_5 
  (make-object neurona% 'o_5
    -5 propagacion_lineal lineal escalon_1))
(define o_6 
  (make-object neurona% 'o_6
    1 propagacion_lineal lineal escalon_1))
(define o_7 
  (make-object neurona% 'o_7
    -7 propagacion_lineal lineal escalon_1))
(define o_8 
  (make-object neurona% 'o_8
    3 propagacion_lineal lineal escalon_1))

(define s_1 
  (make-object neurona% 's_1
    -5 propagacion_lineal lineal escalon_1))
(define s_2 
  (make-object neurona% 's_
    4 propagacion_lineal lineal escalon_1))
(define s_3 
  (make-object neurona% 's_
    -5 propagacion_lineal lineal escalon_1))
(define s_4 
  (make-object neurona% 's_
    9 propagacion_lineal lineal escalon_1))
(define s_5 
  (make-object neurona% 's_
    4 propagacion_lineal lineal escalon_1))
(define s_6 
  (make-object neurona% 's_
    7 propagacion_lineal lineal escalon_1))
(define s_7 
  (make-object neurona% 's_
    9 propagacion_lineal lineal escalon_1))
(define s_8 
  (make-object neurona% 's_
    2 propagacion_lineal lineal escalon_1))
;;;CAPAS
(define capa_1 
  (make-object capa_entrada% 'c_1
    (list n_1 n_2 n_3 n_4 n_5 n_6 n_7 n_8) ))
(define capa_2 
  (make-object capa% 'c_2
    (list o_1 o_2 o_3 o_4 o_5 o_6 o_7 o_8) 
    '((-3 6 5 3 -1 -1 -2 -3) 
      (-6 8 8 6 -8 -6 6 4)
      (-2 -7 8 1 9 7 -6 -6)
      (5 -4 -7 -3 8 6 9 6)
      (4 -7 0 7 8 -2 -3 0)
      (8 1 3 -6 -8 -1 6 3)
      (5 8 7 7 -2 0 -9 6)
      (9 8 -8 3 -5 -5 -5 -8))
    ))
(define capa_3 
  (make-object capa% 'c_3
    (list s_1 s_2 s_3 s_4 s_5 s_6 s_7 s_8) 
    '((3 -4 5 -4 -8 -7 -5 7) 
      (9 -6 5 0 -9 0 -2 0)
      (-9 2 7 2 -2 0 -8 -7)
      (0 -1 -5 -8 -2 -7 0 0)
      (-9 1 4 2 -1 -2 6 4)
      (-6 -8 -3 5 4 8 -8 0)
      (7 0 8 -7 -7 -6 -2 4)
      (-9 -3 3 3 4 1 -4 0))
    ))
;;;RED
(define Red_8 (make-object red% (list capa_1 capa_2 capa_3)))

;;;USO
;(require "Training_set.rkt")

(define estimulos->red
  (lambda (red estimulos);estimulos : training_set
    (printf "(_ _ _ _ _ _ _ _) ==>    Deseada        ==>   Real~n")
    (let go ((i 0)
             (j (length estimulos))
             )
      (if (= i j)
          #t
          (let* ((input (car (list-ref estimulos i)))
                 (deseada (second (list-ref estimulos i)))
                 (resp (send red proceso! input)) )
;            (printf "~a ==> ~a ==> ~a~n" input deseada resp)
            (if (equal? deseada resp)
                (printf "~a ==> ~a ==> ~a~n" input deseada resp)
                (printf "~a --> ~a --> ~a**~n" input deseada resp)       
                )
            (go (add1 i) j)
            )
          )
      )
    )
  )
;
;(estimulos->red Red_8 training)

(provide red% capa% capa_entrada% neurona% neuron_entrada%
         Red_8 estimulos->red)