Пример #1
0
 def calculate(self):
     self.print_test()
     a, b, c = algorithm.matrix_to_3list(self.__get_data_A())
     d = self.__get_data_b()
     x = algorithm.algo(a, b, c, d)
     for i in range(self.n):
         self.table_x.setItem(0, i, QTableWidgetItem(str(x[i])))
Пример #2
0
def route():
    with sqlite3.connect("routr.db") as conn:
        c = conn.cursor()
        rows = c.execute('SELECT * FROM cart').fetchall()
        if len(rows) < 1:
            return apology("Error, no items added")
        else:
            c = conn.cursor()
            stations = []
            rows = c.execute('SELECT DISTINCT "group" FROM cart c INNER JOIN items i on c.name=i.name').fetchall()
            for row in rows:
                stations.append(c.execute('SELECT "x","y","group" FROM groups WHERE "group" = ?',[row[0]]).fetchone())
            print(stations)
            start = c.execute('SELECT x,y FROM "groups" WHERE "group" = "start"').fetchone()
            checkout = c.execute('SELECT x,y FROM "groups" WHERE "group" = "checkout"').fetchone()
            print(start)
            print(checkout)
            route = algo(stations,[start[0],start[1],"start"],[checkout[0],checkout[1],"checkout"])
            items = {}
            rows = c.execute('SELECT c.name, "group" FROM cart c INNER JOIN items i on c.name = i.name').fetchall()
            for row in rows:
                if row[1] not in items:
                    items[row[1]] = [row[0]]
                else:
                    items[row[1]] = items[row[1]]
                    #items[row[1]].append(row[0])
            print(items)
            #count += 1
            return render_template("router.html",route=route,items=items)
Пример #3
0
import user_input as ui
import algorithm
#######################################################################
#import user_input module and accept inputs
#store user input in take_ing list

print('1...Enter the list of ingredients\n')
print('2...Feeling lazy? Choose from list of ingredients')
choice = int(input())
if choice is 1:
    user_in = ui.take_ingridients()
else:
    user_in = ui.choose_ingredients()

#######################################################################

algorithm.algo(user_in)


    
        
        
        
        
        
        
        
        
        
Пример #4
0
def run_algo():
    N = request.json['N_value']
    p = request.json['p_value']
    q = request.json['q_value']

    return jsonify(algo(int(float(N)), int(float(p)), int(float(q))))
Пример #5
0
from algorithm import algo
from colors import colors
from GUI import COLS, FPS, GUI, ROWS
from matrix import matrix
from nodeClasses.goalNode import goalNode
from nodeClasses.spareNode import spareNode
from nodeClasses.startNode import startNode
from nodeClasses.wallNode import wallNode

matr = matrix(ROWS, COLS)
gui = GUI(matr.arr)

gui.update()

path = algo(matr.arr, matr.start, matr.goal, gui)

# waits one second so we can see the initial state before
# starting the interaction
time.sleep(15)
"""
while True:
    # INPUT PROCESSING
    event = pygame.event.poll()

    if event.type == pygame.QUIT:
        # quits the program if clicked to close the window
        break
    elif (event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE):
        # quits the program on pressing ESC
        break
Пример #6
0
def post_number(request):
    if request.method == "POST":
        form = PostNumberForm(request.POST)
        if form.is_valid():
            post = form.save(commit=False)
            post.number_str = algo(post.number_int)
            post.save()
            return HttpResponseRedirect(reverse('post_number'))
    else:
        form = PostNumberForm()
    # текущие данные поля ввода
    try:
        int_numb = list(
            PostNumber.objects.all().order_by('-created')[:1].values_list(
                'number_int', flat=True))[0].replace(',', '.')
        check_nds = list(
            PostNumber.objects.all().order_by('-created')[:1].values_list(
                'nds', flat=True))[0]
        nds_percent = list(
            PostNumber.objects.all().order_by('-created')[:1].values_list(
                'nds_percent', flat=True))[0]
    except IndexError:
        int_numb = ''
        check_nds = False
        nds_percent = 0

    if check_nds and nds_percent != 0:
        int_nds = str(
            algo(float(int_numb.replace(' ', '')) / (100 / nds_percent)))

        string_numb = f'{list(PostNumber.objects.all().order_by("-created")[:1].values_list("number_str", flat=True))[0]}' \
                      f', включая НДС {nds_percent}% в сумме {int_nds}'
    else:
        try:
            string_numb = list(
                PostNumber.objects.all().order_by('-created')[:1].values_list(
                    'number_str', flat=True))[0]
        except IndexError:
            string_numb = ''
    # история ввода. списки атрибутов
    history = list(
        PostNumber.objects.all().order_by('-created')[1:4].values_list(
            'number_str', flat=True))
    history_int = list(
        PostNumber.objects.all().order_by('-created')[1:4].values_list(
            'number_int', flat=True))
    history_nds = list(
        PostNumber.objects.all().order_by('-created')[1:4].values_list(
            'nds_percent', flat=True))
    history_check_nds = list(
        PostNumber.objects.all().order_by('-created')[1:4].values_list(
            'nds', flat=True))
    for i in range(3):
        try:
            if history_nds[i] != 0 and history_check_nds[i] == True:
                history_int[i] = history_int[i].replace(",", ".")
                history_int[i] = history_int[i].replace(" ", "")
                print(history_int[i])
                history[i] = "".join([
                    history[i], f', включая НДС {history_nds[i]}% в сумме '
                    f'{str(algo(float(history_int[i]) / (100 / history_nds[i])))}'
                ])
        except IndexError:
            pass
    content = {
        'form': form,
        'string_numb': string_numb,
        'history': history,
    }

    return render(request, 'mainapp/index.html', content)
Пример #7
0
import scipy.io
from algorithm import algo

mat = scipy.io.loadmat('sp500.mat')
mat = mat['price_move']

for q in [0.7, 0.9]:
    p, fig = algo(q, mat)

    fig.savefig('./'+str(q)+'.png')
    print('p: %.4f q: %.4f' % (p, q))