martes, 8 de octubre de 2013

Robot Planificación

Rafael Alcaraz
Montserrat Romero
Luis S. Gatica



Robot Shakey

1) Formalización:

Estado Inicial:
Por simpleza para el problema, solo tenemos una caja (una es suficiente).
True {At(Shakey,R1),At(B,R1),LsOn(R1),LsOn(R2),LsOn(R3),LsOn(R4),Free(Shakey),OnFloor(Shakey)}
Condiciones que no cambiarán: True{Box(B),Room(R1),Room(R2),Room(R3),Room(R4),Room(Pasillo)}
Estado Objetivo:
True {At(Shakey,R1),At(B,R1),LsOff(R1),LsOff(R2),LsOff(R3),LsOff(R4),Free(Shakey),OnFloor(Shakey)}
Operadores:
Box(x): x es una caja
At(x,r): x es una caja | x es Shakey | r es un cuarto
OnBox(b): Shakey está sobre la caja b | b es una caja
OnFloor(Shakey): Shakey está en el piso
Holding(x): x es una caja y Shakey tiene la caja
Free(Shakey): no tiene ninguna caja agarrada
LsOn(x) = x es un cuarto y la luz está encendida
LsOff(x) = x es un cuarto y la luz está apagada
Room(x): x es un cuarto o el pasillo
Acciones:
ApagarLuz(x): Apaga la luz x
precondiciones: {Room(x)  & LsOn(x) & At(Shakey, x) & Box (y) & At(y,x) & OnBox(y) }
efecto: TRUE {LsOff(x)}
                FALSE {LsOn(x)}
Entrar(x): Entrar al cuarto
precondiciones: {At(Shakey,Pasillo) & OnFloor(Shakey) & Room(x)}
efecto: TRUE {At(Shakey , x)}
                FALSE {At(Shakey, pasillo)}
Salir(x): sale del cuarto
precondiciones: { At(Shakey,x) & Room(x) & OnFloor(Shakey) & Free(Shakey)}
Efecto: TRUE { At(Shakey, Pasillo)}
              FALSE {At(Shakey, x)}
TomarCaja(x): toma una caja
Precondiciones: { free(Shakey) & OnFloor(Shakey) & At(Shakey, r) & At(x,r) & Room(r)}
Efecto: TRUE {holding(x)}
              FALSE {free(Shakey)}
SoltarCaja(x): suelta una caja
Precondiciones: {Holding(x) & box(x) & At(Shakey, y) & Room(y)}
Efecto: TRUE { free(Shakey), At (x,y)}
              FALSE {Holding(x)}
Subirse(x): Shakey se sube a la caja x
Precondiciones: {Free(Shakey) & OnFloor(Shakey) & Box(x) & At(Shakey, y) & Room(y) & At(x, y)}
Efecto: TRUE { OnBox(x)}
              FALSE {OnFloor(Shakey)}

Bajarse(x): Shakey se baja de la caja x
Precondiciones: {Free(Shakey) & OnBox(x) & Box(x) & At(Shakey, y) & Room(y) & At(x, y) }
Efecto: TRUE { OnFloor(Shakey)}
              FALSE {OnBox(x)}


2) Plan Construido:


El plan para este problema es demasiado grande como para ser dibujado, pero describiremos la topología del mismo a continuación:
Tenemos el estado inicial al principio, el cual se encarga de hacer válidas el hecho de que B es caja, existen cuarto R1, R2, R3 y R4. A partir de aquí nunca cambia. De aquí se debe hacer lo siguiente que se enlista cuatro veces para apagar todas las luces. (Evidentemente evitemos salirnos de un cuarto en el que ya esté la caja para volver a entrar).
·         Salir(CuartoActual)
·         Entrar(CuartoDondeEstéCaja)
·         TomarCaja(B)
·         Salir(CuartoActual)
·         Entrar(CuartoConLuzPrendida)
·         SoltarCaja(B)
·         Subirse(B)
·         ApagarLuz(CuartoActual)
·         Bajarse(B)
Finalmente regresamos a Shakey al cuarto R1 y terminamos. Se verá más claro en la corrida.

3) Corrida:

0) Start ->
True {At(Shakey,R1),At(B,R1),LsOn(R1),LsOn(R2),LsOn(R3),LsOn(R4),Free(Shakey),OnFloor(Shakey)}
1) Subirse(B) ->
True {At(Shakey,R1),At(B,R1),LsOn(R1),LsOn(R2),LsOn(R3),LsOn(R4),Free(Shakey),OnBox(B)}
2) ApagarLuz(R1) ->
True {At(Shakey,R1),At(B,R1),LsOff(R1),LsOn(R2),LsOn(R3),LsOn(R4),Free(Shakey),OnBox(B)}
3) Bajarse(B) ->
True {At(Shakey,R1),At(B,R1),LsOff(R1),LsOn(R2),LsOn(R3),LsOn(R4),Free(Shakey),OnFloor(Shakey)}
4) TomarCaja(B) ->
True {At(Shakey,R1),LsOff(R1),LsOn(R2),LsOn(R3),LsOn(R4),Holding(B),OnFloor(Shakey)}
5) Salir(R1) ->
True {At(Shakey,Pasillo),LsOff(R1),LsOn(R2),LsOn(R3),LsOn(R4),Holding(B),OnFloor(Shakey)}
6) Entrar(R2) ->
True {At(Shakey,R2),LsOff(R1),LsOn(R2),LsOn(R3),LsOn(R4),Holding(B),OnFloor(Shakey)}
7) Soltar(B) ->
True {At(Shakey,R2),At(B,R2),LsOff(R1),LsOn(R2),LsOn(R3),LsOn(R4),Free(Shakey),OnFloor(Shakey)}
8) Subirse(B) ->
True {At(Shakey,R2),At(B,R2),LsOff(R1),LsOn(R2),LsOn(R3),LsOn(R4),Free(Shakey),OnBox(B)}
9) ApagarLuz(R2) ->
True {At(Shakey,R2),At(B,R2),LsOff(R1),LsOff(R2),LsOn(R3),LsOn(R4),Free(Shakey),OnBox(B)}
10) Bajarse(B) ->
True {At(Shakey,R2),At(B,R2),LsOff(R1),LsOff(R2),LsOn(R3),LsOn(R4),Free(Shakey),OnFloor(Shakey)}
11) TomarCaja(B) ->
True {At(Shakey,R2),LsOff(R1),LsOff(R2),LsOn(R3),LsOn(R4),Holding(B),OnFloor(Shakey)}
12) Salir(R2) ->
True {At(Shakey,Pasillo),LsOff(R1),LsOff(R2),LsOn(R3),LsOn(R4),Holding(B),OnFloor(Shakey)}
13) Entrar(R3) ->
True {At(Shakey,R3),LsOff(R1),LsOff(R2),LsOn(R3),LsOn(R4),Holding(B),OnFloor(Shakey)}
14) Soltar(B) ->
True {At(Shakey,R3),At(B,R3),LsOff(R1),LsOff(R2),LsOn(R3),LsOn(R4),Free(Shakey),OnFloor(Shakey)}
15) Subirse(B) ->
True {At(Shakey,R3),At(B,R3),LsOff(R1),LsOff(R2),LsOn(R3),LsOn(R4),Free(Shakey),OnBox(B)}
16) ApagarLuz(R3) ->
True {At(Shakey,R3),At(B,R3),LsOff(R1),LsOff(R2),LsOff(R3),LsOn(R4),Free(Shakey),OnBox(B)}
17) Bajarse(B) ->
True {At(Shakey,R3),At(B,R3),LsOff(R1),LsOff(R2),LsOff(R3),LsOn(R4),Free(Shakey),OnFloor(Shakey)}
18) TomarCaja(B) ->
True {At(Shakey,R3),LsOff(R1),LsOff(R2),LsOff(R3),LsOn(R4),Holding(B),OnFloor(Shakey)}
19) Salir(R3) ->
True {At(Shakey,Pasillo),LsOff(R1),LsOn(R2),LsOff(R3),LsOn(R4),Holding(B),OnFloor(Shakey)}
20) Entrar(R4) ->
True {At(Shakey,R4),LsOff(R1),LsOff(R2),LsOff(R3),LsOn(R4),Holding(B),OnFloor(Shakey)}
21) Soltar(B) ->
True {At(Shakey,R4),At(B,R4),LsOff(R1),LsOff(R2),LsOff(R3),LsOn(R4),Free(Shakey),OnFloor(Shakey)}
22) Subirse(B) ->
True {At(Shakey,R4),At(B,R4),LsOff(R1),LsOff(R2),LsOff(R3),LsOn(R4),Free(Shakey),OnBox(B)}
23) ApagarLuz(R4) ->
True {At(Shakey,R4),At(B,R4),LsOff(R1),LsOff(R2),LsOff(R3),LsOff(R4),Free(Shakey),OnBox(B)}
24) Bajarse(B) ->
True {At(Shakey,R4),At(B,R4),LsOff(R1),LsOff(R2),LsOff(R3),LsOff(R4),Free(Shakey),OnFloor(Shakey)}
25) TomarCaja(B) ->
True {At(Shakey,R4),LsOff(R1),LsOff(R2),LsOff(R3),LsOff(R4),Holding(B),OnFloor(Shakey)}
26) Salir(R4) ->
True {At(Shakey,Pasillo),LsOff(R1),LsOn(R2),LsOff(R3),LsOff(R4),Holding(B),OnFloor(Shakey)}
27) Entrar(R1) ->
True {At(Shakey,R1), LsOff(R1),LsOff(R2),LsOff(R3),LsOff(R4),Holding(B),OnFloor(Shakey)}
28) Soltar(B) ->
True {At(Shakey,R1),At(B,R1),LsOff(R1),LsOff(R2),LsOff(R3),LsOff(R4),Free(Shakey),OnFloor(Shakey)}
29) Finish ->
True {At(Shakey,R1),At(B,R1),LsOff(R1),LsOff(R2),LsOff(R3),LsOff(R4),Free(Shakey),OnFloor(Shakey)}
 

No hay comentarios:

Publicar un comentario