(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],
    minimize((schedule(Input, End, Variables),
indomain(End)), End)).

% problem List
problem([task(t1,3,[],m1), task(t2,10,[t1],m2),
	 task(t4,6,[],m4), task(t5,3,[t4],m3),
	 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),

% intializing domain variables
[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([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([tttasks(_,_,_,TS)|Js])   :-

Do you Yahoo!?
Take Yahoo! Mail with you! Get it on your mobile phone.
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