engine: revert some changes

This commit is contained in:
Oliver Gaskell 2025-11-02 13:50:25 +00:00
parent d9c5992d45
commit 3ffddb1638
No known key found for this signature in database
GPG key ID: F971A08925FCC0AD

View file

@ -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:
return res.x
else:
raise ValueError("Optimisation failed.")
if not res.success:
print("WARNING: Optimisation failed.")
return res.x
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."""