Obligatory hours for all students / student sets

Started by maxi_mus, January 09, 2024, 01:00:46 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

maxi_mus

How do I implement obligatory hours for all or a group of students. Concrete example: Morning hours 1-5, all classes have to have an activity at hours 2-5, and can have at most one morning without an activity in hour 1, although that should be the exception.

The second requirement I can achieve with the constraint 'All students begin early' (with value 1), however I'd still like to minimize that, without setting it to a hard 0.

The first requirement I try to achieve by disallowing gaps, the problem is this: Wednesday afternoon is off for everyone, so FET lets some classes go even earlier before lunch on Wednesday morning, which is not allowed. (And this indirectly leads to classes having to stay longer on afternoons, which of course is unwanted as well.)

Is what I'm trying to do only possible indirectly through other constraints or for example with a hack like setting a pseudo-activity on the first hour of Wednesday afternoon?

Liviu Lalescu

#1
Hello, @maxi_mus ,

If I understand correctly, the constraint is "activities occupy min time slots from selection". For each subgroup: all its activities, select with X (red) mornings 2-5, min occupied = 5*4. Then also add begin early max 1 beginnings at second hour. For the occupy min constraint, be careful: you need to update its activities each time you add activities to the students. Also, it should be the lowest category: subgroup; if you are not using subgroups, group; and if you are not using groups, years.

If you want, you can send me your file by email, to check.

A useful constraint might be also students interval max days per week, for the afternoon hours.

Liviu Lalescu

#2
I have revisited your initial post and I saw that I forgot about this: you want to minimize the total number of beginnings at second hour for the students.

This is not possible directly. However, I thought of a possible approach: use the constraint activities min simultaneous in selected time slots. Select all the activities, select Monday 1, not allowed empty slots, min occupied = an arbitrary value, which you can progressively lower as you find new timetables. And add 5 constraints, each for each day first hour. Or a single constraint for all the first 5 slots of Monday-Friday 1.

Maybe other tricks are possible, we can think some more if the above does not work.

maxi_mus

I'm still having a hard time understanding the constraint activities occupy min time slots from selection.

What I'm trying to achieve is this: There are 5 slots in the morning, and 4 in the afternoon.

My use cases are as follows:

1) Wednesday afternoon is off, but on all other afternoons, classes must have an activity for at least the first two hours of the afternoon. (No gaps are allowed ever.)

2) Wednesday afternoon is off, and one additional afternoon can be off. However, if an afternoon is not off, the same as in 1 applies - at least 2 lessons. Also, I might want to achieve 2 free afternoons for every class, but not as a hard constraint.

First of all, there's no possibility of marking certain slots obligatory for all or a set of classes, right? Because it would seem to me that would be the intuitive way of defining this, and not via activities, no?

Also, min hours daily for all students is not usable since this would apply to Wednesday as well, right?

Anyway, for example one, the following seems to work:

Constraint activities occupy min time slots from selection, for each class choose all of it's activities, choose the second hour of the afternoon for all days except for Wednesday, and then set the minimum occupied at 4.

Much easier would be if I could just choose all activities, choose the 4 same time slots, and then multiply 4 * the number of classes. Why does this not work?


Liviu Lalescu

1) You could simply add a break or not available Wednesday afternoon.

No gaps ever: please add a constraint max gaps. If you don't add a constraint, FET does not consider it.

Your occupy min approach is good, but even better would be to select first and second hour of all afternoons except Wednesday, and min occupied = 8. It is better for the algorithm.

Your idea is interesting, but you cannot do it with occupy min. Occupy min will only occupy 4 slots, it will not ensure that in each slot there are number_of_classes activities. You might want to use instead the constraint activities min simultaneous in selected time slots (min value = number of classes), and this is indeed the first time someone shows me this nice trick.

2) For max afternoons per week, use students interval max days per week. Unfortunately, only 100% weight possible. Maybe you can make a progressive approach, lowering this value as you find new timetables.

You can make certain slots mandatory with more constraints activities occupy min time slots from selection or, as you showed me, activities min simultaneous in selected time slots.

Unfortunately, you cannot say that if an afternoon is not empty, there should be at least 2 slots occupied. If you need to consider mornings+afternoons, I can advise you to have a look at the Mornings-Afternoons mode (Morocco and Algeria), where you have 5*2 days per week. There are examples.

maxi_mus

#5
Quote from: Liviu Lalescu on January 15, 2024, 02:54:45 PM1) You could simply add a break or not available Wednesday afternoon.

No gaps ever: please add a constraint max gaps. If you don't add a constraint, FET does not consider it.

Yes, I already have these 2 things.

QuoteYour occupy min approach is good, but even better would be to select first and second hour of all afternoons except Wednesday, and min occupied = 8. It is better for the algorithm.


OK, thanks for the tip! I do have to mention though that I am not using the morning / afternoon mode, but the official mode. However, the lunch hours are marked as a break. (I have a number of questions regarding these 2 modes, but it'll be better to ask that in another thread.)

QuoteYour idea is interesting, but you cannot do it with occupy min. Occupy min will only occupy 4 slots, it will not ensure that in each slot there are number_of_classes activities. You might want to use instead the constraint activities min simultaneous in selected time slots (min value = number of classes), and this is indeed the first time someone shows me this nice trick.


Just to be sure I understand you correctly here: With Occupy min will only occupy 4 slots you mean will only occupy 4 slots over all classes combined?

Quote2) For max afternoons per week, use students interval max days per week. Unfortunately, only 100% weight possible. Maybe you can make a progressive approach, lowering this value as you find new timetables.

You can make certain slots mandatory with more constraints activities occupy min time slots from selection or, as you showed me, activities min simultaneous in selected time slots.

Unfortunately, you cannot say that if an afternoon is not empty, there should be at least 2 slots occupied. If you need to consider mornings+afternoons, I can advise you to have a look at the Mornings-Afternoons mode (Morocco and Algeria), where you have 5*2 days per week. There are examples.


Yes, I will do that soon. However, it is my assumption at this point that very important constraints will become useless in that mode.

When I open a new project in that mode, under Data - Basic - Days and hours - Days per week there is no differentiation between mornings and afternoons. This leads me to believe that technically mornings and afternoons would be considered separate days. This would mean that a whole number of constrains would become useless in this mode. For example, days between would consider mornings and afternoons as separate days, and therefore the same subject could be planned on one day in the morning and in the afternoon. Or am I wrong about this?

Liviu Lalescu

Quote from: maxi_mus on January 17, 2024, 09:34:50 AMOK, thanks for the tip! I do have to mention though that I am not using the morning / afternoon mode, but the official mode. However, the lunch hours are marked as a break. (I have a number of questions regarding these 2 modes, but it'll be better to ask that in another thread.)

I was just suggesting the Mornings-Afternoons mode if you need the afternoons to have 0 or at least 2 hours, and if this condition is essential (note that also mornings will need the same condition). In this mode, the  days are 10: Mon mor, Mon aft, Tue mor, Tue aft, ... , Fri aft.

Quote from: maxi_mus on January 17, 2024, 09:34:50 AMJust to be sure I understand you correctly here: With Occupy min will only occupy 4 slots you mean will only occupy 4 slots over all classes combined?

Yes. From all the selected activities, there will be at least one in each slot.

Quote from: maxi_mus on January 17, 2024, 09:34:50 AMYes, I will do that soon. However, it is my assumption at this point that very important constraints will become useless in that mode.

When I open a new project in that mode, under Data - Basic - Days and hours - Days per week there is no differentiation between mornings and afternoons. This leads me to believe that technically mornings and afternoons would be considered separate days. This would mean that a whole number of constrains would become useless in this mode. For example, days between would consider mornings and afternoons as separate days, and therefore the same subject could be planned on one day in the morning and in the afternoon. Or am I wrong about this?

You can start a new MA mode file and see the constraints. Or even convert your file to MA mode (but please keep a backup. You'll need some editing after that. I think each Official mode constraint is present in the MA mode. There are more constraints in the MA mode.

Mon mor, Mon aft, Tue mor, ..., Fri aft (10 days per week). You are wrong, I hope: min days between is adapted and refers to real days. See its description in the constraints' dialog.

maxi_mus

Quote from: Liviu Lalescu on January 15, 2024, 02:54:45 PMYour occupy min approach is good, but even better would be to select first and second hour of all afternoons except Wednesday, and min occupied = 8. It is better for the algorithm.


As a quick follow up: So if there are 5 (obligatory) hours in the morning, two lunch hours which are always a break, and then 2 (obligatory) hours in the afternoon (except on Wednesday), would it be even better to select  4x 7 hours and 1x 5 hours and make min occupied = 33?

Because my intuitive approach was to never allow a late start, allow no gaps, and mark just the second hour of the afternoon for the min occupied constraint. Everything else should just automatically follow through the other two constraints.

Liviu Lalescu

Quote from: maxi_mus on January 17, 2024, 09:52:21 AMAs a quick follow up: So if there are 5 (obligatory) hours in the morning, two lunch hours which are always a break, and then 2 (obligatory) hours in the afternoon (except on Wednesday), would it be even better to select  4x 7 hours and 1x 5 hours and make min occupied = 33?

Because my intuitive approach was to never allow a late start, allow no gaps, and mark just the second hour of the afternoon for the min occupied constraint. Everything else should just automatically follow through the other two constraints.

Oh, yes, indeed. But also please keep students begin early max 0 beginnings at second hour and max 0 gaps. Because I think it might be more efficient.

PS: In the MA mode, all constraints referring to real days contain "real" and to half days contain nothing. The only exceptions are min/max (half) days between activities.

maxi_mus

Quote from: Liviu Lalescu on January 17, 2024, 09:48:31 AMYou can start a new MA mode file and see the constraints. Or even convert your file to MA mode (but please keep a backup. You'll need some editing after that. I think each Official mode constraint is present in the MA mode. There are more constraints in the MA mode.

Mon mor, Mon aft, Tue mor, ..., Fri aft (10 days per week). You are wrong, I hope: min days between is adapted and refers to real days. See its description in the constraints' dialog.


OK, thank you very much. I will look into MA mode in detail very soon.

The problem is, that this is going to be a tradeoff for me in either case. Reason is, even though (for the types of schools I am evaluating FET at the moment) lunch hours are always a fixed break, there is one exception, which is cooking, which is done over lunch. While I can simulate this in the original mode (cooking starts during regular morning hours and lasts until the end of lunch break) I'm afraid this will make setting up MA mode even more complicated. But I have to test it out first.

maxi_mus

Sorry, what I meant to say was this:

I can simulate this in original mode by having cooking end at the last regular hour of morning. This way, the lunch hours can be marked as breaks for all classes.

Liviu Lalescu

You have some MA mode examples (choose one with Latin characters).

Floating break for a students set can be made with a dummy activity (no teachers), with correspondent preferred times.

Liviu Lalescu

Quote from: maxi_mus on January 17, 2024, 10:09:04 AMI can simulate this in original mode by having cooking end at the last regular hour of morning. This way, the lunch hours can be marked as breaks for all classes.

I am not sure I understand this, but you also have activities preferred times in the MA mode.

maxi_mus

OK, maybe I can explain better.

I need to define lunch hours as breaks in order to avoid a whole bunch of constraints. For example, if I didn't, for every possible double lesson, I would have to have a constraint that it can't be placed at the last hour of the morning and the first hour of the afternoon, because that would not be consecutive, although technically it would be.

Cooking takes place for example on Monday the two last hours of morning and over lunch. Instead of defining it as a block of 4 lessons, I just define it as 2, so in FET every class then actually has the fixed break at lunch. Then when making the actual schedule you can just add in the two missing lessons over lunch.

Liviu Lalescu

Oh, maybe I understand. If it works, it is OK. You know better than me.

PS: I just looked on the MA mode: you have constraints students begin early + begin mornings + begin afternoons early. Also for teachers, mornings/afternoons. They might be useful.