예제 #1
0
def simulate_n_customers(n):
    '''
    Simulate n customers that start together in the store.
    No new customers are added over time.
    The simulation ends once all are checked out.
    '''
    background = np.zeros((700, 1000, 3), np.uint8)
    market = SupermarketMap(MARKET, TILES)
    supermarket = Supermarket(market=market)
    for _ in range(n):
        supermarket.add_new_customers()
    frame = background.copy()

    while len(supermarket.customers) > 0:
        if supermarket.customers_to_move:
            move_between_minutes(market, supermarket, frame)
        else:
            go_to_next_minute(market, supermarket, frame)
        cv2.imshow("frame", frame)

        key = chr(cv2.waitKey(1) & 0xFF)
        if key == 'q':
            break
    cv2.destroyAllWindows()
    market.write_image("./graphics/supermarket.png")
예제 #2
0
def simulate_n_customers(n):
    '''
  Simulate n customers that start together in the store.
  No new customers are added over time.
  The simulation ends once all are checked out.
  '''
    supermarket = Supermarket()
    for _ in range(n):
        supermarket.add_new_customers()

    while len(supermarket.customers) > 0:
        go_to_next_minute(supermarket)
 def load_data(self):
     df = pd.read_csv('./dataset/Produtos.csv',
                      delimiter=";",
                      encoding='latin-1')
     df.columns = ['Produtos', 'Preços']
     df['Preços'] = df['Preços'].str.replace(',', '.').astype(float)
     self.products = dict(df.values.tolist())
     self.supermarket = Supermarket()
예제 #4
0
def draw_simulate_n_customers(n):
    '''
  Simulate n customers that start together in the store.
  Draw their progression through the market.
  No new customers are added and the simulation stops once they all reached the checkout.
  '''
    market = SupermarketMap(MARKET, TILES)
    supermarket = Supermarket(market)
예제 #5
0
def simulate_normal_day(prob_of_new_customer=0.6):
    '''
  simulate a normal day in the supermarket
  '''
    supermarket = Supermarket()

    # from 7 - 21 in minutes
    closing_time = (21 - 7) * 60

    while supermarket.minutes < closing_time:
        go_to_next_minute(supermarket, prob_of_new_customer)
예제 #6
0
    Then cleans the outstore_customers for the next loop.
    '''
    for cust in customers_out:
        for key in revenue_per_visit:
            rev = (cust.visits[key] * revenue_per_visit[key])
            total_revenue[key] += rev
            total_revenue['total'] += rev

    print(total_revenue)
    global outstore_customers
    customers_out = []


hello_supermarket()
market_img = cv2.imread('./img/market.png')
market = Supermarket(market_img, size)

while True:
    time.sleep(0.1)
    old_count = instore_count
    market.draw(instore_customers)
    outstore_customers = [
        cust for cust in instore_customers if cust.finished == True
    ]
    instore_customers = [
        cust for cust in instore_customers if cust.finished == False
    ]
    instore_count = len(instore_customers)
    for x in range(old_count - instore_count):
        generate_new_customer(instore_count, prob_for_new_customer_list)
        generate_new_customer(instore_count, prob_for_new_customer_list)
예제 #7
0
def main():
    supermarket = Supermarket() # we only need to create one supermarket
    Tnow = 0                    # time arbitrarily starts at 0
    supermarket.manageSupermarket(Tnow)
예제 #8
0
from time import sleep
import cv2

import config
from supermarket import Supermarket

if __name__ == '__main__':
    print('Starting simulation')
    market = Supermarket()
    market.add_customers(config.initial_customer_count)

    while True:
        sleep(0.02)
        market.next_frame()
        cv2.imshow('Supermarket', market.frame)

        if cv2.waitKey(1) & 0xFF == ord('q'):
            print('Ending simulation')
            break

cv2.destroyAllWindows()
예제 #9
0
import sys
from supermarket import Supermarket
from os import path
from cli import get_args
from rich.console import Console
from datetime import timedelta, date
from graph import make_bar_chart
from mydate import ShopDate

# Create a console for rich printing
myconsole = Console()
datefile = path.join('data', 'date.txt')
mydateobj = ShopDate(datefile)
# Create a Supermarkt
mysuper = Supermarket(data_folder='data',
                      bought_file='bought.csv',
                      sold_file='sold.csv',
                      current_date=mydateobj.today)

stl_error = "bold red on white"
stl_reg = "bold green"

args = get_args()

if args.command == "buy":
    try:
        mydate = mydateobj.convert_str_to_datetime(args.expiration_date)
        if mydate <= mysuper.current_date:
            myconsole.print("ERROR: product is already expired",
                            style=stl_error)
            sys.exit()
    except ValueError as e: