Cargo Distribution

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

User avatar
fonso
President
President
Posts: 945
Joined: 13 Oct 2007 08:28

Cargo Distribution

Post by fonso » 24 Feb 2009 00:37

So, this is the (n+1)th attempt to provide passenger and cargo with destinations and then getting them there using the existing transport links as efficiently as possible. This means it includes what others call "load balancing". I have moved the main description of cargodist into the wiki, see http://wiki.openttd.org/Passenger_and_c ... stribution. Here you'll only get some status information on the progress for the different mile stones. Basically cargodist does what I envisioned when I started it and now I'm only tweaking some things to integrate it more nicely with the rest of the game. You can get the code from my github repository at http://github.com/ulfhermann/openttd . The relevant branch is "cd". Have a look at https://github.com/ulfhermann/openttd/commits/cd to see the individual milestones which have been reached. If you don't want to use git you can get a diff between trunk and cd at this URL: https://github.com/ulfhermann/openttd/c ... ...cd.diff . You can always find the current trunk revision the patch is meant to be applied to by looking at the topmost commit at https://github.com/ulfhermann/openttd/commits/master . You can also download a source package from https://github.com/ulfhermann/openttd/archive/cd.zip and directly compile that without patching. It is equivalent to the openttd source package, but has cargodist included.

To check out the release branch, do:

Code: Select all

git clone git://github.com/ulfhermann/openttd.git
git checkout origin/cd
The openttd compile farm creates binaries for various platforms from the "cd" branch every night and stores them at http://bundles.openttdcoop.org/cargodist/. Downloading a bundle from there is probably the fastest way to get started with cargodist. If you experience a crash please go ahead and post a report, including crash.log, crash.sav, crash.png and crash.dmp (if available) in this thread. The same goes for any non-crashing unexpected behavior or anything you think might be a bug. I'll examine and fix the problem as soon as possible. If you like to discuss how to play with cargodist and what strategies to apply and so on, please do that in this thread: http://www.tt-forums.net/viewtopic.php?f=29&t=58091

My plan for further development is (in no particular order):
  • Support more order modifications like "unload all" and "transfer" in the routing algorithm rather than just routing like they don't exist.
  • Make the time a thread gets for calculating the linkgraph dependent on the relevant settings and the size of the linkgraph to be calculated. Right now the time reserved for the link graph calculation is based on a worst case scenario and thus very long. This is the direct cause of the long delay between changes in the game and reactions in the routing scheme.
  • Convince people to publicly play network games and show to the devs that Cargodist really is stable and ready for trunk inclusion (or fix any bugs showing up in that process).
Attachments
overlay.png
link graph overlays over main viewport and smallmap
overlay.png (80.04 KiB) Viewed 49341 times
station-gui.png
Station GUI with routing information
station-gui.png (55.02 KiB) Viewed 49341 times
Last edited by fonso on 08 Apr 2013 15:53, edited 80 times in total.
The guy on the picture is not me, it's Alonso.

audigex
Tycoon
Tycoon
Posts: 1919
Joined: 09 Dec 2007 21:28
Contact:

Re: Link Capacities

Post by audigex » 24 Feb 2009 03:40

This sounds very nice, better than the approximate estimation of traffic we have to rely on now.

1) If the station has passengers piling up, it needs more trains
2) If trains are consistantly partially empty, you can remove trains.

It takes so long to check 2) that most routes end up with too many trains, and any shared track ends up with so many trains on it that half the game is spent upgrading it.

Assuming you get this finished, it could be a massive time saver :)
Jon

User avatar
fonso
President
President
Posts: 945
Joined: 13 Oct 2007 08:28

Re: Link Capacities

Post by fonso » 24 Feb 2009 09:16

The timesaving when estimating which routes are over- and underloaded is already feasible. The only problem is that you can't decipher the numbers in the smallmap for short links. If someone comes up with an idea how to solve that and if that's easy to do I'll implement it. For now I'll stick to saving and configuration.

OK, I'll come up with an idea myself: The overall capacity of a link could be represented by the width of a line and the usage ratio by its color. Then you don't need the numbers anymore. I'll try to implement it.
The guy on the picture is not me, it's Alonso.

User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4552
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: Link Capacities

Post by Zuu » 24 Feb 2009 23:40

An idea that pops out of my head is to draw the higher level network not only in the minimap but as a overlay in the main viewport. That way there is more space for more details. Though the overview that might be as important is lost then. And would probably require quite some initial coding time to get that started.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)

User avatar
fonso
President
President
Posts: 945
Joined: 13 Oct 2007 08:28

Re: Link Capacities and Connected Components

Post by fonso » 03 Mar 2009 10:16

updated. See first post.
The guy on the picture is not me, it's Alonso.

User avatar
fonso
President
President
Posts: 945
Joined: 13 Oct 2007 08:28

Re: Cargo Distribution

Post by fonso » 13 Mar 2009 22:38

updated again. See first post. But if no one is interested I will stop updating and only tell you when it's done ...
The guy on the picture is not me, it's Alonso.

User avatar
SirXavius
Transport Coordinator
Transport Coordinator
Posts: 302
Joined: 28 Jun 2006 18:25
Location: Florida

Re: Cargo Distribution

Post by SirXavius » 14 Mar 2009 00:27

No no, don't do that! If you keep us aware of how things are coming along, then we're comforted in a small way that you're still working on it. As a Cargodest fan, i'm interested in your work. But like most of us, i'm more interested in its implementation and what it means to gameplay. This is why we want to know how it's going.

Remember, a lot more folks are interested in your work than those who will actually place a comment in this thread.... Our deep-down dream is that you don't give up, especially because you don't think anyone cares about what you're doing! :wink:

User avatar
fonso
President
President
Posts: 945
Joined: 13 Oct 2007 08:28

Re: Cargo Distribution

Post by fonso » 16 Mar 2009 19:02

So, I found a new toy called git. It allows me to easily create and maintain hierarchical patches on top of each other. So I can give you the link capacities which are fairly useful on their own as standalone version, which is still being maintained while I work on other parts of cargo distribution. As patches to be applied on top of that you get first connected components and then demands. Others will follow. While I did all that I also cleaned up the code so that it conforms to OpenTTD coding standards (or at least tries to). Due to the 3 file limit I'll post only the capacities patch and an all-in-one patch with all of cargo distribution in the first post.
Attachments
capacities_r15743.diff
(28.34 KiB) Downloaded 707 times
linkgraph_r15743.diff
(16.41 KiB) Downloaded 497 times
demands_r15743.diff
(6.93 KiB) Downloaded 499 times
The guy on the picture is not me, it's Alonso.

audigex
Tycoon
Tycoon
Posts: 1919
Joined: 09 Dec 2007 21:28
Contact:

Re: Cargo Distribution

Post by audigex » 17 Mar 2009 02:05

This looks very good, especially compared to what you had when I first posted.

Any chance of a binary? Visual Studio is having a disagreement with my laptop :-(
Jon

User avatar
fonso
President
President
Posts: 945
Joined: 13 Oct 2007 08:28

Re: Cargo Distribution

Post by fonso » 17 Mar 2009 10:29

audigex wrote:This looks very good, especially compared to what you had when I first posted.

Any chance of a binary? Visual Studio is having a disagreement with my laptop :-(
Not from me. I don't use Windows. But of course anyone is free to build a Windows binary. And if you tell me the exact problem you are having I might be able to find out if it's related to my code and fix it if that's the case.
The guy on the picture is not me, it's Alonso.

User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4552
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: Cargo Distribution

Post by Zuu » 19 Mar 2009 14:39

I tried to use your combined diff from the first post. However examinating the patch I found out that SVN tortoise would probably not understand it, so i used patch.exe from cygwin. From reading the patch I figured -p0 is the correct way to apply it but that fails:

Code: Select all

G:\Programming\OpenTTD\Trunk>patch -p0 < cargodist_r15743.diff
patching file source.list
Assertion failed: hunk, file ../patch-2.5.9-src/patch.c, line 354

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
-p1 gives:

Code: Select all

G:\Programming\OpenTTD\Trunk>patch -p 1 < cargodist_r15743.diff
missing header for unified diff at line 5 of patch
can't find file to patch at input line 5
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git source.list source.list
|index 6f34894..0080d24 100644
|--- source.list
|+++ source.list
--------------------------
File to patch:
I type source.list and <enter>

But then I get

Code: Select all

patching file source.list
missing header for unified diff at line 21 of patch
can't find file to patch at input line 21
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|,7 @@ heightmap.cpp
| highscore.cpp
| ini.cpp
| landscape.cpp
|+linkgraph.cpp
| map.cpp
| md5.cpp
| minilzo.cpp
--------------------------
File to patch:
Which seams to correspond to part of the changes to source.list.

I also tried google for patch.exe and downloaded it directly from GnuForWindows, but that just gave the same errors. (not surprisingly as it is the same version)



I don't know if it is anything you can do about it really, just wanted to inform that I tried to do something but it failed.

Edit: I have "updated" to version r15743 using SVN, which is the revision in the patch file name.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)

jmurrayufo
Engineer
Engineer
Posts: 22
Joined: 24 May 2008 23:06

Re: Cargo Distribution

Post by jmurrayufo » 19 Mar 2009 14:50

Very cool project. I'll have to try compiling it this weekend. Any chance we can see a few pictures of the map overlays?

User avatar
fonso
President
President
Posts: 945
Joined: 13 Oct 2007 08:28

Re: Cargo Distribution

Post by fonso » 19 Mar 2009 15:43

Zuu wrote:I tried to use your combined diff from the first post. However examinating the patch I found out that SVN tortoise would probably not understand it, so i used patch.exe from cygwin. From reading the patch I figured -p0 is the correct way to apply it but that fails:

Code: Select all

G:\Programming\OpenTTD\Trunk>patch -p0 < cargodist_r15743.diff
patching file source.list
Assertion failed: hunk, file ../patch-2.5.9-src/patch.c, line 354

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
...
-p0 should be correct. The problem is that git produces diffs with some special lines the windows patch.exe doesn't understand. I'll try to create a Windows-friendly patch by manually running diff between two different trees later when I prepare today's update. And I'll give you a screenshot ...
The guy on the picture is not me, it's Alonso.

DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Re: Cargo Distribution

Post by DaleStan » 19 Mar 2009 21:52

fonso wrote:I'll try to create a Windows-friendly patch by ...
I'd try removing the "index" and "new file" lines.

And Zuu, what's the output of patch -v or patch --version?
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser

User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4552
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: Cargo Distribution

Post by Zuu » 19 Mar 2009 22:10

DaleStan wrote:And Zuu, what's the output of patch -v or patch --version?
patch 2.5.9

And then the copyright notice.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)

DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Re: Cargo Distribution

Post by DaleStan » 20 Mar 2009 00:15

Very much not the answer I was expecting. My patch(1) ("patch 2.5.8", from Cygwin) can apply the patch just fine. Are you sure that the line endings in the diff and the source match?
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser

User avatar
fonso
President
President
Posts: 945
Joined: 13 Oct 2007 08:28

Re: Cargo Distribution

Post by fonso » 20 Mar 2009 01:04

So here are the three patches up-to-date with configurable demands functions per cargo class and with an antisymmetric demand function. I removed all the index and /dev/null entries. Please tell me if that helps.
Attachments
capacities_r15774.diff
(28.15 KiB) Downloaded 578 times
linkgraph_r15774.diff
(16.59 KiB) Downloaded 460 times
demands_r15774.diff
(18.76 KiB) Downloaded 447 times
The guy on the picture is not me, it's Alonso.

User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4552
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: Cargo Distribution

Post by Zuu » 20 Mar 2009 07:35

DaleStan wrote:Very much not the answer I was expecting. My patch(1) ("patch 2.5.8", from Cygwin) can apply the patch just fine. Are you sure that the line endings in the diff and the source match?
About line endings, most likely not. As SVN tortoise convert the line endings if I recall correctly. Meaning that I need to convert the patch file too. As reading your post I guess the patch tool do not handle differences in line ending characters between source and patch file. (or at least not without applying some flag for that)

Thanks for pointing out that DaleStan.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)

audigex
Tycoon
Tycoon
Posts: 1919
Joined: 09 Dec 2007 21:28
Contact:

Re: Cargo Distribution

Post by audigex » 22 Mar 2009 22:59

fonso wrote:
audigex wrote:This looks very good, especially compared to what you had when I first posted.

Any chance of a binary? Visual Studio is having a disagreement with my laptop :-(
Not from me. I don't use Windows. But of course anyone is free to build a Windows binary. And if you tell me the exact problem you are having I might be able to find out if it's related to my code and fix it if that's the case.
Thanks for the offer, but it's nothing to do with your code :-) I can't even make it compile trunk and I'm at a complete loss as to why not. I need to try a different compiler when I get the time.
Jon

User avatar
fonso
President
President
Posts: 945
Joined: 13 Oct 2007 08:28

Re: Link Capacities and Cargo Distribution

Post by fonso » 25 Mar 2009 00:55

I have updated the first post and the patches. I'm using git's patch format again as no one could say if the other one is better. You get the all-in-one patch in this post.
Attachments
cargodist_r15839.diff
all-in-one patch
(61.22 KiB) Downloaded 697 times
The guy on the picture is not me, it's Alonso.

Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 4 guests