WISDEM / WOMBAT

Windfarm Operations & Maintenance cost-Benefit Analysis Tool
https://wisdem.github.io/WOMBAT/
Apache License 2.0
20 stars 11 forks source link

Random seed not respected when specified in configuration file that is loaded automatically given a library path and configuration file name #141

Closed hrnorton closed 2 months ago

hrnorton commented 6 months ago

I seem to have found a small bug in which the random seed I set in my configuration file is not being used in the simulation.

I created my simulation using Simulation() rather than the Simulation.from_config(). Unlike when using the from_config function, when using the default class initialization my random seed loads correctly as part of the Simulation.config attribute but is not applied to the Simulation.random_seed attribute directly. When Simulation._setup_simulation() calls, it passes only the random_seed attribute on the simulation object, not the version from the config attribute, when it instantiates the WombatEnvironment class. As a result, the environment detects no random seed.

Apologies if I have misunderstood something, but it seems like this is probably not the desired behaviour. Everything works fine if I pass the random seed directly as a parameter into the Simulation() function, or if I load using from_config(), so it seems to just be this one case which has the problem.

I am using WOMBAT v0.9.3.

RHammond2 commented 6 months ago

Thanks for catching this, @hrnorton! This seems to be a design inconsistency issue, so I should be able to get a quick fix for this into the develop branch. Would the desired behavior be to use the configuration's random seed if one isn't provided to the Simulation() call, otherwise have Simulation's override the configuration input?

RHammond2 commented 6 months ago

@hrnorton I've just opened PR #142, please let me know if this resolves your issue, or if there's something different you're needing for this fix.

hrnorton commented 6 months ago

That works, thanks!