How to go about implementing a random seed function?
nishraptor opened this issue · 4 comments
Hi, I want my metis partitions to accept a random seed option, so that the partitions are different at each seed. How would I go about implementing that? I know metis has this option.
I think the best way might be what I discussed with @nhartland in #24. Maybe the two of you can work together to come up with a PR?
Yeah that seems like a pretty natural part of an overall expansion of the runtime option passing.
While working on that is definitely on my radar, it's pretty far down my urgency list at the moment so it'll be a few weeks most likely until I can get to it.
I've had some time to think about the approach here.
As far as I can tell pybind11 supports the conversion of a python dict
to an STL map
. Although it's not 100% clear to me how smooth that will run in practice.
I'm inclined to keep the option passing as simple as possible. So if that binding does indeed work ok, I think it makes sense to pass pymetis.part_graph
an options dict of the form:
options = {
"METIS_OPTION_CONTIG": 1,
"METIS_OPTION_XXXX": YYYY
}
With pymetis.part_graph having a signature including
def part_graph( ...., options = {})
We can pass that through pybind, and in the wrapper code loop through the map keys setting the METIS options if/where they are present (we'll need another map of the string keys to the METIS enums but that's not a problem). The default value of options={}
being the fallback to the existing behaviour (don't set these options).
What do you think?