29
UNIVERSIDAD TECNICA PARTICULAR DE LOJA SEMÁFORO INTELIGENTE INTEGRANTES FREDDY FERNANDO OJEDA POMA VANESSA CINDHY CELI

SEMAFORO INTELIGENTE

Embed Size (px)

DESCRIPTION

Aplicando los conocimientos adquiridos en la clase de inteligencia artificial, hemos hecho el estudio de las caracteristicas que debe tener un agente inteligente para que controle el tráfico vehicular en una intersección

Citation preview

Page 1: SEMAFORO INTELIGENTE

UNIVERSIDAD TECNICA PARTICULAR DE LOJA

SEMÁFORO INTELIGENTE

INTEGRANTES

FREDDY FERNANDO OJEDA POMA

VANESSA CINDHY CELI

Page 2: SEMAFORO INTELIGENTE

INTRODUCCIÓN

Los agentes de software han mostrado una nueva forma de trabajar con computadores, permitiendo “delegar” en un programa (el agente) ciertas tareas que, de otra forma, solamente podrían hacer los humanos. En algunos casos, puede tratarse simplemente de tareas repetitivas, pero en otros, puede ser una solución a problemas complejos.

En este trabajo analizamos la posibilidad de emplear un agente “semáforo” cuya función principal es facilitar el control del tránsito de vehículos y peatones, de manera de que pasen alternadamente a través de la intersección.

 

Page 3: SEMAFORO INTELIGENTE

OBJETIVOS

• Conocer a fondo el comportamiento de un agente relacional

Page 4: SEMAFORO INTELIGENTE

Comportamiento de los agentes inteligentes

• Un agente inteligente es una entidad que percibe y actua sobre un entorno

Page 5: SEMAFORO INTELIGENTE

COMO SE CARACTERIZA UN AGENTE

LOS AGENTES INTELIGENTES SE CARACTERIZA POR SER :

Comunicativo: Debe entender las necesidades u objetivos del usuario

Capaz: Debe tener la capacidad de saber como dar un servicio y proporcionar información

Autónomo: Debe poder interactuar con el entorno tomando decisiones y actuando por si solo

Adaptativo: debe ser capaz de aprender del entorno

Page 6: SEMAFORO INTELIGENTE

AGENTE INTLIGENTE SEMAFOROPROBLEMATICA

La congestión vehicular que encontramos en las calles de nuestra ciudad y de cualquier ciudad del país, es causante de mucho malestar a los conductores , aún cuando en las intersecciones de las calles se encuentran semáforos instalados, estos nos garantiza la óptima fluidez vehicular porque cuentan con método estáticos.

Page 7: SEMAFORO INTELIGENTE

AGENTE INTLIGENTE SEMAFORO SOLUCIÓN

• para dar lo solución a esta problemática hemos planteado la propuesta de la creación de un semáforo inteligente el cual permitirá reducir el tiempo de espera en una intersección y · Analizará la cantidad de vehículos que se aproximan al cruce y asignará tiempos de paso y de espera para cada vía.

 

Page 8: SEMAFORO INTELIGENTE

TEDENCIA DE LOS SEMAFOROS INTELIGENTES

• · En la ciudad de Barcelona en el 2008 comenzó la instalación de estos modelos. Tienen varias funcionalidades avanzadas para mejorar la seguridad y ayudar en la regulación del tráfico.

• · Científicos norteamericanos y rumanos han desarrollado un modelo informático basado en información real que atribuye inteligencia a los semáforos para optimizar la gestión del tráfico. De esta forma han comprobado que se reduce un 28% el tiempo de espera en los cruces en hora punta y un 6,5% las emisiones de CO2. El modelo puede potenciarse si se incorpora a los automóviles un software específico que avise a los conductores tanto de las velocidades recomendables en función de las luces de los semáforos, como en función de la cantidad de coches que se pueden encontrar en los atascos. Esta aplicación también podría trasladar información al sistema para mejorar la regulación del tráfico mediante los semáforos.

 

Page 9: SEMAFORO INTELIGENTE

FUNCIONAMIENTO

• · Este proyecto desarrollara un sistema inteligente que , a partir de cámaras IP instaladas en los semáforo, ejecute en tiempo real decisiones sobre los  tiempos de cada luz de un semáforo para la optimización del trafico en una intersección

Page 10: SEMAFORO INTELIGENTE

DESCRIPCION DEL ENTORNO DE TRABAJO DEL AGENTE SEMAFORO

• · agente Medidas de

RendimientoEntorno Actuadores Sensores

Agilizar el Trafico Calles Luz Amarilla Detector de Vehículos

Minimizar los embotellamientos

Peatones Luz verde Cámara

Tráficos Luz Roja

Page 11: SEMAFORO INTELIGENTE

ARQUITECTURA GLOBAL DEL AGENTE INTELIGENTE SEMÁFORO

• · 

Page 12: SEMAFORO INTELIGENTE

ENTORNO DE APRENDIZAJE DE NUESTR AGENTE

• Tenemos lo sensores (cámaras ip) los cuales nos proporcionan datos del numero de vehículos que se aproximan la intersección para luego enviarlos a un control de entrada que este a su vez ·  se comunicará con la organización de los datos los cuales interactúan con el control mientras que el control de salida se comunica con la base de datos

•  

Page 13: SEMAFORO INTELIGENTE

ENTORNO DE APRENDIZAJE DE NUESTR AGENTE

• Para realizar el entorno de aprendizaje de nuestro agente hemos utilizado Ontologías la cuales fueron creadas con la herramienta CmapTools

Page 14: SEMAFORO INTELIGENTE

ARQUITECTURA GLOBAL DEL AGENTE INTELIGENTE SEMÁFORO TRIPLETAS

Page 15: SEMAFORO INTELIGENTE

Código del Programa

• Clase principal semaforoIA• import java.awt.*;

 public class SemaforoIA extends CreaVentanas {

 

private Iniciarnn Semaforo1, Semaforo4;

private Image[] estadoLuces=new Image[4];

private Image carro1, carro3;

private Image cruce, Imgsemaforo1;

private int X2, Y2, X1, Y1;

private AEstrellaParaSemaforo busqueda;

private String semaforo[] = {"verde1.gif","amarillo1.gif","rojo1.gif","apagado.gif"};

private Graphics G;

private Image I;

private Dimension D;

private MediaTracker Mt;

 

 

public SemaforoIA()

{

super("A G E N T E S E M A F O R O Cindhy Celi, Freddy Ojeda \t\t\t\t\t\t Inteligencia Artificial", 0, 0, 0, 0, Color.gray, true);

Mt = new MediaTracker(this);

Page 16: SEMAFORO INTELIGENTE

Código del Programa

cargarsemaf();

cargarImagenes();

X2 = 10; Y2 = 310; //posicion inicial auto de la 18 de nov

X1 = 600; Y1 = 30; //posicion inicial auto Azuay

Iniciar();

 

this.setResizable(false);

this.setVisible(true);

}

 

private void cargarImagenes()

{

 

cruce = Toolkit.getDefaultToolkit().getImage("edificios\\cruce2.png"); //FONDO

carro1 = Toolkit.getDefaultToolkit().getImage("carros\\arrabj4.gif"); //auto de arriba

carro3 = Toolkit.getDefaultToolkit().getImage("carros\\izqder.gif"); //auto izquierda

Imgsemaforo1 = estadoLuces[3]; //Semaforo

}

 

public void cargarsemaf()

{

 

Page 17: SEMAFORO INTELIGENTE

Código del Programa

• for (int i = 0; i < semaforo.length; i++)

{

estadoLuces[i] = Toolkit.getDefaultToolkit().getImage("edificios\\"+

semaforo[i]);

 

Mt.addImage(estadoLuces[i],i);

}

try{Mt.waitForAll();} catch (InterruptedException e){};

}

Page 18: SEMAFORO INTELIGENTE

Código del Programa

public void Iniciar()

{

int tVerde=0, tVerdeParpa=0, tRojo=0;

int nCarrosX=0, nCarrosY=0;// contador=0;

 

nCarrosX =(int)(Math.random()*10);

nCarrosY =(int)(Math.random()*10);

busqueda();

tVerde=tiempoV(nCarrosX, nCarrosY);

tRojo=tiempoR(nCarrosX, nCarrosY);

System.out.println(" \n NUMERO DE VEHICULOS APROXIMÁNDOSE A LA INTERSECCIÓN:\n\t\t por la 18 de Noviembre = "+nCarrosX+"\n\t\t por la Azuay \t= "+nCarrosY);

if(nCarrosX>=nCarrosY) System.out.println("\n Avancen los de la 18 = "+tVerde+" ms"+ "\n Avancen los de la Azuay = "+tRojo+"ms");

else System.out.println("\n Avancen los de la Azuay = "+tVerde+" ms"+ "\n Avancen los de la 18 = "+tRojo+" ms");

Page 19: SEMAFORO INTELIGENTE

Código del Programa

if (nCarrosX >= nCarrosY){ Semaforo1 = new Iniciarnn("Calle Azuay",6000,2000,1000); Semaforo4 = new Iniciarnn("Calle 18 de Nov", tVerde,tVerdeParpa,tRojo); //tiempo del semaforo verde, parpadeaverde, rojo Semaforo1.start(); Semaforo4.start(); } else{ Semaforo1 = new Iniciarnn("Calle Azuay",6000,2000,1000); Semaforo4 = new Iniciarnn("Calle 18 de Nov", tRojo,tVerdeParpa,tVerde); //tiempo del semaforo verde, parpadeaverde, rojo Semaforo1.start(); Semaforo4.start(); }

} public int tiempoV(int nx, int ny) { int tVerde=0; int VelAuto=2000; //tiempo que un auto demora en cruzar el cruce

Page 20: SEMAFORO INTELIGENTE

Código del Programa ny == 0) tVerde=nx*VelAuto;

if(nx >= ny )

tVerde = (nx+ny)*VelAuto/ny;

else

tVerde = (nx+ny)*VelAuto/nx;

// System.out.println("\n return V = "+ tVerde);

return tVerde;

}

 

public int tiempoR(int nx, int ny)

{

int tRojo=0;

int VelAuto=2000; //tiempo que un auto demora en cruzar el cruce

if(nx==0) tRojo=ny*VelAuto;

 

if(ny >= nx )

tRojo = (nx+ny)*VelAuto/ny;

//else{ tRojo = ny * VelAuto;

else{ tRojo = (nx+ny)*VelAuto/nx;

}

// System.out.println("\n return Rojo = "+ tRojo);

return tRojo;

}

Page 21: SEMAFORO INTELIGENTE

Código del Programa public void paint(Graphics g){update(g);}

 

public void update(Graphics g)

{

Dimension d = getSize();

 

if(G == null || d.width != D.width || d.height != D.height)

{ D = d;

I = createImage(D.width, D.height);

G = I.getGraphics();

}

Graphics2D g2 = (Graphics2D) G;

//de arriba a abajo

g2.drawImage(carro1,X1, Y1+Iniciarnn.Y2, this);

//de izquierda a derecha

g2.drawImage(carro3,X2+Iniciarnn.X, Y2, this);

g.drawImage(I, 0, 0, this);

g2.drawImage(cruce,0,0,this.getWidth(),this.getHeight(),this);

g2.drawImage(Imgsemaforo1,550, 250,this);//semaforo

EstadosLuces();

repaint();

Page 22: SEMAFORO INTELIGENTE

Código del Programa • try{Thread.sleep(15);} catch(InterruptedException ie){}• }•  • public void EstadosLuces()• { if(Semaforo1.isAlive())• { // pista = 1;• if(Iniciarnn.getestado() == 0){• Imgsemaforo1=estadoLuces[0];• Iniciarnn.AvanzaX();• }• else• { if(Iniciarnn.getestado() == 1)• { if(Imgsemaforo1 == estadoLuces[0])• { Imgsemaforo1 = estadoLuces[3];• Iniciarnn.AvanzaX();• }• else• {Imgsemaforo1 = estadoLuces[0];• Iniciarnn.AvanzaX();• }• repaint();• }• else• if(Iniciarnn.getestado() == 2){• Imgsemaforo1=estadoLuces[1];• Imgsemaforo1=estadoLuces[2];• Iniciarnn.AvanzaY2();

Page 23: SEMAFORO INTELIGENTE

Código del Programa }

repaint();

}

}

 

if(!Semaforo1.isAlive())

{Imgsemaforo1=estadoLuces[2];

Iniciarnn.AvanzaY2();

Iniciar();

}

}

public void retardo(int pTiempo)

{ try { Thread.sleep(pTiempo); } catch (Exception e) {}

}

 

public static void main(String[] args){new SemaforoIA();

}

Page 24: SEMAFORO INTELIGENTE

Código del Programa Función para crear las Ventanas

 

import java.util.Vectoimport java.awt.*;

import javax.swing.*;

 

public class CrearVentanas extends JFrame

{

Dimension pantalla=Toolkit.getDefaultToolkit().getScreenSize();

public CrearVentanas()

{

this(null,0,0,0,0,Color.gray,false);

}

public CrearVentanas (String pTitulo)

{

this(pTitulo,0,0,200,100,Color.gray,false);

}

public CrearVentanas(String pTitulo, int pX, int pY)

{

this(pTitulo,pX,pY,200,100,Color.gray,false);

}

 

public CrearVentanas(String pTitulo, int pX, int pY, int pAncho, int pLargo)

{

this(pTitulo,pX,pY,pAncho,pLargo,Color.gray,false);

}

 

Page 25: SEMAFORO INTELIGENTE

Código del Programa • public CrearVentanas(String pTitulo, int pX, int pY, int pAncho, int pAlto,Color pcolor, boolean

pPrincipal)• {•  • this.setTitle(pTitulo);• this.setSize(getMaximumSize().width,

getMaximumSize().height);• this.setBackground(pcolor);• this.setLocation(pX,pY);• this.setDefaultCloseOperation(EXIT_ON_CLOSE);• if (pPrincipal)•

this.setDefaultCloseOperation(EXIT_ON_CLOSE);• else•

this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);•  • }•  •

•  •  • };

Page 26: SEMAFORO INTELIGENTE

Código del Programa

public CrearVentanas(String pTitulo, int pX, int pY, int pAncho, int pAlto,Color pcolor, boolean pPrincipal)

{

 

this.setTitle(pTitulo);

this.setSize(getMaximumSize().width, getMaximumSize().height);

this.setBackground(pcolor);

this.setLocation(pX,pY);

this.setDefaultCloseOperation(EXIT_ON_CLOSE);

if (pPrincipal)

this.setDefaultCloseOperation(EXIT_ON_CLOSE);

else

this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);

 

}

 

 

 

};

Page 27: SEMAFORO INTELIGENTE

Código del Programa Función para mover los autos

 

public class MoverAutos extends Thread

{

public static int Y2;

public static int X;

private int verde, amarillo, parpaverde;

private boolean activo;

private static int estado=-1;

private static int aTiempo[];

 

 

public MoverAutos(String pNombre,int pVerde,int pParpaverde,int pAmarillo)

{

super(pNombre);

verde = pVerde;

parpaverde = pParpaverde;

amarillo = pAmarillo;

aTiempo = new int[] { verde, parpaverde, amarillo, 0 };

activo = true;

}

Page 28: SEMAFORO INTELIGENTE

Código del Programa Función para mover los autos

 

public class MoverAutos extends Thread

{

public static int Y2;

public static int X;

private int verde, amarillo, parpaverde;

private boolean activo;

private static int estado=-1;

private static int aTiempo[];

 

 

public MoverAutos(String pNombre,int pVerde,int pParpaverde,int pAmarillo)

{

super(pNombre);

verde = pVerde;

parpaverde = pParpaverde;

amarillo = pAmarillo;

aTiempo = new int[] { verde, parpaverde, amarillo, 0 };

activo = true;

}

Page 29: SEMAFORO INTELIGENTE

Código del Programa public void run()

{

estado();

}

public void estado()

{

synchronized(System.out)

{

if(activo)

{

//System.out.println("estado antes = "+estado);

estado = ++estado % 4;

//System.out.println("estado despues = "+estado);

activo = (estado != 3);

//System.out.print("\n Carril "+getName()+"el semaforo esta en: "+Nombre[estado]+" "+aTiempo[estado]);

retardo(aTiempo[estado]);

estado();

}

 

}

}

public static int getestado()

{

return estado;

}