Esempio n. 1
0
class TestIDS(TestCase):
    @classmethod
    def setUpClass(self):
        self.ids = IDS("https://hub.jazz.net/ccm10", "", "")

    def test_create_session(self):
        assert self.ids.session is not None

    def test_get_work_item_by_id(self):
        WI = self.ids.get_work_item_by_id(16219)
        assert WI is not None
        assert isinstance(WI, Workitem)
        assert WI.id == "16219"
        assert WI.url is not None
        assert WI.description is not None
        print WI.url

    def test_get_work_item_by_owner(self):
        WI = self.ids.get_work_items_by_owner("James Royal")
        assert WI is not None
        assert isinstance(WI, list)
        WI = WI[0]
        assert WI.id == "16219"
        assert WI.url is not None
        assert WI.description is not None
Esempio n. 2
0
def run_ids(Xtr, Ytr, Xt, Yt, lb, min_freq, lambs, log=None):
    ids, nfreq, default = IDS(Xtr, Ytr.values, lambs, freq=min_freq)
    for r in ids:
        print('class: ',
              r.class_label,
              ', cover: {}/{}'.format(len(r.get_correct_cover(Xtr, Ytr)),
                                      len(r.get_cover(Xtr))),
              end='; ')
        r.print_rule()

    for r in ids:
        r.covered = set(r.get_cover(Xtr))

    Y_pred = IDS_predict(ids, Xt, default=default)

    if log is None:
        from logger import log
    [log('ids-lambda', lamb, i) for i, lamb in enumerate(lambs)]
    log('ids-k', len(ids))
    [log('ids-nconds', r.get_length(), i) for i, r in enumerate(ids)]
    log('ids-nfreq', nfreq)
    log('ids-freq', min_freq)
    log('ids-default', default)
    log('ids-auc', roc_auc_score(lb.transform(Yt.values),
                                 lb.transform(Y_pred)))
    log('ids-bacc', balanced_accuracy_score(Yt, Y_pred))
    log('ids-disp', dispersion_(ids, average=True))
    log('ids-overlap', overlap(ids))
    print(confusion_matrix(Yt, Y_pred))

    return Y_pred
def get_solve_graph(algo_enum: AlgoEnum):
    solve_graph: BaseGlobalSearch = None
    if algo_enum == AlgoEnum.IDS:
        solve_graph = IDS(order_int_list, N)
    elif algo_enum == AlgoEnum.BFS:
        solve_graph = BFS(order_int_list, N)
    elif algo_enum == AlgoEnum.A_STAR:
        solve_graph = AStar(order_int_list, N)
    return solve_graph
Esempio n. 4
0
def correr_busqueda(tipo_busqueda=0):
    tablero = CMP(get_mapa_caracteres())

    if tipo_busqueda == 1:
        resultados, tablero = BFS(tablero)
    elif tipo_busqueda == 2:
        resultados, tablero = DFS(tablero)
    elif tipo_busqueda == 3:
        resultados, tablero = IDS(tablero)
    elif tipo_busqueda == 0:
        print("No se envio el parametro tipo de busqueda")
        exit()
    else:
        print("No se envio un tipo de busqueda correcto")
        exit()

    return resultados, tablero
Esempio n. 5
0
from json import loads
from bfs import BFS
from dfs import DFS
from ids import IDS
from hc import HC

# Load tree data from file
filePath = open('./data.json')
data = filePath.read()
dataJson = loads(data)
tree = dataJson['tree']
# list of goals of DFS, DFS, IDS algorithms
goals = dataJson['goals']

hill_climb = dataJson['hill-climb']
# list of goals of HC algorithm
goals_HC = dataJson['hill-climb']['goals']
# root node
root = dataJson['root']

if __name__ == '__main__':
    DFS(tree, root, goals)
    BFS(tree, root, goals)
    IDS(tree, root, goals, 2)
    HC(hill_climb, root, goals_HC)
Esempio n. 6
0
def pump_calibration(step_size, fname):
    old_step = step_size
    step = step_size
    # command = input("Please scan the ") 
    act_count = 0
    i2c = busio.I2C(board.SCL, board.SDA)
    mpr121 = adafruit_mpr121.MPR121(i2c)

    mover = PumpMove()
    forwardbtn = Button("GPIO5")
    backwardbtn = Button("GPIO27")

    BACKWARD_LIMIT_BTN = "GPIO23"
    BACKWARD_LIMIT = DigitalInputDevice(BACKWARD_LIMIT_BTN)

    def forward():
        while forwardbtn.value == 1:
            mover.move("forward")

    def backward():
        while BACKWARD_LIMIT.value != 1:
            mover.move("backward")

    forwardbtn.when_pressed = forward
    backwardbtn.when_pressed = backward

    print("current step size = " + str(step_size)) 
    print("please prepare to measure the solution.")

    while True:
        time.sleep(0.050)
        act = mpr121.touched_pins[1]

        if act:
            if act_count % 5 == 0:
                for i in range(5):
                    mover.move("forward", step)

            act_count += 1
            print("count" + str(act_count))
            if act_count == 15:
                response = input("please enter the amount measured (numeric value) or scan the command id again to exit: ").strip()
                # if the same command RFID is scanned again, exit the while loop
                if response[-2:] == '6b' or response[-2:] == '8e' or response[-2:] == 'ba':
                    break
                else:
                    try:
                        response = int(response)
                    except ValueError:
                        response = int(input("please re-enter the amount measured: ").strip())

                avg_measured_value = response / 3
                print("average value: {}".format(avg_measured_value))
                
                if (avg_measured_value < (300-10) or avg_measured_value > (300+10)):
                    # update step size
                    print("previous step: {}".format(step))
                    step = math.ceil( (step / (avg_measured_value / 5)) *60  )
                    
                    print("modified step: {}".format(step))
                    print("Touch spout to measure again")
                
                act_count = 0

    del(mover)

    date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
    record = "{}\t"*3

    ids = IDS()
    # print out the old/new steps after the calibration
    print("old step size: {}".format(old_step))
    print("new step size: {}".format(step))

    # overwrite the old step size in 'peerpub_config.json' file
    ids.change_step(step)

    f_specifiers = ""
    file_path = file_dir.format(fname)
    print("Update stepsize in " +fname)
    if os.path.isfile(file_path):
        f_specifiers = "a"
    else:
        f_specifiers = "a"

    with open(file_path, f_specifiers) as f:
        f.write((record+"\n").format(date, old_step, step))
Esempio n. 7
0
__author__ = 'muneeb'

from node import Node
from ids import IDS
from dfs import DFS
from bfs import BFS
from graph_generator import  Graph_Generator
import copy
start = "1"
goal = "15"
g = Graph_Generator(8000)
graph = g.generate_graph()

ids = IDS(copy.deepcopy(graph), start, goal)
bfs = BFS(copy.deepcopy(graph), start, goal)
dfs = DFS(copy.deepcopy(graph), start, goal)

ids.walk()
bfs.walk()
dfs.walk()

Esempio n. 8
0
 def setUpClass(self):
     self.ids = IDS("https://hub.jazz.net/ccm10", "", "")
Esempio n. 9
0
        raise RuntimeError('Intrusion Detected.')

    def close_connection(self):
        # Close all files/sockets
        self.s.shutdown(socket.SHUT_WR)
        print("Disconnected from client at: " + str(self.addr))
        self.log_event("Disconnected from client at: " + str(self.addr))
        self.s.close()
        self.log_file.close()


print('Intrusion Detection System Starting...')

# Initialize an IDS
ids = IDS()

print("FTP Server Starting...")

while True:
    # Initialize a socket connection
    conn = ServerConnection()

    try:
        while True:
                # Receive command string
                command = conn.get_message()

                # Send the command to the ftp protocol
                ftp_exit_result = ftp(command, conn)
Esempio n. 10
0
# add handlers
logger.addHandler(fh)
logger.addHandler(ch)
# --------------------------------------------------------------------

parser = argparse.ArgumentParser()
parser.add_argument('-test', type=bool, default=False)

args = parser.parse_args()

# get date and time
datetime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
date = time.strftime("%Y-%m-%d", time.localtime())

# get device and session ids
ids = IDS()
#ids.sessionIncrement()

# speed for the stepper motor
motor_step = ids.step

sTime = time.time()

# get software version from lastest update
filepath = '/home/pi/SocialDrinking/*_update'
if glob.glob(filepath):
    for update in glob.glob(filepath):
        if os.path.getsize(update) > 0:
            with open(update, 'r') as f:
                for line in f:
                    pass