2013. december 29., vasárnap

Instead of RoLa :D.

Title of idea (in 2010, maybe i rewrite this...)
2.) A new, more efficient way of intermodal(railway/highway) transportation.

Exploit the benefits of both railway and highway transportation and minimize their drawbacks by optimally mixing the two methods.
Railway transportation between two points is cheaper and more environmentally friendly, than highway transport, however the later has the advantage of higher flexibility.

Below we describe the case of single delivery of goods between two locations, however the method can be generalized to multi point delivery as well.
Suppose that a company having only a single tractor has to deliver N trucks of goods, to a location (B) that is M km away from the starting point (A) on road and after that the tractor has to return to A. Suppose also that the combined distances of nearest railway stations from points A and B is R., while the distance between these stations over the railway is L, and the cost of transporting a truck 1 km on road is F_road, and on railway is F_rail. See explanatory figure 1. It is widely accepted that F_rail <F_road.

If the company would transport the trucks over highway it would mean N turns and 2NMF_road cost.
Alternatively if a railway service would exist which would involve special long carriages that could fit in a truck, than the company could subscribe to this service and the tractor may deliver the trucks one after another to the nearest railway station at A’, load the railway carriages one by one, and then the tractor is put on the train as well (together with the last truck). Once the train arrives to the station nearest to B than the tractor again delivers the N trucks one by one to point B. In this case there will be N-1 turns both at A and at B, thus altogether 2N, and the overall cost is (2N-1)RF_road+LNF_rail+MF_road. As can be seen the mixed way of transportation is less costly if
(2N-1)RF_road+LNF_rail+MF_road) < 2NMF_road, or
(2N-1)RF_road+LNF_rail<(2N-1)MF_road,
R<M-LNF_rail/(2N-1)F_road.
To get a weaker but simpler condition we can assume that N>>1, and if F_rail is overestimated by assuming it to be the same as F_road, then the mixed transportation will be more cost efficient if
R<M-L/2.
The above condition can be easily probed e.g. over electronic maps of the internet for any specific A and B location of interest.
For this service to work buffer areas have to be developed at the railway stations where the trucks could be accumulated until the loading of the train. Also the special railway carriages needs to be developed (see schematic figure 1 below), where the tractor can load the truck on the carriage (with reverse motion from the side of the carriage), and which would have means to be locked e.g with a code key (the service provider would supply the code) . Finally some IT background needs to be in place for the booking of the buffer area, obtaining accurate time table information and for the ordering of the service, (the same conditions that are at place for the already existing types of intermodal transportation).

The above described case of point to point delivery can be extended to multi point scenario as well, similar to the distribution of goods of large supermarket chains from a central warehouse.
The main difference between the described idea and the already existing types of intermodal transportation like RoLa (http://en.wikipedia.org/wiki/Rolling_highway) is that in our case only a single tractor is involved in the transportation. Instead of the high dead weight of many tractors on the train it involves only a single tractor for many trucks, and also the loading of carriages is more simple than in the case of RoLa, and in length the two methods are comparable.

The above described way of transportation could be beneficial for logistics companies, (even small ones), and also for railway companies, because of the profit coming from this service. Apart from the commercial advantage of the involved parties, general public would also benefit by the smaller environmental impact and smaller load on the highways.


2013. december 16., hétfő

Csapófa algoritmus

Szeretek kitalálni dolgokat.....
(Tegnapelőtt láttam az egyik kedvenc ötletemet kivitelezve.... A Cargónak dolgoztam néhány éve és egyik reggel autóval befelé menet hallgattam egy riportot a mentősökről, tűzoltókról, mozdonyvezetőkről, ütközésekről. Különösen az ütött szöget a fejembe hogy a galád "késsen el mindenki ma, mert úgy döntöttem hogy megküzdök a mozdonnyal" versenyző még integetett is a mozdonyvezetőnek, aki persze nem tudott megállni... Nosza, szereljünk légzsákot a mozdonyra. Az egyik mozdonyvezető meg is  ütközött ezen? Minek légzsák? Ja? Kívülre? Na szóval másoknak is járt ezen az agya és kísérletképpen szereltek is fel egyet, igaz ők autóval ütköztették.....) 
Ritkán adódik meg az hogy  nem csak a magam szórakoztatására ötlök ki valamit, hanem parancsszóra kell ezt megtenni.

Amikor másodjára a MÁV-hoz kerültem (még a múlt évezredben, 1995-ben vala ez), rögtön belecsöppentem egy érdekes, igaz félig külsős projektbe. Ma már nincsen olyan megkötés amivel akkor szembe kellett néznünk, de két számlán kellett keresztül menjen szinte minden utalás, mivel az önelszámoló egységek külön könyveltek, a tetejébe eléggé sztochasztikusan voltak elosztva a bankok az egységek között. 

Itt csinálj te egyszerűen cash pool technikát :). 

Adva volt a feladat, hogy az utalásokat úgy kell csoportosítani, hogy a sorrendiség maradjon, de úgy történjenek meg a kifizetések, hogy lehetőleg ne legyen az ellátmány adásnál bankközi átutalás.

Te vagy a matematikus, ez a te dolgod :D.
Szimplex algoritmus, Gomory módszer, tanultam én ezt, ráhúzzuk a feladatra és kész.
No de nem tudtam ráhúzni. Egyre többet gondolkoztam a dolgon, egyre kevéssé éreztem hogy haladnék előre. "Idő telik, becsület fogy", édesapám kedvenc mondása, és ebben az esetben ez sajna erősen aktuális volt... 
Volt persze más dolgom is, a rendszerrel kapcsolatosan egyébként is, a napi munka is, meg iskolába is jártam épp, no meg a Autóklubos programmal is törődni kellett... De egyre több erőforrást allokáltam erre a feladatra, lassan olyan voltam mint egy alvajáró. Remélem nem motyogtam :).

Ami ebből érdekes, az az amikor a tudatalattim "átadta" az eredményt. Liftben mentem felfelé a BEIG-ben amikor is beugrott. Egyszerűen tudtam hogy megvan a megoldás, és jó is. Azt az eufórikus érzést kívánom hogy próbálja ki mindenki :D. 
Persze azért miközben leprogramoztam, néha elkapott a kétely, amivel Csabit a sírba kergettem. Időnként felkiáltottam hogy nem jó az egész, majd néhány perc múlva azt hogy de, mégiscsak.... 
Elmagyarázni akkor még végképp nem tudtam, pedig roppant egyszerű az egész.

A probléma ugye az volt, hogy meghatározott sorrendben kellett kielégíteni az igényeket amelyek feljöttek a központba - ez is érdekes egyébként, mert nem nagyon csináltak addig olyat az országban amit mi míveltünk, kettős privát kulcsos auth, és egyéb nyalánkságok, arról nem is beszélve hogy 3 pénzügyi rendszert szolgáltunk ki úgy hogy nem állt egy napot se az egész 10 év alatt, ami nem kis szó - és úgy elosztani őket hogy lehetőleg a telephelyek saját bankszámláin keresztül "folyjon' a pénz.

Az ötlet a következő volt:
  • Először nézzük meg hogy mennyi pénz van összesen.
  • Aztán első körben addig menjünk sorrendben a tételeken, ameddig el nem érjük, illetve meghaladjuk ezt az összeget, és mindegyik számlához "írjuk" hozzá ezt, ahol ösvény van. Ez lesz majd a "csapófa".
  • A második körben ugyanezt tesszük, csak ekkor az összes ösvényhez tartozó lehetőséget levonjuk, és kiválasztjuk azt az egyet, ahol a csapófa a legközelebb van a kupac tetejéhez.
Később persze nem értettem hogy ezen miért gondolkodtam annyi ideig :D.

Ábrákban vázolva (az akkori banknevekkel ;-), de nem volt odaírva mind egyébként se....):

Az első menet már lefutott, ennek hatását a színes téglalapok elhelyezkedéséből láthatjuk. Az éppen utalható pénz nagyságát a lila négyzetek mutatják.


 Az osztható pénz a DAEWOO banknál csökkent ( a fehér téglalap).


 A szürke téglalapok az ideutalt - osztható pénz nagyságát mutatják.



 A választás mindíg a kisebb szám alapján történik.







 Egyenlőség esetén az osztható pénz nagysága dönt.



 Ez érvényes a pénz elfogyása esetén is ( a nullánál minden nagyobb...).



 A zöld és világoskék téglalapokkal jelölt utalások az MHB-n keresztül mennek el, egy tétel kimarad.



Ennyi :D.
A nüanszokra  nem térek ki nyilván, az messze vezetne, például alkalmazható ez a módszer dinamikusan is, gubancot okoz ha nagyok az eltérések az összegek között, etcetera, etcetera...
Hátha valakit inspirál ez, szerintem nem csak erre a feladatra jó, pláne hogy az eredeti feladat már nem is létezik. Integrált rendszernél nem érdekes a telepi utalás például.....