Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessing generation number from inside evaluate() #99

Open
andresC98 opened this issue Jul 12, 2019 · 9 comments
Open

Accessing generation number from inside evaluate() #99

andresC98 opened this issue Jul 12, 2019 · 9 comments

Comments

@andresC98
Copy link

Is there any way we could actually access the Generation number (integer) from inside Evaluate() function?

@mikefenton
Copy link
Collaborator

Hi Andres,

You can just import the stats.stats object, we track the generation number there.

@andresC98
Copy link
Author

Thanks! Using stat.stats['gen'] was just what I was looking for!

@andresC98
Copy link
Author

Actually I noticed this does not work if using --multicore option (keeps having stats['gen''] = 0).

Is there any way to workaround this?

@andresC98 andresC98 reopened this Jul 22, 2019
@mikefenton
Copy link
Collaborator

Hmm, if that's true then it's a bug for sure. If you check the code for algorithm.search_loop.search_loop() you can see it's setting the stats['gen'] parameter in each iteration, independent of the multicore operation. Will investigate further.

@dvpfagan
Copy link
Collaborator

dvpfagan commented Jul 23, 2019 via email

@mikefenton
Copy link
Collaborator

@andresC98 can you provide the parameters file you used to produce this error? Running tests here and everything appears to be in order.

@andresC98
Copy link
Author

Sure! I am using a very simple parameters file, with my custom grammar and fitness function:

CODON_SIZE: 100000
GENERATIONS: 10
MAX_GENOME_LENGTH: 500
GRAMMAR_FILE: mlpGrammar.pybnf
POPULATION_SIZE: 15
FITNESS_FUNCTION: NescNNclasGE

and when running the script I add the --multicore option.

I am using a custom fitness function for classification, following the template (I correctly import from fitness.base_ff_classes.base_ff import base_ff and initialize class as super.__init__() , etc).

As you mentioned, I also import stats.stats and when I am accessing the stats dictionary key for 'gen' inside the evaluation function, but always prints "0". However, running the script (with the exact same code for the fitness function) without --multicore works just fine printing correctly the generation number value.

@MarkusEvo
Copy link

Hey, did this Issue ever get solved?

@dvpfagan
Copy link
Collaborator

dvpfagan commented Dec 24, 2020 via email

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

No branches or pull requests

4 participants