This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from scipy.optimize import linprog | |
import numpy as np | |
import itertools | |
#Searching for the counterexample for the following conjecture: | |
# in the shortest hamiltonian path, there is at least one | |
# node, connected to its 12 nearest neighbors | |
# https://www.reddit.com/r/math/comments/17rxc28/travelling_salesman_algorithm/ | |
# Use linear programming to find a counterexample |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
N = 300 #size of the grid | |
M = 20000 #number of pixels | |
potential = np.zeros((N, N), dtype=np.float64) | |
masses = np.zeros((N, N), dtype=np.bool8) | |
def potential_of_mass_at(i, j): | |
"""Returns L1 potential of a mass at (i, j) with mass m | |
potential is calcualted as: |
OlderNewer