(no subject)

From: Josee <josee_nd_at_yahoo.com>
Date: Fri 08 Apr 2005 07:31:46 AM GMT
Message-ID: <20050408073146.67392.qmail@web31808.mail.mud.yahoo.com>
how would u write the c version of the following
scheduling code. i seem to be having problems writing
the code.


:- use_module(library(fd)).
:- use_module(library(structures)).
:- use_module(library(lists)).

:- mode read_data(++,-).
:- mode output_data(++,+).
:- local struct( tttasks(name, jobno, duration,
startime) ).


% minimum schedule
     gp276(End, Variables) :-
        End :: [0..1000],
read_data('//E/PROJECT/bin/a.ecl',Input),
    minimize((schedule(Input, End, Variables),
indomain(End)), End)).


% problem List
problem([task(t1,3,[],m1), task(t2,10,[t1],m2),
task(t3,8,[t2],m3),
	 task(t4,6,[],m4), task(t5,3,[t4],m3),
task(t6,4,[t5],m1),
	 task(t7,3,[],m3), task(t8,7,[t7],m2),
task(t9,5,[t8],m1), task(t10,6,[t9],m4)]).


% schedule program
schedule(List, End, Variables)   :-
          makeVariables(List, Variables, End),
          precedences(List, Variables),
          machines(List, Variables),
          labeltasks(Variables).



% intializing domain variables
makeVariables([],[],_).
makeVariables([task(N,J,D,_,_)|Ts],
[tttasks(N,J,D,TS)|Js], End)  :-
     	TS :: [0..1000],
         TS + D #<= End, %Start time should be less
than the finish time of the sschedule
         makeVariables(Ts, Js, End).

gettttasks(JL, J, N, D, TS)  :-
once(member(tttasks(N,J,D,TS), JL)). %extract a task
from the list of tasks



precedences([],_).
precedences([task(N,_,_,Pre,_)|Ts], Variables)  :-
     	gettttasks(Variables,_, N, _, TS),
	    prectask(Pre, TS, Variables),
	    precedences(Ts, Variables).

prectask([],  _, _).
prectask([Name|Names], PostStart, Variables)  :-
     	gettttasks(Variables, _, Name, D, TS),
	    TS + D #<= PostStart, 	%precedence constraints
	    prectask(Names, PostStart, Variables).% start
time + duration of
	    					%the previous task has to be
	    					%less than the start time of
	    					%the next task


machines([], _).
machines([task(N,_,_,_,M)|Ts], Variables)  :-
     	gettttasks(Variables, _, N, D, TS),
	    machtask(Ts, M, D, TS, Variables),
	    machines(Ts, Variables).

machtask([], _, _, _, _).
machtask([task(SN,_,_,_,M0)|Ts], M, D, TS, Variables)
:-
	     (M #= M0 ->
	         gettttasks(Variables, _, SN, SD, STS),
	         exclude(D, TS, SD, STS)
	     ; true ),
	    machtask(Ts, M, D, TS, Variables).


exclude(_D, TS, SD, STS)  :-  STS + SD #<= TS.
%machine constraints
exclude(D, TS, _SD, STS)  :-  TS + D #<= STS.

labeltasks([]).
labeltasks([tttasks(_,_,_,TS)|Js])   :-
      indomain(TS),
      labeltasks(Js).






		
__________________________________
Do you Yahoo!?
Take Yahoo! Mail with you! Get it on your mobile phone.
http://mobile.yahoo.com/maildemo
Received on Fri Apr 08 12:13:21 2005

This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:07:35 PM GMT GMT