In-Development TradeDangerous: power-user trade optimizer

I'll give this a go to see what happens but what concerns me is that the initial command I used is one that I have used many times before and this is the first time that it has failed to complete.

Ergo, something has changed. The possibilities are that my PC has changed or the database has changed or the analysis code has changed, or a combination of them all. Now I don't think that the code has changed, I'm still using the bgol version but the database schema has changed and so has my PC. I've installed Sourcetree to download the commits, for example.

But, I doubt that the database changes will have caused the problem since I know that Eyeonus has been using the new structure with TD.

So, I'm not sure what is going on here.

What may have changes is now your database has many, many more up-to-date options, no?
 
Not sure. I haven't made any changes to the 'run' code. Let me see what happens when I run your command on my machine.

('python trade.py run --fr="Orang/Bessel Gateway" --cap=720 --cr=11b --ly=24.73 --empty=37.61 --pad=L --hops=2 --jum=3 --max-days-old=2 --loop --summary -vv --progress')

EDIT: Added '-www > run_log.txt'. Looks like it's getting hung up trying to find a hop from "Cemiess/Meech Dock".

Whenever I force quit it, I get something along these lines output:
Code:
>python trade.py run --fr="Orang/Bessel Gateway" --cap=720 --cr=11b --ly=24.73 --empty=37.61 --pad=L --hops=2 --jum=3 --max-days-old=2 --loop --summary -vv --progress -www > run_log.txt
Traceback (most recent call last):
  File "trade.py", line 104, in <module>
    main(sys.argv)
  File "trade.py", line 77, in main
    results = cmdenv.run(tdb)
  File "S:\Elite Dangerous Programs\Trade Dangerous\commands\commandenv.py", line 81, in run
    return self._cmd.run(results, self, tdb)
  File "S:\Elite Dangerous Programs\Trade Dangerous\commands\run_cmd.py", line 1220, in run
    newRoutes = calc.getBestHops(routes, restrictTo=restrictTo)
  File "S:\Elite Dangerous Programs\Trade Dangerous\tradecalc.py", line 909, in getBestHops
    trade = fitFunction(items, startCr, capacity, maxUnits)
  File "S:\Elite Dangerous Programs\Trade Dangerous\tradecalc.py", line 700, in fastFit
    return _fitCombos(0, credits, capacity)
  File "S:\Elite Dangerous Programs\Trade Dangerous\tradecalc.py", line 676, in _fitCombos
    subLoad = _fitCombos(iNo+1, crLeft, capLeft)
  File "S:\Elite Dangerous Programs\Trade Dangerous\tradecalc.py", line 676, in _fitCombos
    subLoad = _fitCombos(iNo+1, crLeft, capLeft)
  File "S:\Elite Dangerous Programs\Trade Dangerous\tradecalc.py", line 676, in _fitCombos
    subLoad = _fitCombos(iNo+1, crLeft, capLeft)
  File "S:\Elite Dangerous Programs\Trade Dangerous\tradecalc.py", line 676, in _fitCombos
    subLoad = _fitCombos(iNo+1, crLeft, capLeft)
  File "S:\Elite Dangerous Programs\Trade Dangerous\tradecalc.py", line 676, in _fitCombos
    subLoad = _fitCombos(iNo+1, crLeft, capLeft)
  File "S:\Elite Dangerous Programs\Trade Dangerous\tradecalc.py", line 676, in _fitCombos
    subLoad = _fitCombos(iNo+1, crLeft, capLeft)
  File "S:\Elite Dangerous Programs\Trade Dangerous\tradecalc.py", line 676, in _fitCombos
    subLoad = _fitCombos(iNo+1, crLeft, capLeft)
  File "S:\Elite Dangerous Programs\Trade Dangerous\tradecalc.py", line 676, in _fitCombos
    subLoad = _fitCombos(iNo+1, crLeft, capLeft)
  File "S:\Elite Dangerous Programs\Trade Dangerous\tradecalc.py", line 676, in _fitCombos
    subLoad = _fitCombos(iNo+1, crLeft, capLeft)
  File "S:\Elite Dangerous Programs\Trade Dangerous\tradecalc.py", line 676, in _fitCombos
    subLoad = _fitCombos(iNo+1, crLeft, capLeft)
  File "S:\Elite Dangerous Programs\Trade Dangerous\tradecalc.py", line 676, in _fitCombos
    subLoad = _fitCombos(iNo+1, crLeft, capLeft)
  File "S:\Elite Dangerous Programs\Trade Dangerous\tradecalc.py", line 635, in _fitCombos
    qtyCeil = min(maxUnits, cap)
KeyboardInterrupt
Whatever station it's checking at the time, it's having trouble filling your hold. Each one of those "subLoad = ..." calls means that whatever cargo it found, that station doesn't have enough of it to fill your capacity, so it's looking to see what to buy next.

The log_run.txt is, unfortunately, not much help. It's obviously getting hung up somewhere, but the log doesn't really indicate where.

I think what you need to do is, instead of pruning, add a minimum required amount of items required. You have a 720 tonne cargo hold. I doubt you want to be carrying less than 20 or so of a single item.

On that note, I added some code to print the name of the station it's currently looking at, and it's been looking at "HIP 112113/Nomen Vision" for about 3 minutes now. So that's probably the station that's freezing the run.

Here's a video showing two runs using your settings, both freezing at the same point, and a third run with the same settings but with '--supply=20' added:
https://youtu.be/GyT0XE6TYXQ

Interesting. I ran it (with my score adjustment) and it completed as not-profitable. I was running the listener as of 15 minutes ago, so I'm up-to-date.


Code:
[B]F:\Elite\TD>'python trade.py run --fr="Orang/Bessel Gateway" --cap=720 --cr=11b --ly=24.73 --empty=37.61 --pad=L --hops=2 --jum=3 --max-days-old=2 --loop --summary -vv --progress'
''python' is not recognized as an internal or external command,
operable program or batch file.

F:\Elite\TD>python trade.py run --fr="Orang/Bessel Gateway" --cap=720 --cr=11b --ly=24.73 --empty=37.61 --pad=L --hops=2 --jum=3 --max-days-old=2 --loop --summary -vv --progress
* Hop   1: .........1 origins
* Hop   2: .......454 origins .. 15,120-958,365cr gain, 21-3,015cr/ton
trade.py: Error: No profitable trades matched your critera, or price data along the route is missing.

Possible causes:
- No profitable runs or routes meet your criteria,
- Missing Systems or Stations along the route (see "local -vv"),
- Missing price data (see "market -vv" or "update -h"),

If you are not sure where to get data from, consider using a crowd-sourcing
project such as "maddavo's" (http://www.davek.com.au/td/).

For more help, see the TradeDangerous Wiki:
    http://kfs.org/td/wiki[/B]

Hmmmm.

That, together with your exit error showing looking for combos, may indicate that you're looking for worst case scenario since there are no profitable runs. Just a thought.
 
Last edited:
Interesting. I ran it (with my score adjustment) and it completed as not-profitable. I was running the listener as of 15 minutes ago, so I'm up-to-date.


Code:
[B]F:\Elite\TD>'python trade.py run --fr="Orang/Bessel Gateway" --cap=720 --cr=11b --ly=24.73 --empty=37.61 --pad=L --hops=2 --jum=3 --max-days-old=2 --loop --summary -vv --progress'
''python' is not recognized as an internal or external command,
operable program or batch file.

F:\Elite\TD>python trade.py run --fr="Orang/Bessel Gateway" --cap=720 --cr=11b --ly=24.73 --empty=37.61 --pad=L --hops=2 --jum=3 --max-days-old=2 --loop --summary -vv --progress
* Hop   1: .........1 origins
* Hop   2: .......454 origins .. 15,120-958,365cr gain, 21-3,015cr/ton
trade.py: Error: No profitable trades matched your critera, or price data along the route is missing.

Possible causes:
- No profitable runs or routes meet your criteria,
- Missing Systems or Stations along the route (see "local -vv"),
- Missing price data (see "market -vv" or "update -h"),

If you are not sure where to get data from, consider using a crowd-sourcing
project such as "maddavo's" (http://www.davek.com.au/td/).

For more help, see the TradeDangerous Wiki:
    http://kfs.org/td/wiki[/B]

Hmmmm.

That, together with your exit error showing looking for combos, may indicate that you're looking for worst case scenario since there are no profitable runs. Just a thought.

That is a glaring indictment against using your code changes. The code as is found a run with an estimated 2.968 million credit gain once I added the supply condition. Your code found nothing.
 
Last edited:
Weird.

I'm getting that answer with both the old AND the new tradecalc (pre/post PR).

I'm going to have to run an eddblink -O clean to see if I just have a corrupted database.
 
Clean Install:
Code:
F:\Elite\TD>trade import -P eddblink -O clean
NOTE: Rebuilding cache file: this may take a few moments.
NOTE: Missing "F:\Elite\TD\data\TradeDangerous.prices" file - no price data.
NOTE: Processing Upgrades: Start time = 2018-06-17 19:18:43.823913
NOTE: Finished processing Upgrades. End time = 2018-06-17 19:18:43.831891
NOTE: Downloading file: 'index.json'.
NOTE: Requesting https://raw.githubusercontent.com/EDCD/coriolis-data/master/dist/index.json
NOTE: Downloaded   0.7MB of gziped data  10.7MB/s
NOTE: Processing Ships: Start time = 2018-06-17 19:18:44.102674
NOTE: Finished processing Ships. End time = 2018-06-17 19:18:44.109655
NOTE: Processing Systems: Start time = 2018-06-17 19:18:44.586381
NOTE: Finished processing Systems. End time = 2018-06-17 19:18:45.944769
NOTE: Processing Stations, this may take a bit: Start time = 2018-06-17 19:18:46.418503
NOTE: Simultaneously processing ShipVendors.
NOTE: Simultaneously processing UpgradeVendors, this will take quite a while.
NOTE: Finished processing Stations. End time = 2018-06-17 19:24:34.191248
NOTE: Processing Categories and Items: Start time = 2018-06-17 19:24:34.671469
NOTE: Finished processing Categories and Items. End time = 2018-06-17 19:24:34.676455
NOTE: F:\Elite\TD\data\Category.csv exported.
NOTE: F:\Elite\TD\data\Item.csv exported.
NOTE: F:\Elite\TD\data\Ship.csv exported.
NOTE: F:\Elite\TD\data\ShipVendor.csv exported.
NOTE: F:\Elite\TD\data\Station.csv exported.
NOTE: F:\Elite\TD\data\System.csv exported.
NOTE: F:\Elite\TD\data\Upgrade.csv exported.
NOTE: F:\Elite\TD\data\UpgradeVendor.csv exported.
NOTE: Processing market data from listings.csv: Start time = 2018-06-17 19:26:30.331444
NOTE: Finished processing market data. End time = 2018-06-17 19:30:54.363104
NOTE: Downloading file: 'listings-live.csv'.
NOTE: Requesting http://elite.ripz.org/files/listings-live.csv
NOTE: Downloaded  13.8MB of gziped data   4.9MB/s
NOTE: Processing market data from listings-live.csv: Start time = 2018-06-17 19:30:57.938089
NOTE: Finished processing market data. End time = 2018-06-17 19:31:41.047833
NOTE: Regenerating .prices file.
NOTE: Import completed.

F:\Elite\TD>

Old penalty function:

Code:
F:\Elite\TD>python trade.py run --fr="Orang/Bessel Gateway" --cap=720 --cr=11b --ly=24.73 --empty=37.61 --pad=L --hops=2 --jum=3 --max-days-old=2 --loop --summary -vv --progress --supply=20
* Hop   1: .........1 origins
* Hop   2: .......454 origins .. 15,120-958,365cr gain, 21-3,015cr/ton
Orang/Bessel Gateway -> Orang/Bessel Gateway (score: 967495.838400)

  Load from Orang/Bessel Gateway (89ls, BMk:N, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y):
      645 x Chemicals/Mineral Oil          197cr vs    1,279cr, 6 hrs vs 7 hrs
       75 x Slavery/Imperial Slaves     14,325cr vs   17,798cr, 6 hrs vs 7 hrs
    Expect to gain 958,365cr (1,331.06cr/ton)

  Load from HR 6565/Naubakht Station (280ls, BMk:N, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y):
      720 x Medicines/Basic Medicines      430cr vs    1,786cr, 7 hrs vs 6 hrs
    Expect to gain 976,320cr (1,356cr/ton)
  ----------------------------------------------------------------------------
Finish at Orang/Bessel Gateway (89ls, BMk:N, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y) gaining 1,934,685cr (1,343cr/ton) => est 11,001,934,685cr total

New Penalty function
Code:
F:\Elite\TD>python trade.py run --fr="Orang/Bessel Gateway" --cap=720 --cr=11b --ly=24.73 --empty=37.61 --pad=L --hops=2 --jum=3 --max-days-old=2 --loop --summary -vv --progress --supply=20
* Hop   1: .........1 origins
* Hop   2: .......454 origins .. 15,120-958,365cr gain, 21-3,015cr/ton
Orang/Bessel Gateway -> Orang/Bessel Gateway (score: 51862864.959120)

  Load from Orang/Bessel Gateway (89ls, BMk:N, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y):
      645 x Chemicals/Mineral Oil          197cr vs    1,279cr, 6 hrs vs 4 hrs
       75 x Slavery/Imperial Slaves     14,325cr vs   17,655cr, 6 hrs vs 4 hrs
    Expect to gain 947,640cr (1,316.17cr/ton)

  Load from Eravapa/Bohr Orbital (37ls, BMk:N, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y):
      720 x Medicines/Basic Medicines      524cr vs    1,786cr, 4 hrs vs 6 hrs
    Expect to gain 908,640cr (1,262cr/ton)
  ----------------------------------------------------------------------------
Finish at Orang/Bessel Gateway (89ls, BMk:N, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y) gaining 1,856,280cr (1,289cr/ton) => est 11,001,856,280cr total

Now without the "supply" addition:

OLD
Code:
F:\Elite\TD>python trade.py run --fr="Orang/Bessel Gateway" --cap=720 --cr=11b --ly=24.73 --empty=37.61 --pad=L --hops=2 --jum=3 --max-days-old=2 --loop --summary -vv --progress
* Hop   1: .........1 origins
* Hop   2: .......454 origins .. 15,120-958,365cr gain, 21-3,015cr/ton
Orang/Bessel Gateway -> Orang/Bessel Gateway (score: 967495.838400)

  Load from Orang/Bessel Gateway (89ls, BMk:N, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y):
      645 x Chemicals/Mineral Oil          197cr vs    1,279cr, 6 hrs vs 7 hrs
       75 x Slavery/Imperial Slaves     14,325cr vs   17,798cr, 6 hrs vs 7 hrs
    Expect to gain 958,365cr (1,331.06cr/ton)

  Load from HR 6565/Naubakht Station (280ls, BMk:N, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y):
      720 x Medicines/Basic Medicines      430cr vs    1,786cr, 7 hrs vs 6 hrs
    Expect to gain 976,320cr (1,356cr/ton)
  ----------------------------------------------------------------------------
Finish at Orang/Bessel Gateway (89ls, BMk:N, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y) gaining 1,934,685cr (1,343cr/ton) => est 11,001,934,685cr total

NEW
Code:
F:\Elite\TD>python trade.py run --fr="Orang/Bessel Gateway" --cap=720 --cr=11b --ly=24.73 --empty=37.61 --pad=L --hops=2 --jum=3 --max-days-old=2 --loop --summary -vv --progress
* Hop   1: .........1 origins
* Hop   2: .......454 origins .. 15,120-958,365cr gain, 21-3,015cr/ton
Orang/Bessel Gateway -> Orang/Bessel Gateway (score: 51862864.959120)

  Load from Orang/Bessel Gateway (89ls, BMk:N, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y):
      645 x Chemicals/Mineral Oil          197cr vs    1,279cr, 6 hrs vs 4 hrs
       75 x Slavery/Imperial Slaves     14,325cr vs   17,655cr, 6 hrs vs 4 hrs
    Expect to gain 947,640cr (1,316.17cr/ton)

  Load from Eravapa/Bohr Orbital (37ls, BMk:N, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y):
      720 x Medicines/Basic Medicines      524cr vs    1,786cr, 4 hrs vs 6 hrs
    Expect to gain 908,640cr (1,262cr/ton)
  ----------------------------------------------------------------------------
Finish at Orang/Bessel Gateway (89ls, BMk:N, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y) gaining 1,856,280cr (1,289cr/ton) => est 11,001,856,280cr total

This makes sense in that the new penalty function prioritzes the 37ls distance from Eravapa/Bohr Orbital over the 280ls distance from HR 6565/Naubakht Station even with the default penalty of 0.5%. To check, when passing --lsp 0 for both, both should return the same path since any changes are ignored.

OLD
Code:
F:\Elite\TD>python trade.py run --fr="Orang/Bessel Gateway" --cap=720 --cr=11b --ly=24.73 --empty=37.61 --pad=L --hops=2 --jum=3 --max-days-old=2 --loop --summary -vv --progress --lsp 0
* Hop   1: .........1 origins
* Hop   2: .......453 origins .. 15,120-958,365cr gain, 21-3,015cr/ton
Orang/Bessel Gateway -> Orang/Bessel Gateway (score: 967342.500000)

  Load from Orang/Bessel Gateway (89ls, BMk:N, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y):
      645 x Chemicals/Mineral Oil          197cr vs    1,279cr, 6 hrs vs 7 hrs
       75 x Slavery/Imperial Slaves     14,325cr vs   17,798cr, 6 hrs vs 7 hrs
    Expect to gain 958,365cr (1,331.06cr/ton)

  Load from HR 6565/Naubakht Station (280ls, BMk:N, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y):
      720 x Medicines/Basic Medicines      430cr vs    1,786cr, 7 hrs vs 6 hrs
    Expect to gain 976,320cr (1,356cr/ton)
  ----------------------------------------------------------------------------
Finish at Orang/Bessel Gateway (89ls, BMk:N, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y) gaining 1,934,685cr (1,343cr/ton) => est 11,001,934,685cr total

NEW
Code:
F:\Elite\TD>python trade.py run --fr="Orang/Bessel Gateway" --cap=720 --cr=11b --ly=24.73 --empty=37.61 --pad=L --hops=2 --jum=3 --max-days-old=2 --loop --summary -vv --progress --lsp 0
* Hop   1: .........1 origins
* Hop   2: .......452 origins .. 15,120-958,365cr gain, 21-3,015cr/ton
Orang/Bessel Gateway -> Orang/Bessel Gateway (score: 967342.500000)

  Load from Orang/Bessel Gateway (89ls, BMk:N, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y):
      645 x Chemicals/Mineral Oil          197cr vs    1,279cr, 7 hrs vs 7 hrs
       75 x Slavery/Imperial Slaves     14,325cr vs   17,798cr, 7 hrs vs 7 hrs
    Expect to gain 958,365cr (1,331.06cr/ton)

  Load from HR 6565/Naubakht Station (280ls, BMk:N, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y):
      720 x Medicines/Basic Medicines      430cr vs    1,786cr, 7 hrs vs 7 hrs
    Expect to gain 976,320cr (1,356cr/ton)
  ----------------------------------------------------------------------------
Finish at Orang/Bessel Gateway (89ls, BMk:N, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y) gaining 1,934,685cr (1,343cr/ton) => est 11,001,934,685cr total

Which it does.

This indicates that the errors Mark, I, and Tromador were seeing were based on our respective databases not being updated. Probably pays to run a "clean" evey now and then.

To be continued…
 
Last edited:
As an aside, it may be that the reason why the revised penalty prioritized the 38ls over the 280ls, is that both are in the "bonus" and the bonus for 0.037 vs. 0.28 is larger under the revised penalty than the old penalty.

Bonus/Distance
0.038
0.280
Old
1.000071
1.000403
New
26.49766
3.544255

Which, mind you, is counter-intuitive in the old case, as closer distances should be prioritized. Then again, having a hyperbolic equation between 0 and 1 in the new case may give too much weight to closeness in the new case. This should be discussed, I reckon.
 
Under the assumption something was wrong in the server db, we ran a clean run on it. Little to no data was lost. I advise everyone to do a clean run to purge whatever faulty data is in the db from your client.
 
Last edited:
The graph below exposes the problem with the current scoring. The colors reflect a small selection of penalties (0.006 being the default). The straight lines are the old method, the dotted is my new one (after I killed the hyperbolic bonus and limited it to 1.5; thanks @eyeonus and @tromador). Note how quickly, depending on the lsp(which ranges from 0.01 to 10 in Kls), the penalty goes below 0. Now the worse things get, the more negative they become. In a situation where all the options are "in the penalty", I'm afraid things get wonky. If the multiplier asymptotically approaches 0, we stay strictly non-negative and sidestep the negative issues. The second graph is the same, but ranges from 1Kls to 100Kls. At this point, even the default 0.006 is negative. Example in next post.
HqoxBDE.png


HqoBB0u.png
 
Last edited:
This is the call that got me started on this path. Compare under the old scoring:
Code:
F:\Elite\TD>trade.py run -vvv --progress --summary --avoid imperial,slaves --insurance 1.51m --pad L --ly 15.06 --cap 264 --no-planet --credits 24m --from "tollan/gord" --to "LHS 2094/Patt" --hops 3
* Hop   1: .........1 origins
NOTE: Pruned 22 origins too far from any end stations
* Hop   2: ........63 origins .. 33,528-382,536cr gain, 127-1,449cr/ton
NOTE: Pruned 435 origins too far from any end stations
* Hop   3: ........17 origins .. 73,392-778,536cr gain, 139-1,474cr/ton
Tollan/Gordon Plant -> LHS 2094/Patterson Vision (score: 346042.656960)
Start CR: 22,490,000
Hops    :          3
Jumps   :          5
Gain CR :    356,136
Gain/Hop:    118,712
Final CR: 22,846,136


  Load from Tollan/Gordon Plant (529ls, BMk:Y, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y):
      264 x Machinery/Water Purifiers      380cr vs      648cr, 9 hrs vs 5 days, total:    100,320cr
    Expect to gain 70,752cr (268cr/ton)

  Load from Rho Cancri/Hamilton Reserve (2.60Kls, BMk:N, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y):
      264 x Metals/Gold                  9,860cr vs   10,930cr, 5 days vs 4 hrs, total:  2,603,040cr
    Expect to gain 282,480cr (1,070cr/ton)

  Load from LFT 601/Cunningham Terminal (2.79Kls, BMk:N, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y):
      264 x Waste/Biowaste                  31cr vs       42cr, 4 hrs vs 9 days, total:      8,184cr
    Expect to gain 2,904cr (11cr/ton)
  ----------------------------------------------------------------------------
Finish at LHS 2094/Patterson Vision (35Kls, BMk:Y, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y) gaining 356,136cr (449cr/ton) => est 24,356,136cr total


F:\Elite\TD>trade.py run -vvv --progress --summary --avoid imperial,slaves --insurance 1.51m --pad L --ly 15.06 --cap 264 --no-planet --credits 24m --from "tollan/gord" --to "LHS 2094/Patt" --hops 3 --prune-score 50
* Hop   1: .........1 origins
NOTE: Pruned 22 origins too far from any end stations
* Hop   2: ........63 origins .. 33,528-382,536cr gain, 127-1,449cr/ton
NOTE: Pruned 435 origins too far from any end stations
NOTE: Pruned 8 origins
* Hop   3: .........9 origins .. 448,536-778,536cr gain, 849-1,474cr/ton
Tollan/Gordon Plant -> LHS 2094/Patterson Vision (score: -29384.355360)
Start CR: 22,490,000
Hops    :          3
Jumps   :          6
Gain CR :    794,876
Gain/Hop:    264,959
Final CR: 23,284,876


  Load from Tollan/Gordon Plant (529ls, BMk:Y, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y):
      264 x Metals/Gold                         9,676cr vs   10,768cr, 9 hrs vs 15 hrs, total:  2,554,464cr
    Expect to gain 288,288cr (1,092cr/ton)

  Load from BD+41 1865/Cori City (10ls, BMk:N, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y):
      264 x Technology/Resonating Separators    5,494cr vs    6,101cr, 15 hrs vs 4 days, total:  1,450,416cr
    Expect to gain 160,248cr (607cr/ton)

  Load from LTT 12449/Rennie Prospect (151ls, BMk:N, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y):
      229 x Metals/Gold                         8,741cr vs   10,011cr, 4 days vs 9 days, total:  2,001,689cr
       35 x Metals/Palladium                   12,326cr vs   13,912cr, 4 days vs 9 days, total:    431,410cr
    Expect to gain 346,340cr (1,311.89cr/ton)
  ----------------------------------------------------------------------------
Finish at LHS 2094/Patterson Vision (35Kls, BMk:Y, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y) gaining 794,876cr (1,003cr/ton) => est 24,794,876cr total

The pruned score should not be higher than the unpruned, if the unpruned sees it all, right? The pruned score is negative; that already tells us something. Now, look what happens when the distance penalty is turned off:
Code:
F:\Elite\TD>trade.py run -vvv --progress --summary --avoid imperial,slaves --insurance 1.51m --pad L --ly 15.06 --cap 264 --no-planet --credits 24m --from "tollan/gord" --to "LHS 2094/Patt" --hops 3 --lsp 0
* Hop   1: .........1 origins
NOTE: Pruned 22 origins too far from any end stations
* Hop   2: ........63 origins .. 33,528-382,536cr gain, 127-1,449cr/ton
NOTE: Pruned 435 origins too far from any end stations
* Hop   3: ........17 origins .. 73,392-785,400cr gain, 139-1,487cr/ton
Tollan/Gordon Plant -> LHS 2094/Patterson Vision (score: 794876.000000)
Start CR: 22,490,000
Hops    :          3
Jumps   :          6
Gain CR :    794,876
Gain/Hop:    264,959
Final CR: 23,284,876


  Load from Tollan/Gordon Plant (529ls, BMk:Y, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y):
      264 x Metals/Gold                         9,676cr vs   10,768cr, 9 hrs vs 15 hrs, total:  2,554,464cr
    Expect to gain 288,288cr (1,092cr/ton)

  Load from BD+41 1865/Cori City (10ls, BMk:N, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y):
      264 x Technology/Resonating Separators    5,494cr vs    6,101cr, 15 hrs vs 4 days, total:  1,450,416cr
    Expect to gain 160,248cr (607cr/ton)

  Load from LTT 12449/Rennie Prospect (151ls, BMk:N, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y):
      229 x Metals/Gold                         8,741cr vs   10,011cr, 4 days vs 9 days, total:  2,001,689cr
       35 x Metals/Palladium                   12,326cr vs   13,912cr, 4 days vs 9 days, total:    431,410cr
    Expect to gain 346,340cr (1,311.89cr/ton)
  ----------------------------------------------------------------------------
Finish at LHS 2094/Patterson Vision (35Kls, BMk:Y, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y) gaining 794,876cr (1,003cr/ton) => est 24,794,876cr total
It's the same as the pruned. What I believe is happening is that the last hop to Patterson Vision, which is 35Kls, returns a solid negative for the score, and then everything breaks loose, as TD is now trying to find the longest (or at least longer) routes. Since the multiplier is negative, TD cannot tell the difference between a HIGH score and a LOW negative multiplier or a LOW score and a HIGH negative multiplier. Somehow, early pruning prevents that, but it's wrong. Using the new scoring algorithm, normalcy returns:
Code:
F:\Elite\TD>trade.py run -vvv --progress --summary --avoid imperial,slaves --insurance 1.51m --pad L --ly 15.06 --cap 264 --no-planet --credits 24m --from "tollan/gord" --to "LHS 2094/Patt" --hops 3
* Hop   1: .........1 origins
NOTE: Pruned 22 origins too far from any end stations
* Hop   2: ........63 origins .. 33,528-382,536cr gain, 127-1,449cr/ton
NOTE: Pruned 435 origins too far from any end stations
* Hop   3: ........17 origins .. 73,392-685,872cr gain, 139-1,299cr/ton
Tollan/Gordon Plant -> LHS 2094/Patterson Vision (score: 725809.815733)
Start CR: 22,490,000
Hops     :          3
Jumps    :          6
Gain CR :    794,876
Gain/Hop:    264,959
Final CR: 23,284,876


        Load from Tollan/Gordon Plant (529ls, BMk:Y, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y):
           264 x Metals/Gold                         9,676cr vs   10,768cr, 9 hrs vs 15 hrs, total:  2,554,464cr
           Expect to gain 288,288cr (1,092cr/ton)

        Load from BD+41 1865/Cori City (10ls, BMk:N, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y):
           264 x Technology/Resonating Separators    5,494cr vs    6,101cr, 15 hrs vs 4 days, total:  1,450,416cr
           Expect to gain 160,248cr (607cr/ton)

        Load from LTT 12449/Rennie Prospect (151ls, BMk:N, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y):
           229 x Metals/Gold                         8,741cr vs   10,011cr, 4 days vs 9 days, total:  2,001,689cr
            35 x Metals/Palladium                   12,326cr vs   13,912cr, 4 days vs 9 days, total:    431,410cr
           Expect to gain 346,340cr (1,311.89cr/ton)
        ----------------------------------------------------------------------------
Finish at LHS 2094/Patterson Vision (35Kls, BMk:Y, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y) gaining 794,876cr (1,003cr/ton) => est 24,794,876cr total

Here is another example:
Code:
F:\Elite\TD>trade.py run -vvv --progress --summary --avoid imperial,slaves --insurance 1.51m --pad L --ly 15.06 --cap 264 --from "MAWU/Dirac" --to "LHS 2094/Patt" --credits 25m
* Hop   1: .........1 origins
NOTE: Pruned 81 origins too far from any end stations
* Hop   2: .........6 origins .. 5,808-97,152cr gain, 22-368cr/ton
Mawu/Dirac Barracks -> LHS 2094/Patterson Vision (score: -64659.978240)
Start CR: 23,490,000
Hops    :          2
Jumps   :          4
Gain CR :     56,496
Gain/Hop:     28,248
Final CR: 23,546,496


  Load from Mawu/Dirac Barracks (2.28Kls, BMk:N, Pad:L, Plt:Y, Shp:N, Out:Y, Ref:Y):
      264 x Waste/Scrap       55cr vs       77cr, 54 days vs 56 days, total:     14,520cr
    Expect to gain 5,808cr (22cr/ton)

  Load from BD+27 1739/Jolliet Point (7.29Kls, BMk:Y, Pad:L, Plt:Y, Shp:N, Out:Y, Ref:Y):
      264 x Waste/Scrap       93cr vs      285cr, 56 days vs 9 days, total:     24,552cr
    Expect to gain 50,688cr (192cr/ton)
  ----------------------------------------------------------------------------
Finish at LHS 2094/Patterson Vision (35Kls, BMk:Y, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y) gaining 56,496cr (107cr/ton) => est 25,056,496cr total


F:\Elite\TD>trade.py run -vvv --progress --summary --avoid imperial,slaves --insurance 1.51m --pad L --ly 15.06 --cap 264 --from "MAWU/Dirac" --to "LHS 2094/Patt" --credits 25m --no-planet
* Hop   1: .........1 origins
NOTE: Pruned 58 origins too far from any end stations
* Hop   2: .........5 origins .. 17,424-97,152cr gain, 66-368cr/ton
Mawu/Dirac Barracks -> LHS 2094/Patterson Vision (score: -442335.801600)
Start CR: 23,490,000
Hops    :          2
Jumps   :          4
Gain CR :    375,144
Gain/Hop:    187,572
Final CR: 23,865,144


  Load from Mawu/Dirac Barracks (2.28Kls, BMk:N, Pad:L, Plt:Y, Shp:N, Out:Y, Ref:Y):
      264 x Waste/Scrap                            55cr vs      175cr, 54 days vs 21 hrs, total:     14,520cr
    Expect to gain 31,680cr (120cr/ton)

  Load from BD+27 1739/Dyomin Terminal (1.48Kls, BMk:N, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y):
      264 x Technology/Resonating Separators    5,584cr vs    6,885cr, 21 hrs vs 9 days, total:  1,474,176cr
    Expect to gain 343,464cr (1,301cr/ton)
  ----------------------------------------------------------------------------
Finish at LHS 2094/Patterson Vision (35Kls, BMk:Y, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y) gaining 375,144cr (710cr/ton) => est 25,375,144cr total

Both scores are negative, but the first call, allowing the planet, has a LESS NEGATIVE score (closer to 0) so it is "better" when it clearly isn't better once the planet is removed as an option. The 343K credits one would get from going to Dyomin Terminal, when multiplied by the negative penalty, is further away from 0 than the paltry 50.6K credits from Jolliet Point when it is affected by the 7Kls penalty. So you're travelling farther for less money because TD is confused.

Under the newer algorithm, the scores remain positive, and both calls return the same result, as should be expected.
Code:
F:\Elite\TD>trade.py run -vvv --progress --summary --avoid imperial,slaves --insurance 1.51m --pad L --ly 15.06 --cap 264 --from "MAWU/Dirac" --to "LHS 2094/Patt" --credits 25m
* Hop   1: .........1 origins
NOTE: Pruned 81 origins too far from any end stations
* Hop   2: .........6 origins .. 5,808-97,152cr gain, 22-368cr/ton
Mawu/Dirac Barracks -> LHS 2094/Patterson Vision (score: 84245.656566)
Start CR: 23,490,000
Hops     :          2
Jumps    :          4
Gain CR :    375,144
Gain/Hop:    187,572
Final CR: 23,865,144


        Load from Mawu/Dirac Barracks (2.28Kls, BMk:N, Pad:L, Plt:Y, Shp:N, Out:Y, Ref:Y):
           264 x Waste/Scrap                            55cr vs      175cr, 54 days vs 21 hrs, total:     14,520cr
           Expect to gain 31,680cr (120cr/ton)

        Load from BD+27 1739/Dyomin Terminal (1.48Kls, BMk:N, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y):
           264 x Technology/Resonating Separators    5,584cr vs    6,885cr, 21 hrs vs 9 days, total:  1,474,176cr
           Expect to gain 343,464cr (1,301cr/ton)
        ----------------------------------------------------------------------------
Finish at LHS 2094/Patterson Vision (35Kls, BMk:Y, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y) gaining 375,144cr (710cr/ton) => est 25,375,144cr total


F:\Elite\TD>trade.py run -vvv --progress --summary --avoid imperial,slaves --insurance 1.51m --pad L --ly 15.06 --cap 264 --from "MAWU/Dirac" --to "LHS 2094/Patt" --credits 25m --no-planet
* Hop   1: .........1 origins
NOTE: Pruned 58 origins too far from any end stations
* Hop   2: .........5 origins .. 17,424-97,152cr gain, 66-368cr/ton
Mawu/Dirac Barracks -> LHS 2094/Patterson Vision (score: 84245.656566)
Start CR: 23,490,000
Hops     :          2
Jumps    :          4
Gain CR :    375,144
Gain/Hop:    187,572
Final CR: 23,865,144


        Load from Mawu/Dirac Barracks (2.28Kls, BMk:N, Pad:L, Plt:Y, Shp:N, Out:Y, Ref:Y):
           264 x Waste/Scrap                            55cr vs      175cr, 54 days vs 21 hrs, total:     14,520cr
           Expect to gain 31,680cr (120cr/ton)

        Load from BD+27 1739/Dyomin Terminal (1.48Kls, BMk:N, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y):
           264 x Technology/Resonating Separators    5,584cr vs    6,885cr, 21 hrs vs 9 days, total:  1,474,176cr
           Expect to gain 343,464cr (1,301cr/ton)
        ----------------------------------------------------------------------------
Finish at LHS 2094/Patterson Vision (35Kls, BMk:Y, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y) gaining 375,144cr (710cr/ton) => est 25,375,144cr total
 
Last edited:
The graph below exposes the problem with the current scoring. The colors reflect a small selection of penalties (0.006 being the default). The straight lines are the old method, the dotted is my new one (after I killed the hyperbolic bonus and limited it to 1.5; thanks @eyeonus and @tromador). Note how quickly, depending on the lsp(which ranges from 0.01 to 10 in Kls), the penalty goes below 0. Now the worse things get, the more negative they become. In a situation where all the options are "in the penalty", I'm afraid things get wonky. If the multiplier asymptotically approaches 0, we stay strictly non-negative and sidestep the negative issues. The second graph is the same, but ranges from 1Kls to 100Kls. At this point, even the default 0.006 is negative. Example in next post.

Please spoiler giant things like pictures and logs.
 
Using eyeonus's equation ((1/((x/2)+1))+(1/8-((25(x-1))/(1+abs(25(x-1)))/8))+(1/8-((50(x-4))/(1+abs(50(x-4)))/8)) where x is Kls - see black curve here: https://goo.gl/uQKT5d) the test cases respond correctly:
Code:
F:\Elite\TD>trade.py run -vvv --progress --summary --avoid imperial,slaves --insurance 1.51m --pad L --ly 15.06 --cap 264 --from "MAWU/Dirac" --to "LHS 2094/Patt" --credits 25m
* Hop   1: .........1 origins
NOTE: Pruned 81 origins too far from any end stations
* Hop   2: .........6 origins .. 5,808-97,152cr gain, 22-368cr/ton
Mawu/Dirac Barracks -> LHS 2094/Patterson Vision (score: 44658.943350)
Start CR: 23,490,000
Hops    :          2
Jumps   :          4
Gain CR :    375,144
Gain/Hop:    187,572
Final CR: 23,865,144


  Load from Mawu/Dirac Barracks (2.28Kls, BMk:N, Pad:L, Plt:Y, Shp:N, Out:Y, Ref:Y):
      264 x Waste/Scrap                            55cr vs      175cr, 55 days vs 34 hrs, total:     14,520cr
    Expect to gain 31,680cr (120cr/ton)

  Load from BD+27 1739/Dyomin Terminal (1.48Kls, BMk:N, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y):
      264 x Technology/Resonating Separators    5,584cr vs    6,885cr, 34 hrs vs 10 days, total:  1,474,176cr
    Expect to gain 343,464cr (1,301cr/ton)
  ----------------------------------------------------------------------------
Finish at LHS 2094/Patterson Vision (35Kls, BMk:Y, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y) gaining 375,144cr (710cr/ton) => est 25,375,144cr total


F:\Elite\TD>trade.py run -vvv --progress --summary --avoid imperial,slaves --insurance 1.51m --pad L --ly 15.06 --cap 264 --from "MAWU/Dirac" --to "LHS 2094/Patt" --credits 25m --no-planet
* Hop   1: .........1 origins
NOTE: Pruned 58 origins too far from any end stations
* Hop   2: .........5 origins .. 17,424-97,152cr gain, 66-368cr/ton
Mawu/Dirac Barracks -> LHS 2094/Patterson Vision (score: 44658.943350)
Start CR: 23,490,000
Hops    :          2
Jumps   :          4
Gain CR :    375,144
Gain/Hop:    187,572
Final CR: 23,865,144


  Load from Mawu/Dirac Barracks (2.28Kls, BMk:N, Pad:L, Plt:Y, Shp:N, Out:Y, Ref:Y):
      264 x Waste/Scrap                            55cr vs      175cr, 55 days vs 34 hrs, total:     14,520cr
    Expect to gain 31,680cr (120cr/ton)

  Load from BD+27 1739/Dyomin Terminal (1.48Kls, BMk:N, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y):
      264 x Technology/Resonating Separators    5,584cr vs    6,885cr, 34 hrs vs 10 days, total:  1,474,176cr
    Expect to gain 343,464cr (1,301cr/ton)
  ----------------------------------------------------------------------------
Finish at LHS 2094/Patterson Vision (35Kls, BMk:Y, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y) gaining 375,144cr (710cr/ton) => est 25,375,144cr total


F:\Elite\TD>trade.py run -vvv --progress --summary --avoid imperial,slaves --insurance 1.51m --pad L --ly 15.06 --cap 264 --no-planet --credits 24m --from "tollan/gord" --to "LHS 2094/Patt" --hops 3
* Hop   1: .........1 origins
NOTE: Pruned 22 origins too far from any end stations
* Hop   2: ........63 origins .. 33,528-382,536cr gain, 127-1,449cr/ton
NOTE: Pruned 435 origins too far from any end stations
* Hop   3: ........17 origins .. 73,392-685,872cr gain, 139-1,299cr/ton
Tollan/Gordon Plant -> LHS 2094/Patterson Vision (score: 670365.380044)
Start CR: 22,490,000
Hops    :          3
Jumps   :          6
Gain CR :    794,876
Gain/Hop:    264,959
Final CR: 23,284,876


  Load from Tollan/Gordon Plant (529ls, BMk:Y, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y):
      264 x Metals/Gold                         9,676cr vs   10,768cr, 22 hrs vs 28 hrs, total:  2,554,464cr
    Expect to gain 288,288cr (1,092cr/ton)

  Load from BD+41 1865/Cori City (10ls, BMk:N, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y):
      264 x Technology/Resonating Separators    5,494cr vs    6,101cr, 28 hrs vs 4 days, total:  1,450,416cr
    Expect to gain 160,248cr (607cr/ton)

  Load from LTT 12449/Rennie Prospect (151ls, BMk:N, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y):
      229 x Metals/Gold                         8,741cr vs   10,011cr, 4 days vs 10 days, total:  2,001,689cr
       35 x Metals/Palladium                   12,326cr vs   13,912cr, 4 days vs 10 days, total:    431,410cr
    Expect to gain 346,340cr (1,311.89cr/ton)
  ----------------------------------------------------------------------------
Finish at LHS 2094/Patterson Vision (35Kls, BMk:Y, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y) gaining 794,876cr (1,003cr/ton) => est 24,794,876cr total


F:\Elite\TD>trade.py run -vvv --progress --summary --avoid imperial,slaves --insurance 1.51m --pad L --ly 15.06 --cap 264 --no-planet --credits 24m --from "tollan/gord" --to "LHS 2094/Patt" --hops 3 --prune-score 50
* Hop   1: .........1 origins
NOTE: Pruned 22 origins too far from any end stations
* Hop   2: ........63 origins .. 33,528-382,536cr gain, 127-1,449cr/ton
NOTE: Pruned 435 origins too far from any end stations
NOTE: Pruned 8 origins
* Hop   3: .........9 origins .. 448,536-685,872cr gain, 849-1,299cr/ton
Tollan/Gordon Plant -> LHS 2094/Patterson Vision (score: 670365.380044)
Start CR: 22,490,000
Hops    :          3
Jumps   :          6
Gain CR :    794,876
Gain/Hop:    264,959
Final CR: 23,284,876


  Load from Tollan/Gordon Plant (529ls, BMk:Y, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y):
      264 x Metals/Gold                         9,676cr vs   10,768cr, 22 hrs vs 28 hrs, total:  2,554,464cr
    Expect to gain 288,288cr (1,092cr/ton)

  Load from BD+41 1865/Cori City (10ls, BMk:N, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y):
      264 x Technology/Resonating Separators    5,494cr vs    6,101cr, 28 hrs vs 4 days, total:  1,450,416cr
    Expect to gain 160,248cr (607cr/ton)

  Load from LTT 12449/Rennie Prospect (151ls, BMk:N, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y):
      229 x Metals/Gold                         8,741cr vs   10,011cr, 4 days vs 10 days, total:  2,001,689cr
       35 x Metals/Palladium                   12,326cr vs   13,912cr, 4 days vs 10 days, total:    431,410cr
    Expect to gain 346,340cr (1,311.89cr/ton)
  ----------------------------------------------------------------------------
Finish at LHS 2094/Patterson Vision (35Kls, BMk:Y, Pad:L, Plt:N, Shp:Y, Out:Y, Ref:Y) gaining 794,876cr (1,003cr/ton) => est 24,794,876cr total
Of course the score is different, but that is irrelevant.
Comparison of my scoring to eyeonus's can be seen in the graph below, but I see no reason not to implement his. It does the same thing, which is prevents necessary, but large, distances from going negative and making TD go nuts.
Straight line is eyeonus, dotted is my adjustment. Outside of keeping < 1Kls always a bonusand having "less" of a penalty for smaller distances both "behave" properly. Graph goes from 0.01 to 100Kls (add a digit to the scale and it will be in ls). Colors are the ls-penalties: Black = 0.006, Blue = 0.2, Green = 0.5, Purple = 0.8, and Red = .994


41523609-a6652556-72a8-11e8-8744-b26421e5a8fe.png

See https://github.com/eyeonus/Trade-Dangerous/pull/5 for more discussion
 
On that, I decided to go with a different formula that trends to y=1 (, rather than y=0 as does the formula of mine Avi posted,) at lower penalty values, to more closely match ksfone's intention:

https://goo.gl/sn1PqQ

The red line is at a penalty of 100%, the black at a penalty of 0%, the darker red lines are 25%, 50%, and 75%. The other colors are the three pieces of the final penalty formula which is in teal.

As you can see from the WolframAlpha limit result, the formula never goes below 0.
 
Last edited:
Today I am mostly feeling glad that I have to do the server admin, the documentation and not the mathematics of distance curves.
 
Back
Top Bottom