mirror of
https://github.com/ANL-CEEESA/MIPLearn.git
synced 2025-12-06 01:18:52 -06:00
MaxCut: add w_jitter parameter to control edge weight randomization
This commit is contained in:
@@ -52,29 +52,23 @@ def test_maxcut_generator_fixed() -> None:
|
||||
n=randint(low=5, high=6),
|
||||
p=uniform(loc=0.5, scale=0.0),
|
||||
fix_graph=True,
|
||||
w_jitter=0.25,
|
||||
)
|
||||
data = gen.generate(3)
|
||||
assert len(data) == 3
|
||||
assert list(data[0].graph.nodes()) == [0, 1, 2, 3, 4]
|
||||
assert list(data[0].graph.edges()) == [
|
||||
(0, 2),
|
||||
(0, 3),
|
||||
(0, 4),
|
||||
(2, 3),
|
||||
(2, 4),
|
||||
(3, 4),
|
||||
]
|
||||
assert data[0].weights.tolist() == [-1, 1, -1, -1, -1, 1]
|
||||
assert list(data[1].graph.nodes()) == [0, 1, 2, 3, 4]
|
||||
assert list(data[1].graph.edges()) == [
|
||||
(0, 2),
|
||||
(0, 3),
|
||||
(0, 4),
|
||||
(2, 3),
|
||||
(2, 4),
|
||||
(3, 4),
|
||||
]
|
||||
assert data[1].weights.tolist() == [-1, -1, -1, 1, -1, -1]
|
||||
for i in range(3):
|
||||
assert list(data[i].graph.nodes()) == [0, 1, 2, 3, 4]
|
||||
assert list(data[i].graph.edges()) == [
|
||||
(0, 2),
|
||||
(0, 3),
|
||||
(0, 4),
|
||||
(2, 3),
|
||||
(2, 4),
|
||||
(3, 4),
|
||||
]
|
||||
assert data[0].weights.tolist() == [-1, -1, 1, 1, -1, 1]
|
||||
assert data[1].weights.tolist() == [-1, -1, -1, -1, 1, -1]
|
||||
assert data[2].weights.tolist() == [1, 1, -1, -1, -1, 1]
|
||||
|
||||
|
||||
def test_maxcut_model():
|
||||
|
||||
Reference in New Issue
Block a user