mirror of
https://github.com/ANL-CEEESA/MIPLearn.git
synced 2025-12-06 09:28:51 -06:00
Knapsack: Make jitter relative instead of absolute
This commit is contained in:
@@ -23,32 +23,3 @@ def test_knapsack_generator():
|
||||
assert round(np.mean(w_sum), -1) == 500.
|
||||
assert round(np.mean(p_sum), -1) == 1250.
|
||||
assert round(np.mean(b_sum), -3) == 25000.
|
||||
|
||||
|
||||
def test_knapsack_fixed_weights_jitter():
|
||||
gen = MultiKnapsackGenerator(n=randint(low=50, high=51),
|
||||
m=randint(low=10, high=11),
|
||||
w=randint(low=0, high=1000),
|
||||
K=randint(low=500, high=501),
|
||||
u=uniform(loc=1.0, scale=0.0),
|
||||
alpha=uniform(loc=0.50, scale=0.0),
|
||||
fix_w=True,
|
||||
w_jitter=randint(low=0, high=1),
|
||||
)
|
||||
instances = gen.generate(100)
|
||||
w = [instance.weights[0,0] for instance in instances]
|
||||
assert np.std(w) == 0.
|
||||
|
||||
gen = MultiKnapsackGenerator(n=randint(low=1, high=2),
|
||||
m=randint(low=10, high=11),
|
||||
w=randint(low=1000, high=1001),
|
||||
K=randint(low=500, high=501),
|
||||
u=uniform(loc=1.0, scale=0.0),
|
||||
alpha=uniform(loc=0.50, scale=0.0),
|
||||
fix_w=True,
|
||||
w_jitter=randint(low=0, high=1001),
|
||||
)
|
||||
instances = gen.generate(5_000)
|
||||
w = [instance.weights[0,0] for instance in instances]
|
||||
assert round(np.std(w), -1) == 290.
|
||||
assert round(np.mean(w), -2) == 1500.
|
||||
Reference in New Issue
Block a user