help-glpk
[Top][All Lists]
Advanced

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

Re: [Help-glpk] CSV output?


From: Noli Sicad
Subject: Re: [Help-glpk] CSV output?
Date: Mon, 26 Jul 2010 08:46:02 +1000

Kevin,

CSV input and output in glpsol can be easily done using Tablets.

Have a look at the transp_csv.mod in ...example\csv folder.
The documentation how to implement it in tablets.pdf in doc folder

You don't need to use csv input to get the csv output.

Here's example below.

Noli

~~~~~~~~~~~
solve;

table tab_result{(i,j) in K} OUT "CSV" "result.csv" :
  i ~ plant, j ~ market, x[i,j] ~ shipment, x[i,j].dual~ dual;

 table ts {i in I} OUT 'CSV' 'supply.csv' :
 i ~ PLANT,
 supply[i].val ~ SUPPLY_VAL,
 supply[i].lb ~ SUPPLY_LB,
 supply[i].ub ~ SUPPLY_UB,
 supply[i].dual ~ SUPPLY_DUAL;

table td {j in J} OUT 'CSV' 'demand.csv' :
 j ~ MARKET,
 demand[j].val ~ DEMAND_VAL,
 demand[j].lb ~ DEMAND_LB,
 demand[j].ub ~ DEMAND_UB,
 demand[j].dual ~ DEMAND_DUAL;


On 7/26/10, Kevin Hunter <address@hidden> wrote:
> Hello List,
>
> I'm attempting to programmatically parse the solution output from GLPK.
>   From what I currently see, there's no way to unambiguously parse the
> output because of a lack of delimiters.  The only "mostly correct" way
> that I see is to use column indices.  The problem with this is if the
> value exceeds the column width, parsing gets much more difficult.
>
> What I would like would be an unambiguous format like what CSV could
> provide.  For example, the 1st example below could be unambiguously (and
> much more easily) parsed if presented as a CSV:
>
> $ glpsol ... --output solution.soln
> $ cat solution.soln | grep -A3 'No.   Row name'
>
>     No.   Row name   St   Activity     Lower bound   Upper bound    Marginal
> ------ ------------ -- ------------- ------------- -------------
> -------------
>       1 cost         B        153.675
>       2 supply[Se]   B            300                         350
>
> $ glpsol ... --output_format csv --output solution.soln
> $ cat solution.soln | grep -A3 'No.,Row name'
>
> No.,Row name,St,Activity,Lower bound,Upper bound,Marginal
> 1,cost,B,153.675,,,
> 2,supply[Se],B,300,,350,
>
> (Please excuse the email formatting, if possible.  If not, I can resend
> the output as an attachment so that it won't get muddled.)
>
> This also has the virtue of
>
>   - Creating a smaller output file
>
>   - The output can more easily be understood by a multitude of tools
>     and libraries (for instance, Excel/Calc, scripting CSV libraries,
>     etc.).  Less ad-hoc and specific parsing necessary.
>
>   - Making unambiguous output, for example, like what currently happens
>      - when row name exceeds 12 characters,
>      - if a string representation of a value exceeds the column width,
>      - or if a value is not specified (like index 2, lower bound)
>
>   - Keeping the "human readable" names of constraints and variables,
>     unlike the -w output format
>
> Is there another way to unambiguously represent the solution output?  If
> not, and if CSV would be welcomed by the developers, I'm happy to create
> a patch.
>
> Thanks,
>
> Kevin
>
> _______________________________________________
> Help-glpk mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/help-glpk
>



reply via email to

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