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 .= "
$cplex.= "\n";
}
+if ($qa->{ShowStalls}>=2) {
+ my $stallpoe= $dbh->prepare(<<END);
+SELECT max(qty*price) FROM buy WHERE stallid=?
+END
+ foreach my $stallid (sort { $a <=> $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 "
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 "<pre>\n" if $qa->{'debug'};
my $found_section= 0;
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);
%
<h2><a name="plan">Voyage trading plan</a></h2>
-<table rules=groups <% printable($m) ? 'width=100%' : '' %> >
+<table class="data" rules=groups <% printable($m) ? 'width=100%' : '' %> >
% my $tbody= sub {
% if (!printable($m)) { return '<tbody>'; }
%# return "<tr><td colspan=7><hr>";
% my $cdspan= $qa->{ShowStalls} ? ' colspan=2' : '';
% my $cdstall= $qa->{ShowStalls} ? '<th>Stall</th>' : '';
<h2><a name="trades">Relevant trades</a></h2>
-<table id="trades" rules=groups>
+<table class="data" id="trades" rules=groups>
<colgroup span=1>
<colgroup span=2>
<% $qa->{ShowStalls} ? '<colgroup span=2>' : '' %>
throw => 'trades_sort', tbrow => 'trades_total' &>
ts_sortkeys= <% to_json_protecttags(\%ts_sortkeys) %>;
</&tabsort>
-
+<p>
<input type=submit name=update value="Update">
% } # !printable