X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?a=blobdiff_plain;f=yarrg%2Fweb%2Froutetrade;h=831a1b1a26a2d46f051ec4265f8089cb13fbf7da;hb=d3f18f5c06089a54b57e8c94483ce48d82975c45;hp=482c13a3e9969e98e51afab2e8a8878be03bfeb3;hpb=a7d3f0bd7f84b3b40a7a7860f467f2beda20a227;p=ypp-sc-tools.main.git diff --git a/yarrg/web/routetrade b/yarrg/web/routetrade index 482c13a..831a1b1 100644 --- a/yarrg/web/routetrade +++ b/yarrg/web/routetrade @@ -38,15 +38,24 @@ $dbh @islandids @archipelagoes $qa +$max_mass +$max_volume +$lossperleaguepct <&| script &> da_pageload= Date.now(); +% if (defined $max_mass || defined $max_volume) { +WARNING - VESSEL CAPACITY LIMIT NOT YET IMPLEMENTED +

+% } + <%perl> +my $loss_per_league= defined $lossperleaguepct ? $lossperleaguepct*0.01 : 1e-7; + my $now= time; -my $loss_per_league= 1e-7; my @flow_conds; my @query_params; @@ -365,7 +374,7 @@ die "$cmpu $uue ?" if length $cmpu > 20;

% if (@islandids<=1) { -Route is trivial. +Route contains only one location. % } % if (!$specific) { Route contains archipelago(es), not just specific islands. @@ -383,9 +392,9 @@ my $cplex= " Maximize totalprofit: - ".(join " + + ".(join " ", map { - sprintf "%.20f %s", $_->{ExpectedUnitProfit}, $_->{Var} + sprintf "%+.20f %s", $_->{ExpectedUnitProfit}, $_->{Var} } @flows)." Subject To @@ -472,7 +481,14 @@ if ($qa->{'debug'}) { die $prerr unless $found_section; }; -$addcols->({ DoReverse => 1 }, qw( +$addcols->({ DoReverse => 1, Special => sub { + my ($flow,$col,$v,$spec) = @_; + if ($flow->{ExpectedUnitProfit} < 0) { + $spec->{Span}= 3; + $spec->{String}= '(Small margin)'; + $spec->{Align}= 'align=center'; + } +} }, qw( OptQty )); $addcols->({ Total => 0, DoReverse => 1 }, qw( @@ -551,16 +567,25 @@ $addcols->({ Total => 0, DoReverse => 1 }, qw( {UidShort} %> value=""> {UidShort} %> value="" <% $flow->{Suppress} ? '' : 'checked' %> > -% foreach my $ci (1..$#cols) { +% my $ci= 1; +% while ($ci < @cols) { % my $col= $cols[$ci]; +% my $spec= { +% Span => 1, +% Align => ($col->{Text} ? '' : 'align=right') +% }; % my $v= $flow->{$col->{Name}}; +% if ($col->{Special}) { $col->{Special}($flow,$col,$v,$spec); } % $col->{Total} += $v % if defined $col->{Total} and not $flow->{Suppress}; % $v='' if !$col->{Text} && !$v; % my $sortkey= $col->{SortColKey} ? % $flow->{$col->{SortColKey}} : $v; % $ts_sortkeys{$ci}{$rowid}= $sortkey; -{Text} ? '' : 'align=right' %>><% $v |h %> +{Span} ? "colspan=$spec->{Span}" : '' + %> <% $spec->{Align} + %>><% exists $spec->{String} ? $spec->{String} : $v |h %> +% $ci += $spec->{Span}; % } % } @@ -597,11 +622,11 @@ $addcols->({ Total => 0, DoReverse => 1 }, qw( % $iquery->execute($islandids[$i]); % my ($islandname) = $iquery->fetchrow_array(); -% my $this_dist= $distance->($islandids[$i-1],$islandids[$i]); -% $total_dist += $this_dist; % if (!$i) { Start at <% $islandname |h %> % } else { +% my $this_dist= $distance->($islandids[$i-1],$islandids[$i]); +% $total_dist += $this_dist; Sail to <% $islandname |h %> - <% $this_dist |h %> leagues % } @@ -643,7 +668,7 @@ $addcols->({ Total => 0, DoReverse => 1 }, qw( } my $total; - my $dline= 1; + my $dline= 0; my $show_flows= sub { my ($od,$arbitrage,$collectdeliver) = @_; @@ -699,7 +724,7 @@ $addcols->({ Total => 0, DoReverse => 1 }, qw( % $total_total += $sign * $total; % } % $total= undef; -% $dline= 1; +% $dline= 0; <%perl> };