commods.unitmass unitmass,
commods.unitvolume unitvolume,
buy.price - sell.price unitprofit,
- min(sell.qty,buy.qty) tqty,
- min(sell.qty,buy.qty) * (buy.price-sell.price) profit
+ min(sell.qty,buy.qty) max_qty,
+ min(sell.qty,buy.qty) * (buy.price-sell.price) max_profit
FROM commods
JOIN buy on commods.commodid = buy.commodid
JOIN sell on commods.commodid = sell.commodid
)
AND buy.price > sell.price
GROUP BY commods.commodid, org_id, org_price, dst_id, dst_price
- ORDER BY org_name, dst_name, profit DESC, commodname,
+ ORDER BY org_name, dst_name, max_profit DESC, commodname,
org_price, dst_price DESC
";
$sth->execute(@query_params);
my @flows;
+my @columns= qw(org_name dst_name commodname
+ org_price org_qty dst_price dst_qty
+ max_qty max_profit);
+
</%perl>
% if ($qa->{'debug'}) {
totalprofit:
".(join " +
- ", map { "$_->{profit} $_->{Var}" } @flows)."
+ ", map { "$_->{unit_profit} $_->{Var}" } @flows)."
Subject To
";
$found_section= 2;
next;
}
- m/^\s*\d+\s+f(\d+)\s+\S+\s+(\d+)\s/ or die "$_ ?";
- die if $1 >= @flows;
- $flows[$1]{Optimal}= $2;
+ my ($ix, $qty) =
+ m/^\s*\d+\s+f(\d+)\s+\S+\s+(\d+)\s/ or die "$_ ?";
+ my $flow= $flows[$ix] or die;
+ $flow->{Opt_qty}= $qty;
+ $flow->{Opt_profit}= $flow->{'unitprofit'} * $qty;
}
print "</pre>\n" if $qa->{'debug'};
pipethrough_run_finish($output, 'glpsol');
print join ' ', map { $_->{Optimal} } @flows;
+push @columns, qw(Opt_qty Opt_profit);
+
</%perl>
+<% join ' ', @columns %>
+
% } # ========== OPTIMISATION ==========
<%init>