engine: revert some changes
This commit is contained in:
parent
d9c5992d45
commit
3ffddb1638
1 changed files with 16 additions and 7 deletions
23
engine.py
23
engine.py
|
|
@ -6,6 +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
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
@ -17,8 +18,8 @@ BRANDS: dict[str, str] = {
|
||||||
|
|
||||||
CACHE_FOLDER = Path(".cache")
|
CACHE_FOLDER = Path(".cache")
|
||||||
|
|
||||||
LOCS_COUNT = 4
|
LOCS_COUNT = 5
|
||||||
DISTS_COUNT = 10
|
DISTS_COUNT = 5
|
||||||
|
|
||||||
FORMAT_FACTOR = 1e6 # μm
|
FORMAT_FACTOR = 1e6 # μm
|
||||||
FIRST_SEP = ':'
|
FIRST_SEP = ':'
|
||||||
|
|
@ -138,14 +139,15 @@ def trilaterate(stations: list[StationT], disp: bool = False) -> tuple[float, fl
|
||||||
|
|
||||||
res = scipy.optimize.minimize(
|
res = scipy.optimize.minimize(
|
||||||
lambda pos: trilat_error(stations, pos),
|
lambda pos: trilat_error(stations, pos),
|
||||||
stations[0][0],
|
# stations[0][0],
|
||||||
|
(0.0, 0.0),
|
||||||
method='Nelder-Mead',
|
method='Nelder-Mead',
|
||||||
)
|
)
|
||||||
|
|
||||||
if res.success:
|
if not res.success:
|
||||||
return res.x
|
print("WARNING: Optimisation failed.")
|
||||||
else:
|
|
||||||
raise ValueError("Optimisation failed.")
|
return res.x
|
||||||
|
|
||||||
|
|
||||||
def encode_greggs(loc: int) -> list[float]:
|
def encode_greggs(loc: int) -> list[float]:
|
||||||
|
|
@ -182,6 +184,13 @@ def encode(location: tuple[float, float]) -> EncodedLocation:
|
||||||
|
|
||||||
return [(v, encode_greggs(i)) for v, i in zip(closest.values, closest.index)]
|
return [(v, encode_greggs(i)) for v, i in zip(closest.values, closest.index)]
|
||||||
|
|
||||||
|
# distances = spherical_dist(repeated, greggs)
|
||||||
|
# distances_i = [(i, dist) for i, dist in enumerate(distances)]
|
||||||
|
# random.shuffle(distances_i)
|
||||||
|
# closest = distances_i[:LOCS_COUNT]
|
||||||
|
|
||||||
|
# return [(v, encode_greggs(i)) for i, v in closest]
|
||||||
|
|
||||||
|
|
||||||
def decode(location: EncodedLocation, disp: bool = False) -> tuple[float, float]:
|
def decode(location: EncodedLocation, disp: bool = False) -> tuple[float, float]:
|
||||||
"""Decode into a location."""
|
"""Decode into a location."""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue