85 lines
2.4 KiB
Python
85 lines
2.4 KiB
Python
import random
|
|
|
|
from data.Item import Item
|
|
from data.Order import Order
|
|
from data.enum.ItemType import ItemType
|
|
from data.enum.Priority import Priority
|
|
from util.ClientParamsFactory import ClientParamsFactory
|
|
|
|
|
|
class InitialStateFactory:
|
|
|
|
@staticmethod
|
|
def generate_item_list(output_list_size: int):
|
|
item_list : [Item] = []
|
|
for i in range(output_list_size):
|
|
item_list.append(InitialStateFactory.__generate_item())
|
|
|
|
return item_list
|
|
|
|
@staticmethod
|
|
def generate_order_list(output_order_list_size: int):
|
|
order_list: [Order] = []
|
|
for i in range(output_order_list_size):
|
|
order_list.append(InitialStateFactory.__generate_order())
|
|
|
|
return order_list
|
|
|
|
@staticmethod
|
|
def generate_order_list_XD(output_order_list_size: int):
|
|
order_list: [Order] = []
|
|
for i in range(output_order_list_size):
|
|
order_list.append(InitialStateFactory.__generate_order_XD())
|
|
|
|
return order_list
|
|
|
|
@staticmethod
|
|
def __generate_order_XD() -> Order:
|
|
order_size = random.randint(1, 4)
|
|
|
|
items: [Item] = []
|
|
for i in range(order_size):
|
|
items.append(InitialStateFactory.__generate_item())
|
|
|
|
time_base = random.randint(8, 20)
|
|
final_time = time_base * order_size
|
|
|
|
client_params = ClientParamsFactory.get_client_params()
|
|
|
|
x = random.randint(0, 2)
|
|
type = Priority.LOW
|
|
if x == 0:
|
|
type = Priority.MEDIUM
|
|
elif x == 2:
|
|
type = Priority.HIGH
|
|
|
|
return Order(final_time, items, type, client_params)
|
|
|
|
@staticmethod
|
|
def __generate_order() -> Order:
|
|
order_size = random.randint(1, 4)
|
|
|
|
items: [Item] = []
|
|
for i in range(order_size):
|
|
items.append(InitialStateFactory.__generate_item())
|
|
|
|
time_base = random.randint(8, 20)
|
|
final_time = time_base * order_size
|
|
|
|
client_params = ClientParamsFactory.get_client_params()
|
|
|
|
return Order(final_time, items, None, client_params)
|
|
|
|
@staticmethod
|
|
def generate_input_sequence(self, input_sequence_size):
|
|
sequence : [Item] = []
|
|
for i in range(0, input_sequence_size):
|
|
sequence.append(self.__generate_item())
|
|
|
|
return sequence
|
|
|
|
@staticmethod
|
|
def __generate_item() -> Item:
|
|
randomly_picked_type = random.choice(list(ItemType))
|
|
return Item(randomly_picked_type)
|