예제 #1
0
from Seller import Seller
from FloorBoss import FloorBoss
from Owner import Owner
owner = Owner()
boss = FloorBoss(owner)
seller = Seller(boss)

while True:
    quantity = int(input())
    price = int(input())
    print(seller.charge(quantity, price))
예제 #2
0
 def find_income(self, surname):
     self.seller_income = Seller.seller_income_by_surname(surname.get())
     return ", income: " + self.seller_income
예제 #3
0
 def update_list(self, listbox):
     listbox.delete(0, END)
     self.seller_list = Seller.show_all_sellers().split('\n')
     for seller in self.seller_list:
         self.allseller_listbox.insert(END, seller)
     return
예제 #4
0
 def update_percent(self, surname, percent):
     Seller.update_percent(surname, float(percent.get()))
     self.update_list(self.allseller_listbox)
예제 #5
0
    def __init__(self, *args, **kwargs):
        Page.__init__(self, *args, **kwargs)

        window = Toplevel(self)
        window.title("Seller window")
        window.state('zoomed')

        all_sellers = Frame(window)
        all_sellers.pack(side=LEFT, fill=Y)
        Label(all_sellers, text="All avaliable sellers").pack()
        self.allseller_listbox = Listbox(all_sellers, width=80)
        self.allseller_listbox.bind('<Double-1>', self.all_list_on_click)
        self.seller_list = Seller.show_all_sellers().split("\n")
        self.seller_list.pop(-1)
        for seller in self.seller_list:
            self.allseller_listbox.insert(END, seller)
        self.allseller_listbox.pack(side="top", fill="both")
        all_docx = Button(all_sellers,
                          text="Export info in docx about all sellers",
                          command=self.form_docx_report())
        all_docx.pack()
        all_exel = Button(all_sellers,
                          text="Export info in exel about all sellers",
                          command=self.form_exel_report())
        all_exel.pack()

        search_seller = Frame(window)
        search_seller.pack(side=LEFT, fill=Y)
        Label(search_seller, text="Search seller by surname").pack()
        enter_name = Entry(search_seller)
        enter_name.pack()
        self.find_listbox = Listbox(search_seller, width=80)
        self.find_listbox.bind('<Double-1>', self.find_list_on_click)
        find_prod = partial(self.search_seller_on_click, self.find_listbox,
                            enter_name)
        search_btn = Button(search_seller, text="Search", command=find_prod)
        search_btn.pack()
        self.find_listbox.pack()

        add_seller = Frame(window)
        add_seller.pack(side=LEFT, fill=Y)
        Label(add_seller, text="Add new seller").grid(row=0,
                                                      column=0,
                                                      columnspan=3)
        name_label = Label(add_seller, text="Enter sellers` name:")
        surname_label = Label(add_seller, text="Enter sellers` surname:")
        middle_name_label = Label(add_seller,
                                  text="Enter sellers middle name:")
        income_percent_label = Label(add_seller,
                                     text="Enter sellers` income price:")
        name_entry = Entry(add_seller)
        surname_entry = Entry(add_seller)
        middle_name_entry = Entry(add_seller)
        income_percent_entry = Entry(add_seller)
        add_sel = partial(self.add_seller, name_entry, surname_entry,
                          middle_name_entry, income_percent_entry,
                          self.allseller_listbox)
        add_btn = Button(add_seller, text="Add", command=add_sel)
        name_label.grid(row=1, column=0)
        surname_label.grid(row=2, column=0)
        middle_name_label.grid(row=3, column=0)
        income_percent_label.grid(row=4, column=0)
        name_entry.grid(row=1, column=1)
        surname_entry.grid(row=2, column=1)
        middle_name_entry.grid(row=3, column=1)
        income_percent_entry.grid(row=4, column=1)
        add_btn.grid(row=5, column=1)
예제 #6
0
from tensorflow.keras.datasets import cifar100, cifar10
import math
from DModel import DModel
from EA import EA_Buyer
import random
import Utils

dataset = "CIFAR10"
n_classes = 10
u = 1

(trainImages, trainLabels), features, (testX, testY) = Utils.load_CIFAR10()
init_image_ids = np.loadtxt("./" + dataset + "/" + str(u) + "/init.csv")
init_image_ids = [int(v) for v in init_image_ids]

seller = Seller(n_classes, trainImages, trainLabels, init_image_ids)

alloc_strat = 'Squareroot'
for budget in [3000, 5000, 6000, 8000, 10000, 20000, 30000, 39000]:
    # for budget in [5000,10000,20000]:
    # for l in [0.01,0.03,0.05,0.07,0.09]:
    for l in [0.05001]:

        seller.reset()
        buyer = EA_Buyer(budget, n_classes, features, trainImages, trainLabels,
                         init_image_ids, seller)
        buyer.l = l
        buyer.allocation_strategy = alloc_strat
        purchase_list = buyer.process()
        write_file = open(
            "./" + dataset + "/" + str(u) + "/EA-" + alloc_strat + "-" +
예제 #7
0
def load_dataset():
    (trainX, trainY), (testX, testY) = Utils.read_Crop()
    features = trainX.copy()
    return (trainX, trainY), features, (testX, testY)


(trainX, trainY), features, (testX, testY) = load_dataset()

init_image_ids = np.loadtxt(folder + "init.csv")
init_image_ids = [int(v) for v in init_image_ids]

total_budget = 100001
budget_list = list(np.arange(2000, 100001, 5000))

seller = Seller(n_classes, trainX, trainY, init_image_ids)
# purchase step
for _ in range(10):
    seller.reset()
    model = CModel()
    buyer = RD_Buyer(total_budget, n_classes, features, trainX, trainY,
                     init_image_ids, model, seller)
    buyer.batch_size = 100
    purchase_list = buyer.process()
    for budget in budget_list:
        write_file = open(folder + "RD-" + str(budget), 'a')
        write_file.write(' '.join([str(v)
                                   for v in purchase_list[:budget]]) + "\n")
        write_file.flush()
        write_file.close()
예제 #8
0
import Utils
from RModel import RModel
import random
import Utils
u=1
n_regions = 16

(trainX, trainY), features, (testX, testY) = Utils.load_RoadNetd()

folder = "./roadnet/roadnet" + str(n_regions) + "/"
init_image_ids = np.loadtxt(folder + str(u) + "/init.csv")
init_image_ids = [int(v) for v in init_image_ids]

all_budgets = list(range(2000,300000,2000))
alloc_strat = 'Linear'
seller = Seller(n_regions, trainX, trainY, init_image_ids, False)

for l in [0.001]:
    # data acquisition
    for budget in all_budgets:
        write_file = open(folder + str(u) + "/EA-" + str(budget), 'w')
        for _ in range(10):
            seller.reset()
            buyer = EA_Buyer(budget, n_regions, features, trainX, trainY, init_image_ids, seller)
            buyer.chenge_to_regression()
            buyer.allocation_strategy = alloc_strat
            buyer.l = l
            purchase_list = buyer.process()
            write_file.write(' '.join([str(v) for v in purchase_list]))
            write_file.flush()
        write_file.close()