22.02.2013 Views

Temas de “Programación lógica e I.A.”

Temas de “Programación lógica e I.A.”

Temas de “Programación lógica e I.A.”

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Planificación <strong>de</strong> tareas con CLP(Q)<br />

① Planificador<br />

✉ Biblioteca CLP(Q)<br />

:- lib(clpq).<br />

✉ planificación(P,TP) se verifica si P es el plan (esto es una lista <strong>de</strong> elementos <strong>de</strong> la<br />

forma tarea/inicio/duración) para realizar las tareas en el menor tiempo posible y<br />

TP es dicho tiempo. Por ejemplo,<br />

[eclipse 3]: planificación(P,TP).<br />

P = [t1/0/5, t2/5/7, t3/12/10, t4/I/2, t5/I/9]<br />

TP = 22<br />

% Linear constraints:<br />

{ I =< 13, I >= 5, I - I >= 2 }<br />

Yes (0.01s cpu)<br />

planificación(P,TP) :tareas(LTD),<br />

restricciones(LTD,P,TP),<br />

minimize(TP).<br />

PL 2004–05 CcIa Programación <strong>lógica</strong> con restricciones 8.15<br />

Planificación <strong>de</strong> tareas con CLP(Q)<br />

Programación <strong>lógica</strong> e I.A. 185<br />

✉ restricciones(LTD,P,TP) se verifica si P es un plan para realizar las tareas <strong>de</strong> LTD<br />

cumpliendo las restricciones <strong>de</strong>finidas por prece<strong>de</strong>ncia/2 y TP es el tiempo que se<br />

necesita para ejecutar el plan P.<br />

restricciones([],[],_TP).<br />

restricciones([T/D | RLTD],[T/I/D | RTID],TP) :-<br />

{I >= 0, I + D =< TP},<br />

restricciones(RLTD,RTID,TP),<br />

restricciones_aux(T/I/D,RTID).<br />

✉ restricciones aux(TID,LTID) se verifica si el triple tarea–inicio–duración TID es consistente<br />

con la lista <strong>de</strong> triples tarea–inicio–duración LTID.<br />

restricciones_aux(_,[]).<br />

restricciones_aux(T/I/D, [T1/I1/D1 | RTID]) :-<br />

( prece<strong>de</strong>(T,T1),!,{I+D =< I1}<br />

; prece<strong>de</strong>(T1,T),!,{I1+D1 =< I}<br />

; true ),<br />

restricciones_aux(T/I/D,RTID).<br />

PL 2004–05 CcIa Programación <strong>lógica</strong> con restricciones 8.16

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!