Skip to content

Commit

Permalink
fix typo with greater/less than
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuhron committed Oct 28, 2022
1 parent 5702030 commit 2b865e4
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions Chaos/CombinedStrangeAttractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def converges_with_complexity(self):
total_unique_ratio = total_unique_points / total_points
return False, total_unique_points, total_points, total_unique_ratio

def get_convergence_points(self, x_min=-1, x_max=1, y_min=-1, y_max=1, resolution=100, max_iterations=10000, max_abs=1e6):
def get_convergence_points(self, x_min=-1, x_max=1, y_min=-1, y_max=1, resolution=100, max_iterations=10000, max_abs=100):
print("getting convergence array")
xs = np.linspace(x_min, x_max, resolution)
ys = np.linspace(y_min, y_max, resolution)
Expand All @@ -56,7 +56,7 @@ def get_convergence_points(self, x_min=-1, x_max=1, y_min=-1, y_max=1, resolutio
print("done getting convergence array")
return convergence

def plot_convergence_points(self, x_min=-1, x_max=1, y_min=-1, y_max=1, resolution=100, max_iterations=10000, max_abs=1e6):
def plot_convergence_points(self, x_min=-1, x_max=1, y_min=-1, y_max=1, resolution=100, max_iterations=10000, max_abs=100):
convergence_array = self.get_convergence_points(x_min, x_max, y_min, y_max, resolution, max_iterations, max_abs)
plt.imshow(convergence_array)
plt.colorbar()
Expand All @@ -77,7 +77,7 @@ def find_convergent_initial_condition(self, min_index, max_index):
x0 = r * np.cos(theta)
y0 = r * np.sin(theta)
# x0, y0 = np.random.uniform(-1, 1, (2,))
trajectory = get_late_trajectory(self, x0, y0, min_index=min_index, max_index=max_index, max_abs=1e6)
trajectory = get_late_trajectory(self, x0, y0, min_index=min_index, max_index=max_index, max_abs=100)
if trajectory_diverges(trajectory):
continue
else:
Expand Down Expand Up @@ -199,21 +199,20 @@ def __repr__(self):
return f"<Random choice mapping from the sub-mappings:\n\t{str_of_mapping_reprs}\n>"


def get_late_trajectory(mapping, x0, y0, min_index, max_index, max_abs=1e9):
def get_late_trajectory(mapping, x0, y0, min_index, max_index, max_abs=100):
assert max_index > min_index
res = []
x,y = x0,y0
BIG = max_abs # if it gets to this distance then assume it diverges
for i in range(max_index):
x,y = mapping(x,y)
if i < min_index:
# don't store these, let it settle into attractor state, if any
continue
else:
res.append((x,y))
if not np.isfinite(x) or not np.isfinite(y) or abs(x) > BIG or abs(y) > BIG:
# assume it will diverge forever if it ever reaches inf/NaN
# just put a nonfinite pair at the end and return
if not np.isfinite(x) or not np.isfinite(y) or abs(x) > max_abs or abs(y) > max_abs:
# assume it will diverge forever if it ever reaches inf/NaN or max_abs
# just put a nonfinite pair at the end and return without checking later iterations
res.append((np.inf, np.inf))
return res
return res
Expand Down Expand Up @@ -303,7 +302,7 @@ def run_mixing_experiment(mapping_names=None):

divergence_count = 0
plot_success = False
while not (plot_success or divergence_count < 5):
while not (plot_success or divergence_count > 5):
try:
mapping.plot_attractor()
plot_success = True # this will break while loop
Expand Down Expand Up @@ -410,7 +409,7 @@ class MappingRecord:
# plt.show()

run_mixing_experiment()
# run_mixing_experiment(["W", "X"])
# run_mixing_experiment(["AL", "AS"])
# while True:
# run_perturbation_experiment(perturbation_nelda=random.choice([1, 1.5, 2, 2.5, 3]))

Expand All @@ -429,6 +428,6 @@ class MappingRecord:
# - AS + Z (zigzag spiral)
# - AS + AK (looks like letters in a curvy script)
# - X + W (messy dusty danish)

# - AS + AL (pentagon made of line bundles)


0 comments on commit 2b865e4

Please sign in to comment.