chiark / gitweb /
routesearch: make absolute/perleague into 2-element arrays rather than macros
[ypp-sc-tools.db-live.git] / yarrg / web / routetrade
index d90bf40fb7afe7993c0f0924e4ea38c2e6dc2ba0..f9ebfeaf3f60fa783ce8c796090906d38c4eefc0 100644 (file)
@@ -57,6 +57,7 @@ my $now= time;
 my @flow_conds;
 my @query_params;
 my %dists;
+my $expected_total_profit;
 
 my $sd_condition= sub {
        my ($bs, $ix) = @_;
@@ -292,7 +293,11 @@ foreach my $f (@flows) {
                        Flow => $f,
                        Org => $sfi->[0],
                        Dst => $sfi->[1],
-                       Var => sprintf "f%ss%s", $f->{Ix}, $sfi->[0]
+                       Var => sprintf "f%ss%s_c%d_p%d_%d_p%d_%d",
+                               $f->{Ix}, $sfi->[0],
+                               $f->{'commodid'},
+                               $sfi->[0], $f->{'org_price'},
+                               $sfi->[1], $f->{'dst_price'}
                };
                push @{ $f->{Subflows} }, $subflow;
                push @subflows, $subflow;
@@ -420,10 +425,9 @@ foreach my $flow (@flows) {
        }
        foreach my $od (qw(org dst)) {
                my $limname= join '_', (
-                       'avail',
-                       $flow->{'commodid'},
                        $od,
-                       $flow->{"${od}_id"},
+                       'i'.$flow->{"${od}_id"},
+                       'c'.$flow->{'commodid'},
                        $flow->{"${od}_price"},
                        $flow->{"${od}_stallid"},
                );
@@ -523,6 +527,9 @@ if ($qa->{'debug'}) {
                        $found_section= 1;
                        next;
                }
+               if (m/^Objective:\s+totalprofit = (\d+\.\d*) /) {
+                       $expected_total_profit= $1;
+               }
                next unless $found_section==1;
                if (!length $continuation) {
                        next if !$continuation &&  m/^[- ]+$/;
@@ -542,7 +549,7 @@ if ($qa->{'debug'}) {
                        (\w+) \s+ (?: [A-Z*]+ \s+ )?
                        ([0-9.]+) \s
                        /x or die "$_ ?";
-               if ($varname =~ m/^f(\d+)s(\d+)$/) {
+               if ($varname =~ m/^f(\d+)s(\d+)_/) {
                        my ($ix,$orgix) = ($1,$2);
                        my $flow= $flows[$ix] or die;
                        my @relsubflow= grep { $_->{Org} == $orgix }
@@ -873,6 +880,9 @@ $addcols->({ Total => 0, DoReverse => 1, TotalSubflows => 1 }, qw(
  %></strong>
 </table>
 <& query_age:dataages, id2age => \%da_ages &>
+Expected average profit:
+ approx. <strong><% sprintf "%d", $expected_total_profit %></strong> poe
+ (considering expected losses, but ignoring rum consumed)
 %
 % } # ========== TRADING PLAN ==========