@islandids
@archipelagoes
$qa
-$max_mass
-$max_volume
-$lossperleaguepct
-$max_capital
+$routeparams
</%args>
<&| script &>
da_pageload= Date.now();
<%perl>
-my $loss_per_league= defined $lossperleaguepct ? $lossperleaguepct*0.01 : 1e-7;
+my $loss_per_league= defined $routeparams->{LossPerLeaguePct}
+ ? $routeparams->{LossPerLeaguePct}*0.01 : 1e-7;
my $loss_per_delay_slot= 1e-8;
my $now= time;
my @flow_conds;
my @query_params;
my %dists;
+my $expected_total_profit;
my $sd_condition= sub {
my ($bs, $ix) = @_;
Flow => $f,
Org => $sfi->[0],
Dst => $sfi->[1],
- Var => sprintf "f%ss%s", $f->{Ix}, $sfi->[0]
+ 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;
}
foreach my $od (qw(org dst)) {
my $limname= join '_', (
- 'avail',
- $flow->{'commodid'},
$od,
- $flow->{"${od}_id"},
+ 'i'.$flow->{"${od}_id"},
+ 'c'.$flow->{'commodid'},
$flow->{"${od}_price"},
$flow->{"${od}_stallid"},
);
}
my $applylimit= sub {
- my ($mv, $max, $f2val) = @_;
+ my ($mv, $f2val) = @_;
+ my $max= $routeparams->{"Max".ucfirst $mv};
$max= 1e9 unless defined $max;
#print " DEFINED MAX $mv $max ";
$cplex .= "
" <= $max";
};
- $applylimit->('mass', $max_mass, sub { $_[0]{'unitmass'} *1e-3 });
- $applylimit->('volume', $max_volume, sub { $_[0]{'unitvolume'}*1e-3 });
- $applylimit->('capital',$max_capital,sub { $_[0]{'org_price'} });
+ $applylimit->('mass', sub { $_[0]{'unitmass'} *1e-3 });
+ $applylimit->('volume', sub { $_[0]{'unitvolume'}*1e-3 });
+ $applylimit->('capital', sub { $_[0]{'org_price'} });
$cplex.= "\n";
}
$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/^[- ]+$/;
(\w+) \s+ (?: [A-Z*]+ \s+ )?
([0-9.]+) \s
/x or die "$_ ?";
- if ($varname =~ m/^f(\d+)s(\d+)$/) {
+ if ($varname =~ m/^f(\d+)s(\d+)_/) {
my ($ix,$orgix) = ($1,$2);
my $flow= $flows[$ix] or die;
my @relsubflow= grep { $_->{Org} == $orgix }
$totals .= sprintf "%g %s", ($max-$got), $units;
$delim= ', ';
};
- $domv->($max_mass, $sail_total[$i]{mass}, 'kg');
- $domv->($max_volume, $sail_total[$i]{volume}, 'l');
+ $domv->($routeparams->{MaxMass}, $sail_total[$i]{mass}, 'kg');
+ $domv->($routeparams->{MaxVolume}, $sail_total[$i]{volume}, 'l');
$totals .= ".\n";
}
$show_total_now->($totals);
%></strong>
</table>
<& query_age:dataages, id2age => \%da_ages &>
+Expected average profit:
+ approx. <strong><% sprintf "%d", $expected_total_profit %></strong> poe
+ (considering expected losses, but ignoring rum consumed)
%
% } # ========== TRADING PLAN ==========