From 0d3c66062113a95c0738df9bfc48192a35340f7a Mon Sep 17 00:00:00 2001 From: cb <12734117+cbhyphen@users.noreply.github.com> Date: Tue, 24 Jan 2023 20:44:27 -0800 Subject: [PATCH 1/2] udpate max k color test test currently has the same number of same-color pairs as different-color pairs. this would have helped me to realize it's a minimization problem quicker. --- tests/test_fitness.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_fitness.py b/tests/test_fitness.py index f7aeb47a..04739273 100644 --- a/tests/test_fitness.py +++ b/tests/test_fitness.py @@ -183,10 +183,10 @@ def test_queens(): @staticmethod def test_max_k_color(): """Test MaxKColor fitness function""" - edges = [(0, 1), (0, 2), (0, 4), (1, 3), (2, 0), (2, 3), (3, 4)] + edges = [(0, 1), (0, 2), (0, 4), (1, 3), (2, 0), (2, 3), (3, 4), (0, 5)] - state = np.array([0, 1, 0, 1, 1]) - assert MaxKColor(edges).evaluate(state) == 3 + state = np.array([0, 1, 0, 1, 1, 0]) + assert MaxKColor(edges).evaluate(state) == 4 @staticmethod def test_custom_fitness(): From 9f4ea3cec8d4dd52bbf225925e6bba9f6a02b9c6 Mon Sep 17 00:00:00 2001 From: cb <12734117+cbhyphen@users.noreply.github.com> Date: Tue, 24 Jan 2023 20:50:16 -0800 Subject: [PATCH 2/2] update doc string for max k color --- mlrose/fitness.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mlrose/fitness.py b/mlrose/fitness.py index 39d8b8ff..a17ddce7 100644 --- a/mlrose/fitness.py +++ b/mlrose/fitness.py @@ -892,11 +892,11 @@ class MaxKColor: >>> import mlrose >>> import numpy as np - >>> edges = [(0, 1), (0, 2), (0, 4), (1, 3), (2, 0), (2, 3), (3, 4)] + >>> edges = [(0, 1), (0, 2), (0, 4), (1, 3), (2, 0), (2, 3), (3, 4), (0, 5)] >>> fitness = mlrose.MaxKColor(edges) - >>> state = np.array([0, 1, 0, 1, 1]) + >>> state = np.array([0, 1, 0, 1, 1, 0]) >>> fitness.evaluate(state) - 3 + 4 Note ----