\documentclass[]{article}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage [] {hyperref}
\usepackage{graphicx}
\usepackage{refcount}
\usepackage{fontawesome5}

%opening
\title{Simutrans-extended\linebreak
	From A to B.\linebreak
	Simple transformation of goods\linebreak Elemental algebraic approach.\footnote{Licensed under the terms of the GPL v3.}}
\author{jimishol}
\begin{document}
	\maketitle
\begin{abstract}
	Before i try my next  game map, i decided to check if my previous reasoning on decision can pass an elementary algebraic check. While it is impressive to me the absence of formulas in posts of such a game, i believe readers will check and correct any mistakes or assumptions that are wrong compared to the game.
	
	It will be examined a simple transformation of goods from production point to its consumer  destination. The time i spent in this study, I feel it belongs to game play time, even if i did not started my new game yet. It might belong to game play time of some readers that intent to start a new map too, before they begin their real play.
\end{abstract}

\section{Units}

In my previous game I did pay too much attention to vehicle speeds, as km/h, compared them to the real world ones. Against this instinctual response, the decisions in game play seemed to act differently. A new perspective by the use of different units might be usefull and make game decisions more justified. 
\subsection{Month unit}
\paragraph*{The game play runs around month} and monthly costs. We see, in default settings, down left on screen the time and beside it the hours per month. \textit{A game month is much less than 24*30 hours.} I start at year 1750. The whole idea of using different units come from the following thought. Why to sent a cart horse, with average speed of 5km/h at a distance of 16km, that seems easy and logical and not think that i sent it in such a distance that it will take 1 whole month for my horse to return back to me, that seems harder as a decision? 
\paragraph{The duration month} is determined by two variables in simconf.tab
\begin{verse}
	meters\_per\_tile = 125
	
	bits\_per\_month = 22
\end{verse}
If one notice the post  \href{https://forum.simutrans.com/index.php?topic=7897.0}{here}, 
he might detect that the exact formula, that gives the duration of a month in hours, is given by the formula
\begin{equation}\label{hours_per_month}
	1\,month = \dfrac{meters\_per\_tile}{10000}*\dfrac{2^{bits\_per\_month}}{2^{13}} \ hours
\end{equation}
Substituting for the above values we get
\[1\ month = 6.4 \ hours\] or 6 hours and 24 minutes. 
\subparagraph*{Using imagination,} if someone, like me, lacks the ability to understand the code, is the only way to interpret the possible meaning of the above formula. Imagine that you, as developer, using a repeated process manage to make a dot moving in your screen. By trial and error, it will come a moment where, having divided the screen into tiles, you are satisfied with the speed of dot, where in every \textit{c cycles} of repetition of some calculations, the dot moves \textit{1 tile}. You think that this could be a fine velocity for a low speed vehicle, as a bicycle, for close ups. For this reason, you declare that speed as 10km/h. That can be written as
\begin{equation}\label{basic_velocity}
	\dfrac{1\ tile}{c\ cycles} = \dfrac{10\ km}{1\  hour}
\end{equation}
Since you are in close up, you declare also that
\begin{equation}\label{tile_metre}
	1\ tile = meters\_per\_tile\ meters \Rightarrow 1000 tiles =  meters\_per\_tile \ km
\end{equation}
So far so good with close ups and bicycles. What about airplanes?

\subparagraph*{If it is airplanes to be involved,} 2000km to 3000km between airports seems normal. If an airport is in the center of our simulated world, we would need a map for about 5000km. So, if a tile equals about 100m, we could expect a map about 10 times larger, in tiles. That means a map about 50000 x 50000 \textit{tiles} x \textit{tiles}. It is not the size of map that can not be handled. The size of network, that will eventually evolve between the many possible places in this large map, will become so huge that neither human nor computer can handle.

We have to fit a possible real area of 5000km x 5000km in an area like 50km x 50km for a more sensible map of 500tiles x 500tiles. With an action like this, we bring cities, for example city A and city B, closer to each other and vehicles that, for some definite speed, would need for example 1 month to travel from A to B, traveling with the same speed, now needs only few hours. We see from equations that
\begin{equation}\label{hour_cycle}
	\eqref{basic_velocity} \Rightarrow 1\ hour = 10*c\ km/tile \ cycles  \overset{\eqref{tile_metre}}{=} \dfrac{10000*c}{meters\_per\_tile}\ cycles
\end{equation} 

 Without shrinking, the travel of 1 month would equal to 30*24=720 more cycles of calculations than the above. We want, for reasons related to the economy of the game, much less cycles for the game's month. Lets declare
 \begin{equation}\label{cycle_month}
 	1\ month = 	2^{bits\_per\_month}\ cycles.
 \end{equation}

 \[\eqref{basic_velocity} \Rightarrow 1\ cycle = \dfrac{1}{10*c}\ tile/km \ hours  \overset{\eqref{tile_metre}}{=} \dfrac{meters\_per\_tile}{10000*c}\ hours \]
 
 So, substituting the 1 cycle, \eqref{cycle_month} becomes
   \begin{equation*}
  	1\ month = 2^{bits\_per\_month} * \dfrac{meters\_per\_tile}{10000*c}\ hours
  \end{equation*}
Assume that the number of cycles of calculation, that gave the so satisfying speed of dot for the close ups of the game, in our initial design, was \[ c = 8192 = 2^{13}. \] and substitute in the last equation. That will give our suggested formula of \eqref{hours_per_month}.
\paragraph{A natural month} of $ 24*30=720\ hours $ could be set, but i can not tell  if it can be supported by the game (probably it can not be). May be it should, but that means, with no shrinking, there will be a small map that probably could fit only for a simulation of the transportation system of one single large city. Since there will be no outside of city areas, there will be no industries and goods to transfer. Economy might collapse, not being able to exist only on pax and mail services. Anyway, no shrinking of some large map means that a month has duration for 720 hours. If one solves for \textit{bits\_per\_month} the formula \eqref{hours_per_month}, so as $ 1\ month = 720 \ hours $, then the solution is
\[bits\_per\_month=\dfrac{log(450000/meters\_per\_tile)+17*log(2)}{log(2)}\]
With $meters\_per\_tile = 125$, that gives $bits\_per\_month = 28.81$.
\subsection{Day duration}
If one turn on the daylight feature, he can have a sense of the duration of the month. Every 30 cycles of dark and light, a month is over. This feature seems to be the only common with the real world time. Of course, setting \textit{bits\_per\_month} to 28 and \textit{ meters\_per\_tile} to 220 one can achieve a common sense day but then he would fall to 1:1 simulation against real world and either the game play will be too slow either everything will move extremely fast. But, the more unpleasant to me was that, because the 220 meters tile simulates almost 4 times more area than that of 125 meters, the new tile visualizes 4 times more citizens and look awkwardly populated.
\paragraph{Duration of day} is irrelevant to the subject of this post so, i will mention only few uncertain things so as not let out this time unit. For me, with defaults in Britain-Ex packset, time is divided in years. Each year consists of 3.2 days and each day consits 3.75 months. So, days are longer than months and not the other way around.
\begin{quote}
	A day lasts 24 hours.
\end{quote}  
At least, that is what i conclude from \textit{job\_replenishment\_per\_hundredths\_of\_months = 375} variable in \textit{simuconf.tab}.

Days have nothing to do with transferring between two points, that is the subjet of the present post. From the mentioned variable they probably have to do with jobs. From minimum and range of \textit{commuting\_tolerance} variables it seems acceptable a job travel that lasts 1/4 of a month (about 90minutes). If it so, the assumption that simutranians go to work only once per 3.75 months can be right too. For my opinion, days correlate with jobs, these with industry, last with customers, all with transportation and economy that will fall apart without jobs. So, days touches the limits that should exist between the real uniform world and a try for 1:1 simulation of it that has to use 1:1 models on vehicles and perhaps for time and space inside of cities and definitely another shrinking scale for time and space outside of them. 
\subparagraph{The problems} with jobs and their daily evolution, despite of the respectable target for simulating the real world in 1:1 scale, for my personal opinion, points to the advice for a player not to trust blindly common logic, that is based on real world experience, for making game play decisions. He needs to think as simutranian and use simutranian units to measure things. I like extended version because i like its goals. Nevertheless, i try to play using different units in my mind, mainly the game month unit. For example, when i think that someone walks (4km/h) from Stop to Industry (1 tile) 125m away, I consider he needs about two (60/32) minutes to do so. If however he travels outside of cities with same speed, i switch my mind to months and consider that he covers the same distance in 1/204.8 of a month, that in real month corresponds to $3\dfrac{1}{2}\ hours$. In this way, i keep the ratio of time needed to travel 1 tile toward some other city against the time needed to unload to next tile in city, same both in real life and in simutrans world. 

\section{Changing units}

Formula \eqref{hours_per_month} is wildly used and not change during game. So, for shortness, we will use the symbol \textit{m} and define that
\[1 \ month = m \ hours.\] In default settings $m = 6.4$. 
\subsection{Time}
We convert from time \textit{t} in \textit{hours} to \textit{T} in \textit{months} by
\begin{equation}\label{convert_time}
	T(t) = t/m
\end{equation}
\subsection{Length}
How far away is your work? 15 minutes, you answer. By foot?

The point is that when your velocity is determined, it is perfectly fine to measure distances by the time you need to go there.
Determining the velocity \textit{v} of some vehicle in \textit{km/h}, we measure the distances it travels by the time it needs to cover them.
\paragraph{A length of 1 month,} for a vehicle that travels at \textit{average} velocity \textit{v km/h}, is the distance it travels in \textit{1 month}. So, the conversion of \textit{l km} to length \textit{L months} needs velocity \textit{v} as parameter.
\begin{equation}\label{convert_length}
	L(l, v) = \frac{l}{v * m}
\end{equation}
So, \textit{1 km} equals to $L(1, v)
\ months.$
\subsection{Velocity}
Velocity is defined as the traveled distance per time needed for this travel. 
\[V=\frac{L}{T}\]
Dividing length month units per time month units, has as result dimensionless units for velocity.
If another vehicle with speed \textit{v'} covers a distance \textit{L'} in time \textit{T'} then
$V = L'/T'= \frac{l'}{v*t'}=v'/v.$ So, the velocity of others is the ratio of their speed against ours. 

Our car compared to itself always run with velocity 1.
\section{Transporting quantities}

One gets paid because of the work he has done. So, a work is demanded, in our case \textit{cp} crates to be transferred \textit{l km} and a reward \textit{r} is agreed as per unit to be transferred per km that will be transported. If one has a cargo car with capacity \textit{cp} that always moves loaded, can calculate that he can earn, by that car, \textit{r * cp} per km it travels. If his car moves unloaded, it transfers zero crates and produce zero work, so the owner will not be paid. 
\paragraph{A simple transportation,} by a vehicle, will be considered the case where, loaded, transports cp crates to some distance and returns empty to get his next load and repeat. This car travels \textit{l km} loaded, returns empty, traveling the same distance of \textit{l km}, and earns for each trip \textit{(r * l) * cp} money for his \textit{cp} going transferring work and zero money for his returning zero transferring work of (\textit{0} crates).

\subparagraph{The power to transport,} of this car,  equals to the cargo it can transfer per time unit. In normal units it is expressed as \[p=\frac{cp}{(2*l)/v}\ \frac{crates}{hours}\]

In our newly units the power of a vehicle to transport is expressed as
\begin{equation}\label{power_month}
	P = \frac{cp}{2 * L(l,v)}\ \frac{crates}{month}
\end{equation}
If it needs \textit{a} time to load or unload its cargo then, because in new units the distance is measured in \textit{months}, one can convert the \textit{a} loading time and express it as \textit{A} in \textit{months} (if $a$ is in minutes then by \eqref{convert_time} we have that $A=T(a/60)$). Then each trip has duration $2*L+2*A$ and the power of a car to transport goods becomes
\begin{equation}\label{power_month_and_load}
	P = \frac{cp}{2 * (L(l,v)+A)}\ \frac{crates}{month}
\end{equation}
If duration of load \textit{A} is very small compared to the duration of the trip, then it can be omitted and one can use the first more simple formula.

\textsl{The minimum of rates of consumption or production per month is a demand for transportation power.} Formula \eqref{power_month_and_load} can help to pick the right car for each demand. One can use more than one cars and add their powers or can chose a car with larger capacity or can decrease L by increasing his average velocity or by choosing a faster vehicle. When the transportation  distance is too small, because cars always move the fastest they can, even slowest and smallest of our cars can overpower the demand. In that case one increase L by reducing the average velocity of his car through scheduling,  so as to keep it unmoved for scheduled time intervals. 

\paragraph{A series of transportation} is not a simple transportation and is not exa-mined in present post, but let note some first thoughts. The coefficient 2 in denominator of formula \eqref{power_month_and_load} exist because the returning trip assumed empty loaded. If the same car do a series of transports then his ability to transport his capacity \textit{cp} remains the same for each individual good it transfer. However, the transport of each good begins only after our car finish the whole chain of lengths of transportations. Its ability to transport \textit{cp} specific goods must be devided by the time it takes to complete the circle of transportations. So, when a vehicle travels always loaded it has less ability to carry every individual good but it will be paid with the sum of all transportations it does. In a series of \textit{k} lengths $L_i$, the power to transport each demand of goods would be
\begin{equation}\label{power_series}
P = \frac{cp}{k*A+\overset{k}{\underset{i=1}{\sum }}L_i}
\end{equation}
From the above formula one can detect that if a demand is overpowered by the capabilities of a vehicle, to use the same vehicle so as to satisfy more demands simultaneously, can be a solution, if it uses 3 or more stops. On a loaded return, where the chain consists only from 2 stops, the vehicle will still be too much, but it will be paid twice. In every moment it does 2 trips simultaneously. One as loaded for the goods it carries and one empty for the goods it has previously unloaded.  Nevertheless, the \eqref{power_series} seems ideal for indeterminate industries where vehicle can transport both the consumption and production, for example the Spinner's cottage where both, wool and textiles, are piece goods and can be carrried by the same car. However, most of the time, concerning goods, this is not the case.  So, formula \eqref{power_month_and_load} might be useful because demand can be estimated more easily.

\textit{Mails,} logically have no loaded returns too, so one might use formula \eqref{power_month_and_load} if he has the ability to formalize the expected arrivals to each stop, knowing of course if trips are generated every month or every day, that is every 3.75 months.

\textit{On passengers transportation,} formula \eqref{power_series} might be proper, because buses are expected to be loaded all the time. However, the formulation of demand is even harder. Are buses full by luck or because the game guarantees the return to their origins? Do workers go to work once every about for 4 months (that equals to a day)? At the start of the 4 months period, do they travel once to go to work and at the start of 3nd month return to their home? Do they keep their jobs till industry closure, say for 10 years, creating a steady transport flow? or they lose their jobs at the end of every of their one day work for random reasons? Not knowing the answers, the use of formalization as decision tool seems useless to me. I suggest trial and error. Play and lose, till you manage, if possible, to win.
\section{Revenue}
\subsection{Distance cost per month}
Cost per distant is given as $cpd$ in cost per $km$. It is converted in new units by
\begin{equation}\label{cost_per_distance}
	Cpd = \frac{cpd}{L(1,v)}\ \frac{distance\ cost}{month}
\end{equation}
We can see that as average speed is increasing, the $L(1,v)$ time to travel $1 km$ is decreasing and so, the cost per month is increasing because you cross more distance with higher velocity.

It is convenient that this cost for distance, in cost per month units, can be added to maintenance cost per month.
\subsection{Distance profit}
Profit is measured as \textit{ppd} money per unit per $km$ it travels. It might seem natural to just divide by L(1) again to convert to new units, as we did for the cost. However there is a catch. By doing so, we assume infinite production, so faster cars means more back and forth and more transferred quantities per month. But it is not the case. Each unit of goods is transferred,  the required distance $L(l,v)$, only once. That means each transferred unit pays exactly $ppd/L(1,v)*L(l,v)$ money. So, the profit per month depends from how much units are transferred per month. That is calculated in formula \eqref{power_month_and_load}. So, profit depends only on the quantity to be transferred so, it is measured as money per unit and $ppd$ is converted to new units by
\begin{equation*}\label{profit_per_distance}
	Ppd = ppd *L(l,v)/L(1,v)= ppd*l\ profit\ units
\end{equation*}

\subsection{Revenue per month}
Since all variables in new units are converted in $month$ units and the maintenance cost per month do so, we are ready to combine all to calculate the revenue of $n$ convoys that do a simple transformation of goods. Our data are

\begin{description}
	\item[n] same convoys
	\item[cpm] maintenance cost per month for each convoy
	\item[cpd] maintenance cost per $km$ for each convoy
	\item[v] average velocity of each convoy
	\item[cp] capacity of each convoy
	\item[a] loading or unloading time in minutes for each convoy
	\item[l] distance that goods must be transferred
	\item[demand] as the minimum of production or consumption per month
	\item[ppd] reward for eah unit of goods transferred 1 $km$
	\item[dstCoeff] multiplier of euclidean distance to estimate the not straight route of convoys 
\end{description}
Since the power \eqref{power_month_and_load} of $n$ convoys to transfer quantities can not be greater than \textit{demand}, the actual quantities transferred per month is
\begin{equation}\label{minimum_quantities}
	Q = min(demand, \ n*P)
\end{equation} 
The distance of industries we see in information popup window is euclidean. Profits most probably are based in this. Maintenance cost per distant are payed based on the greater actual route that convoys take to reach their destination. $dstCoeff$ is used to estimate the length of longer route. If Manhattan distance is used in this case then the coefficient is a number between $1$ and $\sqrt{2}$, depending on how diagonal is the straight euclidian route, where $1$ is for perfectly horizontal or perpendicular on map route. For safety i use the largest value and the cost per distance is estimated as \[n*Cpd*\sqrt{2}.\]
So, Revenue per month is estimated as
\begin{equation}\label{Revenue_per_month}
	Revenue = Q*Ppd - n*(Cpd*\sqrt{2}+cpm)
\end{equation}
\paragraph{The payback time,} in moths, equals to the buying cost of the $n$ convoys divided by the Revenue \eqref{Revenue_per_month}. The point is that if one creates multiple simple transportations the payback time for all of his convoys will not change. Each convoy will contribute, by his revenue, to each own buying cost. So, costs of stops, depots and other infrastructures do not belong in simple transportation study.

The payback time of all infrastructures will start as soon as after each convoy pay back its own buying cost. After that, the sum of all vehicle revenues will contribute to it. So, the more of simple transportations the sooner the payback time of all other infrastructure will be. 
Of course we could add costs of stops in our simple transport but soon enough other transports may use it too and stops cost had to be compared with the revenue of all transportations they use it. 
\subparagraph{Monthly cost of infrastructure} may be that displayed in informations, if it is used only by one convoy, or only a ratio of it (may be $1/ number\ of\ convoys$), if it is used by orther vehicles too. My approach is to compare the revenue \eqref{Revenue_per_month} by whatever ratio of monthly infrastructure i think proper, as a secondary process. 

\section{Elemental analysis}

I measure in $months$ so as to make fast game decisions but usual units help me to understand better what is the motive behind my decision. Lets take a look on how $Revenue$ looks like in normal units.

Because loading or unloading time $A$ adds complexity and almost in all cases, as much lower than trip time, is omitted, I will not include it in analysis because i only want to understand and not to find the exact best revenue.

$Revenue$ in normal units is expressed as
\begin{equation}\label{Revenue_normal}
		Revenue = min(demand,\frac{cp*m*n*v}{2*l})*l*ppd-\sqrt{2}*cpd*m*n*v-n*cpm
\end{equation}
In case that $demand$ is greater than the power $n*P,$ the above becomes
\begin{equation}\label{Revenue_normal_Power}
	Revenue = \frac{cp*m*n*v}{2*l}*l*ppd-\sqrt{2}*cpd*m*n*v-n*cpm
\end{equation}
At first glance we see that by changing $n$ the sign of $Revenue$ remains unchanged. $Revenue$ will be more positive or more negative. Also, by increasing $cp$ definitely we increase $Revenue.$ No interesting here.

$Revenue,$ as function of $v,$ is increasing only when $cp*\frac{ppd}{cpd}>2*\sqrt{2}=2.83$. I will assume that this is always true.

The velocity case looks interesting. Some course of actions seems to arise.
\subsection{Strategy when power is not enough}
\paragraph{The increase of power to transport,} toward $demand$, can be achieved by
\begin{enumerate}
	\item increasing capacity $cp$. If that is not enough then by
	\item increasing average velocity $v$. If that is not enough then by
	\item increasing the number $n$ of convoys.
\end{enumerate}
It seems that we are always able to end in an ideal situation, or close enough to her, where our power to transport equals to the $demand.$ So, this maximized revenue will be
\[
	maxRevenue = demand*l*ppd-\sqrt{2}*cpd*m*n*v-n*cpm
\]
After this point, any farther increase of $n$ or $v$ will decrease our achieved revenue. Furthermore, due to the minus sign in the term involving $v$, we are required to satisfy $demand$ by the lowest possible average velocity $v.$
\subsection{Dealing with demand}
Because convoy's power to transport will, or has to, be equal to demand, formula \eqref{power_month_and_load} is the bit heart of our decisions. In this section we omit loading or unloading times so, we will look at formula \eqref{power_month} instead. 

$Power$ in normal units is expressed as
\begin{equation}\label{Power_normal}
	P=\frac{cp*m*v}{2*l}
\end{equation}
The sum of powers of our $n$ convoys should be equal to $demand.$
\[n*P=demand \Rightarrow n*\frac{cp*m*v}{2*l}=demand\Rightarrow\frac{cp*v}{l}=2*\frac{demand}{n*m}\]
The euclidean distance $l$ between industries do not change and should be in the right side of equation as, more or less, constant. However, lets solve for it
\paragraph{Length} $l$ equals to
\begin{equation}\label{length_demand}
	l=\frac{n*m}{2*demand}*cp*v
\end{equation} 
When we know the capacity $cp$ and the average velocity $v$ of our convoys, we could search for such a distance so as to use them ideally for that speed. However, even then, we should try to reduce speed and increase capacity for even better profit. I just wanted to test the walking workers. Somewhere i read and had the impression that a loaded worker has capacity $cp=1$ and walking speed $1km/h$. In \textit{simuconf.tab} i found only that walking passengers have velocity $4km/h$. Whatever is the case, if the game generates exactly one worker to load from a stop and unload to nearby industry, then, how far we place our stop from industry may affect the satisfaction of industry's demand. So, with $n=1,\ m=6.4,\ demand=12\ units/month$ and if $v=1,$ we better keep the distance lower than $0.27km$ and place our stop not further than 2 tiles away.

\paragraph{Similarities with fluid flow} can be revealed if we rephrase the equation of transfer's power with $demand.$
\[\frac{n*cp/2}{l}*(m*v)=demand\]
Assume that the units of goods of numerator are volume of water in $n$ pipes, that denominator's  $l$ is length of each pipe that connects industries and that the $demand$ is demand in cubic meters of water per month. The pipes are full of water so, the left hand side of equation describes the cross section area of the $n$ pipes multiplied by the velocity of fluid in $km/month$. That defines the water's flow. In that sense, the term \textit{'flow of goods'} would be much better than the term \textit{'power to transfer goods'} i used so far.

\subsection{Limits on flow of goods.}
By \eqref{Power_normal} we see that power $P$ is steady if the product $cp*v$ remains unchanged. We have concluded so far that by reducing average velocity we get more profit. If the capacity of our vehicle was unlimited we could exploit that fact by reducing, through scheduling, the average velocity near zero and use huge capacity vehicle. It would be the same as if someone asked for 4 crates per month and you say 'ok, i will deliver to you 48 creates per year'. He may need 12 deliveries in a year but you intend to deliver only once, larger but equivalent to the demand quantities, so as to save running $km$ and money. 

Storage of stops or stations can be a limit to this exploit. One can not deliver more goods than a stop can handle. However, one can easily overcome it by increasing stop's storage through extensions. So, stops should have nothing to do with satisfaction of a specific demand but they have to  do with the satisfaction of all demands they serve.

It seems necessary to get internal storage of industries in the picture.

I see my market. It consumes 28 fishes per month. It has maximum internal storage, for fishes, of only 2 units. Customers will think that if every 2 units of fishes in market are replenished, it can not be but to consume fresh fishes. They can not know that these fishes might have traveled for many months before they end to market. Neither owner of market cares but, in order for his fishes to seem fresh, he want to replenish fish stock every 2 units. So, he needs a stock only for 2 units and what he wants from transport service is to deliver 2 fishes a time and to do so 14 times in a month. If we deliver 28 units then 13/14 of the month, internal storage may signal it is overstocked and that might trigger production to stop for almost the whole month. Overstocking of consumer's input may not affect all industries but many, i think, are affected. Our aim is to let production and consumption efficient and that puts limits in the capacity each convoy must carry.

Let switch back to $month$ units, in an attempt for better understanding on the limits that internal stock may set.
\paragraph{Limit on convoys} can be easily detected. Having the maximum of our profit independent from distance or time (see section \eqref{profit_per_distance}), by raising the number $n$ of convoys then the running and monthly costs of vehicles can fast overcome that maximum profit.

Let see a case. It is year 1750, $m=6.4$ and my convoys seems to have average velocity $v=5km/h$. When a convoy can carry his capacity $cp$ per month? That is when his power equals to his capacity per month? From the simplified \eqref{power_month} we find that it happens when duration of the trip to go to destination is $L(l,v)=1/2\ months$. That means a distant of $l=16km$. So, when convoy's power equals to demand but distance is larger or when distance is equal to 16km but demand is larger, we need more vehicles and should pay more attention to how revenue is affected. 
\paragraph{Stock limit} can be seen if we express, by, the without loading time, simplified formula \eqref{power_month}, the equality of power of $n$ convoys with $demand$, in $month$ units. 
\begin{equation}\label{eq_nP_demand}
	n*P=demand \Rightarrow cp = demand * \frac{2 * L(l,v)}{n}
\end{equation}
$2*L$ is the time a, just unloaded, convoy needs to go load again and return back. When we use $n$ convoys and spreed them equally through scheduling, $2*L/n$ is the time interval between each arrival. As we suspect, $cp$ can not be greater than the internal storage of industries, for production chain to work flawlessly. Each delivery will supply just enough units in internal storage, that will keep dropping because of consumption, and next delivery will be done just in time. So,
\[cp\leq internal\ storage\] might be the limit on our exploit. Equivalently, from \eqref{eq_nP_demand}, wee seek an average velocity $v\acute{}$ such that duration of trip should be
\[L(l,v\acute{})<=\frac{internal\ storage}{demand}*\frac{n}{2}\]
We may want to increase the time between arrivals, so as to  use larger capacity for each convoy, but owner of industry say \textgravedbl no, you will use such duration for the trip and so many convoys as for to deliver, each time, my internal storage only\textacutedbl. Any time, we will probably try to use a capacity that equals to internal storage. If we substitute \textit{cp} by \textit{internal storage} in formula \eqref{eq_nP_demand}, we can solve to find the proper duration of each trip but, also, we get too close to the \textit{just\_in\_time} variable in \textit{simuconf.tab}. Unfortunately, the default value of 4 does not have an explanation in Britain-Ex pakset but one can find the explanation in the \textit{simuconf.tab} that exists in \textit{config} folder in the root directory of simutrans game.

\begin{quote}
\textit{	At 4, industries will demand goods whenever their internal storage does not have sufficient stock to last until the next delivery is estimated to arrive if the goods were to leave the producing factory now.}
\end{quote}

All now depends on how the above explanation is really applied. Formula \eqref{eq_nP_demand} and our decision to use a capacity $cp=internal\ storage$ agree with the shorter explanation
\begin{quote}
 	At 4, industries will demand goods whenever their internal storage does not have sufficient stock to last until the next delivery is estimated to arrive.
\end{quote}
That is because,  as we explained above, $2*L/n$ is the time interval between each arrival. Game may just record uploads to estimate next arrival  accurately (despite that, as i personally repeatedly checked, the initially estimated duration of a long chain of transports shows up exactly at 0:00:00 time of the next month so,  initially, estimation might be far from right.).
If the phrase \textit{\textgravedbl\dots if the goods were to leave the producing factory now\textacutedbl} is not just a philological
 addition, then best strategy, obeying to stock limit philosophy, can achieved only if, by chance, a transport is done by two convoys. From explanation in \textit{simuconf.tab}, it seems we might be able to supply an empty internal storage, at maximum, with $dl$ units,
where $dl=demand*L(l,v)$. Internal storage philosophy of existence, leads to $cp=internal\ storage$. Substituting to formula \eqref{eq_nP_demand} we get
\begin{equation*}
	internal\ storage=\frac{2}{n}*dl \Rightarrow dl=\frac{n}{2} *internal\ storage
\end{equation*} 
 
  If transport is done by one convoy, game reduce our best capacity's strategy to half of it. Only in  cases of willing to use more than 2 convoys, we can exploit the game mechanism and use more capacity than that the \textgravedbl owner\textacutedbl of industry would like. However, I highly doubt that there can be a profitable such case.
  
  Let examine the situation from another point of view too.
  
   If the phrase estimates duration through the average velocity that is close to the maximum one, then, because capacity $cp$ is always given by \eqref{eq_nP_demand}, we get
   \[demand * \frac{2 * L(l,v\acute{})}{n}<=demand*L(l,v)\Rightarrow L(l,v\acute{})<=\frac{n}{2} * L(l,v)\]
   that there is a limitation where we can not get beneficial longer duration of trip, compared with the non scheduled duration, unless we can afford to use 3 or more convoys.
  
  If the phrase estimates duration through the actual average velocity $v\acute{}$ we seek, then
   \[demand * \frac{2 * L(l,v\acute{})}{n}<=demand*L(l,v\acute{})\Rightarrow n>=2\] 
 that there is a limitation to use 2 or more convoys and not get the maximum that would earn a single convoy.
  
  
  I do not like to change defaults. I have to consider, though, that i should do so with \textit{just\_in\_time} variable. If I do, values 1 or 3 might be good candidates.\\
  
  \textit{Stock limits concerned the demand and internal storage of destination's industry.}
  \paragraph{Duration limit} can exist if we care so as that the internal storage of origin's industry to not be overflowed. We care, if we can consume all the production and want it not to stop due to overflow. In place of $demand$, consider the production rate of source industry. Then formula \eqref{eq_nP_demand} gives the produced units between arrivals of convoys. Those must be less or equal to source's internal storage. So, the limit we get for maximum duration of trip, due to the scheduled average velocity $v\acute{}$ is 
  \[L(l,v\acute{})<=\frac{internal\ storage}{production}*\frac{n}{2}\]
  
  \subsubsection{Scheduling} aims to save distance costs by increasing the duration of trip from $L(l,v)$ to $L(l,v\acute{})$ . Maximum revenue is expected when we satisfy exactly the demand. Substituting $Q=demand$ and $Cpd$ in \eqref{Revenue_per_month}
  \begin{equation}\label{Revenue_schedule}
  	Revenue = demand*Ppd - n*(\frac{cpd*l}{L(l,v\acute{})}*\sqrt{2}+cpm)
  \end{equation}
we see that only duration of trip and number of convoys can affect it. Without scheduling an average velocity, close to the maximum velocity of our convoys is considered granted. By scheduling we alter that velocity to $v\acute{}$ so, we increase the duration of trip to $L(l,v\acute{})$ as much we can, but obeying to the limits on flow we mentioned.

\textit{In all cases, we do not mind to evaluate $v\acute{}$. We care only on the modified duration $L(l,v\acute{})$}
\paragraph{Scheduling departure times} on source industry might need number theory and might not affect duration of trip much, as time intervals can have maximum duration of 1 month. In case, though, that $n=1$ and $2*L(l,v)<1$, we can approach what stock limit would suggest as ideal duration of trip and get\[L(l,v\acute{})=\frac{1}{2*departures\ per\ month}>L(l,v)\]
In that case revenue per month would be
\[Revenue = demand*ppd*l - (2*\sqrt{2}*cpd*l*departures+cpm)\]
\paragraph{Scheduling loading} seems more drastic, only if game does not decide to let vehicle to depart before it completes his scheduled load. Again, when convoys are more than one, i need number theory so, i will let the case out. If we schedule our single convoy for $cp$ load, then, with $production$ units per month, the new duration will be
\[L(l,v\acute{})=\frac{cp}{2*production}>L(l,v)\] 
In this case, revenue from \eqref{Revenue_schedule} becomes
\[Revenue = demand*ppd*l - (2*\sqrt{2}*cpd*l*\frac{production}{cp}+cpm)\]
where $v$ is the normal average velocity near the maximum speed of vehicles.
\subsection{Bypassing flow limits} might be either a good strategy or an exploit of weakness.

Flow limits appeared because our A to B simple transportation included both source and destination industries. Stations and stops do not have restrictions because they can extend indefinitely their capacities. The idea to bypass the limits is to create two additional stations between and very near to each of the edges of the desired route between A and B. Say we create a station C very near to A but far enough so no walking products will decide to go to C. The distance of two are so close that the limits on flow from A will cost the less possible. Do the same and create a D station very near to B.  The distance of two are so close that the limits on flow to B will cost the less possible.
The much larger distance from C to D, that would cost us a lot due to the limits on flow, can be scheduled without limits because it is a flow between stations.

Can be profitable such a strategy? I did not checked. I leave the testing to any worthy reader, who honored me and, reading so far, managed to bypass the \textit{Too Long To Read} attitude.
\section{Final thoughts on a simple network}
Questions about how simutrans extended simulates real world create final thoughts in my head.

In this post we tried to study a simple transportation between two industries. Assume that both need workers and, additionally, industry B need customers too. If we consider a third building C that provides them, we are faced a simple network or a simple world. C represents the population.

Consider a single direction of creation. Population creates industries to satisfy his needs. If population drops or raises, industries will drop or raise their operation rates or their number. Some kind of ratio between them will remain with value 1. Because of that, we can say that world is in stable equilibrium.

Consider the opposite single direction of creation. Industries breed population to satisfy their needs of work and consumption of their products. If industries drop or raise, population will drop or raise. Some kind of ratio between them will remain with value 1. Because of that, we can say that world is in stable equilibrium.

Now consider that a double direction of creation is active. If industries support less population, in the next calculation of what they support, population will drop. Less population will lessen the operational rate of industries that will support even less population and so on until both disappear. If industries support more population, population will grow. More population will increase the number or the operational rate of industries that will support even more population and so on until the whole world will be an overpopulated huge city. The same will happen if population alters their creation rate on industries. Some kind of ratio between them will remain different than 1. Because of that, we can say that world is unstable. 

Randomness may create a sense of live world but, my opinion is that stability can not coexist with the double direction creation. Even if we randomize by a ratio with average value of 1, the result will be a pick from a distribution of a product that will have average value of exactly 1 but also will have huge variance. That means, any game will be a pick that, almost certain, will be away from 1 and look unstable. Even if player can make small corrections toward stability, the game for a moment might look in equilibrium but it will be in an unstable equilibrium that will be lost soon. Like trying to balance a pencil on his nose.

The problem with above thoughts is not only that the mentioned ratio of balance is not well defined. It is not defined at all. What then might guaranty stability through game play? Many would say, a successful 1:1 simulation of real world through a copy of real data in configurations. They might be right but this is not a mathematical argument. Furthermore, the hidden assumption that real world is stable, might be false. A respectable minority percentage of people or gamers might believe that real world is unstable. If they are right and simulation works perfectly well, the 1:1 copy of data will create an unstable game that soon becomes apparent to the players because of time compression. Since game do not understand economic crashes, wars and other unpleasant results, instability is the only thing it will produce in that case. In whatever world players think they live, all prefer to experience stability in their game play simulation creations.

\textit{I always suspected that transportation systems can not ever be simple. Even only due to the problem of topology optimization they include. Writing this, I was surprised by the fact that even a transfer from A to B was not as simple as the present title implied. Do you?}

\tableofcontents
\end{document}
	