forked from idaholab/raven
-
Notifications
You must be signed in to change notification settings - Fork 0
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
NSGA-II features Update on Optimizers/GeneticAlgorithm #12
Open
JunyungKim
wants to merge
91
commits into
Jimmy-INL:devel
Choose a base branch
from
JunyungKim:Junyung-Jimmy-NSGAII-ManualUpdate-DefectsFix
base: devel
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
91 commits
Select commit
Hold shift + click to select a range
061058e
NSGA-II implementation with properly printing optimal solutions at th…
JunyungKim ab4315c
Unnecessary changes in DataSet.py have been removed.
JunyungKim 8b7f5d3
Unnecessary changes in DataSet.py have been removed.
JunyungKim 3fcde82
ZDT test is added.
JunyungKim 15debe4
Optimizer.py and RavenSampled.py are updated after having regression …
JunyungKim 64510df
minor update on Optimizer.py
JunyungKim b1f0c3f
temporary fix, not the way I want
Jimmy-INL 52389c3
NSGA-II testing fiels (multiSum wConstratint and ZDT1) are added.
JunyungKim 391b9c3
moving models, xmls, and trying to resolve GD after converting object…
Jimmy-INL da9e0dd
fixing simulated annealing to accept a list of objectives
Jimmy-INL 1fd2175
fixing rook to compare infs
Jimmy-INL 7cedf83
Merge branch 'junyung-Mohammad-NSGAII' into JunyungKim-junyung-Mohamm…
Jimmy-INL 305c2ac
making one mod in RAVENSAmpled
Jimmy-INL c820eea
making self._minMax a list
Jimmy-INL 21bf42d
erroring out if type is not in ['min', 'max']
Jimmy-INL e639803
updating HERON to b316024
Jimmy-INL 12e11f0
Merge branch 'devel' into enablingMinMaxList
Jimmy-INL be64a4d
updating dependencies
Jimmy-INL ccde4d9
Merge branch 'enablingMinMaxList' of github.com:Jimmy-INL/raven into …
Jimmy-INL 95682a1
removing a trailing space
Jimmy-INL c3688e2
removing windows line endings
Jimmy-INL e25cc37
change to unix ending
Jimmy-INL f0d1412
adding the zdt_model.py
Jimmy-INL c2ca46e
converting zdt to unix line endings
Jimmy-INL 1f1b969
Juan's change to simulateData for the interface
Jimmy-INL c7aebf3
resolving diff based on different batch Size, thanks @wangcj05
Jimmy-INL 64e97a9
converting SimukateData.py to unix line endings
Jimmy-INL b29661b
regolding to print all batches in MOO
Jimmy-INL 9626956
slight mods
Jimmy-INL 34d5cb2
regolding and reverting inf in fitness
Jimmy-INL e0df314
trying to add all outputs to the rlz
Jimmy-INL c0476f7
adding everything to bestPoint
Jimmy-INL 81dc580
chenging type==str to len(self._objectVar) == 1
Jimmy-INL 3f27965
removing unnecessary if statement, this needs revisiting
Jimmy-INL facf74e
modifying reverting cycle length to its value not the inverse
Jimmy-INL a92049c
simulateData updating cost model.
0faeb9c
minor change is made in ZDT1 test.
JunyungKim e9ea9a2
Merge branch 'enablingMinMaxList' of https://github.com/Jimmy-INL/rav…
JunyungKim dbad22c
myConstraints for MultiSum is updated.
JunyungKim 699b3de
Two issues are resolved: population and objective value mismatch, min…
JunyungKim 8cffedb
minor things are corrected. Nothing important.
JunyungKim 9f4eecd
Additional minor changes are made. Nothing important.
JunyungKim 2487621
Additional minor change is made. Nothing important.
JunyungKim 3657634
fitness data structure is changed from data xarray to dataSet. It wor…
285575f
single objective optimization works well with three different types o…
7707f67
NSGA-II improvement is in progress.
a32a45c
fitness-based NSGA-II is in progress. min-min is working well with to…
a9577f4
NSGA-II fitness-based rank and CD calcuration is completed. Temporary…
9b42d7d
minor bugs are fixed.
f6ecb5f
Every type of fitness is now working with newly updated GA interface …
8a26285
multi-objective optimization using invLinear and logistics now works.
51eb867
constraint handling for single and multi objective optimization in _u…
061c3bc
1. If-else statement for survivorSelection in _useRealization is remo…
59d43e1
1. Mohammad's comments are reflected; 2. Unneccesary if-else statemen…
8fb32c3
1. missing descriptions of self are added.
4dc0e57
tournamentSelection method in parentSelectors.py is enhanced followin…
JunyungKim 4f457fe
tournamemntSelection for multi-objective is completed. RouletteWheel …
JunyungKim 9d27568
simpleKnapsackTournament optOut file is regoldened. Final solution is…
JunyungKim 255b58f
Comments from Mohammad are reflected.
JunyungKim f1ad2b3
Minor fixes to the fitness though a list of objective and penalty wei…
Jimmy-INL fae31be
Merge branch 'Junyung-Jimmy-enablingMinMaxList' into JunyungLatest-en…
JunyungKim ea59893
Merge pull request #3 from Jimmy-INL/JunyungLatest-enablingMinMaxList
JunyungKim d23ef44
test file for multi-objective optimization changed: the number of ite…
JunyungKim 44b0b54
method to convert InputData to XML node(s)
GabrielSoto-INL 80161ee
fixing input docstring
GabrielSoto-INL df6b98d
Junyung-Jimmy-enablingMinMaxList_vf_desk is merged to most-updated de…
f564f29
devel is merged with enabling MinMaxList_vf_desk.
02a961e
Modifications are done: All unit tests and GeneticAlgorithms-related …
JunyungKim ed460f9
SimulateData.py is now identical with the one from devel branch.
JunyungKim f339bf3
GeneticAlgorithm.py is updated. new file beale_flipped2.py is added. …
JunyungKim 261799a
Issues that RAVEN could not catch error when non-rankNCrowdingBased s…
JunyungKim 0259e38
unit test for convertToXML
GabrielSoto-INL fc625db
Merge pull request #2264 from GabrielSoto-INL/inputDataToXML
dylanjm 679ab96
Removing numexpr dependency. (#2287)
joshua-cogliati-inl d97a3d1
Add BayCal plugin (#2285)
wangcj05 ed708c7
LaTeX _ escape improvement (#2292)
joshua-cogliati-inl 677b474
RAVEN Manual related changes only are made.
JunyungKim cf67660
Minor changes are made. Functionally identical, just for readibility …
JunyungKim 916eda0
two methods related to survivorSelectors are moved to survivorSelecto…
JunyungKim 366974e
Some comments are left in fitness.py for future reference. invLinear …
JunyungKim ceb701d
Some comments are left in fitness.py for future reference. invLinear …
JunyungKim 35e65e7
Some comments are added/deleted.
JunyungKim c8ac5c9
some files in NSGAII folder which are already relocated to other fold…
JunyungKim ce0aaad
commentations and code cleaning is dnoe in GeneticAlgorithm.py. Funct…
JunyungKim cfd5b31
rlzDict in def _resolveNewGenerationMulti is updated to avoid SIMULAT…
JunyungKim 9d8941c
user manual related update - Equation correction
JunyungKim a055d68
Merge branch 'devel' into Junyung-Jimmy-NSGAII-ManualUpdate-DefectsFix
JunyungKim 580cad8
user manual related update - Equation correction
JunyungKim 06f4a46
very minor change made for user manuel.
JunyungKim a903939
survivorSelection.py is created.
JunyungKim 8482a39
contaminated HERON and TEAL is now back to RAVEN.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
ravenframework/Optimizers/survivorSelection/survivorSelection.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
# Copyright 2017 Battelle Energy Alliance, LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
""" | ||
Implementation of survivorSelection step for new generation | ||
selection process in Genetic Algorithm. | ||
|
||
Created Apr,3,2024 | ||
@authors: Mohammad Abdo, Junyung Kim | ||
""" | ||
# External Modules---------------------------------------------------------------------------------- | ||
import numpy as np | ||
import xarray as xr | ||
from ravenframework.utils import frontUtils | ||
# External Modules End------------------------------------------------------------------------------ | ||
|
||
# Internal Modules---------------------------------------------------------------------------------- | ||
from ...utils.gaUtils import dataArrayToDict, datasetToDataArray | ||
# Internal Modules End------------------------------------------------------------------------------ | ||
|
||
# @profile | ||
|
||
def singleObjSurvivorSelect(self, info, rlz, traj, offSprings, offSpringFitness, objectiveVal, g): | ||
if self.counter == 1: | ||
self.population = offSprings | ||
self.fitness = offSpringFitness | ||
self.objectiveVal = rlz[self._objectiveVar[0]].data | ||
else: | ||
self.population, self.fitness,\ | ||
self.popAge,self.objectiveVal = self._survivorSelectionInstance(age=self.popAge, | ||
variables=list(self.toBeSampled), | ||
population=self.population, | ||
fitness=self.fitness, | ||
newRlz=rlz, | ||
offSpringsFitness=offSpringFitness, | ||
popObjectiveVal=self.objectiveVal) | ||
|
||
def multiObjSurvivorSelect(self, info, rlz, traj, offSprings, offSpringFitness, objectiveVal, g): | ||
if self.counter == 1: | ||
self.population = offSprings | ||
self.fitness = offSpringFitness | ||
self.constraintsV = g | ||
# offspringObjsVals for Rank and CD calculation | ||
offObjVal = [] | ||
for i in range(len(self._objectiveVar)): | ||
offObjVal.append(list(np.atleast_1d(rlz[self._objectiveVar[i]].data))) | ||
|
||
# offspringFitVals for Rank and CD calculation | ||
fitVal = datasetToDataArray(self.fitness, self._objectiveVar).data | ||
offspringFitVals = fitVal.tolist() | ||
offSpringRank = frontUtils.rankNonDominatedFrontiers(np.array(offspringFitVals)) | ||
self.rank = xr.DataArray(offSpringRank, | ||
dims=['rank'], | ||
coords={'rank': np.arange(np.shape(offSpringRank)[0])}) | ||
offSpringCD = frontUtils.crowdingDistance(rank=offSpringRank, | ||
popSize=len(offSpringRank), | ||
objectives=np.array(offspringFitVals)) | ||
|
||
self.crowdingDistance = xr.DataArray(offSpringCD, | ||
dims=['CrowdingDistance'], | ||
coords={'CrowdingDistance': np.arange(np.shape(offSpringCD)[0])}) | ||
self.objectiveVal = [] | ||
for i in range(len(self._objectiveVar)): | ||
self.objectiveVal.append(list(np.atleast_1d(rlz[self._objectiveVar[i]].data))) | ||
else: | ||
self.population,self.rank, \ | ||
self.popAge,self.crowdingDistance, \ | ||
self.objectiveVal,self.fitness, \ | ||
self.constraintsV = self._survivorSelectionInstance(age=self.popAge, | ||
variables=list(self.toBeSampled), | ||
population=self.population, | ||
offsprings=rlz, | ||
popObjectiveVal=self.objectiveVal, | ||
offObjectiveVal=objectiveVal, | ||
popFit = self.fitness, | ||
offFit = offSpringFitness, | ||
popConstV = self.constraintsV, | ||
offConstV = g) | ||
|
||
self._collectOptPointMulti(self.population, | ||
self.rank, | ||
self.crowdingDistance, | ||
self.objectiveVal, | ||
self.fitness, | ||
self.constraintsV) | ||
self._resolveNewGenerationMulti(traj, rlz, info) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we have a folder called survivorSelectors and another called survivorSelection? Or did you mean to remove one?