From: Ian Jackson Date: Fri, 4 Sep 2009 18:29:17 +0000 (+0100) Subject: Merge branch 'ijackson' X-Git-Tag: 3.4~10 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?a=commitdiff_plain;h=6335baf49c849e16ae7845016d97bcb76d4b7cf6;hp=2bc58b52308e6baee9d353b507861925815ec5be;p=ypp-sc-tools.db-live.git Merge branch 'ijackson' --- diff --git a/yarrg/web/check_lossperleague b/yarrg/web/check_lossperleague index aaeb5b0..5994f6f 100644 --- a/yarrg/web/check_lossperleague +++ b/yarrg/web/check_lossperleague @@ -48,7 +48,7 @@ s/^\s+//; s/\s+$//; my $res= sub { my ($pct,$str) = @_; push @{ $h->{Results} }, [ $pct ]; - ${ $h->{Canon} }= "Considering expected losses of $str per league"; + ${ $h->{Canon} }= "$str per league"; }; if (!m/\S/) { diff --git a/yarrg/web/query_route b/yarrg/web/query_route index 96e8c32..ea48357 100644 --- a/yarrg/web/query_route +++ b/yarrg/web/query_route @@ -109,7 +109,7 @@ Vessel or capacity:   -Estimated loss per league: +Expected losses: <&| qtextstring, qa => $qa, dbh => $dbh, prefix => 'll', thingstring => 'lossperleague', emsgstore => \$emsg, diff --git a/yarrg/web/routetrade b/yarrg/web/routetrade index 9311f1a..831a1b1 100644 --- a/yarrg/web/routetrade +++ b/yarrg/web/routetrade @@ -50,16 +50,12 @@ $lossperleaguepct WARNING - VESSEL CAPACITY LIMIT NOT YET IMPLEMENTED

% } -% if (defined $lossperleaguepct) { -WARNING - DEFINED LOSS PER LEAGUE NOT YET IMPLEMENTED -<% $lossperleaguepct |h %> -

-% } <%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; @@ -396,9 +392,9 @@ my $cplex= " Maximize totalprofit: - ".(join " + + ".(join " ", map { - sprintf "%.20f %s", $_->{ExpectedUnitProfit}, $_->{Var} + sprintf "%+.20f %s", $_->{ExpectedUnitProfit}, $_->{Var} } @flows)." Subject To @@ -485,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( @@ -564,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}; % } % }