Hello Emanuele You should join the mailing list if you wish to post. Moreover, your subject line "Suggestions for GLPK" is not especially clear and it would help both you and those later wishing to search the archives if your post was more precisely titled.
------------------------------------------------------------ To: help-glpk@gnu.org Subject: Suggestions for GLPK From: Emanuele Miucci <1kron...@gmail.com> Date: Thu, 31 May 2012 12:09:06 +0200 ------------------------------------------------------------ > Dear GLPK group, > > I'm Emanuele a PhD student in TLC engeneering at the > University of Rome "Sapienza". "TLC" engineering? What is that? > I'm using GLPK to solve an optimization problem: the > input files (.mod and .dat) are written by a C program, > and then they are used calling glpsol.exe with a > system(). > > After the solve command in .mod file I've put a check > on the results because I want that the system() returns > 0 only if the optimal solution is found, otherwise it > has to return a number different from 0. If I use GLPK > v.4.45 everything works: the solver performs the check > when the optimal solution is found and when it's not > found. But if I use GLPK v.4.47 the check is performed > only when the optimal solution is found. Can you give > me some suggestions? Do you know another way to do > these operations? > > Thanks a lot for your attention! Best regards > > Emanuele As you correctly noted, the GLPSOL interface does not offer a rich set of return codes. However I was not aware of the change in behavior between versions 4.45 and 4.47 you mention. As a consequence of your query, I will add a new "Exit status" section to the GLPK wikibook: http://en.wikibooks.org/wiki/GLPK/Using_GLPSOL But I need confirmation from Andrew here: 0 = solver completed successfully but does not mean that an optimal solution was necessarily found -- the solver may have detected a proven infeasibility for instance / this exit status corresponds to 0 being returned from the appropriate solver call, one of: 'glp_simplex', 'glp_exact', 'glp_interior', or 'glp_intopt' else non-zero I think that the GLPK API manual should also be updated to record this information. Getting back to your original question. If you code using the GLPK APIs (rather than invoke the 'system' function), you can examine the value returned by the (above mentioned) solver call and respond accordingly (more details in the API manual). Moreover, GLPK offers APIs to read in MathProg models and write out the solutions in various formats. Otherwise you can continue with the 'stdlib.h' 'system' call, redirect the GLPSOL terminal output to a text file, and then read this file in and examine its contents (someone who uses Windows might be able to help with the redirect syntax for that system). Personally I would use 'Boost.String_Algo' or even 'Boost.Regex' C++ libraries for the text scanning part (but you could also use standard C string functions): http://www.boost.org/doc/libs/1_49_0/doc/html/string_algo.html http://www.boost.org/doc/libs/1_49_0/libs/regex/doc/html/index.html The first suggestion is programmatically cleaner. The second option would need to be updated whenever GLPK modifies its terminal reporting. HTH, Robbie --- Robbie Morrison PhD student -- policy-oriented energy system simulation Technical University of Berlin (TU-Berlin), Germany University email (redirected) : morri...@iet.tu-berlin.de Webmail (preferred) : rob...@actrix.co.nz [from Webmail client] _______________________________________________ Help-glpk mailing list Help-glpk@gnu.org https://lists.gnu.org/mailman/listinfo/help-glpk