X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?a=blobdiff_plain;f=yarrg%2Fweb%2Froutetrade;h=831a1b1a26a2d46f051ec4265f8089cb13fbf7da;hb=27941f861802c5de63b470bf87bd60c1a077bc3a;hp=7e1a06e6b90fd5cd872bb5ca78048667a3018a6e;hpb=9493637c44b0e22b2b9f72cf9e2748585064be56;p=ypp-sc-tools.db-test.git diff --git a/yarrg/web/routetrade b/yarrg/web/routetrade index 7e1a06e..831a1b1 100644 --- a/yarrg/web/routetrade +++ b/yarrg/web/routetrade @@ -40,6 +40,7 @@ $dbh $qa $max_mass $max_volume +$lossperleaguepct %args> <&| script &> da_pageload= Date.now(); @@ -52,8 +53,9 @@ $max_volume <%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; @@ -372,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. @@ -390,9 +392,9 @@ my $cplex= " Maximize totalprofit: - ".(join " + + ".(join " ", map { - sprintf "%.20f %s", $_->{ExpectedUnitProfit}, $_->{Var} + sprintf "%+.20f %s", $_->{ExpectedUnitProfit}, $_->{Var} } @flows)." Subject To @@ -479,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( @@ -558,16 +567,25 @@ $addcols->({ Total => 0, DoReverse => 1 }, qw(