News:

The Forum Rules and Guidelines
Our forum has Rules and Guidelines. Please, be kind and read them ;).

Idea: metronome for timetables

Started by mopoona, October 25, 2010, 09:04:39 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

inkelyad

Yes, i don't want to break savegame compatibility.

mopoona

Did I get it right: Spacing is enabled only by line, not by station? So this does ensure a distance between 2 vehicles of one line?

inkelyad

Quote from: mopoona on December 03, 2010, 03:09:20 PM
So this does ensure a distance between 2 vehicles of one line?
More or less. But it is not distance based. It is time based. Parameter is 'convoys/month'.

jamespetts

I am just looking through this thread and other discussions on the topic to determine whether to include this patch in 9.0 or leave it until 10.x. One thing that needs consideration in particular, I think, is what Prissi wrote here about months:

Quote
First, the time you see in simutrans is different dependent on your setting. A month can be either three days or 28-31 days long. (The first option make sense when you have small number of bit_per_month).

Inkelyad - how does your code deal with this?
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

inkelyad

Quote from: jamespetts on December 04, 2010, 12:01:54 AM
Inkelyad - how does your code deal with this?
It is why I use convoy/month -- it is affected by month length same way as 'max wait' setting. There is no clock/calendar confusion.

Industry production also use units/month. So 'right' value for convoy/month should be 'right' for any bit_per_month.

mopoona

I still would like to see that this feature is improved so structured timetables are possible in the game to ensure low waiting times and efficient use of the given infrastructure, like in my original request.
One example: Lets say you have network off many single-track rails. In SE, the average speed of line will decrease, when a train has to wait a long time before the track before it is cleared.

inkelyad

You want synchronization, right?
My patch will do this. Enable spacing on all stops => convoys on all stops will departure simultaneously.

But then trains will wait at stop. it is not much better.

Ex:
spacing is 30 cnv/month. path from A to B in only 1 km. Then convoy will wait almost whole day at B as journey time A->B is very small.

jamespetts

I have now, eventually, had a chance to test this - see my new branch on Github. I have also added the ability to save the "spacing" setting, although this will break compatibility with previous games saved using the 9.x branch home-compiled binaries. To make sure that older games can be saved, save them as Experimental version 8 before upgrading to the newer version on this branch.

Overall, it seems to work well, and seems to be a worthwhile additional option. One or two small things: first of all, the new code uses the "snprintf" method in simconvoi.cc, yet this method is not defined in any of the requisite include files, so it gives a compile error. It works file with the less safe "sprintf", but I am intrigued as to how you managed to get the version with snprintf to compile without additional #include files.

Secondly, there is a GUI glitch: the new spacing command does not appear when the schedule window is accessed through the convoy window rather through the depot or line windows. I have also tried to make the tool greyed out when it will have no effect as suggested by SDog, but this does not seem to work properly: it is only greyed out when the minimum load setting is returned to zero after being at another setting. This also applies to the maximum wait tool, so this may be a problem that ultimately comes from Standard, as I replicated the Standard code when implementing this.

Finally, I have produced a draft revised help file for the schedule window to take into account the new features, which I reproduce below. Please let me know if I have misdescribed the feature, or if it could be explained better:


<title>Schedule Help</title>

<h1><strong>Schedule</strong></h1>

<p>
The <strong>Schedule</strong> window sets the schedule for a <a href="convoiinfo.txt">Convoy</a> or a <a href="linemanagement.txt">Line</a>.
It lists<a href="station.txt">Stops</a>, where convoys pick up and drop off goods and passengers, and waypoints, which can be used to determine which route that convoys use, with their respective map co-ordinates.
</p>
<p>
The <strong>Schedule</strong> window for a particular convoy can be accessed by pressing the "schedule" button in the <a href="convoiinfo.txt">Convoy Information</a> window or  the <a href="depot.txt">Depot</a> window.
To open the <strong>Schedule</strong> window for a line, select "New line" or "Update line" in the <a href="linemanagement.txt">Line Management</a> or <a href="depot.txt">Depot</a> windows.
</p>
<p>
When the <strong>Schedule</strong> window is opened from the Convoy Information window, the assigned Line (if there is one) is shown at the top of the window.
</p>
<p>
<em>Serves</em> <a href="linemanagement.txt"><em>line:</em></a> This shows the line currently served by the current convoy. To change the line served by this convoy, click on the left/right-arrow buttons to cycle through the lines, or click on the name box to open a drop-down-list of the lines, then click one to select it.
Click on the name box and type new name to change the name of the line.
</p>
<p>
<em>Minimum load:</em> This is the minimum quantity of passengers or goods that must be loaded at the selected stop before the convoy will leave the stop for its next destination.
The percentage figure refers to the total capacity of the convoy and not an indiviual type of item carried.<br>
To use this feature, click on a stop in the list to select it, then use arrow buttons to cycle through the percentages, or type in a precise percentage in the text box.<br>
</p>
<em>Max. wait for load:</em> This is the maximum amount of time that a convoy will wait at a stop for the load level specified in "Minimum load". If this is set to "off", the convoy will wait as long as it takes to get the loading level stipulated. The remaining settings are proportions of game months: at 1/1, the convoy will wait up to one game month before departing the stop whether it has reached the specified loading level or not. At 1/512, the convoy will wait 1/512th of a month before moving off even if it does not have the specified level of load.<br>
<em>Tip:</em> Use this feature on lines carrying passengers, mail or other time-sensitive loads to make sure that the journey times are not too long if the "minimum load" feature is set.
</p>
</p>
<em>Spacing cnv/month</em>: This option only works if the "Minimum load" option is set. If this option is set in a schedule with a minimum load, the convoy will wait until either the minimum load specified is reached or the stipulated time (in fractions of game months: "2" is 1/2 of a month, etc.) has passed since the last convoy departed from this stop.
<em>Tip</em>: Use this feature to cause convoys to spaced evenly throughout a line, reducing waiting times.
</p>
<p>
<em>Mirror schedule:</em> If this option is selected, the convoys using this schedule will reverse the direction in which they follow the schedule when they get to the end of it. So, for example, if a line has the schedule A>B>C, if this button is not selected, the convoy will go A>B>C>A>B>C, etc. If this is selected, the convoy will instead travel A>B>C>B>A>B, etc.<br>
<em>Tip:</em> If this option is used with trains on double-track railways, the game will automatically work out which direction platform should be used, but this does mean that the exact platform cannot always be specified when this option is enabled.
</p>
<em>Alternate directions:</em> If this option is selected, each convoy assigned to this line will start in the opposite end of the schedule to the last convoy assigned to this line. This is useful for making sure that convoys are evenly spaced on a line.
<p>
Option buttons (click to use, button is indented when selected) include:
</p>
<p>
<em>Add</em> <a href="station.txt"><em>Stop:</em></a> This places a stop used by vehicles to pick up or drop off goods and passengers (water transport vehicles may use any square of water in the catchment area of a dock) or waypoint on the route.<br>
To add a stop or waypoint: click on the option to select (which changes the cursor to a "stop" arrow), then click the required point in the main game window for the stop or waypoint. It must be a point on road, track or water as appropriate for type of vehicle. A stop placed outside a station will automatically create a waypoint.<br>
<em>Tip:</em> Vehicles do not pick up or drop off goods and passengers at waypoints.
</p>
<p>
<em>Insert:</em> This places a <a href="station.txt">Stop</a> or waypoint on route, before an existing stop or waypoint.<br>
To insert a stop or waypoint: click on an existing stop/waypoint in list to select, then click on the insert button (which changes the cursor to a "stop" arrow), then click required point in the main game window for the stop or waypoint.
</p>
<p>
<em>Remove:</em> option deletes a stop or waypoint from the schedule. Click on the "remove", then click on a stop or waypoint in the schedule to remove it.
</p>
<p>
<em>Promote to</em> <a href="linemanagement.txt"><em>Line:</em></a> (only available when the <strong>Schedule</strong> window is opened from the <a href="convoiinfo.txt">Convoy Information</a> window) creates a new line using the current schedule.
</p>


Edit: One thing that I do notice with this, however, is that, when the spacing feature is used without also using the maximum wait time feature, the average speed can get very, very low and the journey times very, very high. Is this feature designed to be combined with the maximum waiting time feature?
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

inkelyad

Quote from: jamespetts on December 12, 2010, 05:32:28 PM
Overall, it seems to work well, and seems to be a worthwhile additional option. One or two small things: first of all, the new code uses the "snprintf" method in simconvoi.cc, yet this method is not defined in any of the requisite include files, so it gives a compile error. It works file with the less safe "sprintf", but I am intrigued as to how you managed to get the version with snprintf to compile without additional #include files.
It is MSVC 'fault'. Microsoft don't like snprintf for some reason. See here.

Quote
Secondly, there is a GUI glitch: the new spacing command does not appear when the schedule window is accessed through the convoy window rather through the depot or line windows.
Spacing is line schedule feature, not convoy schedule. So it is more or less intuitive.
Quote
the stipulated time (in fractions of game months: "2" is 1/2 of a month, etc.) has passed since the last convoy departed from this stop.
It is not correct. Departure/arrival time don't used here.
It work like this:
Every 1/n month is departure time. If month == 30*24 hours, spacing=60, then convoys will depart at 00:00 and 12:00 every day.

Quote
One thing that I do notice with this, however, is that, when the spacing feature is used without also using the maximum wait time feature,
It is intended mode of operation. If journey time too long => you need more convoys and larger value for spacing.

Quote
Is this feature designed to be combined with the maximum waiting time feature?
It can be combined. Useful, if for particular station (busy hub, for example) spacing waiting can be too long and we wand override it.

Relevant code is in void convoi_t::laden():

        halthandle_t halt = haltestelle_t::get_halt(welt, fpl->get_current_eintrag().pos,besitzer_p);
        if(go_on_ticks==WAIT_INFINITE) {
                sint64 go_on_ticks_spacing = WAIT_INFINITE;
                if (line.is_bound() && fpl->get_spacing() && line->count_convoys()) {
                        uint32 spacing = welt->ticks_per_world_month/fpl->get_spacing();
                        sint64 wait_from_ticks = (welt->get_zeit_ms()/spacing) * spacing; // remember, it is integer division
                        int queue_pos = halt.is_bound()?halt->get_queue_pos(self):1;
                        go_on_ticks_spacing = wait_from_ticks + spacing * queue_pos;
                }
                sint64 go_on_ticks_waiting = WAIT_INFINITE;
                if ( fpl->get_current_eintrag().waiting_time_shift>0) {
                        go_on_ticks_waiting = welt->get_zeit_ms() + (welt->ticks_per_world_month >> (16-fpl->get_current_eintrag().waiting_time_shift));
                }
                go_on_ticks = (std::min)(go_on_ticks_spacing, go_on_ticks_waiting);
        }

it is easy to understand.

jamespetts

Inkelyad,

thank you for your responses - most helpful.

1. Thank you for pointing me to that. I  have used the workaround suggested there and it works nicely now.

2. Ahh, I understand now! I shall update the help file accordingly.

3. Is it assumed that every month has 30 days, or are adjustments made for particular months (and then for leap years); or is 60 simply a fixed number of departures per month? Also, does this represent 60 departures/month from each stop on the schedule, or 60 departures  per month from any stop on the schedule?

Thank you again for your help with this!

Edit: Updated draft help file attached:


<title>Schedule Help</title>

<h1><strong>Schedule</strong></h1>

<p>
The <strong>Schedule</strong> window sets the schedule for a <a href="convoiinfo.txt">Convoy</a> or a <a href="linemanagement.txt">Line</a>.
It lists<a href="station.txt">Stops</a>, where convoys pick up and drop off goods and passengers, and waypoints, which can be used to determine which route that convoys use, with their respective map co-ordinates.
</p>
<p>
The <strong>Schedule</strong> window for a particular convoy can be accessed by pressing the "schedule" button in the <a href="convoiinfo.txt">Convoy Information</a> window or  the <a href="depot.txt">Depot</a> window.
To open the <strong>Schedule</strong> window for a line, select "New line" or "Update line" in the <a href="linemanagement.txt">Line Management</a> or <a href="depot.txt">Depot</a> windows.
</p>
<p>
When the <strong>Schedule</strong> window is opened from the Convoy Information window, the assigned Line (if there is one) is shown at the top of the window.
</p>
<p>
<em>Serves</em> <a href="linemanagement.txt"><em>line:</em></a> This shows the line currently served by the current convoy. To change the line served by this convoy, click on the left/right-arrow buttons to cycle through the lines, or click on the name box to open a drop-down-list of the lines, then click one to select it.
Click on the name box and type new name to change the name of the line.
</p>
<p>
<em>Minimum load:</em> This is the minimum quantity of passengers or goods that must be loaded at the selected stop before the convoy will leave the stop for its next destination.
The percentage figure refers to the total capacity of the convoy and not an indiviual type of item carried.<br>
To use this feature, click on a stop in the list to select it, then use arrow buttons to cycle through the percentages, or type in a precise percentage in the text box.<br>
</p>
<em>Max. wait for load:</em> This is the maximum amount of time that a convoy will wait at a stop for the load level specified in "Minimum load". If this is set to "off", the convoy will wait as long as it takes to get the loading level stipulated. The remaining settings are proportions of game months: at 1/1, the convoy will wait up to one game month before departing the stop whether it has reached the specified loading level or not. At 1/512, the convoy will wait 1/512th of a month before moving off even if it does not have the specified level of load.<br>
<em>Tip:</em> Use this feature on lines carrying passengers, mail or other time-sensitive loads to make sure that the journey times are not too long if the "minimum load" feature is set.
</p>
</p>
<em>Spacing cnv/month</em>: This option only works if the "Minimum load" option is set. If this option is set in a schedule with a minimum load, the convoy will wait until either the minimum load specified or the stipulated departure time is reached. The "spacing" value represents the number of departures from the particular stop per game month, and a departure time for each vehicle calling at the stop is automatically calculated based on an even distribution of these times. This value is set for the whole schedule, not each stop.<br>
<em>Note:</em> This feature is only available for the schedules of lines, not individual convoys. The "spacing" setting will not be visible when editing an individual convoy's schedule.<br>
<em>Tip:</em> Use this feature to cause convoys to spaced evenly throughout a line, reducing waiting times.
</p>
<p>
<em>Mirror schedule:</em> If this option is selected, the convoys using this schedule will reverse the direction in which they follow the schedule when they get to the end of it. So, for example, if a line has the schedule A>B>C, if this button is not selected, the convoy will go A>B>C>A>B>C, etc. If this is selected, the convoy will instead travel A>B>C>B>A>B, etc.<br>
<em>Tip:</em> If this option is used with trains on double-track railways, the game will automatically work out which direction platform should be used, but this does mean that the exact platform cannot always be specified when this option is enabled.
</p>
<p>
<em>Alternate directions:</em> If this option is selected, each convoy assigned to this line will start in the opposite end of the schedule to the last convoy assigned to this line. This is useful for making sure that convoys are evenly spaced on a line.
</p>
<p>
<em>Add</em> <a href="station.txt"><em>Stop:</em></a> This places a stop used by vehicles to pick up or drop off goods and passengers (water transport vehicles may use any square of water in the catchment area of a dock) or waypoint on the route.
To add a stop or waypoint: click on the option to select (which changes the cursor to a "stop" arrow), then click the required point in the main game window for the stop or waypoint. It must be a point on road, track or water as appropriate for type of vehicle. A stop placed outside a station will automatically create a waypoint.<br>
<em>Tip:</em> Vehicles do not pick up or drop off goods and passengers at waypoints.
</p>
<p>
<em>Insert:</em> This inserts a stop or waypoint into a schedule immediately before the currently selected stop or waypoint. To insert a stop or waypoint, click on an existing stop or waypoint in list to select it, then click on the insert button (which changes the cursor to a "stop" arrow), then click the required point in the main game window.
</p>
<p>
<em>Remove:</em> option deletes a stop or waypoint from the schedule. Click on the "remove", then click on a stop or waypoint in the schedule to remove it.
</p>
<p>
<em>Promote to</em> <a href="linemanagement.txt"><em>Line:</em></a> (only available when the <strong>Schedule</strong> window is opened from the <a href="convoiinfo.txt">Convoy Information</a> window) creates a new line using the current schedule.
</p>
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

inkelyad

Quote from: jamespetts on December 12, 2010, 08:13:01 PM
Inkelyad,
3. Is it assumed that every month has 30 days, or are adjustments made for particular months (and then for leap years); or is 60 simply a fixed number of departures per month?
30 days was an example.
It is fixed number of departures per month.

Quote
Also, does this represent 60 departures/month from each stop on the schedule, or 60 departures  per month from any stop on the schedule?
Uh, I don't understand this.

With spacing == 60 we will have 'table' of 60 evenly spaced departure times.
Every stop with 'Min load' will use it.

jamespetts

1. Right, thank you, that's helpful (and makes more sense).

2. I should explain more clearly: suppose that a schedule is:

Stop A
Stop B
Stop C

and the "spacing" setting is 10. Is that 10 departures/month from Stop A, 10 departures/month from Stop B and 10 departures/month from Stop C, or is it 10 departures/month from stops A, B and C combined?
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

inkelyad

Quote from: jamespetts on December 12, 2010, 10:03:48 PM
Stop A
Stop B
Stop C

and the "spacing" setting is 10. Is that 10 departures/month from Stop A, 10 departures/month from Stop B and 10 departures/month from Stop C, or is it 10 departures/month from stops A, B and C combined?
It is former. What give you idea it can be latter?
It make no sense to do this.

jamespetts

Thank you for the clarification! I was just being a little dim, I think.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

jamespetts

Inkelyad's patch is now included in 9.0.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

ӔO

#50
just to confirm, the convoy spacing feature must be used along with the minimum load function as well, correct?

Currently, as far as city buses go (50km/h), I get good results with
(1.5x buses / 1 stop (mirrored)) with 15 convoy/month
(2.0x buses / 1 stop (mirrored)) with 32 convoy/month
(2.5x buses / 1 stop (mirrored)) with 40 convoy/month
(3.0x buses / 1 stop (mirrored)) with 45 convoy/month

using mercedes citrao G that has 2100 loading time.
40~45 convoy/month seems to be the saturation limit for a bus with 2100 loading time.
These numbers are under ideal conditions with no other private vehicles or intersecting bus lines interfering.
My Sketchup open project sources
various projects rolled up: http://dl.dropbox.com/u/17111233/Roll_up.rar

Colour safe chart:

inkelyad

Minimum load decision override spacing and max wait decision. When 'min load' = 0 convoy will not wait for anything.

Also, loaded up to 'min load' convoy will not wait too.

As for rest, I don't understand question.

ӔO

Quote from: inkelyad on December 21, 2010, 09:26:03 AM
Minimum load decision override spacing and max wait decision. When 'min load' = 0 convoy will not wait for anything.

Also, loaded up to 'min load' convoy will not wait too.

As for rest, I don't understand question.
In order for this to work, minimum load must be greater than 1% and convoy/month must be set to 1 or more.
correct?
My Sketchup open project sources
various projects rolled up: http://dl.dropbox.com/u/17111233/Roll_up.rar

Colour safe chart:

inkelyad


ӔO

#54
okay, thank you for clarification. :)

It seems to take some trial and error to get the timing right, but this is a fantastic tool. Great job.
My Sketchup open project sources
various projects rolled up: http://dl.dropbox.com/u/17111233/Roll_up.rar

Colour safe chart:

inkelyad

Here is another demo.
Take note on end stop for bus -- it is cargo only, no passengers.