On Tue, 18 Oct 2011, Andrew Makhorin wrote:
Yes when I print status I got numbers but I would like to have OPT ...
switch (glp_get_status(lp))
{ case GLP_OPT:
s = "OPTIMAL";
break;
case GLP_INFEAS:
case GLP_NOFEAS:
s = "INFEASIBLE";
break;
. . .
}
number_to_name.h:
#define datum(arg) { arg, # arg }
struct number_to_name {
int index,
const char *name;
} ;
const char *number_to_name(int index);
number_to_name.c:
#include "number_to_name.h"
const char *number_to_name(const struct number_to_name *table, int index)
{
for(int j=0; table[j].name; ++j) {
if(index==table[j].index) return table[j].name;
} // j
return "?";
}
main.c:
#include "number_to_name.h"
#include "glpk.h"
...
const struct number_to_name fred = {
datum(GLP_OPT),
datum(INFEAS),
datum(NOFEAS),
0, 0
} ;
...
s=number_to_name(fred, slp_get_status(lp));
A bit more complicated if one is just doing it once,
but the problem-specific stuff is only in main.c .
--
Michael [email protected]
"Pessimist: The glass is half empty.
Optimist: The glass is half full.
Engineer: The glass is twice as big as it needs to be."
_______________________________________________
Help-glpk mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-glpk