def parallel_update_velocity(cars, grid, cell_width, cell_height, grid_width, grid_height):
    task2(grid, grid_width, grid_height, scale_rule1)
    for car in cars:
        if car.next_junction.is_exit:
            if dist((car.x, car.y), (car.next_junction.x, car.next_junction.y)) < exit_communication_radius:
                car.vx, car.vy = sub((car.next_junction.x, car.next_junction.y), (car.x, car.y))
                continue
Example #2
0
def main():
    tasknum=input('Select the task which you want to run? (1 - Mandatory homework / 2 - Advanced homework): ')
    if tasknum=='1':
        task1()
    elif tasknum=='2':
        task2()
    else:
        print("You've entered invalid character. Please enter 1 or 2.")
        main()
Example #3
0
def main():
    while True:
        print(
            'Choose which task u want to execute: \n(Note - Execute Task 2 before Task 3)'
        )
        ch = input(
            '\n1. Task 1\n2. Task 2\n3. Task 3\n4. Exit\nEnter Choice: ')
        if ch == '1':
            task1.task1()
        elif ch == '2':
            task2.task2()
        elif ch == '3':
            task3.task3()
        elif ch == '4':
            break
Example #4
0
def main():
    all_files = listdir(TASK2_FILES)
    for file in all_files:
        if file.startswith("test") and file.endswith(".jpg"):
            number = file[4:-4]
            img = cv2.imread(TASK2_FILES + file)
            if img is not None:
                nums, roi = task2.task2(img)

                # Output region
                cv2.imwrite(TASK2_OUTPUT + "DetectedArea" + number + ".jpg",
                            roi)

                #Output text file
                f = open(TASK2_OUTPUT + "Building" + number + ".txt", "w+")
                for num in nums:
                    actual_num = num[:3]
                    direct = num[-1:]
                    directional = "left"
                    if direct == 'R':
                        directional = "right"
                    f.write("Building " + actual_num + " to the " +
                            directional + "\n")
                f.close()

    print("Complete")
Example #5
0
def validate2(datastore):
    ncorrect = 0
    tried = len(datastore["Directional"])

    for ds in datastore["Directional"]:
        img = cv2.imread('res/' + ds + ".jpg")
        classify, roi = task2.task2(img, ds)
        ans = datastore["Directional"][ds]

        correct = True

        if len(classify) == len(ans):
            for i, cla in enumerate(classify):
                if cla != ans[i]:
                    correct = False
                    break
        else:
            correct = False

        if correct:
            ncorrect = ncorrect + 1
            print("Correct for", ds, ". Got", classify)
        else:
            print("FAIL for", ds, ". Got", classify, 'expected', ans)
            cv2.waitKey(0)

    print('OVERALL', round(100.0 * ncorrect/tried, 2), "% correct\n")
Example #6
0
def main():
    if (len(sys.argv) != 2 and len(sys.argv) != 3) or (sys.argv[1] != '1'
                                                       and sys.argv[1] != '2'
                                                       and sys.argv[1] != '3'):
        print("Usage: python " + sys.argv[0] + " <TASK>")
        print("Where TASK is one of 1, 2 or 3.")
        return

    task = sys.argv[1]

    if task == '1':
        strategy = sys.argv[2]
        if strategy == 'bovw':
            task1_BOVW()
        else:
            task1_CNN()
    elif task == '2':
        task2()
    else:
        task3()
Example #7
0
def main():
    m, n, k = map(int, input('m, n, k: ').split())
    data = datagen(m, n, k)
    t1 = task1(data)
    t1data = t1.run()
    print('task1: \n', t1data)

    t2 = task2(data)
    t2data = t2.run()
    print('task2: \n', t2data)

    t3 = task3(data)
    t3data = t3.run()
    print('task3: \n', t3data)
Example #8
0
 def test_negative_value(self):
     self.assertEqual(
         tk2.task2(-50),
         "Incorrect value, supported only non-negative numbers")
Example #9
0
 def test_value_with_zero(self):
     self.assertEqual(tk2.task2(80), 8)
Example #10
0
 def test_with_same_numbers(self):
     self.assertEqual(tk2.task2(1111), 1111)
Example #11
0
 def test_zero_value(self):
     self.assertEqual(tk2.task2(0), 0)
Example #12
0
import cv2
from task1a3 import task1, task3
from task2 import task2
from task4 import task4
from task5 import task5

print("**********task1**************")
print(
    "There might be a warning here, but everything works so I'm sure its fine~"
)
task1()
print("**done**")
print("**********task2**************")
task2()
print("**done**")
print("**********task3**************")
task3()
print("**done**")
print("**********task4**************")
task4()
print("**done**")
print("**********task5**************")
task5()
print("**done**")
cv2.waitKey(0)
Example #13
0
                                a[i].get('step'))

        for idx, alpha in enumerate(alpha_range):
            print(str(idx) + "/" + str(len(alpha_range)) + " " + str(alpha))
            estP_w2 = EstimatorAdaptative(alpha=alpha,
                                          rho=rho[i],
                                          metric="precision")
            estR_w2 = EstimatorAdaptative(alpha=alpha,
                                          rho=rho[i],
                                          metric="recall")
            estP_w2.fit(X_est)
            estR_w2.fit(X_est)
            X_res_A = task3(X_est, X_pred, rho[i], alpha, True)
            X_res_B = task3(X_est, X_pred, rho[i], alpha, False)
            X_res_h4, _ = task1(X_est, X_pred, rho[i], alpha, connectivity=4)
            X_res_t2 = task2(X_est, X_pred, rho[i], alpha, pixels[i])
            X_res_sh_A = task4(X_est, X_pred, rho[i], alpha, True)
            X_res_sh_B = task4(X_est, X_pred, rho[i], alpha, False)

            Pr_w2.append(estP_w2.score(y_pred, X=X_pred))
            Re_w2.append(estR_w2.score(y_pred, X=X_pred))
            Pr_h4.append(evaluate(X_res_h4, y_pred, "precision"))
            Re_h4.append(evaluate(X_res_h4, y_pred, "recall"))
            Pr_A.append(evaluate(X_res_A, y_pred, "precision"))
            Re_A.append(evaluate(X_res_A, y_pred, "recall"))
            Pr_B.append(evaluate(X_res_B, y_pred, "precision"))
            Re_B.append(evaluate(X_res_B, y_pred, "recall"))
            Pr_t2.append(evaluate(X_res_t2, y_pred, "precision"))
            Re_t2.append(evaluate(X_res_t2, y_pred, "recall"))
            Pr_sh_A.append(evaluate(X_res_sh_A, y_pred, "precision"))
            Re_sh_A.append(evaluate(X_res_sh_A, y_pred, "recall"))
Example #14
0
import matplotlib.pyplot as plt
import numpy as np
from numpy import sqrt
import task2
import math
import time
import re
import levitq
import svgwrite
import binsearch as b

print('starting work, please wait')
X = []
Y = []
nodes, adjs, adjlf, weights, nodei, hospitals, nearnodes, highways, lat, lon, delat, delon, nodesfortest, dwg = task2.task2(
    False)

print('Where is a warehouse?')
print("Input longitude")
lonp = input()
lons = re.split('[, .]', lonp)
while not (len(lons) == 2 and lons[0].isdigit() and lons[1].isdigit()
           and float(lonp) >= lon[0] and float(lonp) <= lon[len(lon) - 1]
           and len(lons[1]) > 2):
    print("Input longitude")
    lonp = input()
    lons = re.split('[, .]', lonp)

print("Input latitude")
latp = input()
lats = re.split('[, .]', latp)
Example #15
0
                "Error: Please enter the number corresponding to one of the choices above"
            )
            continue

        # Perform the correct task based on the choice of the user
        if choice == 1:
            task1.task1(new_dict, pid_to_author_sequence,
                        pid_to_title_year_conf, aid_to_author_name)
        elif choice == 2:
            phrases = {}
            for pid in pid_to_keyword:
                for word in pid_to_keyword[pid]:
                    if word not in phrases.keys():
                        phrases[word] = []
                    phrases[word].append(pid_to_keyword)
            task2.task2(phrases, new_dict)
        elif choice == 3:
            task3.task3(new_dict)
        elif choice == 4:
            task4.task4(aid_to_author_name, pid_to_author_sequence)
        elif choice == 6:
            task6.task6(pid_to_title_year_conf, pid_to_keyword,
                        pid_to_author_sequence)
        elif choice == 7:
            task7.task7(pid_to_title_year_conf, pid_to_keyword,
                        pid_to_author_sequence)
        elif choice == 5:
            task5.task5(pid_to_keyword)
        elif choice == 8:
            break
        else:
Example #16
0
from task2 import task2
from engineer2 import engineer2

timeResultsList = []
stateResultsList = []

timeliness = 0.0
taskDiff = 10.0
engSkill = 1.0

for x in range(0, 1000):

    # create an engineer (0)
    e0 = engineer2(0, engSkill, 1)  # ID = 0, Skill = 5, Category = 1
    e0.setTimeliness(timeliness)
    t0 = task2(taskDiff, 1, 1.0, 100,
               'task0')  # def __init__(self,diff,cat,prio,days,name):
    t1 = task2(taskDiff, 1, 1.0, 100,
               'task1')  # def __init__(self,diff,cat,prio,days,name):
    e0.addTask(t0)
    e0.addTask(t1)

    # create a new engineer (1)
    e1 = engineer2(1, engSkill, 1)
    e1.setTimeliness(timeliness)
    t2 = task2(taskDiff, 1, 1.0, 100,
               'task2')  # def __init__(self,diff,cat,prio,days,name):
    t3 = task2(taskDiff, 1, 1.0, 100,
               'task3')  # def __init__(self,diff,cat,prio,days,name):
    e1.addTask(t2)
    e1.addTask(t3)
Example #17
0
import dijkstra
import astarsearch as a
import time
import levit
import random
import task2

print('starting work, please wait')
start = time.time()
nodes, adjs, adjlf, weights, nodei, hospitals, nearnode, highways, lat, lon, delat, delon, nodesfortest = task2.task2(
    True)
print('testing:')
test = random.sample(nodesfortest, 100)
print('testing astar with dif f:')

for wm in range(1, 4):
    astartime = 0
    for nodep in test:
        astarstart = time.time()
        for i in nearnode:
            dastar, astarpath = a.astar(weights, adjs, nodei.get(nodep),
                                        nodei.get(i), nodes, lat, lon, delat,
                                        delon, adjlf, wm)
        astarend = time.time()
        astartime += astarend - astarstart
    print('astar', wm.__str__() + ':', astartime / 100, 'sec')

print('main testing')
dtime = 0
astartime = 0
levittime = 0
Example #18
0
__author__ = "anton"
# -*- coding:utf-8 -*-

from task2 import task2

if __name__ == "__main__":
    print("Для ввода чисел с консоли нажмите 1. Для считывания координат из файла нажмите 2")
    answer = input()

    if answer == "1":
        print("n = ")
        n = int(input())
        print("m = ")
        m = int(input())
        if 0 <= n <= m <= 10e14:
            print(task2(n, m))
        else:
            print("Некорректный ввод")
    elif answer == "2":
        print("Имя файла с расширением")
        file_name = input()
        try:
            f = open(file_name)
            for line in f:
                n_str, m_str = line.split(" ")
                n = int(n_str)
                m = int(m_str)
                if 0 <= n <= m <= 10e14:
                    print(task2(n, m))
                else:
                    print("Некорректный ввод")