#lang racket

;;Ajustada con un AG
;;La parametrización funciona. Para comprobarlo, descomentar
;;líneas 101 y 129
(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
    1 propagacion_lineal lineal escalon_1))
(define o_2 
  (make-object neurona% 'o_2
    1 propagacion_lineal lineal escalon_1))
(define o_3 
  (make-object neurona% 'o_3
    1 propagacion_lineal lineal escalon_1))
(define o_4 
  (make-object neurona% 'o_4
    1 propagacion_lineal lineal escalon_1))
(define o_5 
  (make-object neurona% 'o_5
    1 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
    1 propagacion_lineal lineal escalon_1))
(define o_8 
  (make-object neurona% 'o_8
    1 propagacion_lineal lineal escalon_1))

(define s_1 
  (make-object neurona% 's_1
    0 propagacion_lineal lineal escalon_1))
(define s_2 
  (make-object neurona% 's_2
    0 propagacion_lineal lineal escalon_1))
(define s_3 
  (make-object neurona% 's_3
    0 propagacion_lineal lineal escalon_1))
(define s_4 
  (make-object neurona% 's_4
    0 propagacion_lineal lineal escalon_1))
(define s_5 
  (make-object neurona% 's_5
    0 propagacion_lineal lineal escalon_1))
(define s_6 
  (make-object neurona% 's_6
    0 propagacion_lineal lineal escalon_1))
(define s_7 
  (make-object neurona% 's_7
    0 propagacion_lineal lineal escalon_1))
(define s_8 
  (make-object neurona% 's_8
    0 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) 
    '((1 0 0 0 0 0 0 0)
      (0 1 0 0 0 0 0 0)
      (0 0 1 0 0 0 0 0)
      (0 0 0 1 0 0 0 0)
      (0 0 0 0 1 0 0 0)
      (0 0 0 0 0 1 0 0)
      (0 0 0 0 0 0 1 0)
      (0 0 0 0 0 0 0 1)
      )
    ))
(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) 
    '((-1 0 0 0 0 0 0 0)
      (0 -1 0 0 0 0 0 0)
      (0 0 -1 0 0 0 0 0)
      (0 0 0 -1 0 0 0 0)
      (0 0 0 0 -1 0 0 0)
      (0 0 0 0 0 -1 0 0)
      (0 0 0 0 0 0 -1 0)
      (0 0 0 0 0 0 0 -1))
    ))
;;;RED
(define analisis_olfativo (make-object red% (list capa_1 capa_2 capa_3)))
;;;;;;;;

;(require "Training-olfato.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)
            )
          )
      )
    )
  )

(provide red% capa% capa_entrada% neurona% neuron_entrada%
         analisis_olfativo estimulos->red)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;(estimulos->red analisis_olfativo training)

