variables - Solve "Out of local stack" in this specific constraint programming in prolog -


i'm trying create schedules bus drivers in prolog. wish find limited number of solutions. "out of local stack" error, , suppose because i'm getting many solutions.

how can prevent error given following code? tips on whatever i'm not doing correctly immensely too.

count_drivers: counts number of drivers d_id driver_id  ( need them work less "max_hours").  vehicle: represents bus , respective routes.  connected: represents connection between relief opportunities  ( route consists of group of relief points , respective "connection"  between them)  workpiece: segment of work in same vehicle between 2 relief points  spell: group of workpieces done same driver  spreadover: whole shift 1 driver has do. 

here code:

?- use_module(library(clpfd)). ?- use_module(library(lists)). ?- use_module(library(aggregate)).  %workpiece(bus,[ro1,ro2],weight).   workpiece(1,[1,2],1). workpiece(1,[2,3],2). workpiece(1,[3,4],1). workpiece(1,[4,5],2). workpiece(1,[5,6],1). workpiece(2,[7,8],2). workpiece(2,[8,9],2). workpiece(2,[9,10],1). workpiece(2,[10,11],2). workpiece(2,[11,12],1). workpiece(3,[13,14],2). workpiece(3,[14,15],1). workpiece(3,[15,16],2). workpiece(3,[16,17],1). workpiece(3,[17,18],2).  %spell spell(vehicle,[[ro1,ro2]|tail]):-vars = [ro1,ro2], vars in 1..18, workpiece(vehicle,[ro1,ro2],_),spell(vehicle,tail,ro2),labeling([],vars). spell(_,[],_). spell(vehicle,[[ro1,ro2]|tail],ro3):- vars = [ro3], vars in 1..18, ro3 #= ro1, workpiece(vehicle,[ro1,ro2],_),spell(vehicle,tail,ro2), labeling([],vars).   %spreadover de cada driver spreadover(_,list):- vars = i, vars in 1..15, length(list,i), #>= 1. spreadover(driver,[head|tail]):- vars = [vehicle,i], vars in 1..9, vehicle #>= 1, vehicle #=< 3, spell(vehicle,head), length(head,i), #>= 1, spreadover(driver,tail), labeling([],vars).  %ocupar workpieces todas %minimizando os shifts %cobrir todas routes  %length 15 %drivershifts  drivershifts(_,list):- vars = i, vars in 1..15, length(list,i), #= 15. drivershifts(numdrivers,[[driver|list]|tail]):-vars = driver, vars in 1..numdrivers, driver #>= 1, driver #=< numdrivers, spreadover(driver,list), labeling([],vars). 

i thank in advance time can spare in helping me.

edit: changed code around bit, load of unassigned variables query of forall(spreadover(1,list),writeln(list)). or 1 unassigned variable spreadover(1,list). restricted domains wherever could, aren't sure if i'm doing correctly. queries above should generate spreadovers(a set of spells) driver 1.

not sure if should post new question or rewrite 1 either, decided rewrite one.

you have many warnings singleton variables, , style solve them. @ least, prefix variables know unused underscore, avoid warning.

now loop: you're calling diagram free variable, causing infinite recursion 'construct' infinite list of partially instantiated variables.

i can't understand intended meaning of diagram/1. sure, miss base case: add like

diagram([]). 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -