X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?a=blobdiff_plain;f=yarrg%2Fweb%2Froutetrade;h=c7dd03e5d0166e63c4054ed3561450e8824ffff1;hb=53b0011bf5dd8b8b0686848ba5e0a384de1b9326;hp=c6ed408d80fe9d779e54de724856c6abf02ab673;hpb=fdf4e5538945f9d058f3ad54ddfe707b0977e1d4;p=ypp-sc-tools.db-test.git diff --git a/yarrg/web/routetrade b/yarrg/web/routetrade index c6ed408..c7dd03e 100644 --- a/yarrg/web/routetrade +++ b/yarrg/web/routetrade @@ -261,6 +261,15 @@ foreach my $v (qw(MaxMass MaxVolume)) { <& dumptable:end, qa => $qa &> % } +% if (@islandids==1) { +% if (defined $islandids[0]) { +Searched for arbitrage trades only. +% } else { +Searched for arbitrage trades only, in <% $archipelagoes[0] |h %> +[?]. +% } +% } + <%perl> my @sail_total; @@ -524,7 +533,7 @@ if ($qa->{'debug'}) { $found_section= 1; next; } - if (m/^Objective:\s+totalprofit = (\d+\.\d*) /) { + if (m/^Objective:\s+totalprofit = (\d+(?:\.\d*)?) /) { $expected_total_profit= $1; } next unless $found_section==1; @@ -565,6 +574,7 @@ if ($qa->{'debug'}) { my $prerr= "\n=====\n$cplex\n=====\n$glpsol_out\n=====\n "; pipethrough_run_finish($output,$prerr); map { defined $_->{OptQty} or die "$prerr $_->{Flow}{Ix}" } @subflows; + defined $expected_total_profit or die "$prerr ?"; }; $addcols->({ DoReverse => 1, TotalSubflows => 1, Special => sub { @@ -585,17 +595,32 @@ $addcols->({ Total => 0, DoReverse => 1, TotalSubflows => 1 }, qw( % } # ========== OPTIMISATION ========== +% if (!printable($m)) {

Contents

+% } else { +% my @tl= gmtime $now or die $!; +

+Generated by YARRG at <% + sprintf "%04d-%02d-%02d %02d:%02d:%02d UTC", + $tl[5]+1900, @tl[4,3,2,1,0] + |h %>. +% } % if ($optimise) { # ========== TRADING PLAN ========== % @@ -607,9 +632,16 @@ $addcols->({ Total => 0, DoReverse => 1, TotalSubflows => 1 }, qw( %

Voyage trading plan

- +
> +% my $tbody= sub { +% if (!printable($m)) { return ''; } +%# return " +<% $tbody->(1) %> +<% $tbody->(0) %> % } % $total += $t->{Total}; % my $span= 0 + keys %{ $t->{Stalls} }; % my $td= "td rowspan=$span"; - +% tr_datarow($m,$dline); <<% $td %>><% $collectdeliver %> <<% $td %>><% $t->{'commodname'} |h %> % @@ -735,7 +767,7 @@ $addcols->({ Total => 0, DoReverse => 1, TotalSubflows => 1 }, qw( <<% $td %> align=right><% $t->{Total} |h %> total % % foreach my $stallix (1..$#stalls) { - +% tr_datarow($m,$dline); % $pstall->($stallix); % } % @@ -767,7 +799,7 @@ $addcols->({ Total => 0, DoReverse => 1, TotalSubflows => 1 }, qw( $show_total_now->($totals); } - +<% $tbody->(1) %>' : '';

Relevant trades

@@ -882,14 +915,14 @@ Islands shown in reverse order of visits.
-% foreach my $col (@cols) { +% foreach my $col (@cols) { @@ -923,17 +956,17 @@ Islands shown in reverse order of visits.
%>><% exists $spec->{String} ? $spec->{String} : $v |h %> % $ci += $spec->{Span}; % } -% } +% }

"; +% my ($c)= qw(40 00)[$_[0]]; +% return "
"; +% }; +% % foreach my $i (0..$#islandids) { -
% $iquery->execute($islandids[$i]); % my ($islandname) = $iquery->fetchrow_array(); @@ -714,12 +746,12 @@ $addcols->({ Total => 0, DoReverse => 1, TotalSubflows => 1 }, qw( (Data age: <% prettyprint_age($age) %>) % } elsif (!defined $total) { % $total= 0; -
Total distance: <% $total_dist %> leagues. Overall net cash flow <% @@ -781,7 +813,7 @@ Expected average profit: % % } # ========== TRADING PLAN ========== -% { +% if (!printable($m)) {

Data age summary

<%perl> my $sth_i= $dbh->prepare(< % } -% my %ts_sortkeys; -% { +% if (!printable($m)) { +% my %ts_sortkeys; +% { % my $cdspan= $qa->{ShowStalls} ? ' colspan=2' : ''; % my $cdstall= $qa->{ShowStalls} ? '
Stall Capital Profit % } -% } +% }
-% } +% } -% foreach my $flowix (0..$#flows) { +% foreach my $flowix (0..$#flows) { % my $flow= $flows[$flowix]; % my $rowid= "id_row_$flow->{UidShort}";
Total -% foreach my $ci (3..$#cols) { +% foreach my $ci (3..$#cols) { % my $col= $cols[$ci]; % if (defined $col->{Total}) { <% $col->{Total} |h %> % } -% } +% }
<&| tabsort, cols => \@cols, table => 'trades', rowclass => 'datarow', @@ -943,6 +976,8 @@ Islands shown in reverse order of visits.
+% } # !printable + <%init> use CommodsWeb; use Commods;