help-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-glpk] glp_get_status


From: Robbie Morrison
Subject: Re: [Help-glpk] glp_get_status
Date: Tue, 18 Oct 2011 08:54:13 +1300 (NZDT)
User-agent: SquirrelMail/1.4.17

Hi all

------------------------------------------------------------
To:           name name <address@hidden>
Subject:      Re: [Help-glpk] glp_get_status
Message-ID:  <address@hidden>
From:         Andrew Makhorin <address@hidden>
Date:         Mon, 17 Oct 2011 23:33:21 +0400
------------------------------------------------------------

>> I solve LP model like this
>> glp_simplex(lp, parm)
>>
>> I wont like to have the status of the solution to ba able to write
>> something like this
>>
>> if(status ==optimal)...
>>
>> else if (status== infisible)....
>>
>> how can I do that?
>
> ret = glp_simplex(lp, parm);
> if (ret != 0)
>    goto fail;
> status = glp_get_status(lp);
> if (status == GLP_OPT)
>    ...
> else if (status == GLP_NOFEAS)
>    ...

Because 'status' is integral, you can also
use a switch statement:

    switch ( status )
      {
      case GLP_OPT:
      case GLP_FEAS:
        ...
        break;
      case GLP_INFEAS:
        ...
        break;
      default:
        ...
        break;
}

Don't forget the break statements!

If you want robust code, I would throw an C++ exception
rather than use a goto -- but then I come from the
generation that was taught that gotos were poor style.

Robbie
---
Robbie Morrison
PhD student -- policy-oriented energy system simulation
Technical University of Berlin (TU-Berlin), Germany
University email (redirected) : address@hidden
Webmail (preferred)           : address@hidden
[from Webmail client]






reply via email to

[Prev in Thread] Current Thread [Next in Thread]