Hi all

------------------------------------------------------------
To:           name name <[email protected]>
Subject:      Re: [Help-glpk] glp_get_status
Message-ID:  <1318880001.11562.1.camel@corvax>
From:         Andrew Makhorin <[email protected]>
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) : [email protected]
Webmail (preferred)           : [email protected]
[from Webmail client]




_______________________________________________
Help-glpk mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-glpk

Reply via email to