FET Forum

FET Development => Custom FET for Particular Needs => Topic started by: biritxi on February 15, 2012, 10:52:11 AM

Title: Distinct periods per day
Post by: biritxi on February 15, 2012, 10:52:11 AM
Hi!

We are leading a project in Basque Country to try to introduce FET in some education centers. At this time we have implemeted a VB.NET application over the FET, the .NET application comunicates with FET through command line and runs well, but we want to take out the .NET application and use only FET. Just now we've started to explore the Fet´s code and find a serious trouble.

In most of the education centers have distinct periods per day and per group (or set of groups). I'll give an example:
We have 4 groups (G1, G2, G3, G4), some teachers (T1, T2,T3,...) and 2 templates that contains the periods per day (H1, H2) the days are always 5, but the hours are distincts.
H1 hours: 9.00-10.00                            H2 hours: 8.00-8.55
                10.00-11.00                                           8.55-9.50
                11.30-12.30                                           9.50-10.45
                12.30-13.30                                         11.15-12.10
                14.30-15.30                                         12.10-13.05
                15.30-16.30                                         14.30-15.25
                16.30-17.30                                         15.25-16.20

G1 and G2 have H1 template and G3 and G4 H2 template. All teachers can teach to all the groups.
Without code's changes, we insert all the hours in FET and then for each group a time break that corresponding with the hours of the other template (For G1the H2 hours would be time breaks). After generate timetable we meet some teachers who have times overlaping, for example: T1 teach G3 at 9.50-10.45 and teach G1 at 10.00-11.00, that would be impossible.

We are thinking about some code changes but don´t have very clear where to start. If it is possible, can you help, please.

Thank you!
Title: Re: Distinct periods per day
Post by: Liviu Lalescu on February 15, 2012, 11:14:30 AM
There are two possible approaches:

1) I think you cannot and are not willing to do that: consider the highest common divisor of all the periods (I think it is 5 minutes) - this will be a FET hour, so 9.00-10.00 has 60/5=12 FET hours. But you need to increase the number of maximum hours possible in FET, or reconsider a larger common divisor which is not perfect, like 15 minutes or 30 minutes.

2) This one follows your current approach, but you may need to add many constraints. Use the new constraint, introduced in FET-5.15.0, "activities occupy max time slots from selection". Let me detail:

For each teacher, choose each pair of overlapping slots and use the mentioned constraint to say that the teacher can have only one of them occupied.

In your case, for each teacher, for each day, add :

9.00-10.00 != 8.55-9.50
9.00-10.00 != 9.50-10.45
10.00-11.00 != 9.50-10.45
11.30-12.30 != 11.15-12.10
11.30-12.30 != 12.10-13.05
12.30-13.30 != 12.10-13.05
14.30-15.30 != 14.30-15.25
14.30-15.30 != 15.25-16.20
15.30-16.30 != 15.25-16.20

(I hope I didn't miss any pair)

So, 9 constraints per day, for each day and each teacher. It is some work, but not impossible.

The constraint is highly optimized (I did my best); I also tested with many constraints, not exactly your situation, but I thought of it, and FET was not slowed down too much (see the Morocco sample for something similar, but with less constraints, I think only one constraint for each day and for each teacher).

Please let me know.
Title: Re: Distinct periods per day
Post by: biritxi on February 15, 2012, 12:48:18 PM
Firstly, thanks Liviu to respond so quickly.

The second option is discarded because could have 100 or 300 teachers and find for each teacher the pair of overlapping slots would be an arduous task.
So I'll try the first one, I'll increase the MAX_HOURS_PER_DAY to 144 (to encompass from 8.00 to 19.00) and test it.

Regards!



Title: Re: Distinct periods per day
Post by: Liviu Lalescu on February 15, 2012, 01:13:46 PM
Quote from: biritxi on February 15, 2012, 12:48:18 PM
Firstly, thanks Liviu to respond so quickly.

The second option is discarded because could have 100 or 300 teachers and find for each teacher the pair of overlapping slots would be an arduous task.


I hope it is not that difficult as you think and actually I would go for it, because:

1) Adding "not overlapping" constraints is not that difficult. What do you mean "find for each teacher the pair of overlapping slots"? The slots are the same for all teachers. Please add this constraint for one teacher two days, and for another teacher, another two days. Then see the .fet XML file. If you can generate the constraint from an external program or modify FET to add it automatically with a single button click, it would be really easy.

2) You said you wanted to modify the FET code. Then, it is easy to take the existing constraint, see how it works, and make it act for all teachers and all days (and you specify only the 9 conflicts in a day). This way, you will have a slightly improved speed and memory consumption than adding all the constraints like I suggested.

Please try to add at least one constraint and see how it works, I think you did not consider it in more detail.

Quote

So I'll try the first one, I'll increase the MAX_HOURS_PER_DAY to 144 (to encompass from 8.00 to 19.00) and test it.


On the other hand, this is also a very nice solution (remember to increase the activities' duration).
Title: Re: Distinct periods per day
Post by: biritxi on February 15, 2012, 02:45:54 PM
Thanks a lot Liviu,

I'll follow your advice and I'm going to test the constraint that you mean and try to understand how it works.

Regards!
Title: Re: Distinct periods per day
Post by: biritxi on February 16, 2012, 10:35:42 AM
Hi!

I've some questions about the new constraint "activities occupy max time slots from selection".
- you said to add this constraint for one teacher but this constraint is added to a set of activities, therefore I've to add it to all the teacher's activities?
I added one:
<ConstraintActivitiesOccupyMaxTimeSlotsFromSelection>
   <Weight_Percentage>100</Weight_Percentage>
   <Number_of_Activities>8</Number_of_Activities>
   <Activity_Id>1</Activity_Id>
   <Activity_Id>2</Activity_Id>
   <Activity_Id>3</Activity_Id>
   <Activity_Id>4</Activity_Id>
   <Activity_Id>36</Activity_Id>
   <Activity_Id>37</Activity_Id>
   <Activity_Id>38</Activity_Id>
   <Activity_Id>39</Activity_Id>
   <Number_of_Selected_Time_Slots>2</Number_of_Selected_Time_Slots>
   <Selected_Time_Slot>
      <Selected_Day>Monday</Selected_Day>
      <Selected_Hour>08:55</Selected_Hour>
   </Selected_Time_Slot>
   <Selected_Time_Slot>
      <Selected_Day>Monday</Selected_Day>
      <Selected_Hour>09:00</Selected_Hour>
   </Selected_Time_Slot>
   <Max_Number_of_Occupied_Time_Slots>1</Max_Number_of_Occupied_Time_Slots>
   <Active>true</Active>
   <Comments></Comments>
</ConstraintActivitiesOccupyMaxTimeSlotsFromSelection>


All the activities ids are one teacher's activities.
This constraint means that Mondays this teacher can teach at 08:55 or 09:00 but not at both?

Thanks!
Title: Re: Distinct periods per day
Post by: Liviu Lalescu on February 16, 2012, 11:31:46 AM
Yes, exactly.

I am not sure how fast would FET be with 9 * n_days * n_teachers constraints like this. It would be best to make a test. I hope the speed will be not much lower than without the constraints, but I didn't do an exact test like that (I did for the Morocco sample, but there were only n_days/3 * n_teachers constraints I think. The speed remained good). I did my best to optimize this constraint thinking that there may be many of them.

I think that you don't need to try to optimize this constraint for your case. I think that adding these many constraints (as compared to you implementing only a single constraint for your special case) only increases memory consumption and file size, but does not affect the generation speed. So, maybe you just need to add a button in FET, which adds all the necessary constraints (for all teachers, all days and all conflicting hours in a day).

I am not sure which approach is best, with 5 minute FET "hours" and 144 FET "hours" per day, or with this "max occupied" constraint - maybe you should do a comparison.
Title: Re: Distinct periods per day
Post by: biritxi on February 17, 2012, 12:08:04 PM
Thanks a lot!

Finally we'll try to do it with the new constraint because we need to export the timetable from FET to a web application in a txt file and with the other approach (5 minute FET "hours") we would convert the timetable activities/groups/teachers hours (each 5 minutes) in the correct hours (08:00-8:55 for example) and it would be an ardous task.

Thank you very much for your help, sure more dudes will emerge because we want to add new Qlist to store the distinct templates with them hours by day, and show in "constraint students set not available times" form to select the adequate template for each group and automatically add the constraint for each group.

Thanks again for you help!