Hi Mark,
I'm by no means an expert on constraint programming but I will try to give you
some ideas.
My understanding is that every student has a number of modules.
Every module has exactly one group, and a group can at most belong to one
module.
I believe that in order to constrain the number of students in a group, you
have to create a direct relationship between students and groups. Up to now
this relationship is only represented by the structure of the Sol record. What
we need are actual constraints that represent this information.
You might for example create a finite set of groups for every student:
GroupsOfStudent = {Record.map Sol
fun {$ Groups}
StudentGroups={FS.var.bounds nil 1#172}
in
{FS.card StudentGroups {Width Groups}}
for G in {Record.toList Groups} do
{FS.include G StudentGroups}
end
StudentGroups
end
}
Now we create a record of FD variables that represent the membership of
students to a given group. For each student, this record has a FD variable that
has either the value 0 (student is not member) or 1 (student is member):
fun {ReifiedStudentsOfGroup Group}
{Record.map GroupsOfStudent
fun {$ StudentGroups}
{FS.reified.isIn Group StudentGroups}
end
}
end
With this function we can finally post the constraint that a group has at most
X students:
{FD.sum {ReifiedStudentsOfGroup 93} '=<:' 20}
I'm not sure if this is the best or even a feasible solution, but I hope it
helps...
Cheers,
Wolfgang
> Hi ,
> I wonder if anyone can help me?
> I'm building a system for my final year project to allocate university
> students to module groups. (The room availability is already done)
> I am using a record 'sol' which has features from 'S1' to the number of
> students, 'Sn'.
> Each field is then a FD.record with features 'xxxx' (where xxxx is the
> code for each module the student does) and the fields represent the
> groups available for that module.
> It looks like this: (part solved)
>
> sol('S1'('2CAL':1
> '2CAP':_{1#18 92#95 164#172}
> '2CHL':6
> '2CHP':_{1#18 92#95 164#172}
> '3CAL':10
> '3CAP':_{1#18 92#95 164#172}
> '3CHL':15
> '3CHP':_{1#18 92#95 164#172}
> 'CDVL':92
> 'CDVP':_{1#18 92#95 164#172}
> 'S2'('2CHL':6
> '2CHP':_{1#18 92#95 164#172}
> '3CAL':10
> '3CAP':_{1#18 92#95 164#172}
> '3CHL':15
> '3CHP':_{1#18 92#95 164#172}......etc
>
> What I'm struggling with is how to post the constraint that the number
> of students in group 93 for example must be less than 20.
> The position of each module in the FD.record cannot be guaranteed.
> I was trying to think along the lines of using FD.sum along with some
> version of Fold but I'm quite confused at this stage.
> Any help would be really appreciated.
>
> Regards
> Mark Richardson
>
> Mark Richardson
> Final year undergraduate
> University of Teesside
>
> _________________________________________________________________________________
> mozart-users mailing list
> [email protected]
> http://www.mozart-oz.org/mailman/listinfo/mozart-users
--
Sensationsangebot nur bis 30.11: GMX FreeDSL - Telefonanschluss + DSL
für nur 16,37 Euro/mtl.!* http://dsl.gmx.de/?ac=OM.AD.PD003K11308T4569a
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users