/* ** The train Problem solution in Euclid ** This program attempts to solve the automated ** train driver program for a smooth ride (for ** the passengers) and better consumption (for ** the company). ** ** Solving this type of problems in Euclid takes these few steps: ** 1. Think of the properties that describe the problem ** 2. Give their initial values, their relations to ** each other and any other values known ** 3. Describe any explicit and more complicated relations ** through predicates. ** 4. Relax and watch the system find the solution ** Use constraints to describe the quantities of the system ** and logic to show when constraints are applicable. ** ** (C) Copyright K J Dryllerakis 1993-1995 ** ALL RIGHTS RESERVED ** $Id: train.eu,v 1.2 1995/03/24 12:48:06 kd Exp kd $ */ solve(A,T1,T2,Tf,D,Umax,Acc):- initial_data(U,A,D,Acc,Umax,Tf,S) , acceleration_f(0,Tf,A,D,S,Acc,Umax,0,T1,T2,Tf) , T1 = T2, /* We did not reach the Umax */ U@T1=Umax. solve(A,T1,T2,Tf,D,Umax,Acc):- initial_data(U,A,D,Acc,Umax,Tf,S) , acceleration_f(0,Tf,A,D,S,Acc,Umax,0,T1,T2,Tf), T1 \= T2. initial_data(U,A,D,Acc,Umax,Tf,S):- functions([U,A,S]) , reals([D,Acc,Umax,Tf]), U@0=0 , U@Tf=0 , U=integral(A) , continuous(U) , S@0=0 , S@Tf=D , S=integral(U) , continuous(S). acceleration_f(0,Tf,FF,D,S,Acc,Umax,0,T1,T2,Tf):- functions([F1,F2]) , F1={[cc(0,T1):(Acc)//X]} , T1>0 , S@T1 > D/2, F2=F1#{[oc(T1,T2):0//X]}, T1 < T2, FF=F2 # {[oc(T2,Tf):(-Acc)//X]}, T2 0 , S@T1 <= D/2, T1=T2, FF=F1 # {[oc(T2,Tf):(-Acc)//X]}, T2