X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?a=blobdiff_plain;f=yarrg%2Fweb%2Froutetrade;h=9e9256a72529cdb83088032a16a9d5ff1fca7409;hb=refs%2Ftags%2F6.4;hp=1b7c8c945bb312b0c7073eb5de1e8361910cd148;hpb=452812a6729674dcf2d35454aab8c2e2034288d8;p=ypp-sc-tools.web-test.git diff --git a/yarrg/web/routetrade b/yarrg/web/routetrade index 1b7c8c9..9e9256a 100644 --- a/yarrg/web/routetrade +++ b/yarrg/web/routetrade @@ -49,6 +49,7 @@ $quri my $loss_per_league= defined $routeparams->{LossPerLeaguePct} ? $routeparams->{LossPerLeaguePct}*0.01 : 1e-7; my $loss_per_delay_slot= 1e-8; +my $max_gems= 25; my $minprofit= $routeparams->{MinProfit} || 0; @@ -147,6 +148,7 @@ my $stmt= " commods.ordval ordval, commods.posinclass posinclass, commods.commodclassid commodclassid, + commods.flags flags, dist dist, buy.price - sell.price unitprofit FROM commods @@ -292,6 +294,8 @@ my $oppo_key= sub { return join '_', map { $f->{$_} } qw(org_id dst_id commodid); }; +my $any_previous_suppression= 0; + foreach my $f (@flows) { $f->{MaxQty}= $f->{'org_qty_agg'} < $f->{'dst_qty_agg'} @@ -390,6 +394,7 @@ foreach my $f (@flows) { } } else { if (!defined $qa->{"T$f->{UidShort}"}) { + $any_previous_suppression= 1; $f->{Suppress}= 1; } } @@ -413,13 +418,24 @@ foreach my $f (@flows) { } -% my $optimise= $specific; -% if (!$optimise) { +% my $optimise= 1; -

% if (!$specific) { +% $optimise= 0; Route contains archipelago(es), not just specific islands. +% } elsif (!@subflows) { +% $optimise= 0; +% if ($any_previous_suppression) { +All available trades deselected. +% } else { +No available trades meet the specified minimum trade value, so +all available trades deselected. +% } % } + +% if (!$optimise) { + +

Therefore, optimal voyage trade plan not calculated. % } else { # ========== OPTMISATION ========== @@ -512,6 +528,14 @@ foreach my $ci (0..($#islandids-1)) { $applylimit->('mass', sub { $_[0]{'unitmass'} *1e-3 }); $applylimit->('volume', sub { $_[0]{'unitvolume'}*1e-3 }); $applylimit->('capital', sub { $_[0]{'org_price'} }); + + my @gem_subflows= grep { $_->{Flow}{flags} =~ m/g/ } @rel_subflows; + if (@gem_subflows) { + $cplex .= " + ". sprintf("%-10s","gems_$ci:")." ". + join(" + ", map { $_->{Var} } @gem_subflows). " <= $max_gems"; + } + $cplex.= "\n"; }