prolog - Schedule planning strategy -


i going attempt solving scheduling problem prolog. have set of requests people in format

req_id, user_id, start_date, end_date, state 

each of these people in 1 or more groups

group_id, user_id 

and each group defined by

group_id, loose, strict 

where loose , strict integers >= 0

the initial state of each request unknown, , can changed either rejected or approved.

to explain loose , strict on groups consider following example

group - loose 1 - strict 1 group b - loose 1 - strict 0 group c - loose 0 - strict 1 

given these data @ given time need 3 people @ work 1 person can solve both , b loose (given in both of groups) , 1 person needed strict , 1 person c strict.

the date span limited 5-6 weeks - never open ended searches.

problem 1: how represent available personnel @ given time no group rules can broken

problem 2: how "force" prolog searches maximum possible accept actions instead of rejecting requests


edit

sorry late followup, hurt leg , haven't had time this.

my current code is:

updategroupstrict(     [ group(group,n,loose) | groupsrest ],     [ usergroup(user,group) | _ ],     user,     [ group(group,m,loose) | groupsrest ] ) :- n > 0,     m n - 1.  % reduce strict helper, try next group updategroupstrict( [ grouphead | groupsrest ], usergroups, user, [ grouphead | updatedgroups ] ) :- updategroupstrict(groupsrest,usergroups,user,updatedgroups).  % reduce strict helper, try next usergroup updategroupstrict(groups,[ _ | usergrouptail ],user,updatedgroups) :- updategroupstrict(groups,usergrouptail,user,updatedgroups).  handle(groups, _, userrequest( _, [ request(_, accept) | _ ]), groups).  % reject request, groups should updated in following way % - strict accept should update 1 strict group handle(     groups,     usergroups,     userrequest( user, [ request(_, reject) | _ ]),     updatedgroups ) :- updategroupstrict(groups, usergroups, user, updatedgroups).  % success when requests have been processed - meaning list empty, , groups 0,0. planned([],_,[]).  % if group not have more unsatisfied reduce planned( [ group(_,0,0) | groupstail ], usergroups, requests ) :- planned( groupstail, usergroups, requests ).  % reduce list of requests, handle head, , continue on rest planned( groups, usergroups, [ requesthead | requesttail] ) :-     handle( groups, usergroups, requesthead, updatedgroups ),     planned( updatedgroups, usergroups, requesttail ). 

the assumptions made in code there strict rules, requests same length (completely overlapping), , users have made request.

planned([group(group1,1,0)],[usergroup(user1,group1)],[userrequest(user1,[request(request1,requestaction1)]),userrequest(user2,[request(request2,requestaction2)])]).

so managed find solution. instead of these intermediate representations have two

  1. a list of requests start , end date represented integer offset (request(user,firstday,lastday,mode))
  2. a list of groups represent each day users can work day in them (group(day,limit,[users])

this way able remove user group's users when request approved. , leave him if rejected. , check if there enough users in group accordingly limit.


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -