Skip to content

Commit

Permalink
changes only in 3 files: GA, and 2 workshop exercises (#2012)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimmy-INL authored Nov 15, 2022
1 parent d2e8c31 commit 959b9c1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
</Models>

<Distributions>
<UniformDiscrete name='woRep_dist'><!--Fill this in-->
<UniformDiscrete name='woRep_dist'>
<lowerBound>2</lowerBound>
<upperBound>7</upperBound>
<strategy>withoutReplacement</strategy>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</Steps>

<Models>
<ExternalModel ModuleToLoad="../../Models/myLocalSum.py" name="myLocalSum" subType="">
<ExternalModel ModuleToLoad="../../Models/LocalSum.py" name="myLocalSum" subType="">
<variables>x1,x2,x3,x4,x5,x6,obj</variables>
</ExternalModel>
</Models>
Expand All @@ -55,15 +55,15 @@
<Optimizers>
<GeneticAlgorithm name="GAopt">
<samplerInit>
<limit>15</limit><!--Complete this-->
<limit>15</limit>
<initialSeed>42</initialSeed>
<writeSteps>every</writeSteps>
<type>min</type><!--Complete this-->
<type></type><!--Complete this-->
</samplerInit>

<GAparams>
<populationSize>20</populationSize><!--Complete this-->
<parentSelection>rouletteWheel</parentSelection><!--Complete this-->
<populationSize>20</populationSize>
<parentSelection>rouletteWheel</parentSelection>
<reproduction>
<crossover type="onePointCrossover">
<crossoverProb>0.8</crossoverProb>
Expand All @@ -76,7 +76,7 @@
<a>1.0</a>
<b>1.0</b>
</fitness>
<survivorSelection>fitnessBased</survivorSelection><!--Complete this-->
<survivorSelection>fitnessBased</survivorSelection>
</GAparams>

<convergence>
Expand Down
17 changes: 12 additions & 5 deletions ravenframework/Optimizers/GeneticAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,18 @@ def getInputSpecification(cls):
contentType=InputTypes.StringType,
printPriority=108,
descr=r"""a subnode containing the implemented fitness functions.
This includes: a. invLinear: $fitness = -a \times obj - b \times \sum_{j=1}^{nConstraint} max(0,-penalty\_j) $.
b. logistic: $fitness = \frac{1}{1+e^{a\times(obj-b)}}$.
c. feasibleFirst: $fitness = \left\{\begin{matrix} -obj & g_j(x)\geq 0 \; \forall j \\ -obj_{worst}- \Sigma_{j=1}^{J}<g_j(x)> & otherwise \\ \end{matrix}\right.$""")
This includes: \begin{itemize}
\item invLinear:
\[fitness = -a \times obj - b \times \sum\\_{j=1}^{nConstraint} max(0,-penalty\\_j) \].
\item logistic:
\[fitness = \frac{1}{1+e^{a\times(obj-b)}}\].
\item
feasibleFirst: \[fitness =
-obj \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \text{for} \ \ g\\_j(x)\geq 0 \; \forall j\] and
\[fitness = -obj\\_{worst} - \Sigma\\_{j=1}^{J}<g\\_j(x)> \ \ \ \ \ \ \ \ otherwise \]
\end{itemize}.""")
fitness.addParam("type", InputTypes.StringType, True,
descr=r"""[invLin, logistic, feasibleFirst]""")
objCoeff = InputData.parameterInputFactory('a', strictMode=True,
Expand Down

0 comments on commit 959b9c1

Please sign in to comment.