kstaats / karoo_gp

A Genetic Programming platform for Python with TensorFlow for wicked-fast CPU and GPU support.
Other
159 stars 61 forks source link

Can't use "t" in the pause menu twice in a row #12

Closed DestyNova closed 5 years ago

DestyNova commented 5 years ago

If I run in interactive mode (I've also seen it at the end of a "minimal" mode run), then I can use the pause menu at most once per generation:

  2 trees [ 1 38] offer the highest fitness scores.

         (pause) t
...
 Confusion matrix:
[[3072  984]
 [2997  947]]

         (pause) t
         Select from the options given. Try again ...

         (pause) ?
         Select from the options given. Try again ...

         (pause) p
         Select from the options given. Try again ...

         (pause) 30
         Select from the options given. Try again ...

I'm guessing it's some kind of parsing bug where the state of some buffer is left inconsistent after the first "t" operation. All I can do now is hit enter and let the next generation run, after which I'll be able to use "t" on (at most) one of the winners from that generation.

DestyNova commented 5 years ago

Okay, a quick snoop in the source code revealed that when you get to the "real" pause menu, you're in the pause function around line 21 of modules/karoo_gp_pause.py, which looks like this:

    options = ['','?','help','i','m','g','s','db','ts','min','bal','l','pop','t','p','id','dir','load','w','cont','q']

    while True:
        try:
            menu = raw_input('\n\t\033[36m (pause) \033[0;0m')
            if menu not in options: raise ValueError()
            else: break
        except ValueError: print '\t\033[32m Select from the options given. Try again ...\033[0;0m'
        except KeyboardInterrupt: print '\n\t\033[32m Enter q to quit\033[0;0m'

However after you've entered a command it doesn't bring you back to this place; instead it brings you to an identical looking prompt (and error message) in the fx_karoo_pause function, around line 319 of modules/karoo_gp_base_class.py, which looks like this:

        if pause == 0: # ENTER enables next step in generational, interactive, and debug display
            while True:
                try:
                    query = raw_input('\n\t\033[36m (pause) \033[0;0m')
                    if query not in ['']: raise ValueError()
                    else: break 
                except ValueError: print '\t\033[32m Select from the options given. Try again ...\033[0;0m'
                except KeyboardInterrupt: print '\n\t\033[32m Enter q to quit\033[0;0m'

The problem here is that the only valid input is the empty string. I guess what we want is that the "generic" pause mode is used (with all the introspection options)... will try to fix it here and do a PR, although I'm not sure if other parts of the code will have problems with the new behaviour of pause.

ByteSumoLtd commented 5 years ago

@DestyNova -- fyi if you are playing with the code. I have fork too and have been been playing around with some minor changes. https://github.com/ByteSumoLtd/karoo_gp/commits/master

kstaats commented 5 years ago

Let's jump on the phone to discuss. A few things I want to improve, just no time :)

On 1/25/19 4:17 PM, Andrew Morgan wrote:

@DestyNova -- fyi if you are playing with the code. I have fork too and have been been playing around with some minor changes. https://github.com/ByteSumoLtd/karoo_gp/commits/master

kstaats commented 5 years ago

To DestyNova's original issue, I offer my sincere apology for a lack of follow-through. My research in an totally different arena has dominated my time for several months. Now, my work at LIGO is bringing me back to SIMOC again, with a need to not only look into an correct these known, outstanding issues, but also bring Karoo up to Python 3.x.

I appreciate your patience, and look forward to providing an improved product soon.

kstaats commented 5 years ago

The final Python 2.7 version of Karoo has been pushed to github. I am now returning to active development of Karoo. The next task is to improve the means by which I present and execute the functions of the Pause menu, so as to remove the potential for this loop. I will look at ByteSumo's mods and implement soon. Stay tuned!

kstaats commented 5 years ago

This is fully resolved with the new Karoo GP 2.3 for Python 3.6. The menu functions are fully rebuilt with no nested loops. Please sync with the latest version and we'll call this closed! :)