You selected pert.pl

% PERT   2001.11.24.

% æs‡˜ŠÖŒW

order(a,[],5).
order(b,[a],4).
order(c,[a],7).
order(d,[b,c],3).
order(e,[c],5).
order(f,[e,d],2).
%

complete(X,E,L,F):-
    early_complete(X,E),
    late_complete(X,L),
    F is L - E.
start(X,E,L,F):-
    early_start(X,E),
    late_start(X,L),
    F is L - E.

% Å‘Š®—¹Žž
early_complete(X,Dur):-
    order(X,[],Dur).
early_complete(X,Early):-
    order(X,Pre,Dur),
    Pre \= [],
    member(Y1,Pre),
    early_complete(Y1,E1),
    \+ ( member(Y2,Pre),
        early_complete(Y2,E2),
        order(Y2,_,_),
        E2  > E1 ),
    Early is Dur + E1.

% Å‘ŠJŽnŽž
early_start(X,Early):-
    early_complete(X,Late),
    order(X,_,Dur),
    Early is Late - Dur.


% Å’xŠ®—¹Žž
late_complete(X,T):-
    early_complete(X,T),
    \+ (order(_,Z,_),
        member(X,Z)).
late_complete(X,E1):-
    order(X,_,_),
    order(Y,Z,_),
    Z \= [],
    member(X,Z),
    early_start(Y,E1),
    \+ ( 
      order(Y1,Z1,_),
      Z1 \= [],
      member(X,Z1),
      early_start(Y1,E2),
      E2  < E1 ).

% Å’xŠJŽnŽž
late_start(X,Late):-
    order(X,_,Dur),
    late_complete(X,L),
    Late is L - Dur.

%

n_write(X):-
  order(X,_,C),
  concat(X,'/',Y),
  concat(Y,C,Z),
  write(Z).

arrow:-write('------>').
node(N):-write('['),write(N),write(']').

chart2:-
  N1 = 0, N2 = 1, N3 = 3, N4 = 5, N5 = 6,
             N6 = 2, N7 = 4,
  nl,tab(9),n_write(a),tab(7),
  n_write(b),tab(7),n_write(d),tab(7),n_write(f),
  nl,tab(5),
  node(N1), arrow, node(N2), arrow, 
  node(N3), arrow, node(N4), arrow, node(N5),
  nl,tab(7),write('_'),tab(14),write('^'),tab(8),write('^'),
  nl,tab(9),write('_«'),n_write(c),
  tab(5),write('^'),tab(8),write('^ª'),n_write(e),
  nl,tab(11),write('_'),tab(6),write('^ªdummy'),tab(1),write('^'),
  nl,tab(13),write('_'),tab(2),write('^'),tab(8),write('^'),
  nl,tab(15),node(N6), arrow,node(N7),
  nl,tab(18),write('dummy').

chart:-
  N1 = 0, N2 = 1, N3 = 3, N4 = 5, N5 = 6,
             N6 = 2, N7 = 4,
  nl,tab(9),n_write(a),tab(7),
  n_write(b),tab(7),n_write(d),tab(7),n_write(f),
  nl,tab(5),
  node(N1), arrow, node(N2), arrow, 
  node(N3), arrow, node(N4), arrow, node(N5),
  nl,tab(16),write('|'),tab(7),write('^'),tab(8),write('^'),
  nl,tab(11),n_write(c),write('«|'),
  tab(5),write('^'),tab(7),write('^ª'),n_write(e),
  nl,tab(16),write('|'),tab(2),write('^ªdummy'),tab(1),write('^'),
  nl,tab(16),write('|'),write('^'),tab(8),write('^'),
  nl,tab(15),node(N6), arrow,node(N7),
  nl,tab(18),write('dummy').

:-chart.

% end of program


return to front page.