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

NSGA-II features Update on Optimizers/GeneticAlgorithm #12

Open
wants to merge 91 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 90 commits
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 Feb 19, 2023
ab4315c
Unnecessary changes in DataSet.py have been removed.
JunyungKim Feb 19, 2023
8b7f5d3
Unnecessary changes in DataSet.py have been removed.
JunyungKim Feb 19, 2023
3fcde82
ZDT test is added.
JunyungKim Feb 22, 2023
15debe4
Optimizer.py and RavenSampled.py are updated after having regression …
JunyungKim Feb 24, 2023
64510df
minor update on Optimizer.py
JunyungKim Feb 24, 2023
b1f0c3f
temporary fix, not the way I want
Jimmy-INL Mar 11, 2023
52389c3
NSGA-II testing fiels (multiSum wConstratint and ZDT1) are added.
JunyungKim Mar 13, 2023
391b9c3
moving models, xmls, and trying to resolve GD after converting object…
Jimmy-INL Mar 14, 2023
da9e0dd
fixing simulated annealing to accept a list of objectives
Jimmy-INL Mar 21, 2023
1fd2175
fixing rook to compare infs
Jimmy-INL Mar 22, 2023
7cedf83
Merge branch 'junyung-Mohammad-NSGAII' into JunyungKim-junyung-Mohamm…
Jimmy-INL Mar 22, 2023
305c2ac
making one mod in RAVENSAmpled
Jimmy-INL Apr 1, 2023
c820eea
making self._minMax a list
Jimmy-INL Apr 3, 2023
21bf42d
erroring out if type is not in ['min', 'max']
Jimmy-INL Apr 3, 2023
e639803
updating HERON to b316024
Jimmy-INL Apr 3, 2023
12e11f0
Merge branch 'devel' into enablingMinMaxList
Jimmy-INL Apr 3, 2023
be64a4d
updating dependencies
Jimmy-INL Apr 4, 2023
ccde4d9
Merge branch 'enablingMinMaxList' of github.com:Jimmy-INL/raven into …
Jimmy-INL Apr 4, 2023
95682a1
removing a trailing space
Jimmy-INL Apr 4, 2023
c3688e2
removing windows line endings
Jimmy-INL Apr 4, 2023
e25cc37
change to unix ending
Jimmy-INL Apr 5, 2023
f0d1412
adding the zdt_model.py
Jimmy-INL Apr 5, 2023
c2ca46e
converting zdt to unix line endings
Jimmy-INL Apr 5, 2023
1f1b969
Juan's change to simulateData for the interface
Jimmy-INL Apr 6, 2023
c7aebf3
resolving diff based on different batch Size, thanks @wangcj05
Jimmy-INL Apr 6, 2023
64e97a9
converting SimukateData.py to unix line endings
Jimmy-INL Apr 8, 2023
b29661b
regolding to print all batches in MOO
Jimmy-INL Apr 11, 2023
9626956
slight mods
Jimmy-INL Apr 12, 2023
34d5cb2
regolding and reverting inf in fitness
Jimmy-INL Apr 12, 2023
e0df314
trying to add all outputs to the rlz
Jimmy-INL Apr 12, 2023
c0476f7
adding everything to bestPoint
Jimmy-INL Apr 13, 2023
81dc580
chenging type==str to len(self._objectVar) == 1
Jimmy-INL Apr 13, 2023
3f27965
removing unnecessary if statement, this needs revisiting
Jimmy-INL Apr 18, 2023
facf74e
modifying reverting cycle length to its value not the inverse
Jimmy-INL Apr 20, 2023
a92049c
simulateData updating cost model.
Jun 12, 2023
0faeb9c
minor change is made in ZDT1 test.
JunyungKim Jul 15, 2023
e9ea9a2
Merge branch 'enablingMinMaxList' of https://github.com/Jimmy-INL/rav…
JunyungKim Jul 17, 2023
dbad22c
myConstraints for MultiSum is updated.
JunyungKim Jul 27, 2023
699b3de
Two issues are resolved: population and objective value mismatch, min…
JunyungKim Aug 8, 2023
8cffedb
minor things are corrected. Nothing important.
JunyungKim Aug 8, 2023
9f4eecd
Additional minor changes are made. Nothing important.
JunyungKim Aug 8, 2023
2487621
Additional minor change is made. Nothing important.
JunyungKim Aug 8, 2023
3657634
fitness data structure is changed from data xarray to dataSet. It wor…
Aug 30, 2023
285575f
single objective optimization works well with three different types o…
Aug 31, 2023
7707f67
NSGA-II improvement is in progress.
Sep 4, 2023
a32a45c
fitness-based NSGA-II is in progress. min-min is working well with to…
Sep 6, 2023
a9577f4
NSGA-II fitness-based rank and CD calcuration is completed. Temporary…
Sep 7, 2023
9b42d7d
minor bugs are fixed.
Sep 10, 2023
f6ecb5f
Every type of fitness is now working with newly updated GA interface …
Sep 17, 2023
8a26285
multi-objective optimization using invLinear and logistics now works.
Sep 21, 2023
51eb867
constraint handling for single and multi objective optimization in _u…
Sep 21, 2023
061c3bc
1. If-else statement for survivorSelection in _useRealization is remo…
Sep 25, 2023
59d43e1
1. Mohammad's comments are reflected; 2. Unneccesary if-else statemen…
Sep 26, 2023
8fb32c3
1. missing descriptions of self are added.
Sep 26, 2023
4dc0e57
tournamentSelection method in parentSelectors.py is enhanced followin…
JunyungKim Oct 14, 2023
4f457fe
tournamemntSelection for multi-objective is completed. RouletteWheel …
JunyungKim Oct 15, 2023
9d27568
simpleKnapsackTournament optOut file is regoldened. Final solution is…
JunyungKim Oct 15, 2023
255b58f
Comments from Mohammad are reflected.
JunyungKim Jan 29, 2024
f1ad2b3
Minor fixes to the fitness though a list of objective and penalty wei…
Jimmy-INL Jan 29, 2024
fae31be
Merge branch 'Junyung-Jimmy-enablingMinMaxList' into JunyungLatest-en…
JunyungKim Jan 29, 2024
ea59893
Merge pull request #3 from Jimmy-INL/JunyungLatest-enablingMinMaxList
JunyungKim Jan 29, 2024
d23ef44
test file for multi-objective optimization changed: the number of ite…
JunyungKim Jan 29, 2024
44b0b54
method to convert InputData to XML node(s)
GabrielSoto-INL Feb 16, 2024
80161ee
fixing input docstring
GabrielSoto-INL Feb 16, 2024
df6b98d
Junyung-Jimmy-enablingMinMaxList_vf_desk is merged to most-updated de…
Feb 26, 2024
f564f29
devel is merged with enabling MinMaxList_vf_desk.
Mar 4, 2024
02a961e
Modifications are done: All unit tests and GeneticAlgorithms-related …
JunyungKim Mar 6, 2024
ed460f9
SimulateData.py is now identical with the one from devel branch.
JunyungKim Mar 6, 2024
f339bf3
GeneticAlgorithm.py is updated. new file beale_flipped2.py is added. …
JunyungKim Mar 6, 2024
261799a
Issues that RAVEN could not catch error when non-rankNCrowdingBased s…
JunyungKim Mar 20, 2024
0259e38
unit test for convertToXML
GabrielSoto-INL Mar 20, 2024
fc625db
Merge pull request #2264 from GabrielSoto-INL/inputDataToXML
dylanjm Mar 21, 2024
679ab96
Removing numexpr dependency. (#2287)
joshua-cogliati-inl Mar 26, 2024
d97a3d1
Add BayCal plugin (#2285)
wangcj05 Mar 26, 2024
ed708c7
LaTeX _ escape improvement (#2292)
joshua-cogliati-inl Apr 2, 2024
677b474
RAVEN Manual related changes only are made.
JunyungKim Apr 2, 2024
cf67660
Minor changes are made. Functionally identical, just for readibility …
JunyungKim Apr 2, 2024
916eda0
two methods related to survivorSelectors are moved to survivorSelecto…
JunyungKim Apr 2, 2024
366974e
Some comments are left in fitness.py for future reference. invLinear …
JunyungKim Apr 2, 2024
ceb701d
Some comments are left in fitness.py for future reference. invLinear …
JunyungKim Apr 2, 2024
35e65e7
Some comments are added/deleted.
JunyungKim Apr 2, 2024
c8ac5c9
some files in NSGAII folder which are already relocated to other fold…
JunyungKim Apr 2, 2024
ce0aaad
commentations and code cleaning is dnoe in GeneticAlgorithm.py. Funct…
JunyungKim Apr 2, 2024
cfd5b31
rlzDict in def _resolveNewGenerationMulti is updated to avoid SIMULAT…
JunyungKim Apr 3, 2024
9d8941c
user manual related update - Equation correction
JunyungKim Apr 3, 2024
a055d68
Merge branch 'devel' into Junyung-Jimmy-NSGAII-ManualUpdate-DefectsFix
JunyungKim Apr 3, 2024
580cad8
user manual related update - Equation correction
JunyungKim Apr 3, 2024
06f4a46
very minor change made for user manuel.
JunyungKim Apr 3, 2024
a903939
survivorSelection.py is created.
JunyungKim Apr 3, 2024
8482a39
contaminated HERON and TEAL is now back to RAVEN.
May 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "plugins/TEAL"]
path = plugins/TEAL
url = https://github.com/idaholab/TEAL.git
[submodule "plugins/HERON"]
path = plugins/HERON
url = https://github.com/idaholab/HERON.git
Expand All @@ -16,3 +13,6 @@
[submodule "plugins/FARM"]
path = plugins/FARM
url = https://github.com/Argonne-National-Laboratory/FARM.git
[submodule "plugins/BayCal"]
path = plugins/BayCal
url = https://github.com/idaholab/BayCal.git
5 changes: 1 addition & 4 deletions dependencies.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ Note all install methods after "main" take
<importlib_metadata/>
<pyside2 optional='True'/>
<nomkl os='linux' skip_check='True'/>
<numexpr os='linux'/>
<cmake skip_check='True' optional='True'/>
<dask source="pip" pip_extra="[complete]"/>
<ray source="pip" pip_extra="[default]">2.6</ray>
Expand Down Expand Up @@ -97,7 +96,6 @@ Note all install methods after "main" take
<pip>remove</pip>
<python>remove</python>
<nomkl>remove</nomkl>
<numexpr>remove</numexpr>
<liblapack>remove</liblapack>
</alternate>
<alternate name="none">
Expand All @@ -106,6 +104,5 @@ Note all install methods after "main" take
<pip>remove</pip>
<python>remove</python>
<nomkl>remove</nomkl>
<numexpr>remove</numexpr>
</alternate>
</dependencies>
</dependencies>
14 changes: 7 additions & 7 deletions doc/user_manual/generated/generateOptimizerDoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def insertSolnExport(tex, obj):
</samplerInit>

<GAparams>
<populationSize>20</populationSize>
<populationSize>10</populationSize>
<parentSelection>rouletteWheel</parentSelection>
<reproduction>
<crossover type="onePointCrossover">
Expand All @@ -177,32 +177,32 @@ def insertSolnExport(tex, obj):

<variable name="x1">
<distribution>uniform_dist_woRepl_1</distribution>
<initial>1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20</initial>
<initial>1,2,3,4,5,6,7,8,9,10</initial>
</variable>

<variable name="x2">
<distribution>uniform_dist_woRepl_1</distribution>
<initial>2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,1</initial>
<initial>2,3,4,5,6,7,8,9,10,1</initial>
</variable>

<variable name="x3">
<distribution>uniform_dist_woRepl_1</distribution>
<initial>3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,1,2</initial>
<initial>3,4,5,6,7,8,9,10,1,2</initial>
</variable>

<variable name="x4">
<distribution>uniform_dist_woRepl_1</distribution>
<initial>4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,1,2,3</initial>
<initial>4,5,6,7,8,9,10,1,2,3</initial>
</variable>

<variable name="x5">
<distribution>uniform_dist_woRepl_1</distribution>
<initial>5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,1,2,3,4</initial>
<initial>5,6,7,8,9,10,1,2,3,4</initial>
</variable>

<variable name="x6">
<distribution>uniform_dist_woRepl_1</distribution>
<initial>6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,1,2,3,4,5</initial>
<initial>6,7,8,9,10,1,2,3,4,5</initial>
</variable>

<objective>ans</objective>
Expand Down
202 changes: 189 additions & 13 deletions doc/user_manual/generated/internalRom.tex

Large diffs are not rendered by default.

573 changes: 573 additions & 0 deletions doc/user_manual/generated/optimizer.tex

Large diffs are not rendered by default.

560 changes: 289 additions & 271 deletions doc/user_manual/generated/sklRom.tex

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions plugins/BayCal
Submodule BayCal added at 348b6e
1 change: 0 additions & 1 deletion plugins/TEAL
Submodule TEAL deleted from 97e32d
827 changes: 588 additions & 239 deletions ravenframework/Optimizers/GeneticAlgorithm.py

Large diffs are not rendered by default.

17 changes: 11 additions & 6 deletions ravenframework/Optimizers/GradientDescent.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ def __init__(self):
self._followerProximity = 1e-2 # distance at which annihilation can start occurring, in ?normalized? space
self._trajectoryFollowers = defaultdict(list) # map of trajectories to the trajectories following them
self._functionalConstraintExplorationLimit = 500 # number of input-space explorations allowable for functional constraints
self._canHandleMultiObjective = False # Currently Gradient Descent cannot handle multiobjective optimization
# __private
# additional methods
# register adaptive sample identification criteria
Expand Down Expand Up @@ -338,7 +339,11 @@ def _useRealization(self, info, rlz):
@ Out, None
"""
traj = info['traj']
optVal = rlz[self._objectiveVar]
# if not self._canHandleMultiObjective and len(self._objectiveVar) == 1:
# self._objectiveVar = self._objectiveVar[0]
if len(self._objectiveVar) > 1 and type(self._objectiveVar)==list:
self.raiseAnError(IOError, 'Gradient Descent does not support multiObjective optimization yet! objective variable must be a single variable for now!')
optVal = rlz[self._objectiveVar[0]]
info['optVal'] = optVal
purpose = info['purpose']
if purpose.startswith('opt'):
Expand All @@ -353,13 +358,13 @@ def _useRealization(self, info, rlz):
gradMag, gradVersor, _ = self._gradientInstance.evaluate(opt,
grads,
gradInfos,
self._objectiveVar)
self._objectiveVar[0])
self.raiseADebug(' ... gradient calculated ...')
self._gradHistory[traj].append((gradMag, gradVersor))
# get new step information
try:
newOpt, stepSize, stepInfo = self._stepInstance.step(opt,
objVar=self._objectiveVar,
objVar=self._objectiveVar[0],
optHist=self._optPointHistory[traj],
gradientHist=self._gradHistory[traj],
prevStepSize=self._stepHistory[traj],
Expand All @@ -378,7 +383,7 @@ def _useRealization(self, info, rlz):
except NoConstraintResolutionFound:
# we've tried everything, but we just can't hack it
self.raiseAMessage(f'Optimizer "{self.name}" trajectory {traj} was unable to continue due to functional or boundary constraints.')
self._closeTrajectory(traj, 'converge', 'no constraint resolution', opt[self._objectiveVar])
self._closeTrajectory(traj, 'converge', 'no constraint resolution', opt[self._objectiveVar[0]])
return

# update values if modified by constraint handling
Expand Down Expand Up @@ -598,7 +603,7 @@ def _checkAcceptability(self, traj, opt, optVal, info):
# Check acceptability
if self._optPointHistory[traj]:
old, _ = self._optPointHistory[traj][-1]
oldVal = old[self._objectiveVar]
oldVal = old[self._objectiveVar[0]]
# check if following another trajectory
if self._terminateFollowers:
following = self._stepInstance.trajIsFollowing(traj, self.denormalizeData(opt), info,
Expand Down Expand Up @@ -815,7 +820,7 @@ def _checkConvObjective(self, traj):
return False
o1, _ = self._optPointHistory[traj][-1]
o2, _ = self._optPointHistory[traj][-2]
delta = mathUtils.relativeDiff(o2[self._objectiveVar], o1[self._objectiveVar])
delta = mathUtils.relativeDiff(o2[self._objectiveVar[0]], o1[self._objectiveVar[0]])
converged = abs(delta) < self._convergenceCriteria['objective']
self.raiseADebug(self.convFormat.format(name='objective',
conv=str(converged),
Expand Down
16 changes: 10 additions & 6 deletions ravenframework/Optimizers/Optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ def getInputSpecification(cls):
specs.description = 'Optimizers'

# objective variable
specs.addSub(InputData.parameterInputFactory('objective', contentType=InputTypes.StringType, strictMode=True,
specs.addSub(InputData.parameterInputFactory('objective', contentType=InputTypes.StringListType, strictMode=True,
printPriority=90, # more important than <variable>
descr=r"""Name of the response variable (or ``objective function'') that should be optimized
(minimized or maximized)."""))
descr=r"""Name of the objective variable(s) (or ``objective function'') that should be optimized
(minimized or maximized). It can be a single string or a list of strings if it is a multi-objective problem. """))

# modify Sampler variable nodes
variable = specs.getSub('variable')
Expand All @@ -103,7 +103,8 @@ def getInputSpecification(cls):
descr=r"""seed for random number generation. Note that by default RAVEN uses an internal seed,
so this seed must be changed to observe changed behavior. \default{RAVEN-determined}""")
minMaxEnum = InputTypes.makeEnumType('MinMax', 'MinMaxType', ['min', 'max'])
minMax = InputData.parameterInputFactory('type', contentType=minMaxEnum,
minMaxList = InputTypes.StringListType()
minMax = InputData.parameterInputFactory('type', contentType=minMaxList,
descr=r"""the type of optimization to perform. \xmlString{min} will search for the lowest
\xmlNode{objective} value, while \xmlString{max} will search for the highest value.""")
init.addSub(seed)
Expand Down Expand Up @@ -160,7 +161,7 @@ def __init__(self):
# public
# _protected
self._seed = None # random seed to apply
self._minMax = 'min' # maximization or minimization?
self._minMax = ['min'] # maximization or minimization?
self._activeTraj = [] # tracks live trajectories
self._cancelledTraj = {} # tracks cancelled trajectories, and reasons
self._convergedTraj = {} # tracks converged trajectories, and values obtained
Expand Down Expand Up @@ -248,7 +249,6 @@ def handleInput(self, paramInput):
@ Out, None
"""
# the reading of variables (dist or func) and constants already happened in _readMoreXMLbase in Sampler
# objective var
self._objectiveVar = paramInput.findFirst('objective').value

# sampler init
Expand All @@ -263,6 +263,10 @@ def handleInput(self, paramInput):
minMax = init.findFirst('type')
if minMax is not None:
self._minMax = minMax.value
if len(self._minMax) != len(self._objectiveVar):
self.raiseAnError(IOError, 'The length of <type> in <Optimizers>-<GeneticAlgorithm>-<SamplerInit> and <objective> in <Optimizers>-<GeneticAlgorithm> must be of the same length!')
if list(set(self._minMax)-set(['min','max'])) != []:
self.raiseAnError(IOError, "<type> under <Optimizers>-<GeneticAlgorhtm> must be a either 'min' and/or 'max'")

# variables additional reading
for varNode in paramInput.findAll('variable'):
Expand Down
Loading