About a command-line only version of FET

Started by sederek, October 30, 2010, 03:42:16 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

sederek

Hi there,

First of all, I want to thank Liviu Lalescu for such a great application. I've had an assignment about preparing timetables for various user inputs, FET helped me through with that.

I have a custom FET version request and a suggestion, all in one question: can you make a command-line only version of FET?
I'm trying myself, but you are more familiar with the source codes. In fact, I don't know where Qt steps in, where it steps out; or which files I should change to get the command-line working and not the user interface.

About why I asked for that: FET is such a great program, I examined about 3-4 other software for timetabling problems, FET is the only one that supports so many constraints and prepares the schedule in a short time.

It would be best if users had a command-line only version, because:
  • One could integrate FET into any application he wants, as long as s/he could execute shell commands.
  • Some users in the forum asked for an API, a command-line only version is not the same but it could be a start for filling in such requests.
Another situation is going on with Institution name and Comments section - I think it would be very nice to have these fields as table header and footer rows, consider this: if the generated timetable wanted to be printed out, all the tables would have the header row and the footer row with user inputted data in it. For example, one should enter school address, website info and phone number in such area.

I'm looking forward to your replies, thanks again.

Keep up the good work,

Kerem Ulutas

Liviu Lalescu

About command line: there are some problems even if I make only a command line version. The generation section of FET uses Qt classes like QList, QSet, QHash and maybe others. You still need the Qt shared libraries for that. I know, I should have used stl, but it is too late now to change.

Maybe you could use Qt as a static library. This way, a command line only FET might be small. Or you could get the code for QList, QSet and QHash from Qt code and integrate it into FET command line.

I cannot take care of a command line FET in parallel with the GUI version, because it is too difficult for a single person. But I can tell you how to obtain a command line version by modifying the sources.

Just use the src/engine/ files and src/interface/fet.h & .cpp. Modify fet.cpp, which is not complicated. If you get some errors about undefined variables, add these (I think from src/interface/fetmainform.h & .cpp) or ask me for further advice.

To obtain an API is my idea of a good timetabling program. I am only interested in solving the timetable, I am not very interested in the interface. If someone else develops a nice program using FET generation algorithm, it might replace FET.

The data structures for FET API are in src/engine/generate_pre.h & .cpp. You may need also some portions of src/engine/rules.h & .cpp, which are based on the other parts of the directory src/engine/.

About header and footer change, I am not sure it is a good one. The name of the institution appears as a heading, and the comments may be too large.

But you can always modify the source code or develop your small application to process the output of FET and generate your exact required output.

Let me know further problems.

sederek

#2
I just began with doing that, it's a long way to go.

BTW, I didn't mean 2 seperate versions: think of a library (src/engine/* in this occasion) and a command line version (using the library) and another gui application (the actual FET, as it is now) which is just an interface to let users use the library.

This way, you won't have to keep track of changes between command-line version and/or library, they will be all in one project again. As usual, you'll code on which part you want more -- because those will be layers of the FET application.

About the Qt libraries interference: I don't want to change anything about the current sources, only the way they work - so I won't try to get Qt out of the equasion, as it may be good to sacrifice disc space instead of sacrificing performance.

Like I said, I'll try to edit the sources in my seperate time, I wish I will succeed. Thanks for the comments, keep up the good work ;)

Liviu Lalescu

#3
QuoteI just began with doing that, it's a long way to go.

BTW, I didn't mean 2 seperate versions: think of a library (src/engine/* in this occasion) and a command line version (using the library) and another gui application (the actual FET, as it is now) which is just an interface to let users use the library.

This way, you won't have to keep track of changes between command-line version and/or library, they will be all in one project again. As usual, you'll code on which part you want more -- because those will be layers of the FET application.

About the Qt libraries interference: I don't want to change anything about the current sources, only the way they work - so I won't try to get Qt out of the equasion, as it may be good to sacrifice disc space instead of sacrificing performance.

Like I said, I'll try to edit the sources in my seperate time, I wish I will succeed. Thanks for the comments, keep up the good work ;)

You are right, I should have made FET a modular application, but my knowledge is not too good in this domain.

I am not sure, do you know that it is currently possible to run FET in command line? Just run fet (or fet.exe) with parameters, like: "fet --inputfile=data.fet" (the complete options are written in the README file). If you add any parameters, FET will start in command line and not GUI.

sederek

Yes, I've managed to use FET in my assignment that way -- but there is a small problem, the application still gives FET critical or FET warning message boxes while running in command-line mode.

I built a web application using PHP and SQLite, gathering data from user input & passing them to FET command line. My mentor mentioned that it would be a product which is installable by a setup file, I achieved that also. But the message boxes kept popping up, which is unusual in a PHP driven website (running in localhost, not internet environment).

It's a very interesting idea to keep everything simple in aspects of application design. You try to let every part do only and only their job - not others. Depending on the level you achieve that, you'll get your product layered at that level. Same thing goes on with web technologies, take a look at http://www.csszengarden.com/ They try to keep html to contain only the content & a css file to contain all the style info. It's quite amazing to see one css file makes all that changes in the examples @ that site.

Now I'm trying to isolate the QMessageBox lines from the sources, I'm simply changing them like that:

QString s = tr("The constraint\n%1 will be modified into constraint\n%2 because there is only one room left in the constraint").arg(c->getDetailedDescription(*this)).arg(c2->getDetailedDescription(*this));
cout << s.toStdString();


Maybe that behaviour would be changed by simply logging into a file or sth, but that's just fine for the beginning. Consider my assignment, in case of an error or warning I would simply let the user know that command-line FET returned an integer other than 0, and show him/her the output of the stdout & tell to change his/her input, by not showing message boxes.

Thanks, and happy coding ;)

Kerem Ulutas

Liviu Lalescu

#5
You are right about separating tasks, but they were not clear at the beginning of coding. Also, I needed to do all the tasks by myself (with the help of Volker after a while) and I was a bit overwhelmed.

You may try to replace "QMessageBox" with "CustomQMessageBox" (replace in a text editor with the Replace command) - I think you only need to do that in rules.cpp and generate_pre.cpp. Then, implement CustomQMessageBox as a class to do what you need :-)

sederek

#6
Hello again,

I managed to get a working command-line only FET. Here you can get the source code:
http://www.megaupload.com/?d=4SD58V8S

I would be very glad if you take a look at it, check if anything is wrong - I probably missed something, I do not comfortable because I'm not familiar with the codes as you are.

After this code will be maintained, the next move is to make a dll out of everything except main.cpp file. That would give us the FET API. Then, we could use that DLL inside the FET gui application or anywhere we would like. But first, please check the codes and tell me if everything is fine.

I'm not very good at writing command-line applications which take arguments, so that part may be tweaked. I'm working on an Ubuntu environment, so you may have to compile on your own system. As I used Qt Creator like you, I don't think there would be problems about that.

Thanks and keep up the good work.

P.S.: Gheorge Hagi is the coach of Galatasaray (again) He is one of the best footballers ever seen, I think :) What do you think about him, in Turkey he is like a football god. :)

Liviu Lalescu

It seems fine, short code, but you didn't follow what I suggested, to change the MessageBox references to a custom class and implement that class. You won't have the error messages available to the user.

Observations:

1) fet.cpp should be removed?
2) #includes in main.cpp, not time.h or stdlib.h, but ctime and cstdlib
3) OBJECTS_DIR and MOC_DIR in fetconsole.pro should direct to an existing directory, maybe you should make them: OBJECTS_DIR=tmp and MOC_DIR=tmp and create a "tmp" subdirectory (and in this subdirectory, put a placeholder file, like I did).

Yes, Hagi is appreciated also here :-)

sederek

Yes, I didn't change the behaviour of QMessageBox lines for now. This is the precise moment we step in to change this. I think we should add an extra class, for user informing kinda stuff. That'll be like:

CustomClass("let the user know this", true) --> true so that it'll be logged, for instance
CustomClass("ask user that ?", true, &userinput) --> so that we could know user's answer, userinput can be overloaded so that various types of possible answers would be passed

The logging work can also be done there, the API would be more elastic for user interaction. I'm thinking of the class right now.

Maybe I'll feel lazy & do what you suggested, just don't know :)

Liviu Lalescu

I was saying that you can replace (using the Replace string function of a text editor), QMessageBox with another class, CustomMessageBox, and the same for LongTextMessageBox. Then, the class CustomMessageBox has the same member functions as QMessageBox, but implemented as you like. You don't need to change anything else in the FET code - so this change is very easy.

Example: QMessageBox::information(QString&, QString&, QString&) - implement a function CustomMessageBox::information(QString&, QString&, QString&) which writes the third string to cout.

Aaron Redmond

I know this thread is a bit old, but I just wanna say thank you. I am creating an online timetabling & management system as a college project, and a command line version of FET is exactly what I need.

Cheers

Liviu Lalescu

I am glad to hear this :-)

You are invited to post your results and links to your project.

Aaron Redmond

I certainly will, provided I remember. The project will be open source and hopefully I will implement most of it

Liviu Lalescu

Reviving an old topic: a FET command line without using the X-server is available, see the fet-cl executable in the FET archive (after compiling, or directly available in the Windows executable archive).

deewahyu

#14
Quote from: Aaron Redmond on February 03, 2011, 07:25:24 PMI know this thread is a bit old, but I just wanna say thank you. I am creating an online timetabling & management system as a college project, and a command line version of FET is exactly what I need.

Cheers

Hi Aaron, I am strugling to make FET can be accessed online. Could you please share the code?. As you said before, the code will be opened.