help-glpk
[Top][All Lists]

## Re: [Help-glpk] CSV outputting MathProg for summary report mapulation

 From: Noli Sicad Subject: Re: [Help-glpk] CSV outputting MathProg for summary report mapulation Date: Thu, 1 Mar 2012 21:19:32 +1100

```Finally got it.

Here's the right mathprog script for the problem.

#############################################3

param f,symbolic := "WoodFlowSummaryR.csv";

printf "Writing output to %s\n", f;

printf "Period,ClearfellArea" > f;

for  {p in PRODUCT: Status[p] in YIELD} printf ",%s", p >> f;

printf "\n" >> f;

for{t in PERIOD} {

printf "%d,%f",t, (sum {(t,i,j) in HARVEST} Y[t,i,j])>>f;

for {p in PRODUCT: Status[p] in YIELD} printf ",%f", (sum{(t,i,j) in
HARVEST} Y[t,i,j]*Yield[p,i,j])>>f;

printf "\n" >>f;

}

##############################3
Here's the table now:

Period,ClearfellArea,TRV,P1P2,SLOG,PULP
1,3086.198217,1382637.725042,102798.000000,726261.758977,553577.966065
2,1268.435551,510967.374538,65270.600000,241168.957090,204527.817449
3,1414.810346,499699.031451,73155.626951,226543.404499,200000.000000
4,1050.017274,500236.363522,88775.432342,211460.931180,200000.000000
5,996.278617,500455.414672,105285.098810,195170.315862,200000.000000
6,1108.693198,533655.860669,125261.038572,195129.472586,213265.349511
7,1304.170924,620943.788743,150564.046286,222190.315724,248189.426733
8,1541.747873,732194.846730,180771.895544,258734.268933,292688.682253
9,1820.969969,867194.215303,217282.674652,303194.183828,346717.356822
10,2184.610549,1037886.398363,260252.789583,363014.506653,414619.102127
.
.
45

It needs just formatting now.

Noli

On 3/1/12, Meketon, Marc <address@hidden> wrote:
> Printing out the CSV header using printf is probably doable with a statement
> like:
>
>   printf {p in PRODUCT} : "%s," PRODUCT[p] > "filename.csv" ; #no "new line"
>   printf "DUMMY\n;  #last one has the new line
>
> The DUMMY was added because the last comma would be hanging out by itself
> without it.
>
> I would guess that you could dump out the data this way as well, but add a
> dummy value at the end.
>
> This is somewhat convoluted and probably there is a better way.
>
> -----Original Message-----
> Sent: Thursday, March 01, 2012 2:55 AM
> To: Meketon, Marc
> Subject: Re: [Help-glpk] CSV outputting MathProg for summary report
> mapulation
>
> This is the data set for the problem.
>
>
> set PRODUCT:=
>
> TRV
>
> SCOST
>
> PCOST
>
> P1P2
>
> SLOG
>
> PULP
>
> CFREV
>
> LCOST
>
> TCOST
>
> SACOST
>
> RCOST;
>
>
>
> #param Type{PRODUCT} symbolic;                          #  Product (Final),
> Thinning
> (Intermediate), Residue
>
>
>
> param Type:=
>
> TRV     Final
>
> SCOST   Intermediate
>
> PCOST   Intermediate
>
> P1P2    Final
>
> SLOG    Final
>
> PULP    Final
>
> CFREV   Final
>
> LCOST   Final
>
> TCOST   Final
>
> SACOST  Final
>
> RCOST   Final;
>
>
>
> #param Status{PRODUCT} symbolic;    #  Revenue, Cost, Yield, Ignore
>
> param Status:=
>
> TRV             Yield
>
> SCOST           Cost
>
> PCOST           Cost
>
> P1P2            Yield
>
> SLOG            Yield
>
> PULP            Yield
>
> CFREV           Revenue
>
> LCOST           Cost
>
> TCOST           Cost
>
> SACOST          Cost
>
> RCOST           Cost
>
> ;
>
> Noli
>
>> Thanks for the suggestion.
>>
>>> Second line was incorrect.  A better approximation is:
>>>
>>> printf " Period,ClearfellArea,TRV,P1P2,SLOG,PULP\n" > "filename.csv"
>>> printf {(t,i,j) in HARVEST}: "%d,%f\n"  t, sum {(t,i,j) in HARVEST}
>>> Y[t,i,j]
>>>>> "filename.csv"
>>>
>>
>> However, TRV, P1P2, SLOG, PULP are inputs so it changes from time to
>> time. It could not be hardcoded. Some of the data sets for case
>> studies, the YIELD may have PRODUCTS where are P1, P2, SLOG1, SLOG2,
>> K1, K2, C1, C2, PULP.
>>
>> Any suggestion how to do this using
>>
>> for {p in PRODUCT} { } syntax.
>>
>> #######################
>>
>> {p in PRODUCT: Status[p] in YIELD} <sum {(t,i,j) in HARVEST}
>> Y[t,i,j]*Yield[p,i,j] ~ (p)>;
>>
>> Thanks.
>>
>> Noli
>>
>
> This e-mail and any attachments may be confidential or legally privileged.
> If you received this message in error or are not the intended recipient, you
> should destroy the e-mail message and any attachments or copies, and you are
> prohibited from retaining, distributing, disclosing or using any information
> contained herein.  Please inform us of the erroneous delivery by return
> e-mail. Thank you for your cooperation.
>

```