From 5b0690cc2d23aa69180aea98397d4ad44b528559 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Fri, 25 Dec 2009 19:19:34 +0000 Subject: [PATCH] Limit gems to 25 per leg --- yarrg/Commods.pm | 2 +- yarrg/web/routetrade | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/yarrg/Commods.pm b/yarrg/Commods.pm index af03a64..bce9a8e 100644 --- a/yarrg/Commods.pm +++ b/yarrg/Commods.pm @@ -222,7 +222,7 @@ sub parse_info1 ($$$) { $ordval= $1; $ordval =~ s/^(\d+)\+$/ $1 + $lnoix * 10 /e; } elsif ($prop =~ m/^\!([a-z]+)$/) { - $c->{Flags} .= $prop; + $c->{Flags} .= $1; } else { die "unknown property $prop for $ucname"; } diff --git a/yarrg/web/routetrade b/yarrg/web/routetrade index 21f4711..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 @@ -526,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"; } -- 2.30.2