Comments (6)
That's odd, because that should always result in a number between 0 and -0.5.
Hmmm. Maybe it's the "x^(x/4)' bit that's overflowing?
I'll look into it.
from trade-dangerous.
So, I did this:
try:
penalty = (-1 + 1 / (cruiseKls + 1) ** ((cruiseKls + 1) / 4)) / 2
except OverflowError as e:
print(str(e) + "cKls: " + str(cruiseKls))
and got this:
[ ] (34, 'Result too large')cKls: 4218.0
[== ] (34, 'Result too large')cKls: 4218.0
[==== ] (34, 'Result too large')cKls: 4218.0
[============= ] (34, 'Result too large')cKls: 4218.0
[=========================] (34, 'Result too large')cKls: 514.4
First of all, what damned system has a station 4.2 MILLION ls away from the entry point?
Secondly, now I need to decide which of two options to use, those being:
- Use "sys.float_info.max" instead of "(cruiseKls + 1) ** ((cruiseKls + 1) / 4)" when an overflow occurs.
- Use the decimal module to do this math, which doesn't overflow until 9E+999999999999999999.
(Which might still overflow if any stations are far enough away, but in that case I can easily get away with assuming "1/(cruiseKls + 1) ** ((cruiseKls + 1) / 4)" == 0.)
Thoughts?
from trade-dangerous.
4.2m ls, pshaw, that's nothing. Hutton Orbital in Proxima Centaurii is 6,784,404 ls! Over a 40 minute trip (I've yet to do it).
Converting the penalty into logs would look like:
penalty = (1 / exp(0.25 * (cruiseKls + 1) * log(cruiseKls + 1)) - 1) * 0.5
However, in this case, using logs doesn't really help, since log(Max(Double) is a hair over 709.78 and Hutton orbital would require exp(0.25 * 6201 * log(6201))
which becomes exp(13537.51) which overflows like mad. Actually, you have a form of Lambert W function here since you have a*Xe^X
whew a is 0.25 and X is cruiseKls + 1. The largest Lambert W able to be calculated using double precision is a bit over 703.22. So, I'm not at home so I cannot try it, but perhaps the following will work:
cappeddist = min(0.25 * (cruiseKls + 1) * log(cruiseKls + 1), 709.78)
penalty = (1/exp(cappeddist) - 1) * 0.5
This should work and return the -0.5 for large numbers like Hutton Orbital without overflowing, If you haven't tried it by tonight, I will. Thanks!
from trade-dangerous.
Changed cap to 709.78 since we're not actually calculating Lambert W_0 but the exponentiation of capped dist. Not tghat it really matters, that's all going to be -0.5 anyway, we just need to make sure Python doesn't see a number it doesn't like.
if you wanted to use try, you'd probably want:
try:
penalty = (-1 + 1 / (cruiseKls + 1) ** ((cruiseKls + 1) / 4)) / 2
except OverflowError:
penalty = -0.5
Which is faster, try:except or the min?
from trade-dangerous.
Your math is off.
(-1 + 1 / (x + 1) ** ((x + 1) / 4)) / 2 != (1 / exp(0.25 * (x + 1) * log(x + 1)) - 1) * 0.5
from trade-dangerous.
My math is correct when you take into account that the FooPlot website has an ln
operator so log
is base 10, where R and Python both assume log
to be natural :)
from trade-dangerous.
Related Issues (20)
- EDDB certificate issue? HOT 1
- Unknown Space listed as a System in trade route jump HOT 5
- Signalling of Live vs Legacy in EDMarketConnector data export HOT 5
- Will not run on fresh install of Python 3.11.1 HOT 1
- Minor Bug in rare case that files end up on two different drives HOT 5
- remove deprecated escape sequences HOT 1
- github actions needs some updates HOT 4
- Window closes after running HOT 1
- EDDB will soon cease operations HOT 121
- Windows Docker solution HOT 1
- GUI missing credits option for trade HOT 2
- Wrong encoding of database record
- How do I get Odyssey data? HOT 1
- trade run - legal/illegal only goods HOT 3
- ModuleNotFoundError: No module named MFD HOT 4
- Bug with olddata HOT 1
- SQL errors on first launch HOT 5
- coriolis index.json is 404 nowadays HOT 4
- "No module named 'mfd'" error in x52pro.py + fix HOT 1
- No current data anymore HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from trade-dangerous.