UI elements using the new structs #8

Merged
remoll merged 37 commits from feature/unify-api-frontend into main 2024-06-23 19:21:50 +00:00
2 changed files with 17 additions and 16 deletions
Showing only changes of commit d8d425a922 - Show all commits

View File

@ -1,5 +1,5 @@
from src.optimizer import solve_optimization
from src.optimizer import landmark
from src.optimizer import Landmark
from fastapi import FastAPI
app = FastAPI()
@ -12,18 +12,18 @@ def main(max_steps: int, print_details: bool):
#max_steps = 16
# Initialize all landmarks (+ start and goal). Order matters here
landmarks = []
landmarks.append(landmark("départ", -1, (0, 0)))
landmarks.append(landmark("tour eiffel", 99, (0,2))) # PUT IN JSON
landmarks.append(landmark("arc de triomphe", 99, (0,4)))
landmarks.append(landmark("louvre", 99, (0,6)))
landmarks.append(landmark("montmartre", 99, (0,10)))
landmarks.append(landmark("concorde", 99, (0,8)))
landmarks.append(landmark("arrivée", -1, (0, 0)))
# Initialize all Landmarks (+ start and goal). Order matters here
Landmarks = []
Landmarks.append(Landmark("départ", -1, (0, 0)))
Landmarks.append(Landmark("tour eiffel", 99, (0,2))) # PUT IN JSON
Landmarks.append(Landmark("arc de triomphe", 99, (0,4)))
Landmarks.append(Landmark("louvre", 99, (0,6)))
Landmarks.append(Landmark("montmartre", 99, (0,10)))
Landmarks.append(Landmark("concorde", 99, (0,8)))
Landmarks.append(Landmark("arrivée", -1, (0, 0)))
visiting_order = solve_optimization(landmarks, max_steps, print_details)
visiting_order = solve_optimization(Landmarks, max_steps, print_details)
#return visiting_order

View File

@ -1,14 +1,15 @@
from scipy.optimize import linprog
import numpy as np
from scipy.linalg import block_diag
from dataclasses import dataclass
# Defines the landmark class (aka some place there is to visit)
class landmark :
def __init__(self, name: str, attractiveness: int, loc: tuple):
self.name = name
self.attractiveness = attractiveness
self.loc = loc
@dataclass
class Landmark :
name : str
attractiveness : int
loc : tuple
# Convert the solution of the optimization into the list of edges to follow. Order is taken into account
def untangle(resx: list) :