added dataclass
Some checks failed
Test code / Test code (push) Failing after 3s
Build and release APK / Build APK (pull_request) Has been cancelled
Build web / Build Web (pull_request) Has been cancelled
Test code / Test code (pull_request) Has been cancelled

This commit is contained in:
Kilian Scheidecker 2024-05-23 10:39:14 +02:00
parent 70cebc0aa1
commit d8d425a922
2 changed files with 17 additions and 16 deletions

View File

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

View File

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