\n" if $qa->{'debug'}; my $found_section= 0; my $glpsol_out= ''; @@ -519,6 +553,9 @@ if ($qa->{'debug'}) { $found_section= 1; next; } + if (m/^Objective:\s+totalprofit = (\d+(?:\.\d*)?) /) { + $expected_total_profit= $1; + } next unless $found_section==1; if (!length $continuation) { next if !$continuation && m/^[- ]+$/; @@ -536,9 +573,9 @@ if ($qa->{'debug'}) { my ($varname, $qty) = m/^ \s* \d+ \s+ (\w+) \s+ (?: [A-Z*]+ \s+ )? - ([0-9.]+) \s - /x or die "$_ ?"; - if ($varname =~ m/^f(\d+)s(\d+)$/) { + ([+-e0-9.]+) \s + /x or die "$cplex \n==\n $glpsol_out $_ ?"; + if ($varname =~ m/^f(\d+)s(\d+)_/) { my ($ix,$orgix) = ($1,$2); my $flow= $flows[$ix] or die; my @relsubflow= grep { $_->{Org} == $orgix } @@ -557,6 +594,7 @@ if ($qa->{'debug'}) { my $prerr= "\n=====\n$cplex\n=====\n$glpsol_out\n=====\n "; pipethrough_run_finish($output,$prerr); map { defined $_->{OptQty} or die "$prerr $_->{Flow}{Ix}" } @subflows; + defined $expected_total_profit or die "$prerr ?"; }; $addcols->({ DoReverse => 1, TotalSubflows => 1, Special => sub { @@ -577,120 +615,32 @@ $addcols->({ Total => 0, DoReverse => 1, TotalSubflows => 1 }, qw( % } # ========== OPTIMISATION ========== -% my %ts_sortkeys; -% { -% my $cdspan= $qa->{ShowStalls} ? ' colspan=2' : ''; -% my $cdstall= $qa->{ShowStalls} ? 'Stall ' : ''; -
- | >Collect - | >Deliver - | - | Collect - | Deliver - | Profit - | Max - | - | Max -% if ($optimise) { - | Planned -% } - - | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
- | Island <% $cdstall %> - | Island <% $cdstall %> - | Commodity - | Price - | Qty - | Price - | Qty - | Margin - | Unit - | Qty - | Capital - | Profit - | Dist - | Mass - | Vol -% if ($optimise) { - | Qty - | Capital - | Profit -% } -% } - - |
-% } - -% foreach my $flowix (0..$#flows) { -% my $flow= $flows[$flowix]; -% my $rowid= "id_row_$flow->{UidShort}"; - | ||||||||||||||||||
{UidShort} %> value=""> - {UidShort} %> value="" - <% $flow->{Suppress} ? '' : 'checked' %> > -% my $ci= 1; -% while ($ci < @cols) { -% my $col= $cols[$ci]; -% my $spec= { -% Span => 1, -% Align => ($col->{Text} ? '' : 'align=right') -% }; -% my $cn= $col->{Name}; -% my $v; -% if (!$col->{TotalSubflows}) { -% $v= $flow->{$cn}; -% } else { -% $v= 0; -% $v += $_->{$cn} foreach @{ $flow->{Subflows} }; -% } -% if ($col->{Special}) { $col->{Special}($flow,$col,$v,$spec); } -% $col->{Total} += $v -% if defined $col->{Total} and not $flow->{Suppress}; -% $v='' if !$col->{Text} && !$v; -% my $sortkey= $col->{SortColKey} ? -% $flow->{$col->{SortColKey}} : $v; -% $ts_sortkeys{$ci}{$rowid}= $sortkey; - | {Span} ? "colspan=$spec->{Span}" : ''
- %> <% $spec->{Align}
- %>><% exists $spec->{String} ? $spec->{String} : $v |h %>
-% $ci += $spec->{Span};
-% }
+% if (!printable($m)) {
+Contents+
|
"; +% my ($c)= qw(40 00)[$_[0]]; +% return " | ||||||||||||||||||||||||
"; +% }; +% % foreach my $i (0..$#islandids) { - | ||||||||||||||||||||||||
+<% $tbody->(1) %> + | ||||||||||||||||||||||||
Start at <% $islandname |h %> + | [what are these codes?] + | % } else { % my $this_dist= $distance->($islandids[$i-1],$islandids[$i]); % $total_dist += $this_dist; + | <%perl> my $total_value= 0; foreach my $sf (@subflows) { @@ -728,12 +690,11 @@ $addcols->({ Total => 0, DoReverse => 1, TotalSubflows => 1 }, qw( <%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'};
@@ -743,6 +704,7 @@ $addcols->({ Total => 0, DoReverse => 1, TotalSubflows => 1 }, qw(
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)),
@@ -754,6 +716,33 @@ $addcols->({ Total => 0, DoReverse => 1, TotalSubflows => 1 }, qw(
dstArbitrage => 0,
} unless $$todo;
$$todo->{'commodname'}= $f->{'commodname'};
+ $$todo->{'posinclass'}= '';
+ my $incl= $f->{'posinclass'};
+
+ my $findclass= $dbh->prepare(< "
+ .$abbrev." ";
+ }
$$todo->{'stallname'}= $stallname;
$$todo->{Price}= $price;
$$todo->{Timestamp}= $f->{"${od}_timestamp"};
@@ -785,7 +774,7 @@ $addcols->({ Total => 0, DoReverse => 1, TotalSubflows => 1 }, qw(
%perl>
- | <% $xinfo %>
+ | <% $xinfo %>
| <% $totaldesc %>
| <% $totalwas |h %> total
<%perl>
@@ -808,14 +797,15 @@ $addcols->({ Total => 0, DoReverse => 1, TotalSubflows => 1 }, qw(
(Data age: <% prettyprint_age($age) %>)
% } elsif (!defined $total) {
% $total= 0;
- | Total distance: <% $total_dist %> leagues.
+%perl>
+<% $tbody->(1) %> | Total distance: <% $total_dist %> leagues.
| Overall net cash flow
| <%
$total_total < 0 ? -$total_total." loss" : $total_total." gain"
%>
| |
+ | >Collect + | >Deliver + | + | Collect + | Deliver + | Profit + | Max + | + | Max +% if ($optimise) { + | Planned +% } + + | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
+ | Island <% $cdstall %> + | Island <% $cdstall %> + | Commodity + | Price + | Qty + | Price + | Qty + | Margin + | Unit + | Qty + | Capital + | Profit + | Dist + | Mass + | Vol +% if ($optimise) { + | Qty + | Capital + | Profit +% } +% } + + |
+% } + +% foreach my $flowix (0..$#flows) { +% my $flow= $flows[$flowix]; +% my $rowid= "id_row_$flow->{UidShort}"; + | ||||||||||||||||||
{UidShort} %> value=""> + {UidShort} %> value="" + <% $flow->{Suppress} ? '' : 'checked' %> > +% my $ci= 1; +% while ($ci < @cols) { +% my $col= $cols[$ci]; +% my $spec= { +% Span => 1, +% Align => ($col->{Text} ? '' : 'align=right') +% }; +% my $cn= $col->{Name}; +% my $v; +% if (!$col->{TotalSubflows}) { +% $v= $flow->{$cn}; +% } else { +% $v= 0; +% $v += $_->{$cn} foreach @{ $flow->{Subflows} }; +% } +% if ($col->{Special}) { $col->{Special}($flow,$col,$v,$spec); } +% $col->{Total} += $v +% if defined $col->{Total} and not $flow->{Suppress}; +% $v='' if !$col->{Text} && !$v; +% my $sortkey= $col->{SortColKey} ? +% $flow->{$col->{SortColKey}} : $v; +% $ts_sortkeys{$ci}{$rowid}= $sortkey; + | {Span} ? "colspan=$spec->{Span}" : '' + %> <% $spec->{Align} + %>><% exists $spec->{String} ? $spec->{String} : $v |h %> +% $ci += $spec->{Span}; +% } +% } + | |||||||||||||||||
+ | Total +% foreach my $ci (3..$#cols) { +% my $col= $cols[$ci]; + | +% if (defined $col->{Total}) { +<% $col->{Total} |h %> +% } +% } + |
+ + +% } # !printable + <%init> use CommodsWeb; use Commods;