Main Menu
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Davide G. M. Salvetti

#1
Suggestions / Re: best and current timetable for cli
November 12, 2011, 02:45:56 PM
I'm testing the 2011-11-12 snapshot (Debian GNU/Linux here):

  • sending SIGTERM works as declared;
  • constraint comments and sorting thereon work as expected (i.e., lexicographically on comments)
  • the constraint activate/deactivate flag works as epxected;
  • activity comments work as expected; would it be possible to sort on comments the activity list as well?
Thanks! :-)

I have a question/suggestion more: I wonder if it's sensible to write a .fet file with all placed activities time and space constraints spelled out (i.e., just like the usual _data_and_timetable.fet, where each activity is (non permanently) blocked in time and space) even when fet gets interrupted, rather than only if it completes succesfully.  I think it could be useful, because that file could then be reused as a start, maybe manually deleting or adding some constraint.  What do you think?
#2
Suggestions / Re: best and current timetable for cli
November 11, 2011, 10:47:56 AM
Quote from: Liviu Lalescu on November 11, 2011, 10:31:04 AM
Quote from: Davide G. M. Salvetti on November 11, 2011, 10:21:46 AM
To me it's important to have the choice between dumping and continue and dumping and stop, so I see use for at least two signals.

Sorry, but there are not enough ANSI signals. Did you see that page? The only "decent" signal for me to handle would be SIGTERM. SIGINT must be left untouched by me.

Yes, I saw both pages, but I did not understand you thought you should catch only SIGTERM, leaving SIGINT untouched: I thought you considered using both of them.

Quote from: Liviu Lalescu on November 11, 2011, 10:31:04 AM
I think to write current+best timetable and continue generation would not be useful. But I would add it, if I had other "decent" ANSI signals.

I will try to express my motivation about why I consider allowing fet to continue after timetables dumping far more important than stopping it:

  • if fet nearly reached completion (say 998 activities placed out of 1000 total activities) and seems to have gotten stuck, the user might consider dumping the best timetable and working manually on it to try to place the few unplaced activities by hand while letting fet continue to run, hoping it will eventually reach completion, in case the user discovers to be actually unable to place the missing activies by hand, or just because fet could find a better solution, after all;
  • if I want fet to stop after timetables dumping, I can always stop it by hand; if I want fet to continue after it has stopped, I cannot.

Quote from: Liviu Lalescu on November 11, 2011, 10:31:04 AM
I am working on it right now :-)

Thanks :-)
#3
Suggestions / Re: best and current timetable for cli
November 11, 2011, 10:21:46 AM
Quote from: Liviu Lalescu on November 11, 2011, 06:31:39 AM

OK, I read that <csignal> is ANSI, so even under Windows it should compile.


I see.  I have no idea of how a Windows user can send signals to the application, however; I imagine that C-c from CLI could be SIGINT, but what about SIGTERM?  Maybe by killing the window?

In any case, with only two possibility, I would vote to have one of them dumping both the current timetable and the best timetable while continuing to compute new timetables, while the other could dump both current and best timetable and stop.

Quote from: Liviu Lalescu on November 11, 2011, 06:31:39 AM

The only problem in SIGTERM+SIGINT is that user cannot abandon generation without writing any timetable.


This is a minor problem, IMO, because the user can always easily delete unwanted timetables by hand.


Quote from: Liviu Lalescu on November 11, 2011, 06:31:39 AM

Edited to add: would it be better to write current timetable and best timetable on SIGTERM?


To me it's important to have the choice between dumping and continue and dumping and stop, so I see use for at least two signals.
#4
Suggestions / Re: interface improvement: sort constraints
November 11, 2011, 10:10:03 AM
Quote from: Liviu Lalescu on November 11, 2011, 09:26:58 AM
I thought some more:

Each constraint has Boolean 'active' and string 'comments'. Sorting is based on comments (so the user can add comment like: "rank: 1", "rank: 2"). And 'active' and 'comments' can only be edited from all time/space constraints.


That would be very good:

  • an active flag would let the user disable a constraint without deleting it and will, among its other uses, also avoid the need to have no-op like min hours daily = 1 just to keep the list complete;
  • you reminded me that many times I really missed comments, even only to annotate to myself the reason I added a particular constraint: comments are indeed very good for themselves;
  • sorting on comments could be a good compromise; of course having the possibility to sort on the fly on the base of different criteria without the need to alter comments would be better, but even only sorting on comments would be IMO a huge step forward toward ease of management for constraints.
#5
Suggestions / interface improvement: sort constraints
November 10, 2011, 09:56:17 PM
Hi,

out of my experience, when you have a lot of constraints (say, teacher not available constraints, min days between activities, min hours daily, ...), it would be desirable to be allowed to sort them, just like one can sort teacher, subjects, and so on.  The filter really helps finding out things, but works unfortunately in one-at-a-time only mode.  Sorting constraints (say, by teacher surname, by student group, et coetera, whenever and wherever appliable) would IMO allow a more productive management of the constraints set.

On a similar ease of management vein, I would also add the possibility to specify min hour daily = 1, just to allow the user to raise and lower this parameter at will, even to 1, without needing to delete and add again the constraints (which, if done for many teachers, in the absence of sorting, let's the list quickly turn into a mess); of course fet should plainly ignore min hour daily = 1, treating it like interface sugar, because the allow empty days box should always be kept checked in this case.

What do you think?
#6
Suggestions / Re: best and current timetable for cli
November 10, 2011, 09:40:23 PM
Quote from: Liviu Lalescu on November 10, 2011, 02:51:21 PM

1) I would like a unified treatment of any environment (GNU/Linux, Windows, Mac OS X);


You can use signals on every POSIX compliant OS, which includes GNU/Linux and Mac OS X.  Unfortunately, I believe Windows has no concept of signals (I might be mistaken here, though, I don't grok Windows); maybe we can use a file system polling approach instead, see below.

Quote from: Liviu Lalescu on November 10, 2011, 02:51:21 PM

2) How can I treat signals? (I have no experience.).


The basic concept is to define a handler (function / method) for a particular signal and let the OS know about it: whenever that signal arrives the OS will pass control to the handler, which runs by default without context switching.  A minimal C example should clarify:

Quote

#include <stdio.h>
#include <signal.h>

/* Define the handler */
void
sigusr1_handler (int signum)    /* the signum parameter allows to let a
                                                    single function handle more than one
                                                    signal; we don't need it here */
{
  printf ("Hi there, we've just got a USR1 signal.\n"); /* whatever */
  return;
}

int
main (void)
{
  signal (SIGUSR1, sigusr1_handler); /* register the handler with the OS
                                                             for the USR1 signal  */
  for ( ;; ) {}                   /* wait for ever */
}


In a POSIX compliant system you should compile, run and `kill -USR1 $pid' to see it in action.  There are many signals, not all of them can be handled with a custom handler, but I think USR1 and USR2 are what we want here.

Quote from: Liviu Lalescu on November 10, 2011, 02:51:21 PM

Should I take care of other things? Like writing the impossible activity and so on?


Yes, I think you can handle this sort of things by writing to the `result.txt' file.

What can you do on Windows?  Well, I don't really know, but I think on every OS with a file system you can use file system polling: once in a while you look for the existance of a special named file in a special place, let's say $outputdir/write_current_timetable; if it exists, you handle the request and delete it afterwards.  This way the user could touch the file to notify fet of the request.  Of course signalling is technically superior to file system polling, but if nobody comes forth with a better suggestion which includes Windows, I believe file system polling will work everywhere.  That said, I think it would be good to have fet both handle signals on POSIX system _and_ do file system polling everywhere.
#7
Suggestions / best and current timetable for cli
November 10, 2011, 02:30:39 PM
Hi,

first of all, many, many thanks to Liviu for the latest version release.

I have a suggestion which I deem very useful for the command line interface of fet: as I understand, there is at this moment no way to tell fet to save the current or best timetable if started from cli, just like one can do with the gui.

In a Unix environment, I would suggest to let fet save to disk the current timetable on receiving SIGUSR1 and the best timetable on receiving SIGUSR2, or something like that.  I don't know enough about Windows to suggest something for that.

Thanks.
#8
Quote
Quote
I would like to set a per teacher constraint along this lines: a teacher should do either the first or the last hour, but not both (i.e., if a teacher did the first hour, she should be free at the last one, and viceversa).

...

Do you have other solutions?

...

Yes, I think I have perfect solutions.

1.  a) For each teacher, add an activity split into n_days_per_week subactivities/components, min days between subactivities = 1 with 100% weight. Preferred time slots for this activity = first or last hour, each day (so, allowed 2*n_days_per_week slots). Or better, preferred slot for subactivity j = first hour or last hour of day j (no min days constraints needed in this case, and generation might be a bit faster). If you don't care about teachers' gaps (if your .fet file does not contain max gaps constraints per day/week for teachers), that's all. If you care about teachers' gaps, you have point (b), below:


Oh, thanks, nice idea, but I do care about teachers' gaps, so I think I will go with the next solution.

Quote

    b) Make a "copy" of all teachers and their activities, but the copy of activities should NOT include any students (a lot of work). Teacher T is real, teacher T' is fake. Then, add max gaps constraints individually, only for teacher T (and the rest of real ones). For teacher T', add the special activities of point (a). Then, add many constraints activities same starting time, for each corresponding pair of activities of teachers T and T' (a lot of work).


Now, I see that it is a lot of work, but with this marvelous shadow teachers trick you opened up a world to me!  Many thanks!  It would be less work if the constraint interface was scriptable: if I had a scriptable API which allowed me to parse the fet file and programmatically add activities and constraints it would be easy to automate; maybe this would be a work for XSLT, which unfortunately I don't grok very much.  In any case, I can probably use Emacs to automate at least part of the work, the XML .fet file is text, after all.

Quote

2. Modification of FET sources, an easy change. No additional changes to the .fet file. The only drawback is that not all people can benefit, since I am reluctant to add this constraint to the official FET. Let me know if you want the code (I think it is a matter of less than a page of code, maybe only a few lines of code). If other users ask me such a constraint, I might consider adding it to the official FET.

I think (2) is faster than (1), but I am not sure if much faster or even if it is observable.

Please let me know.

I would love to have a teacher constraint allowing me to state this and that (or all) teachers should stay at school no more than n hours, gaps or non gaps.

If you would be so kind to code it, I'd gladly accept!

Thanks!
#9
Get Help / Teacher constraint: either first or last hour
September 05, 2011, 06:41:13 AM
Hi,
first of all thank you for FET!

I would like to set a per teacher constraint along this lines: a teacher should do either the first or the last hour, but not both (i.e., if a teacher did the first hour, she should be free at the last one, and viceversa).

I see one way to set it would be to tell FET a teacher shouldn't do more than n-1 hours per day, but then FET doesn't count gaps, which does not suit me (I could add fictious activity for the gaps, but I would like not to predetermine the actual number of gaps).

Another way I see would be to tell FET that in each particular day the teacher is not available at firt or last hour, but in this way I have to manually chose the days: for a few teachers this can be done, but if the teachers with this constraint are numerous one could run into not easily spotted not enough teachers for first of last hour all constraint considered situations.

Do you have other solutions?

Thanks!
#10
Get Help / Re: Teacher in certain hours of a day
September 05, 2011, 10:00:26 PM
Quote
OK, I took note of your request. I still believe that my formulation "We need this new constraint: in a set of time slots, there can be placed maximum x number of activities from a specified set of activities (it is the negative of what you need)." is the most general.

But:

1) I cannot think of a decent FET style name for such a constraint; please let us know your proposals.
Maybe it's not the best, but this is what I can think of:

Time -> Activities -> Max number of activities from a set allowed in a set of time slots

Quote
2) I cannot promise I'll do it (soon).

By the way, Davide G. M. Salvetti, this would apply also to your first request: http://lalescu.ro/liviu/fet/forum/index.php?topic=413.0 , because we add n_days_per_week such constraints for each day j, with all activities of the teacher, and two slots: first and last hour of day j, allowed to occupy only one slot. (am I right?)
Yes, I think you are right, that would do.
#11
Get Help / Re: Teacher in certain hours of a day
September 05, 2011, 07:03:27 PM
Quote
QuoteI could do that, if I knew which activities to place.

But I only know that the teacher has to be in an activity, it doesn't matter, which activity this is. I only care that he has one (any of his) activities.

Background: The teacher has to prove to some government agency that he cannot be at home at certain times, because he has to work.

This cannot be done directly in current FET. We need this new constraint: in a set of time slots, there can be placed maximum x number of activities from a specified set of activities (it is the negative of what you need). I'll add this in the TODO, but don't know if and when I'll do it.

You may try to use some tricks, but it is clear that FET lacks something here.

Maybe you could use min gaps between activities.

I'm also interested in the original request (background: vice-headmaster, an otherwise normal teacher, has to be at school teaching no matter what in certain hours, most notably at the beginning of the day, to be able to possibly deal with pupils headmaster matters when the headmaster is not there, if need arises).

How could we make use of min gaps between activities to set this constraint?