Skip to content

Conversation

elmbeech
Copy link
Contributor

@elmbeech elmbeech commented Jun 13, 2025

Take warned_rng variable global to be able to suppress the mislead message 'WARNING: Setting the random seed again.' when models in consecutive episodes are run.

This issue was discussed with @drbergman on slack 2025-05-22:

Elmar Bucher 8:40 AM
Good morning, Daniel.
I have a question.
Could we change the this warning slightly, as suggested below?
Or is there a static variable I could set, before I run the second episode, that this warning not occurs?
I thought this is not a problem, but it even confused my collaborators.
WARNING: Setting the random seed again.
        You probably have set a user parameter called random_seed, if you are not running a series of episodes of your model.
        If so, we will use the random seed set in user parameters.
        HOWEVER, as of PhysiCell 1.14.0, you should set the random seed in the <options><random_seed> element in the config file.
        Future versions of PhysiCell may throw an error here. Kindly remove the user parameter and just use the <options><random_seed> element. 

Daniel Bergman 8:53 AM
I thought about this when we were discussing your PR. 
I think what I liked best was a global variable that would take the place of the boolean warned. 
maybe call it issue_rng_warning and then when running episodes, you can set it to false (and it will be set to false after issuing the warning once, regardless)

Elmar Bucher 8:55 AM
i agree, this would be a proper solution!
should i make a PR? do you think this will be accepted?

Daniel Bergman 8:56 AM
set it to false in the episodes project after either loading from the XML (when rng should be set first) or at the end of the first episode
yeah, go for it!

Elmar Bucher 11:05 AM
ok! i will.
though might take some days. because of school work i have to take care.
but definitely will make sure that this is in the next release!
11:05
thank you!

Daniel Bergman
All good by me. I’m in no rush for this

@drbergman drbergman requested a review from Copilot June 26, 2025 19:28
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the random seed warning behavior by promoting the warned_rng variable to a global scope to allow controlled suppression of the warning when running consecutive episodes. It also updates the platform macro check for directory creation on Windows.

  • Promotes warned_rng to a global variable to manage warning behavior.
  • Updates preprocessor directives for Windows platform checks.
  • Adjusts configuration file processing in episode projects.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
sample_projects/episode/main.cpp Sets warned_rng to true to suppress redundant RNG warning
modules/PhysiCell_settings.cpp Updates Windows macro detection for directory creation
core/PhysiCell_utilities.h Declares warned_rng globally instead of using local/static variable
core/PhysiCell_utilities.cpp Replaces static warned with the global warned_rng variable
Comments suppressed due to low confidence (2)

sample_projects/episode/main.cpp:163

  • Consider adding a brief comment explaining why warned_rng is set to true here to suppress the RNG warning, clarifying that this is intended for consecutive episode runs.
			warned_rng = true;

modules/PhysiCell_settings.cpp:360

  • Verify that replacing the previous mingw-specific conditions with _WIN32 covers all intended Windows scenarios, including MinGW builds, to prevent any potential platform-specific regressions.
#if defined(_WIN32)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants