X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.web-live.git;a=blobdiff_plain;f=yarrg%2Fweb%2Froutetrade;h=d66e8b1772c8bb8a4b8db0dceedac4e244dff740;hp=f9ebfeaf3f60fa783ce8c796090906d38c4eefc0;hb=64f37d1c80bfd082dab4a11db206515890af6f44;hpb=d66f27768708df0b8ce256e2d868ff4f7060ef3f diff --git a/yarrg/web/routetrade b/yarrg/web/routetrade index f9ebfea..d66e8b1 100644 --- a/yarrg/web/routetrade +++ b/yarrg/web/routetrade @@ -38,10 +38,7 @@ $dbh @islandids @archipelagoes $qa -$max_mass -$max_volume -$lossperleaguepct -$max_capital +$routeparams <&| script &> da_pageload= Date.now(); @@ -49,7 +46,8 @@ $max_capital <%perl> -my $loss_per_league= defined $lossperleaguepct ? $lossperleaguepct*0.01 : 1e-7; +my $loss_per_league= defined $routeparams->{LossPerLeaguePct} + ? $routeparams->{LossPerLeaguePct}*0.01 : 1e-7; my $loss_per_delay_slot= 1e-8; my $now= time; @@ -468,7 +466,8 @@ foreach my $ci (0..($#islandids-1)) { } my $applylimit= sub { - my ($mv, $max, $f2val) = @_; + my ($mv, $f2val) = @_; + my $max= $routeparams->{"Max".ucfirst $mv}; $max= 1e9 unless defined $max; #print " DEFINED MAX $mv $max "; $cplex .= " @@ -480,9 +479,9 @@ foreach my $ci (0..($#islandids-1)) { " <= $max"; }; - $applylimit->('mass', $max_mass, sub { $_[0]{'unitmass'} *1e-3 }); - $applylimit->('volume', $max_volume, sub { $_[0]{'unitvolume'}*1e-3 }); - $applylimit->('capital',$max_capital,sub { $_[0]{'org_price'} }); + $applylimit->('mass', sub { $_[0]{'unitmass'} *1e-3 }); + $applylimit->('volume', sub { $_[0]{'unitvolume'}*1e-3 }); + $applylimit->('capital', sub { $_[0]{'org_price'} }); $cplex.= "\n"; } @@ -865,8 +864,8 @@ $addcols->({ Total => 0, DoReverse => 1, TotalSubflows => 1 }, qw( $totals .= sprintf "%g %s", ($max-$got), $units; $delim= ', '; }; - $domv->($max_mass, $sail_total[$i]{mass}, 'kg'); - $domv->($max_volume, $sail_total[$i]{volume}, 'l'); + $domv->($routeparams->{MaxMass}, $sail_total[$i]{mass}, 'kg'); + $domv->($routeparams->{MaxVolume}, $sail_total[$i]{volume}, 'l'); $totals .= ".\n"; } $show_total_now->($totals);