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

Adding adaptive mutation and crossover to Genetic Algorithms #11

Open
wants to merge 27 commits into
base: JunyungKim-Junyung-Jimmy-NSGAII_RegressionTest_UnitTest_Fix
Choose a base branch
from

Conversation

GEONKIM1
Copy link

@GEONKIM1 GEONKIM1 commented Mar 18, 2024

This is a new methodology about adaptive mutation and crossover.
Adaptive mutation : DHM/ILC, ILM/DHC(Linearly increasing or decreasing) , quadratic function method, step function method.
Adaptive crossover : DHM/ILC, ILM/DHC(Linearly increasing or decreasing) , quadratic function method

Pull Request Description

What issue does this change request address? (Use "#" before the issue to link it, i.e., idaholab#42.

Closes idaholab#2286

What are the significant changes in functionality due to this change request?

For Change Control Board: Change Request Review

The following review must be completed by an authorized member of the Change Control Board.

  • 1. Review all computer code.
  • 2. If any changes occur to the input syntax, there must be an accompanying change to the user manual and xsd schema. If the input syntax change deprecates existing input files, a conversion script needs to be added (see Conversion Scripts).
  • 3. Make sure the Python code and commenting standards are respected (camelBack, etc.) - See on the wiki for details.
  • 4. Automated Tests should pass, including run_tests, pylint, manual building and xsd tests. If there are changes to Simulation.py or JobHandler.py the qsub tests must pass.
  • 5. If significant functionality is added, there must be tests added to check this. Tests should cover all possible options. Multiple short tests are preferred over one large test. If new development on the internal JobHandler parallel system is performed, a cluster test must be added setting, in XML block, the node <internalParallel> to True.
  • 6. If the change modifies or adds a requirement or a requirement based test case, the Change Control Board's Chair or designee also needs to approve the change. The requirements and the requirements test shall be in sync.
  • 7. The merge request must reference an issue. If the issue is closed, the issue close checklist shall be done.
  • 8. If an analytic test is changed/added is the the analytic documentation updated/added?
  • 9. If any test used as a basis for documentation examples (currently found in raven/tests/framework/user_guide and raven/docs/workshop) have been changed, the associated documentation must be reviewed and assured the text matches the example.

ravenframework/Optimizers/GeneticAlgorithm.py Outdated Show resolved Hide resolved
ravenframework/Optimizers/GeneticAlgorithm.py Outdated Show resolved Hide resolved
ravenframework/Optimizers/GeneticAlgorithm.py Outdated Show resolved Hide resolved
@GEONKIM1 GEONKIM1 requested a review from Jimmy-INL April 1, 2024 21:08
@GEONKIM1 GEONKIM1 force-pushed the Geon-Adaptive_mutation_and_crossover_method branch from a5bfe23 to 98160fe Compare April 3, 2024 19:00
@GEONKIM1 GEONKIM1 requested a review from Jimmy-INL April 3, 2024 19:03
ravenframework/Optimizers/GeneticAlgorithm.py Outdated Show resolved Hide resolved
ravenframework/Optimizers/GeneticAlgorithm.py Show resolved Hide resolved
for ind,parent in enumerate(parentsPairs):
parent = np.array(parent).reshape(2,-1) # two parents at a time

if randomUtils.random(dim=1,samples=1) <= crossoverProb:
if randomUtils.random(dim=1,samples=1) <= kwargs['crossoverProb']:
if (kwargs['points'] == None) or ('points' not in kwargs.keys()):
Copy link
Owner

Choose a reason for hiding this comment

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

Why is this changed? Could you please remind me?

@@ -215,3 +212,49 @@ def uniformCrossoverMethod(parent1,parent2,crossoverProb):
children2[pos] = parent2[pos]

return children1,children2

def twoPointsCrossoverMethod2(parent1,parent2,locL,locU):
"""
Copy link
Owner

Choose a reason for hiding this comment

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

Is this a new function? Why is that? When will it be called?

@GEONKIM1 GEONKIM1 requested a review from Jimmy-INL April 10, 2024 22:51
@@ -91,7 +91,7 @@
<Samplers>
<MonteCarlo name="MC_samp">
<samplerInit>
<limit>10</limit>
<limit>20</limit>
<initialSeed>050877</initialSeed>
</samplerInit>
<variable name="x1">
Copy link
Owner

Choose a reason for hiding this comment

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

Is this the test? This doesn't test the adaptive crossover/mutation!!
Please modify this and compare the results, if this reaches convergence faster, please regold.

printPriority=108,
descr=r""" The probability governing the crossover step, i.e., the probability that if exceeded crossover will occur.""")
crossoverProbability.addParam("type", InputTypes.makeEnumType('crossoverProbability','crossoverProbabilityType',['static','adaptive']), True,
descr="type of crossover operation to be used (e.g., static,adaptive)")
Copy link
Owner

Choose a reason for hiding this comment

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

Please update description for more details. For instance, give more information about what static means and what adaptive means, and state that adaptive only accepts linear (explain and give the equation) and quadratic (explain and give the equation)

printPriority=108,
descr=r""" The probability governing the mutation step, i.e., the probability that if exceeded mutation will occur.""")
mutationProbability.addParam("type", InputTypes.makeEnumType('mutationProbability','mutationProbabilityType',['static','adaptive']), True,
descr="type of mutation probability operation to be used (e.g., static, adaptive)")
mutation.addSub(mutationProbability)
Copy link
Owner

Choose a reason for hiding this comment

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

same as above.

if(self._crossoverProbType == "static"):
crossOverProb = self._crossoverProb
if(self._crossoverProb == "linear"):
crossOverProb = getLinearCrossoverProbability(self.getIteration(traj),self.limit)
Copy link
Owner

Choose a reason for hiding this comment

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

What happens if the user enter's Linear instead of linear. when we spoke before I showed you that in the if statement you can add .lower() to convert the whole word to lower case. (e.g., if(self._crossoverProb.lower() == "linear"):).
In addition, what if the user entered something else other than linear or quadratic, their should be a final else that raises an error. self.raiseAnError(IOError, "{} is not implemeted!. Currently only 'linear' and 'quadratic' are implemented".format(self._crossoverProb))

@Jimmy-INL Jimmy-INL force-pushed the Geon-Adaptive_mutation_and_crossover_method branch from 7bb293f to 65ca176 Compare April 16, 2024 01:06
@GEONKIM1 GEONKIM1 requested a review from Jimmy-INL April 22, 2024 19:34
@Jimmy-INL Jimmy-INL force-pushed the Geon-Adaptive_mutation_and_crossover_method branch from ceb167b to 9bb29bc Compare April 27, 2024 15:44
@Jimmy-INL Jimmy-INL changed the base branch from JunyungKim-Junyung-Jimmy-NSGAII_RegressionTest_UnitTest_Fix to devel May 19, 2024 03:47
@Jimmy-INL Jimmy-INL changed the title Modified methodology: Adaptive mutation and crossover Adding adaptive mutation and crossover to Genetic Algorithms May 19, 2024
@Jimmy-INL Jimmy-INL changed the base branch from devel to JimmyTestingAdaptiveMutation-crossover May 20, 2024 19:37
@Jimmy-INL Jimmy-INL changed the base branch from JimmyTestingAdaptiveMutation-crossover to JunyungKim-Junyung-Jimmy-NSGAII_RegressionTest_UnitTest_Fix May 20, 2024 19:39
@Jimmy-INL Jimmy-INL changed the base branch from JunyungKim-Junyung-Jimmy-NSGAII_RegressionTest_UnitTest_Fix to devel May 21, 2024 20:47
@Jimmy-INL Jimmy-INL changed the base branch from devel to JunyungKim-Junyung-Jimmy-NSGAII_RegressionTest_UnitTest_Fix May 21, 2024 20:48
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.

[TASK] Enabling adaptive mutation and crossover in Genetic Algorithm
4 participants