From ae926461ebeb67c806caa7be5d85d18a02a08177 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 14 Nov 2009 17:13:41 +0000 Subject: [PATCH] Allow computing and using dest stall poe limit --- yarrg/web/docs | 14 ++++++++++++++ yarrg/web/lookup | 7 ++++++- yarrg/web/routetrade | 26 +++++++++++++++++++++++++- 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/yarrg/web/docs b/yarrg/web/docs index 8c48814..010fd45 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 41a2534..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', @@ -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 b198b9b..7db0772 100644 --- a/yarrg/web/routetrade +++ b/yarrg/web/routetrade @@ -407,11 +407,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 .= " @@ -485,6 +491,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 " @@ -512,7 +536,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;
-- 
2.30.2