2022-04-16 14:55:25 +02:00
|
|
|
import random
|
2022-04-16 15:55:43 +02:00
|
|
|
|
2022-04-16 14:55:25 +02:00
|
|
|
from data.Item import Item
|
|
|
|
from data.ItemType import ItemType
|
|
|
|
from data.Order import Order
|
|
|
|
|
|
|
|
|
2022-04-16 15:55:43 +02:00
|
|
|
class InitialStateFactory:
|
2022-04-16 14:55:25 +02:00
|
|
|
|
2022-04-16 15:55:43 +02:00
|
|
|
@staticmethod
|
2022-04-16 14:55:25 +02:00
|
|
|
def generate_order_list(self, output_order_list_size: int):
|
|
|
|
order_list = [Order]
|
|
|
|
for i in range(0, output_order_list_size):
|
2022-04-16 15:55:43 +02:00
|
|
|
order_list.append(self.__generate_order())
|
2022-04-16 14:55:25 +02:00
|
|
|
|
|
|
|
return order_list
|
|
|
|
|
2022-04-16 15:55:43 +02:00
|
|
|
@staticmethod
|
|
|
|
def __generate_order(self) -> Order:
|
2022-04-16 14:55:25 +02:00
|
|
|
order_size = random.randint(1, 4)
|
|
|
|
|
|
|
|
items = [Item]
|
|
|
|
for i in range(order_size):
|
|
|
|
items.append(self.generate_item())
|
|
|
|
|
|
|
|
time_base = random.randint(8, 20)
|
|
|
|
final_time = time_base * order_size
|
|
|
|
|
|
|
|
value = sum(i.price for i in items)
|
|
|
|
|
|
|
|
return Order(final_time, items, value)
|
|
|
|
|
2022-04-16 15:55:43 +02:00
|
|
|
@staticmethod
|
2022-04-16 14:55:25 +02:00
|
|
|
def generate_input_sequence(self, input_sequence_size):
|
|
|
|
sequence = [Item]
|
|
|
|
for i in range(0, input_sequence_size):
|
2022-04-16 15:55:43 +02:00
|
|
|
sequence.append(self.__generate_item())
|
2022-04-16 14:55:25 +02:00
|
|
|
|
|
|
|
return sequence
|
|
|
|
|
|
|
|
@staticmethod
|
2022-04-16 15:55:43 +02:00
|
|
|
def __generate_item() -> Item:
|
2022-04-16 14:55:25 +02:00
|
|
|
randomly_picked_type = random.choice(list(ItemType))
|
|
|
|
return Item(randomly_picked_type)
|