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

Sim3 interface multicycle optimization #2350

Draft
wants to merge 93 commits into
base: devel
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 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
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
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
97a20bc
the branch, Junyung-Jimmy-NSGAII-ManualUpdate-DefectsFix, is now merg…
May 23, 2024
372f384
trailing whitespaces are removed.
May 23, 2024
289094e
Issues created due to having objective variable type be List are part…
May 23, 2024
7b66055
MultiObjective_Beale-Bealeflipped is added.
May 23, 2024
542943e
[WIP] Crossover.py and GeneticAlgorithm.py have been modified to incl…
jluque-inl Jul 18, 2024
e13f190
Interface changes for multicycle optimization 7/18
jluque-inl Jul 19, 2024
a762df1
RAVEN/SIM3 Interface updated to work with quarter rotational symmetry…
jluque-inl Jul 31, 2024
13f6791
Core average burnup extractor for nth cycle opt was added
jluque-inl Aug 6, 2024
6935456
Changes made to the interface for octant symmetry
jluque-inl Aug 16, 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
3 changes: 0 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 Down
2 changes: 1 addition & 1 deletion dependencies.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,4 @@ Note all install methods after "main" take
<python>remove</python>
<nomkl>remove</nomkl>
</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
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def YY(Input):#Complete this: give the function the correct name#
return g


def XX(Input):#You are free to pick this name but it has to be similar to the one in the xml#
def expConstr1(Input): #You are free to pick this name but it has to be similar to the one in the xml#
"""
Let's assume that the constraint is:
$ x3+x4 < 8 $
Expand All @@ -54,7 +54,7 @@ def XX(Input):#You are free to pick this name but it has to be similar to the on
@ In, Input, object, RAVEN container
@ out, g, float, explicit constraint 1 evaluation function
"""
g = # Write the explicit constraint here
g = Input.x3 + Input.x4 - 8 # Write the explicit constraint here
return g

def expConstr2(Input):
Expand All @@ -76,7 +76,7 @@ def impConstr1(Input):
@ In, Input, object, RAVEN container
@ out, g, float, implicit constraint 1 evaluation function
"""
return 10 - Input.x1**2 - Input.obj
return 10 - Input.x1**2 - Input.ans

def impConstr2(Input):
"""
Expand All @@ -85,5 +85,5 @@ def impConstr2(Input):
@ In, Input, object, RAVEN container
@ out, g, float, implicit constraint 2 evaluation function
"""
g = Input.x1**2 + Input.obj - 10
g = Input.x1**2 + Input.ans - 10
return g
4 changes: 2 additions & 2 deletions doc/workshop/optimizer/GeneticAlgorithms/Models/LocalSum.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def evaluate(Inputs):
Sum = 0
for ind,var in enumerate(Inputs.keys()):
# write the objective function here
Sum +=
Sum += (ind+1) * Inputs[var]
return Sum[:]

def run(self,Inputs):
Expand All @@ -40,4 +40,4 @@ def run(self,Inputs):
@ In, Inputs, dict, additional inputs
@ Out, None
"""
self.?? = evaluate(Inputs) # Complete This # make sure the name of the objective is consistent obj
self.ans = evaluate(Inputs) # Complete This # make sure the name of the objective is consistent obj
226 changes: 175 additions & 51 deletions ravenframework/CodeInterfaceClasses/SIMULATE3/SimulateData.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.
"""
Created on June 04, 2022
@author: khnguy22 NCSU
@author: khnguy22 NCSU, luquj NCSU

comments: Interface for SIMULATE3 loading pattern optimzation
"""
Expand All @@ -36,13 +36,17 @@ def __init__(self,filen):
# retrieve data
self.data['axial_mesh'] = self.axialMeshExtractor()
self.data['keff'] = self.coreKeffEOC()
self.data['FDeltaH'] = self.maxFDH()
self.data["MaxFDH"] = self.maxFDH()
self.data["kinf"] = self.kinfEOC()
self.data["boron"] = self.boronEOC()
self.data["max_boron"] = self.boronEOC()
self.data["cycle_length"] = self.EOCEFPD()
self.data["PinPowerPeaking"] = self.pinPeaking()
self.data["pin_peaking"] = self.pinPeaking()
self.data["exposure"] = self.burnupEOC()
self.data["assembly_power"] = self.assemblyPeakingFactors()
self.data["neutron_leakage"] = self.neutron_leakage()
self.data["core_avg_burnup"] = self.core_avg_burnup()
# self.data["assembly_power"] = self.assemblyPeakingFactors()
# self.data["fuel_cost"] = self.fuel_cost()

# this is a dummy variable for demonstration with MOF
# check if something has been found
if all(v is None for v in self.data.values()):
Expand Down Expand Up @@ -142,52 +146,52 @@ def coreKeffEOC(self):
return outputDict


def assemblyPeakingFactors(self):
"""
Extracts the assembly radial power peaking factors as a dictionary
with the depletion step in GWD/MTU as the dictionary keys.
@ In, None
@ Out, outputDict, dict, the dictionary containing the read data (None if none found)
{'info_ids':list(of ids of data),
'values': list}
"""
radialPowerDictionary = {}
searching_ = False
outputDict = None
for line in self.lines:
if "Case" in line and "GWd/MT" in line:
elems = line.strip().split()
depl = elems[-2]
if depl in radialPowerDictionary:
pass
else:
radialPowerDictionary[depl] = {}
if "** H- G- F- E- D- C- B- A- **" in line:
searching_ = False

if searching_:
elems = line.strip().split()
if elems[0] == "**":
posList = elems[1:-1]
else:
radialPowerDictionary[depl][elems[0]] = {}
for i,el in enumerate(elems[1:-1]):
radialPowerDictionary[depl][elems[0]][posList[i]] = float(el)

if "PRI.STA 2RPF - Assembly 2D Ave RPF - Relative Power Fraction" in line:
searching_ = True

if not radialPowerDictionary:
return ValueError("No values returned. Check Simulate File executed correctly")
else:
maxPeaking = 0.0
for depl in radialPowerDictionary:
for row in radialPowerDictionary[depl]:
for col in radialPowerDictionary[depl][row]:
maxPeaking = max(radialPowerDictionary[depl][row][col],maxPeaking)
outputDict = {'info_ids':['FA_peaking'], 'values': [maxPeaking] }

return outputDict
# def assemblyPeakingFactors(self):
# """
# Extracts the assembly radial power peaking factors as a dictionary
# with the depletion step in GWD/MTU as the dictionary keys.
# @ In, None
# @ Out, outputDict, dict, the dictionary containing the read data (None if none found)
# {'info_ids':list(of ids of data),
# 'values': list}
# """
# radialPowerDictionary = {}
# searching_ = False
# outputDict = None
# for line in self.lines:
# if "Case" in line and "GWd/MT" in line:
# elems = line.strip().split()
# depl = elems[-2]
# if depl in radialPowerDictionary:
# pass
# else:
# radialPowerDictionary[depl] = {}
# if "** H- G- F- E- D- C- B- A- **" in line:
# searching_ = False

# if searching_:
# elems = line.strip().split()
# if elems[0] == "**":
# posList = elems[1:-1]
# else:
# radialPowerDictionary[depl][elems[0]] = {}
# for i,el in enumerate(elems[1:-1]):
# radialPowerDictionary[depl][elems[0]][posList[i]] = float(el)

# if "PRI.STA 2RPF - Assembly 2D Ave RPF - Relative Power Fraction" in line:
# searching_ = True

# if not radialPowerDictionary:
# return ValueError("No values returned. Check Simulate File executed correctly")
# else:
# maxPeaking = 0.0
# for depl in radialPowerDictionary:
# for row in radialPowerDictionary[depl]:
# for col in radialPowerDictionary[depl][row]:
# maxPeaking = max(radialPowerDictionary[depl][row][col],maxPeaking)
# outputDict = {'info_ids':['FA_peaking'], 'values': [maxPeaking] }

# return outputDict

def EOCEFPD(self):
"""
Expand Down Expand Up @@ -256,6 +260,8 @@ def pinPeaking(self):
spot = elems.index('Max-3PIN')
list_.append(float(elems[spot+1]))

print(f"This is Fq={max(list_)}")

if not list_:
return ValueError("No values returned. Check Simulate File executed correctly")
else:
Expand Down Expand Up @@ -486,6 +492,124 @@ def burnupEOC(self):

return outputDict

def fuel_cost(self):
"""
Extracts the fuel types used in the core map and calculates the fuel cost based on a front end approach.
This function applies only to quarter core symmetries.
@ In, Non
@ Out, outputDict, dict, the dictionary containing the rea data (None if non found)
{'info_ids': list(of ids of data),
'values': list}
"""
outputDict = None
# First, we need to parse the core map from the output file.
# NOTE: Given that a run is not needed to know the Loading Pattern, this function could be on the input side.
FA_list = []
for line in self.lines:
if "'FUE.TYP'" in line:
p1 = line.index(",")
p2 = line.index("/")
search_space = line[p1:p2]
search_space = search_space.replace(",","")
temp = search_space.split()
for i in temp:
FA_list.append(float(i))
FA_types = list(set(FA_list))
quartcore_size = len(temp)

# We separate the core map depending on how many times their elements are counted in the symmetry:
# FA_list_A counted once, as it is the center of the core.
# FA_list_B counted twice, as they are are the centerlines.
# FA_list_C counted four times, as they are are the rest of fuel assemblies.
FA_list_A = FA_list[0]
FA_list_B = FA_list[1:quartcore_size] + FA_list[quartcore_size:quartcore_size*(quartcore_size-1)+1:quartcore_size]
FA_list_C = []
for i in range(quartcore_size-1):
FA_list_C.append(FA_list[(i+1)*quartcore_size + 1: (i+2)*quartcore_size])
FA_list_C = [item for sublist in FA_list_C for item in sublist] # To flatten FA_list_C
# Now we proceed to count how many fuel types of each type are there in our core.
FA_count_A = [float(fa == FA_list_A) for fa in FA_types]
FA_count_B = [float(FA_list_B.count(fa)*2) for fa in FA_types]
FA_count_C = [float(FA_list_C.count(fa)*4) for fa in FA_types]
FA_count = [FA_count_A[j] + FA_count_B[j] + FA_count_C[j] for j in range(len(FA_types))]
# And create a dictionary with all the fuel types count.
FA_types_dict = {int(FA_types[i]):FA_count[i] for i in range(len(FA_types))}

# Dictionary with the unit cost for each FA type.

# FA type 0 = empty -> M$ 0.0
# FA type 1 = reflector -> M$ 0.0
# FA type 2 = 2.00 wt% -> M$ 2.69520839
# FA type 3 = 2.50 wt% -> M$ 3.24678409
# FA type 4 = 2.50 wt% + Gd -> M$ 3.24678409
# FA type 5 = 3.20 wt% -> M$ 4.03739539
# FA type 6 = 3.20 wt% + Gd -> M$ 4.03739539
# The cost of burnable poison is not being considered.

cost_dict = {
0: 0,
1: 0,
2: 2.69520839,
3: 3.24678409,
4: 3.24678409,
5: 4.03739539,
6: 4.03739539
}

fuel_cost = 0
for fuel_type, fuel_count in FA_types_dict.items():
fuel_cost += fuel_count * cost_dict[fuel_type]

if not fuel_cost:
return ValueError("No values returned. Check Simulate file executed correctly.")
else:
outputDict = {'info_ids':['fuel_cost'], 'values': [fuel_cost]}
return outputDict

def neutron_leakage(self):
"""
Returns Maximum neutron leakage found in the current cycle.
@ In, None
@ Out, outputDict, dict, the dictionary containing the read data (None if none found)
{'info_ids':list(of ids of data),
'values': list}
"""
outputDict = None
leakage_list = []
for line in self.lines:
if "Total Neutron Leakage" in line:
elems = line.strip().split()
leakage_list.append(float(elems[-1]))
if not leakage_list:
return ValueError("No values returned. Check Simulate File executed correctly")
else:
outputDict = {'info_ids':['neutron_leakage'], 'values':[10000*max(leakage_list)]}
return outputDict

def core_avg_burnup(self):
"""
Returns the accumulated average core burnup at EOC.
@ In, None
@ Out, outputDict, dict, the dictionary containing the read data (None if none found)
{'info_ids':list(of ids of data),
'values': list}
"""
list_ = []
outputDict = None
for line in self.lines:
if "Core Average Exposure" in line:
if "EBAR" in line:
elems = line.strip().split()
spot = elems.index("EBAR")
list_.append(float(elems[spot+1]))
print(list_)
print(list_[-1])
if not list_:
return ValueError("No values returned. Check Simulate file executed correctly.")
else:
outputDict = {'info_ids':['core_avg_exp'], 'values': [list_[-1]]}
return outputDict

def writeCSV(self, fileout):
"""
Print Data into CSV format
Expand Down
Loading