simulacion sistemas inteligentes

Upload: libardo-salazar

Post on 01-Mar-2016

213 views

Category:

Documents


0 download

DESCRIPTION

simulación de una glorieta con varios carriles y vehículos en multiples direcciones. se simula en el sistema netlogo

TRANSCRIPT

Los agentes se representan de la siguiente manera:

Motos: se representaron con bicicletas (bikes) de color azul. Vehculos particulares: se representan como los agentes car de color rojo y como agentes tipo van side de color violeta. Vehculos pesados: se representaron como agentes "truk" de color cafe. Vehculos de carga: se representaron como agentes "ambulance" de color blanco y como agentes tipo "train passenger car" de color lima

Presentacin del mundo: Las calles por donde transitan los vehculos se pintan de color gris, las entradas y salidas se separan por recuadros amarillos quedando as cuatro entradas y cuatro salidas. La glorieta se represent como un cuadrado de color gris oscuro de centro blanco. El espacio verde representa el resto del mundo.

Procesos utilizados: Inicio y creacin de los agentes: Setup Creacin del mundo: draw-road Movimiento de los agentes: go

Problemas durante el desarrollo:

No se logr crear la glorieta con forma circular. No se logr darle el comportamiento esperado a los agentes ni en netlogo ni en Matlab.

Nota:Se adjunta archivo en netlogo con nombre Entregable_2_3_SI.nlogo como evidencia del trabajo. Este abre sin problema en la versin 5.1.0

Adicionalmente se adjunta archivo con nombre Roundabout with Right Turn Lane el cual muestra la complejidad de la simulacin propuesta. Fue bajada de internet. Este abre en la versin 4.1.3

Cdigo :

globals [ stop-light loop-counter look-ahead speed-up slow-down]turtles-own [ speed speed-limit speed-min lane ;; the current lane of the car target-lane ;; the desired lane of the car patience ;; the driver's current patience max-patience ;; the driver's maximum patience change? ;; true if the car wants to change lanes goal dest velocity ]

patches-own [ clear-in ]

;; ----INICIO----

; A CONTINUACION SE CREAN CADA UNO DE LOS AGENTES(VEHICULOS PARTICULARES, PESADOS, DE CARGA Y MOTOS.

; MOTOS: SE REPRESENTARON CON VICICLTAS(BIKES) DE COLOR AZUL. ; VEHICULOS PARTICULATES: SE REPRESENTAN COMO LOS AGENTES CAR DE COLOR ROJO Y COMO AGENTES TIPO VAN SIDE DE COLOR VIOLETA.; VEHICULOS PESADOS: SE REPRESENTARON COMO AGENTES "TRUK" DE COLOR CAFE.; VEHICULOS DE CARGA: SE REPRESENTARON COMO AGENTES "AMBULANCE" DE COLOR BLANCO Y COMO AGENTES TIPO "train passenger car" DE COLOR LIMA

breed [coches coche]

to setup ca draw-road ; diseo del mundo ;;PASO 1. Creamos 5 tortugas(particulares) de tamao 1.5, las situamos en una posicin aleatoria del mundo y las pintamos de rojo. set-default-shape coches "car" create-coches 5 [ ;set xcor random-pxcor set ycor random-pycor set color red] set shape "car" set size 1.5 set color red avoid-collision ] ;;PASO 2. Creamos 4 tortugas-moto de tamao 1.5, las situamos en una posicin aleatoria del mundo y las pintamos de azul set-default-shape coches "car" create-coches 4 [ set shape "bike" ; set size 1.5 set xcor random-pxcor set ycor random-pycor set color blue] set size 1.5 set color blue avoid-collision ] ;;PASO 3. Creamos 3 tortugas-carga de tamao 2, las situamos en una posicin aleatoria del mundo y las pintamos de blanco set-default-shape coches "car" create-coches 3 [ set shape "ambulance" set size 2 ; set xcor random-pxcor set ycor random-pycor set color white avoid-collision ] ;;PASO 4. Creamos 2 tortugas-pesado de tamao 2, las situamos en una posicin aleatoria del mundo y las pintamos de blanco set-default-shape coches "car" create-coches 2 [ set shape "truck" set size 1.5 ; set color brown avoid-collision ] ;;PASO 5. Creamos 5 tortugas(particulares) de tamao 1.5, las situamos en una posicin aleatoria del mundo y las pintamos de rojo. set-default-shape coches "car" create-coches 5 [ set shape "train passenger car" set size 2 set color lime separate-cars avoid-collision ] ;;PASO 6. Creamos 2 tortugas-pesado de tamao 2, las situamos en una posicin aleatoria del mundo y las pintamos de blanco set-default-shape coches "car" create-coches 2 [ set shape "van side" set size 2 ; set color violet separate-cars avoid-collision ] end

;******************************************************* to separate-cars ;; turtle procedure if any? other turtles-here [ fd 1 separate-cars ]end ;********************************************************** to avoid-collision set loop-counter (loop-counter + 1) let max-iterations 100 if any? other coches-here [ forward random 3 if (loop-counter < 100) [ avoid-collision ] ] end;*********************************************************** ;;PASO 5. Pedimos a las tortugas rojas que avancen 5 posiciones. ;ask turtles with [color = red] [fd 5] ;;PASO 6. Pedimos a las tortugas azules que adquieran tamao 4. ;ask turtles with [color = blue] [set size 4] ;;PASO 7. Pedimos a las tortugas blancas que muestren Ambulancia como etiqueta. ;ask turtles with [color = white] [set label "Ambulancia" show label]

;;PASO 8. Pedimos a las tortugas que tengan coordenada y positiva que avancen 3 posiciones. ;ask turtles with [ycor > 0] [fd 3] ;wait (1) ;; dejamos un segundo de pausa entre paso y paso ;; PASO 9. Pedimos a los patches que tengan coordenada x negativa que se vuelvan de color amarillo. ;; ask patches with [pxcor < 0] [set pcolor yellow]

;***********************************************************

; aqui diseamos el mundo o el entorno en donde se moveran los agentes(vehiculos) creados anteriormente to draw-road ask patches [ set pcolor green if ((pycor > -4) and (pycor < 4)) [ set pcolor gray] if ((pycor = 0) and ((pxcor mod 3) = 0)) [ set pcolor yellow ] ;if ((pycor = 4) or (pycor = -4)) [ set pcolor black ] if ((pxcor > -4) and (pxcor < 4)) [ set pcolor gray] if ((pxcor = 0) and ((pycor mod 3) = 0)) [ set pcolor yellow ] ;if ((pycor < 4) or (pxcor > 4)) [ set pcolor black ] ask patches with [abs pxcor < 2 and abs pycor < 2 ] [set pcolor gray - 3] ask patches with [pxcor = 1 and pycor = 1] [ set plabel "GLORIETA"] ask patches with [pxcor = 0 and pycor = 0] [ set pcolor white ] ] end ;; +++++GO ES EL PROCESO QUE MODELA O INDICA LA FORMA COMO SE COMPORTARAN LOS AGENTES++++++ to go ask turtles with [ color = lime] [ set ycor random-ycor set heading 0 set speed 0.1 + random-float .9 set speed-limit 1 set speed-min 0 separate-cars avoid-collision ; set lane (random 1) set target-lane lane ifelse (lane = 0) [ set xcor 2 set ycor random-ycor ;setxy random-ycor 2 ] [ ] ] ask turtles with [ color = violet] [ set ycor random-ycor set heading 0 set speed 0.1 + random-float .9 set speed-limit 1 set speed-min 0 separate-cars avoid-collision ;set lane (random 1) ;set target-lane lane ifelse (lane = 0) [ set xcor -2 set ycor random-ycor ] [ ] ] ask turtles with [ color = brown] [ set xcor random-xcor set heading 360 ;;; set initial speed to be in range 0.1 to 1.0 set speed 0.1 + random-float .9 set speed-limit 1 set speed-min 0 separate-cars avoid-collision set lane (random 1) set target-lane lane ifelse (lane = 0) [ setxy random-xcor 2 ] [ ] ] ask turtles with [ color = white] [ set xcor random-xcor set heading 0 ;;; set initial speed to be in range 0.1 to 1.0 set speed 0.1 + random-float .9 set speed-limit 1 set speed-min 0 separate-cars avoid-collision set lane (random 1) set target-lane lane ifelse (lane = 0) [ setxy random-xcor 2 ] [ ] ] ask turtles with [ color = blue] [ set xcor random-xcor set heading 270 ;;; set initial speed to be in range 0.1 to 1.0 set speed 0.1 + random-float .9 set speed-limit 1 set speed-min 0 separate-cars avoid-collision set lane (random 1) set target-lane lane ifelse (lane = 0) [ setxy random-xcor -2.5 ] [ ] ] ask turtles with [ color = red] [ set xcor random-xcor set heading 90 ;;; set initial speed to be in range 0.1 to 1.0 set speed 0.1 + random-float .9 set speed-limit 1 set speed-min 0 avoid-collision set lane (random 1) set target-lane lane ifelse (lane = 0) [ setxy random-xcor -1.8 ] [ ; setxy random-xcor 2 ] ] ;ask turtles with [color = red] ; if xcor > -4) and xcor < 0 ; rt 90 end;******************************************************************++++++++++++++++++++++++++++++++++++***************************************************************************