[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-glpk] glp_get_status
From: |
Michael Hennebry |
Subject: |
Re: [Help-glpk] glp_get_status |
Date: |
Tue, 18 Oct 2011 08:28:35 -0500 (CDT) |
User-agent: |
Alpine 1.00 (DEB 882 2007-12-20) |
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 address@hidden
"Pessimist: The glass is half empty.
Optimist: The glass is half full.
Engineer: The glass is twice as big as it needs to be."
Re: [Help-glpk] glp_get_status, Robbie Morrison, 2011/10/17