Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions mlrose/fitness.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
----
Expand Down
6 changes: 3 additions & 3 deletions tests/test_fitness.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down