Closed sleepymalc closed 2 years ago
Hi,
As I understand, the instance generators (ecole.instance.SetCoverGenerator
) are python generators (https://docs.python.org/3/glossary.html#term-generator) so you can iterate over them or access the next item by calling next(instance_generator)
. Here's a small snippet that generates train_size
.lp files and saves them to file at my/output/path/special_instance_name_{i}.lp
:
import ecole
train_size = 10
rng = ecole.RandomGenerator(0)
instance_generator = ecole.instance.SetCoverGenerator(n_rows=500, n_cols=1000, density=0.5, rng=rng)
for i, instance in enumerate(instance_generator):
if i == train_size:
break
instance.write_problem(f"my/output/path/special_instance_name_{i}.lp")
Hi @sleepymalc
@amf272's solution works. You can use the write_problem
on the instances you created.
Hi! I'm currently looking at learn2branch-ecole reimplementation and want to reproduce some of the results. But since the file seems incomplete, specifically, there are no
01_generate_instances.py
mentioned in theREADME
, hence I decide to do it myself as I think this is rather simple.As far as I can tell, here is how the official reimplementation creates a dataset for setcover:
I'm not sure how to store files ended in
.lp
generated bywhich I assume should be the right way to generate instances for
instances_train
in this case by iterating throughtrain_size
.Thanks for helping!