def test_generate_instance(instance_generator): """Use stateless instance generating function.""" if isinstance(instance_generator, ecole.instance.FileGenerator): pytest.skip("No generate_instance for file loaders") InstanceGenerator = type(instance_generator) model = InstanceGenerator.generate_instance( random_engine=ecole.RandomEngine()) assert isinstance(model, ecole.scip.Model)
def test_RandomEngine(): """Test bindings of the RandomEngine.""" assert ecole.RandomEngine.min_seed < ecole.RandomEngine.max_seed random_engine = ecole.RandomEngine(42) rand_val_1 = random_engine() assert isinstance(rand_val_1, int) random_engine.seed(42) rand_val_2 = random_engine() assert rand_val_1 == rand_val_2
def test_RandomEngine_copy(): """Copy create a new RandomEngine with same state.""" random_engine = ecole.RandomEngine(42) random_engine_copy = copy.copy(random_engine) assert random_engine_copy == random_engine assert random_engine_copy is not random_engine random_engine_deepcopy = copy.deepcopy(random_engine) assert random_engine_deepcopy == random_engine assert random_engine_deepcopy is not random_engine
def test_seed(): """Random engine is consumed.""" env = MockEnvironment() env.seed(33) assert env.random_engine == ecole.RandomEngine(33)
def test_generate_instance(instance_generator): """Use stateless instance generating function.""" InstanceGenerator = type(instance_generator) model = InstanceGenerator.generate_instance( random_engine=ecole.RandomEngine()) assert isinstance(model, ecole.scip.Model)
def test_random_engine_init(instance_generator): """Construct a random engine.""" type(instance_generator)(random_engine=ecole.RandomEngine())
def test_RandomEngine_pickle(): """Pickle preserve the state of the RandomEngine.""" random_engine = ecole.RandomEngine(42) assert random_engine == pickle.loads(pickle.dumps(random_engine))
def test_set_random_state(self, model): """Random engine is consumed.""" random_engine = ecole.RandomEngine(33) self.dynamics.set_dynamics_random_state(model, random_engine) assert random_engine != ecole.RandomEngine(33)
def test_random_engine_init(instance_generator): """Construct a random engine.""" if isinstance(instance_generator, ecole.instance.FileGenerator): pytest.skip("No dataset in default directory") type(instance_generator)(random_engine=ecole.RandomEngine())