From: Ian Jackson Date: Sat, 14 Nov 2009 17:16:48 +0000 (+0000) Subject: Merge branch 'stable-5.x' X-Git-Tag: 6.0~3 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.db-test.git;a=commitdiff_plain;h=8de9e86e749db455deea697684b67be7874c5efa;hp=a0835ba69f333931705bf31f39b82339e7c5b16a Merge branch 'stable-5.x' --- diff --git a/yarrg/web/check_capacitystring b/yarrg/web/check_capacitystring index b958dff..e1f2da4 100644 --- a/yarrg/web/check_capacitystring +++ b/yarrg/web/check_capacitystring @@ -130,7 +130,7 @@ my $parse_term= sub { $_ *= $pct / 100.0; } push @canon, sprintf "%g%%", $pct; - } elsif (!m/[^a-z]/i) { + } elsif (!m/[^a-z ]/i) { $debugf->("TERM NAME"); expected_error("Name (should be unit or commodity)". escerrq($_). diff --git a/yarrg/web/docs b/yarrg/web/docs index 0f62491..2be018e 100755 --- a/yarrg/web/docs +++ b/yarrg/web/docs @@ -178,6 +178,20 @@ You can enter the value in the box either as a percentage, or as a fraction 1/divisor, eg 1/2000 is the same as 0.05%; in each case it is taken as the loss for each league of the voyage. +

Caution about stalls' poe reserves

+ +If you select Also be cautious about stalls' poe reserves, +YARRG will calculate a minimum amount of poe that each stall has on +hand (by looking at all the offers that stall is making), and never +plan for you to sell goods at that stall for more than the available +poe. + +

+ +Goods planned to be bought at the stall (which might boost the stall's +poe reserves) are not considered, to avoid having to calculate the +stall's cash reserves at various different times. +

Available capital

If you don't specify the amount of capital you have available to diff --git a/yarrg/web/lookup b/yarrg/web/lookup index eb9f53d..fd66f1a 100755 --- a/yarrg/web/lookup +++ b/yarrg/web/lookup @@ -78,6 +78,9 @@ my %styles; Before => '', Values => [ [ 0, 'Show total quantity at each price' ], [ 1, 'Show individual stalls' ], + [ 2, "Also be cautious about stalls'". + " poe reserves", + '[?]' ] ], QuerySpecific => 1, }, { Name => 'RouteSearchType', @@ -133,8 +136,8 @@ $ours div.query { background: #d7d8b3; padding: 1em; } div.results { padding: 1em; } table.data { background: #b5b686; } - tr.datarow0 { background: #e3e3e3; } - tr.datarow1 { background: #ffffff; } + tr.datarow0 { background: #ffffff; } + tr.datarow1 { background: #e3e3e3; } <&| script &> function register_onload(f) { @@ -191,7 +194,7 @@ my $prselector_core= sub { my $cvalix= 0; foreach my $valr (@{ $var->{Values} }) { print $delim; $delim= "\n|\n"; - my ($value,$html) = @$valr; + my ($value,$html,$finally) = @$valr; my $iscurrent= &{$var->{CmpCanon}}($value) eq $canon; my $after; if ($iscurrent) { @@ -200,6 +203,7 @@ my $prselector_core= sub { } else { my %qf= (%baseqf,%queryqf); delete $qf{$lname}; + delete $qf{$_} foreach grep { m/^[A-Z]/ } keys %qf; $qf{$lname}= $value if $cvalix; @@ -207,6 +211,7 @@ my $prselector_core= sub { $after= ''; } print $html, $after; + print " ", $finally if defined $finally; $cvalix++; } print "

\n\n"; diff --git a/yarrg/web/routetrade b/yarrg/web/routetrade index 59a8566..9660094 100644 --- a/yarrg/web/routetrade +++ b/yarrg/web/routetrade @@ -410,11 +410,17 @@ Maximize totalprofit: "; +my %stall_poe_limits; + foreach my $sf (@subflows) { my $eup= $sf->{Flow}{ExpectedUnitProfit}; $eup *= (1.0-$loss_per_delay_slot) ** $sf->{Org}; $cplex .= sprintf " %+.20f %s", $eup, $sf->{Var}; + if ($qa->{ShowStalls}>=2) { + my $stall= $sf->{Flow}{'dst_stallid'}; + push @{ $stall_poe_limits{$stall} }, $sf; + } } $cplex .= " @@ -488,6 +494,24 @@ foreach my $ci (0..($#islandids-1)) { $cplex.= "\n"; } +if ($qa->{ShowStalls}>=2) { + my $stallpoe= $dbh->prepare(< $b } keys %stall_poe_limits) { + $stallpoe->execute($stallid); + my ($lim)= $stallpoe->fetchrow_array(); + $stallpoe->finish(); + $cplex.= " + ". sprintf("%-15s","poe_$stallid:")." ". + join(" + ", map { + sprintf "%d %s", $_->{Flow}{'dst_price'}, $_->{Var}; + } @{ $stall_poe_limits{$stallid} }). + " <= $lim"; + } + $cplex.= "\n"; +} + $cplex.= " Bounds ".(join " @@ -515,7 +539,7 @@ if ($qa->{'debug'}) { my $input= pipethrough_prep(); print $input $cplex or die $!; my $output= pipethrough_run_along($input, undef, 'glpsol', - qw(glpsol --tmlim 2 --memlim 5 --intopt --cuts --bfs + qw(glpsol --tmlim 5 --memlim 5 --intopt --cuts --bfs --cpxlp /dev/stdin -o /dev/stdout)); print "

\n" if $qa->{'debug'};
 	my $found_section= 0;