engine: trilat improvements
This commit is contained in:
parent
913b558ebf
commit
2edce7c73a
1 changed files with 19 additions and 11 deletions
30
engine.py
30
engine.py
|
|
@ -6,7 +6,7 @@ import overpy
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import scipy
|
import scipy
|
||||||
# import random
|
import random
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
@ -19,7 +19,7 @@ BRANDS: dict[str, str] = {
|
||||||
CACHE_FOLDER = Path(".cache")
|
CACHE_FOLDER = Path(".cache")
|
||||||
|
|
||||||
LOCS_COUNT = 5
|
LOCS_COUNT = 5
|
||||||
DISTS_COUNT = 5
|
DISTS_COUNT = 2
|
||||||
|
|
||||||
FORMAT_FACTOR = 1e6 # μm
|
FORMAT_FACTOR = 1e6 # μm
|
||||||
FIRST_SEP = ':'
|
FIRST_SEP = ':'
|
||||||
|
|
@ -137,17 +137,25 @@ def trilaterate(stations: list[StationT], disp: bool = False) -> tuple[float, fl
|
||||||
Each station is of the format ((lat, lon), distance).
|
Each station is of the format ((lat, lon), distance).
|
||||||
"""
|
"""
|
||||||
|
|
||||||
res = scipy.optimize.minimize(
|
best_err = None
|
||||||
lambda pos: trilat_error(stations, pos),
|
best = (0., 0.)
|
||||||
# stations[0][0],
|
|
||||||
(0.0, 0.0),
|
|
||||||
method='Nelder-Mead',
|
|
||||||
)
|
|
||||||
|
|
||||||
if not res.success:
|
for pos, _ in stations:
|
||||||
print("WARNING: Optimisation failed.")
|
res = scipy.optimize.minimize(
|
||||||
|
lambda pos: trilat_error(stations, pos),
|
||||||
|
# stations[0][0],
|
||||||
|
pos,
|
||||||
|
method='Nelder-Mead',
|
||||||
|
)
|
||||||
|
|
||||||
return res.x
|
if not res.success:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if best_err is None or res.fun < best_err:
|
||||||
|
best = res.x
|
||||||
|
best_err = res.fun
|
||||||
|
|
||||||
|
return best
|
||||||
|
|
||||||
|
|
||||||
def encode_greggs(loc: int) -> list[float]:
|
def encode_greggs(loc: int) -> list[float]:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue