Skip to content

Instantly share code, notes, and snippets.

View ryanpeach's full-sized avatar

Ryan Peach ryanpeach

View GitHub Profile
@ryanpeach
ryanpeach / frozenlakeq675.md
Created November 2, 2016 23:43
Frozen Lake v0 Q Learner Writeup 675
@ryanpeach
ryanpeach / hungarian.py
Created September 28, 2016 18:03
A Python 2 implementation of both the Hungarian and Murty's Algorithm, which I believe runs in O(n^3) time, with sources, memoization, testing methods, and capable of being run in parallel instances with multiprocessing.pool.
# Ryan Peach 3/1/2016
# References Used for this Implementation
# https://en.wikipedia.org/wiki/Hungarian_algorithm
# https://github.com/bmc/munkres/blob/master/munkres.py
# http://csclab.murraystate.edu/bob.pilgrim/445/munkres.html
# ---
# No copying and pasting of online code was performed, though some code may turn out to be similar due to the standardized nature of this algorithm.
# This is a very different implementation due to the fact that it heavily uses numpy, vastly simplifies many poorly pythonized coding elements
# removes the "class" approach for a function based one. Etc.
# Improvements that need to be made is to require the matrix class, and to vectorize iterations through the matrix.
@ryanpeach
ryanpeach / timeout.py
Created September 23, 2016 06:57
Good for single loop timeout functions which may or may not contain a non-nested timeout element themselves. Ran into issues when nesting this function within one of it's own, timeout is not referenced within sub-scopes.
from time import time, sleep
from functools import wraps
import socket
import unittest
class TimeoutError(socket.timeout):
pass
none_val = lambda x: 0.0 if x is None else float(x) # Returns float(x), or 0 if x is None