[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-glpk] mathprog and multiline strings
From: |
Henri Gourvest |
Subject: |
Re: [Help-glpk] mathprog and multiline strings |
Date: |
Sat, 09 Feb 2013 23:07:06 +0100 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130107 Thunderbird/17.0.2 |
Le 09/02/13 22:56, Jeffrey Kantor a écrit :
Hi Henri,
This would be very helpful, indeed. Could you give a brief usage example?
yes of course, this is the newsvendor print section in html
param html, symbolic, default "solution.html";
param header, symbolic, default """
<h4>%s</h5>
<table class="table table-condensed">
<thead>
<tr>
<th>Scenario</th>
<th>Prob</th>
<th>Demand</th>
<th>Order</th>
<th>Sold</th>
<th>Salvage</th>
<th>Profit</th>
</tr>
</thead>
""";
param line, symbolic, default """
<tr>
<td>%s</td>
<td>%.2f</td>
<td>%.2f</td>
<td>%.2f</td>
<td>%.2f</td>
<td>%.2f</td>
<td>%.2f</td>
</tr>
""";
param footer, symbolic, default """
<tr class="info">
<td>%s</td>
<td/>
<td>%.2f</td>
<td>%.2f</td>
<td>%.2f</td>
<td>%.2f</td>
<td>%.2f</td>
</tr>
</table>
""";
# align col number on the right
printf """
<style>
table td:not(:first-child),
table th:not(:first-child)
{text-align: right !important;}
</style>
""" >> html;
printf header, "Expected value of the mean solution" >> html;
printf {k in SCENS} line,
k, Pr[k], D[k], ExD, min(ExD,D[k]), max(ExD-D[k],0),
-c*ExD + r*min(ExD,D[k]) + w*max(ExD-D[k],0) >> html;
printf footer,
'MEAN', ExD, ExD, sum{k in SCENS}Pr[k]*min(ExD,D[k]),
sum{k in SCENS}Pr[k]*max(ExD-D[k],0),EVM >> html;
printf header, "Expected value with perfect information" >> html;
printf {k in SCENS} line,
k, Pr[k], D[k], D[k], D[k], 0, -c*D[k] + r*D[k] >> html;
printf footer,
'MEAN', ExD, ExD, ExD,0,EVPI >> html;
printf header, "Two stage stochastic programming" >> html;
printf {k in SCENS} line,
k, Pr[k], D[k], x, y[k], x-y[k], -c*x + r*y[k] + w*(x-y[k]) >> html;
printf footer,
'MEAN', ExD, x, sum{k in SCENS}Pr[k]*y[k],
sum{k in SCENS}Pr[k]*(x-y[k]),ExProfit >> html;
printf """
<ul>
<li>Order Quantity = %g</li>
<li>Expected Profit = %g</li>
<li>Value of perfect information: %.2f</li>
<li>Value of the stochastic solution: %.2f</li>
</ul>
""",
x, ExProfit, EVPI - ExProfit, ExProfit - EVM >> html;