X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?a=blobdiff_plain;f=yarrg%2Fweb%2Froutetrade;h=f9ebfeaf3f60fa783ce8c796090906d38c4eefc0;hb=ba117b2a7d73eae16ad76edf42ebf7e7c93f282a;hp=d90bf40fb7afe7993c0f0924e4ea38c2e6dc2ba0;hpb=18bdd63163d8af1276eb26a67ccc6e78a1f7c158;p=ypp-sc-tools.db-live.git diff --git a/yarrg/web/routetrade b/yarrg/web/routetrade index d90bf40..f9ebfea 100644 --- a/yarrg/web/routetrade +++ b/yarrg/web/routetrade @@ -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( %> <& query_age:dataages, id2age => \%da_ages &> +Expected average profit: + approx. <% sprintf "%d", $expected_total_profit %> poe + (considering expected losses, but ignoring rum consumed) % % } # ========== TRADING PLAN ==========