--- /dev/null
+<%doc>
+
+ This is part of the YARRG website. YARRG is a tool and website
+ for assisting players of Yohoho Puzzle Pirates.
+
+ Copyright (C) 2009 Ian Jackson <ijackson@chiark.greenend.org.uk>
+ Copyright (C) 2009 Clare Boothby
+
+ YARRG's client code etc. is covered by the ordinary GNU GPL (v3 or later).
+ The YARRG website is covered by the GNU Affero GPL v3 or later, which
+ basically means that every installation of the website will let you
+ download the source.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ Yohoho and Puzzle Pirates are probably trademarks of Three Rings and
+ are used without permission. This program is not endorsed or
+ sponsored by Three Rings.
+
+
+ This Mason component simply defines how to interpret capital.
+
+</%doc>
+
+<%attr>
+</%attr>
+
+<%method preparse>
+<%args>
+$h
+</%args>
+<%perl>
+
+$_= ${ $h->{String} };
+s/^\s+//; s/\s+$//;
+
+my $res= sub {
+ my ($capital) = @_;
+ push @{ $h->{Results} }, [ $capital ];
+ ${ $h->{Canon} }= "$capital PoE";
+};
+
+if (!m/\S/) {
+} elsif (m/^([1-9]\d*)( PoE)?$/i) {
+ $res->( $1 );
+} else {
+ ${ $h->{Emsg} }= "Cannot understand capital \`$_'.";
+ return;
+}
+
+</%perl>
+</%method>
sponsored by Three Rings.
- This Mason component simply defines how to interpret capacities.
+ This Mason component simply defines how to interpret losses per league.
</%doc>
fraction 1/<em>divisor</em>, eg 1/200 is the same as 0.5%; in each
case it is taken as the loss for each league of the voyage.
+<h3><a name="capital">Available capital</a></h3>
+
+If you don't specify the amount of capital you have available to
+invest in the voyage, the trading plan will assume that your capital
+is unlimited. If you specify an amount in PoE here, the trading plan
+will never require you to spend more than that amount on commodities.
+
+<p>
+
+The trading plan does not take into account accumulated profits from
+each leg of the journey when applying the available capital
+constraint. For example, if you specify a journey from A to B to C
+and a capital limit of 10000 PoE, the trading plan will not tell you
+to buy 1000 peas at A for 10 PoE each, sail them to B and sell all of
+them for 20 PoE each, and then buy 2000 beans at B for 10 PoE each and
+sail them to C to sell for 20 PoE each even if such a trade would in
+fact be possible. In practice this is unlikely to be a problem!
+
<& footer &>
foreach my $var (keys %ARGS) {
next unless $var =~
- m/^(?: (?:route|commod|capacity)string |
+ m/^(?: (?:route|commod|capacity|capital)string |
lossperleague |
commodid |
islandid \d |
$routestring => '';
$capacitystring => '';
$lossperleague => '';
+$capitalstring => '';
$someresults
$emsgokorprint
</%args>
my %islandid2;
my ($max_volume, $max_mass);
my $lossperleaguepct;
+my $capital;
my $qa= \%ARGS;
&>
size=9
</&>
+</tr>
+<tr>
+<td>Available capital:
+
+<&| qtextstring, qa => $qa, dbh => $dbh, prefix => 'ac',
+ thingstring => 'capitalstring', emsgstore => \$emsg,
+ helpref => 'capital',
+ perresult => sub { ($capital)= @_; }
+ &>
+ size=9
+</&>
+</td>
+</tr>
</table>
% } else { #---------- dropdowns, user selects from menus ----------
<input type=submit name=submit value="<% $goupdate->() %>">
% my $ours= sub { $_[0] =~
-% m/^island|^archipelago|^routestring|^capacitystring|^lossperleague|^[RT]/;
+% m/^island|^archipelago|^routestring|^capacitystring|^lossperleague|^capitalstring|^[RT]/;
% };
<& "lookup:formhidden", ours => $ours &>
qa => $qa,
max_mass => $max_mass,
max_volume => $max_volume,
- lossperleaguepct => $lossperleaguepct
+ lossperleaguepct => $lossperleaguepct,
+ max_capital => $capital
&>
</form>
% }
$max_mass
$max_volume
$lossperleaguepct
+$max_capital
</%args>
<&| script &>
da_pageload= Date.now();
join(" + ", map { ($_->{"unit$mv"}*1e-3).' f'.$_->{Ix} } @rel_flows).
" <= $max";
}
+ if (defined $max_capital) {
+ $cplex .= "
+ ". sprintf("%-10s","capital_$ci:")." ".
+ join(" + ", map { ($_->{"org_price"}).' f'.$_->{Ix} } @rel_flows).
+ " <= $max_capital";
+ }
$cplex.= "\n";
}