Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
94e39af
commit f023d02
Showing
2 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from __future__ import annotations | ||
from datetime import datetime | ||
import os | ||
|
||
class Flight: | ||
origin = None | ||
destination = None | ||
departure = None | ||
arrival = None | ||
price = None | ||
|
||
def __init__(self, | ||
origin: str = None, | ||
destination: str = None, | ||
departure: datetime.time = None, | ||
arrival: datetime.time = None, | ||
price: float = None): | ||
self.origin = origin | ||
self.destination = destination | ||
self.departure = departure | ||
self.arrival = arrival | ||
self.price = price | ||
|
||
|
||
def load_flights(flights_path) -> list[Flight]: | ||
flights = [] | ||
for line in open(flights_path, 'r'): | ||
split = line.split(",") | ||
flights.append(Flight( | ||
split[0], | ||
split[1], | ||
datetime.strptime(split[2], "%H:%M"), | ||
datetime.strptime(split[3], "%H:%M"), | ||
float(split[4]) | ||
)) | ||
return flights | ||
|
||
if __name__ == '__main__': | ||
pass | ||
#print(load_flights(os.getcwd()+'/data/flights.txt')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from abc import ABC, ABCMeta, abstractmethod | ||
import random | ||
import math | ||
|
||
|
||
class FlightAlgorithm(metaclass=ABCMeta): | ||
def __init__(self, domain, fitness_function, seed=random.randint(10, 100), | ||
set_all_generators=False, init=[]): | ||
self.domain = domain | ||
self.fitness_function = fitness_function | ||
self.seed = seed | ||
self.init = init | ||
self.init_seed(set_all_generators) | ||
|
||
self.start_time = 0.0 # Loop starting time | ||
|
||
def init_seed(self, set_all_generators=False): | ||
self.r_init = random.Random(self.seed) | ||
|
||
if set_all_generators: | ||
random.seed(self.seed) | ||
|
||
@abstractmethod | ||
def get_base(self) -> str: | ||
pass | ||
|
||
@abstractmethod | ||
def get_name(self) -> str: | ||
pass | ||
|
||
@abstractmethod | ||
def run(self, **kwargs) -> tuple: | ||
pass |