stevedwards / strong-graphs

A graph generator for strongly connected directed graphs with controllable features.
MIT License
1 stars 1 forks source link

Different distributions? #4

Open stevedwards opened 4 years ago

stevedwards commented 4 years ago

Currently the arc weights are just selected uniformly between bounds. I'd like to be more flexible

simonbowly commented 4 years ago

I think you're on the right track with the way you're passing distribution functions around, this should achieve what you want. Per issue #8, best to use a Random object here, and I'd suggest using partial instead of a lambda (but that's not really based on anything)...

rstate = random.Random(some_seed_value)

# Keep a distributions module of these?
def integer_log_normal(rstate, mu, sigma): return math.ceil(rstate.lognormvariate(mu=mu, sigma=sigma))

from functools import partial

network, tree, distances = build_instance(
        n,
        m,
        tree_weight_distribution=partial(rstate.randint, 0, 1000),
        non_tree_weight_distribution=partial(integer_log_normal, rstate, mu=1, sigma=5),
        arc_distribution=D3,
        ensure_non_negative=ensure_non_neg,
)
simonbowly commented 4 years ago

Also - switching between different distributions and their parameters using command line flags might start to get unwieldy. I was trying to figure out a specification for this sort of thing a while back (https://github.com/simonbowly/destined) to give a config file separate from the code that defines an instance distribution. For the LP/MIP stuff I ended up deciding that a python file with distributions as arguments was actually more readable.

stevedwards commented 4 years ago

I knew you would have sensible things to say about this! Yeah I started going down the path of command line flags for different distributions but it started feeling very messy. It looks like someone else used destined? That's cool.

simonbowly commented 4 years ago

Hmm nah that seems like an error in githubs dependency checker haha