Skip to content

Instantly share code, notes, and snippets.

View tobyodavies's full-sized avatar

Toby Davies tobyodavies

View GitHub Profile
@tobyodavies
tobyodavies / tsp_visualiser.py
Last active April 29, 2016 20:03
An interactive TSP visualizer
"""
An interactive visualizer for TSP instances if you add `Visualizer.update(solution)`
after improving your solution you will see the new path and its cost.
>>> points = [(0, 0), (1, 1), (1, 2)]
>>> vis = Visualizer(points)
>>> Visualizer.update([0, 1, 2])
"""
A simple generic wrapper for calling an external program to solve assignments
in Discrete Optimization
Copyright (C) 2012 Toby Davies
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
class HashableFunc(object):
"""
This class acts as a decorator to make a function persistently hashable
"""
relevant_attr_names = ['co_argcount', 'co_cellvars', 'co_code', 'co_consts',
'co_filename', 'co_firstlineno', 'co_flags', 'co_freevars',
'co_lnotab', 'co_name', 'co_names', 'co_nlocals', 'co_stacksize',
'co_varnames']