engine: revert some changes
This commit is contained in:
parent
d9c5992d45
commit
3ffddb1638
1 changed files with 16 additions and 7 deletions
21
engine.py
21
engine.py
|
|
@ -6,6 +6,7 @@ import overpy
|
|||
import numpy as np
|
||||
import pandas as pd
|
||||
import scipy
|
||||
# import random
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
|
|
@ -17,8 +18,8 @@ BRANDS: dict[str, str] = {
|
|||
|
||||
CACHE_FOLDER = Path(".cache")
|
||||
|
||||
LOCS_COUNT = 4
|
||||
DISTS_COUNT = 10
|
||||
LOCS_COUNT = 5
|
||||
DISTS_COUNT = 5
|
||||
|
||||
FORMAT_FACTOR = 1e6 # μm
|
||||
FIRST_SEP = ':'
|
||||
|
|
@ -138,14 +139,15 @@ def trilaterate(stations: list[StationT], disp: bool = False) -> tuple[float, fl
|
|||
|
||||
res = scipy.optimize.minimize(
|
||||
lambda pos: trilat_error(stations, pos),
|
||||
stations[0][0],
|
||||
# stations[0][0],
|
||||
(0.0, 0.0),
|
||||
method='Nelder-Mead',
|
||||
)
|
||||
|
||||
if res.success:
|
||||
if not res.success:
|
||||
print("WARNING: Optimisation failed.")
|
||||
|
||||
return res.x
|
||||
else:
|
||||
raise ValueError("Optimisation failed.")
|
||||
|
||||
|
||||
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)]
|
||||
|
||||
# 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]:
|
||||
"""Decode into a location."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue