MoseleyBioinformaticsLab / SAGA_optimize

Combined simulated annealing and genetic algorithm (SAGA) for model parameter optimization
BSD 3-Clause Clear License
6 stars 2 forks source link

ElementDescription option "mutateRandomRangedInteger" causes exception. #2

Open jmmitc06 opened 2 years ago

jmmitc06 commented 2 years ago

Created an initial guess as follows:

chromosome = [SAGA_optimize.ElementDescription(low=0, high=1, mutate="mutateRandomRangedInteger") for _ in genes]

Then created a SAGA instance per the tutorial and called optimize. This results in an exception stating that too many parameters are passed to the ElementDescription on line 143:

TypeError: ElementDescription._mutateRandomRangedInteger() takes 1 positional argument but 3 were given.

Removing the argument eliminates the error:

chromosome = [SAGA_optimize.ElementDescription(low=0, high=1) for _ in genes]

The call signature for _mutateRandomRangedInteger on line 48 (and maybe _mutateRandomRangedFloat on line 42 as well) might be incorrect given what line 143 is doing. The call signatures for the population informed versions of these mutation operators appear to take 3 parameters. If you concur, I can fix, test, and submit pull request.

Possibly related: perhaps I should be using 'mutatePopulationRangedInteger' instead? The difference is not described in the documentation.

jmmitc06 commented 2 years ago

To clarify,chromosome = [SAGA_optimize.ElementDescription(low=0, high=1, mutate="mutatePopulationRangedInteger") for _ in genes] does not produce the exception.

hunter-moseley commented 2 years ago

Josh,

I made a mistake when I indicated mutateRandomRangedFloat. This is the direct mutate function. It was supposed to be mutatePopulationRangedInteger which is the population initialization function.

The difference is population initialization versus mutation.

Warm regards, Hunter

On Wed, May 25, 2022 at 2:45 PM jmmitc06 @.***> wrote:

To clarify, chromosome = [SAGAoptimize.ElementDescription(low=0, high=1, mutate="mutatePopulationRangedInteger") for in genes] does not produce the exception.

— Reply to this email directly, view it on GitHub https://github.com/MoseleyBioinformaticsLab/SAGA_optimize/issues/2#issuecomment-1137708661, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADEP7B5DVG2QUIFUA27GSWDVLZYMFANCNFSM5W6BO6OA . You are receiving this because you are subscribed to this thread.Message ID: @.*** com>

-- Hunter Moseley, Ph.D. -- Univ. of Kentucky Associate Professor, Dept. of Molec. & Cell. Biochemistry / Markey Cancer Center / Institute for Biomedical Informatics / UK Superfund Research Center Not just a scientist, but a fencer as well. My foil is sharp, but my mind sharper still.

Email: @. (work) @. (personal) Phone: 859-218-2964 (office) 859-218-2965 (lab) 859-257-7715 (fax) Web: http://bioinformatics.cesb.uky.edu/ Address: CC434 Roach Building, 800 Rose Street, Lexington, KY 40536-0093

jmmitc06 commented 2 years ago

Thanks for the clarification. That change got my analysis working.

However, I don't think the non-population versions of the functions will not work as currently implemented and it seems implied that they should work in this context as they are used anywhere outside of:


        self.mutateCollections = {'mutateRandomRangedFloat': self._mutateRandomRangedFloat, 'mutateRandomRangedInteger': self._mutateRandomRangedInteger, 'mutatePopulationRangedFloat': self._mutatePopulationRangedFloat, 'mutatePopulationRangedInteger': self._mutatePopulationRangedInteger}
        self.mutate = self._mutatePopulationRangedFloat if mutate is None else self.mutateCollections[mutate]

I can still fix it, no big deal.

hunter-moseley commented 2 years ago

Josh,

Go ahead and submit a pull request.

On Wed, May 25, 2022 at 3:18 PM jmmitc06 @.***> wrote:

Thanks for the clarification. That change got my analysis working.

However, I don't think the non-population versions of the functions will not work as currently implemented and it seems implied that they should work in this context as they are used anywhere outside of:

    self.mutateCollections = {'mutateRandomRangedFloat': self._mutateRandomRangedFloat, 'mutateRandomRangedInteger': self._mutateRandomRangedInteger, 'mutatePopulationRangedFloat': self._mutatePopulationRangedFloat, 'mutatePopulationRangedInteger': self._mutatePopulationRangedInteger}
    self.mutate = self._mutatePopulationRangedFloat if mutate is None else self.mutateCollections[mutate]

I can still fix it, no big deal.

— Reply to this email directly, view it on GitHub https://github.com/MoseleyBioinformaticsLab/SAGA_optimize/issues/2#issuecomment-1137759139, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADEP7BZPZ2GI3ARQOP53GNDVLZ4JVANCNFSM5W6BO6OA . You are receiving this because you commented.Message ID: @.***>

-- Hunter Moseley, Ph.D. -- Univ. of Kentucky Associate Professor, Dept. of Molec. & Cell. Biochemistry / Markey Cancer Center / Institute for Biomedical Informatics / UK Superfund Research Center Not just a scientist, but a fencer as well. My foil is sharp, but my mind sharper still.

Email: @. (work) @. (personal) Phone: 859-218-2964 (office) 859-218-2965 (lab) 859-257-7715 (fax) Web: http://bioinformatics.cesb.uky.edu/ Address: CC434 Roach Building, 800 Rose Street, Lexington, KY 40536-0093