X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.main.git;a=blobdiff_plain;f=yarrg%2Fweb%2Froutetrade;h=27cf295d19376abb8451f7dbba43f972a7aab100;hp=5dc5e774a40f8c839a26ef28c75d8c6b9bc7b31a;hb=5d7aa1e2df29f74f0fbaa8dcb21fa1f7921f30a8;hpb=62e5bf60d55a8e6ff3d938e2719d910ee4367210 diff --git a/yarrg/web/routetrade b/yarrg/web/routetrade index 5dc5e77..27cf295 100644 --- a/yarrg/web/routetrade +++ b/yarrg/web/routetrade @@ -140,6 +140,9 @@ my $stmt= " commods.commodid commodid, commods.unitmass unitmass, commods.unitvolume unitvolume, + commods.ordval ordval, + commods.posinclass posinclass, + commods.commodclassid commodclassid, dist dist, buy.price - sell.price unitprofit FROM commods @@ -292,22 +295,6 @@ foreach my $f (@flows) { $f->{"Max$v"}= sprintf "%.1f", $f->{"Max${v}SortKey"} * 1e-6; } - my $sfis= $ipair2subflowinfs{$f->{'org_id'},$f->{'dst_id'}}; - foreach my $sfi (@$sfis) { - my $subflow= { - Flow => $f, - Org => $sfi->[0], - Dst => $sfi->[1], - Var => sprintf "f%ss%s_c%d_p%d_%d_p%d_%d", - $f->{Ix}, $sfi->[0], - $f->{'commodid'}, - $sfi->[0], $f->{'org_price'}, - $sfi->[1], $f->{'dst_price'} - }; - push @{ $f->{Subflows} }, $subflow; - push @subflows, $subflow; - } - $f->{MarginSortKey}= sprintf "%d", $f->{'dst_price'} * 10000 / $f->{'org_price'}; $f->{Margin}= sprintf "%3.1f%%", @@ -385,8 +372,23 @@ foreach my $f (@flows) { if (defined $qa->{"R$f->{UidShort}"} && !defined $qa->{"T$f->{UidShort}"}) { $f->{Suppress}= 1; + } else { + my $sfis= $ipair2subflowinfs{$f->{'org_id'},$f->{'dst_id'}}; + foreach my $sfi (@$sfis) { + my $subflow= { + Flow => $f, + Org => $sfi->[0], + Dst => $sfi->[1], + Var => sprintf "f%ss%s_c%d_p%d_%d_p%d_%d", + $f->{Ix}, $sfi->[0], + $f->{'commodid'}, + $sfi->[0], $f->{'org_price'}, + $sfi->[1], $f->{'dst_price'} + }; + push @{ $f->{Subflows} }, $subflow; + push @subflows, $subflow; + } } - } @@ -421,13 +423,7 @@ Subject To my %avail_lims; foreach my $flow (@flows) { - if ($flow->{Suppress}) { - foreach my $sf (@{ $flow->{Subflows} }) { - $cplex .= " - $sf->{Var} = 0\n"; - } - next; - } + next if $flow->{Suppress}; foreach my $od (qw(org dst)) { my $limname= join '_', ( $od, @@ -553,7 +549,7 @@ if ($qa->{'debug'}) { my ($varname, $qty) = m/^ \s* \d+ \s+ (\w+) \s+ (?: [A-Z*]+ \s+ )? - ([0-9.]+) \s + ([+-e0-9.]+) \s /x or die "$cplex \n==\n $glpsol_out $_ ?"; if ($varname =~ m/^f(\d+)s(\d+)_/) { my ($ix,$orgix) = ($1,$2); @@ -632,7 +628,7 @@ Generated by YARRG at <% %

Voyage trading plan

- > +
> % my $tbody= sub { % if (!printable($m)) { return ''; } %# return " -' : '';

Relevant trades

-

"; @@ -642,7 +638,7 @@ Generated by YARRG at <% % % foreach my $i (0..$#islandids) { <% $tbody->(1) %> -
+
% $iquery->execute($islandids[$i]); % my ($islandname) = $iquery->fetchrow_array(); % if (!$i) { @@ -666,12 +662,11 @@ Generated by YARRG at <% <%perl> my $age_reported= 0; my %flowlists; - #print "
" if $qa->{'debug'}; + #print "
" if $qa->{'debug'}; foreach my $od (qw(org dst)) { #print " [[ i $i od $od " if $qa->{'debug'}; foreach my $sf (@subflows) { my $f= $sf->{Flow}; - next if $f->{Suppress}; next unless $sf->{ucfirst $od} == $i; #print " FLOW $f->{Ix} SUB #$sf->{Org}..$sf->{Dst} " # if $qa->{'debug'}; @@ -681,6 +676,7 @@ Generated by YARRG at <% my $price= $f->{"${od}_price"}; my $stallname= $f->{"${od}_stallname"}; my $todo= \$flowlists{$od}{ + (sprintf "%010d", $f->{'ordval'}), $f->{'commodname'}, (sprintf "%07d", ($od eq 'dst' ? 9999999-$price : $price)), @@ -692,6 +688,20 @@ Generated by YARRG at <% dstArbitrage => 0, } unless $$todo; $$todo->{'commodname'}= $f->{'commodname'}; + $$todo->{'posinclass'}= ''; + if ($f->{'posinclass'}) { + my $findclass= $dbh->prepare(<execute($f->{'commodclassid'}); + my $classinfo= $findclass->fetchrow_hashref(); + $$todo->{'posinclass'}= + sprintf "(%s %d/%d)", + $classinfo->{'commodclass'}, + $f->{'posinclass'}, + $classinfo->{'maxposinclass'} + if $classinfo->{'maxposinclass'} > 9; + } $$todo->{'stallname'}= $stallname; $$todo->{Price}= $price; $$todo->{Timestamp}= $f->{"${od}_timestamp"}; @@ -723,7 +733,7 @@ Generated by YARRG at <%
-<% $xinfo %> +<% $xinfo %> <% $totaldesc %> <% $totalwas |h %> total <%perl> @@ -754,6 +764,7 @@ Generated by YARRG at <% % tr_datarow($m,$dline); <<% $td %>><% $collectdeliver %> <<% $td %>><% $t->{'commodname'} |h %> +<<% $td %>><% $t->{'posinclass'} |h %> % % my @stalls= sort keys %{ $t->{Stalls} }; % my $pstall= sub { @@ -800,7 +811,7 @@ Generated by YARRG at <% } <% $tbody->(1) %>
Total distance: <% $total_dist %> leagues. +Total distance: <% $total_dist %> leagues. Overall net cash flow <% $total_total < 0 ? -$total_total." loss" : $total_total." gain" @@ -865,7 +876,7 @@ Islands shown in reverse order of visits.
% my $cdspan= $qa->{ShowStalls} ? ' colspan=2' : ''; % my $cdstall= $qa->{ShowStalls} ? '
Stall
+
<% $qa->{ShowStalls} ? '' : '' %> @@ -973,7 +984,7 @@ Islands shown in reverse order of visits.
throw => 'trades_sort', tbrow => 'trades_total' &> ts_sortkeys= <% to_json_protecttags(\%ts_sortkeys) %>; - +

% } # !printable