Skip to content

Commit

Permalink
Adding tests, still need to gold
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimmy-INL committed Apr 27, 2024
1 parent 65ca176 commit 9bb29bc
Show file tree
Hide file tree
Showing 12 changed files with 2,159 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
<?xml version="1.0" ?>
<Simulation verbosity="debug" profile="jobs">
<TestInfo>
<name>raven/tests/framework/Optimizers/GA.MultiObjZDT1</name>
<author>Junyung Kim</author>
<created>2023-02-21</created>
<classesTested/>
<description>ZDT1 test using NSGA-II.
design variable $\vec{x} = [x1,x2,...x_n]; n here is equal to 3$

$obj_1(x) = x_1$

$g(x) = 1 + \frac{9}{n-1} \sum_{2}^{n} x_i = 1 + 4.5 * (x_2 + x_3)$

$h(obj1,g(x)) = 1 - \sqrt{\frac{obj_1}{g(x)}} = 1 - \sqrt(\frac{x_1}{1 + 4.5 * (x_2 + x_3)})$

$obj_2 = g(x) * h(obj_1,g(x))$ = [1 + 4.5 * (x_2 + x_3)] * \sqrt(x_1) * \sqrt(1 + 4.5 * (x_2 + x_3))

The analytic solution of this problem is as follows:
Pareto front:
$\vec{x}$:
$0 \leq x_1 \leq 1, x_2 = 0, x_3 = 0,$
$obj_1$:
$0 \leq obj_1 \leq 1$
$obj_2$
$1 \geq obj_1 \geq 0$

1.0 *
*
*
*
0.8 *
* o
* o
* o
0.6 * o
* o
obj_2 * o
* o
0.4 * o
* o
* o
* o
0.2 * o
* o
* o
* o
0 * o
/.......................................................................
0 0.2 0.4 0.6 0.8 1.0
obj_1 = x_1
</description>
</TestInfo>

<RunInfo>
<WorkingDir>ZDT1-adaptive-LinearXover-LinearMutation</WorkingDir>
<Sequence>optimize,print</Sequence>
<batchSize>1</batchSize>
</RunInfo>

<Steps>
<MultiRun name="optimize" re-seeding="2286">
<Input class="DataObjects" type="PointSet">placeholder</Input>
<Model class="Models" type="ExternalModel">ZDT</Model>
<Optimizer class="Optimizers" type="GeneticAlgorithm">GAopt</Optimizer>
<SolutionExport class="DataObjects" type="PointSet">opt_export</SolutionExport>
<Output class="DataObjects" type="PointSet">optOut</Output>
<Output class="OutStreams" type="Print">opt_export</Output>
</MultiRun>
<IOStep name="print">
<Input class="DataObjects" type="PointSet">opt_export</Input>
<Input class="DataObjects" type="PointSet">optOut</Input>
<Output class="OutStreams" type="Print">opt_export</Output>
<Output class="OutStreams" type="Print">optOut</Output>
<Output class="OutStreams" type="Plot">opt_path</Output>
<Output class="OutStreams" type="Plot">population</Output>
</IOStep>
</Steps>

<Models>
<ExternalModel ModuleToLoad="../../../../AnalyticModels/optimizing/ZDT_model.py" name="ZDT" subType="">
<variables>x1,x2,x3,obj1,obj2</variables>
</ExternalModel>
</Models>

<Distributions>
<Uniform name='unifDist'>
<lowerBound>0</lowerBound>
<upperBound>1</upperBound>
</Uniform>
</Distributions>

<Optimizers>
<GeneticAlgorithm name="GAopt">
<samplerInit>
<limit>15</limit>
<initialSeed>42</initialSeed>
<writeSteps>every</writeSteps>
<type>min,min</type>
</samplerInit>

<GAparams>
<populationSize>10</populationSize>
<parentSelection>tournamentSelection</parentSelection>
<reproduction>
<crossover type="twoPointsCrossover">
<crossoverProb type="adaptive">linear</crossoverProb>
</crossover>
<mutation type="randomMutator">
<mutationProb type="adaptive">linear</mutationProb>
</mutation>
</reproduction>
<fitness type="feasibleFirst">
</fitness>
<survivorSelection>rankNcrowdingBased</survivorSelection>
</GAparams>

<convergence>
<AHDp>0.0</AHDp>
</convergence>

<variable name="x1">
<distribution>unifDist</distribution>
</variable>
<variable name="x2">
<distribution>unifDist</distribution>
</variable>
<variable name="x3">
<distribution>unifDist</distribution>
</variable>
<objective>obj1, obj2 </objective>
<TargetEvaluation class="DataObjects" type="PointSet">optOut</TargetEvaluation>
<Sampler class="Samplers" type="MonteCarlo">MC_samp</Sampler>
</GeneticAlgorithm>
</Optimizers>

<Samplers>
<MonteCarlo name="MC_samp">
<samplerInit>
<limit>10</limit>
<initialSeed>050877</initialSeed>
</samplerInit>
<variable name="x1">
<distribution>unifDist</distribution>
</variable>
<variable name="x2">
<distribution>unifDist</distribution>
</variable>
<variable name="x3">
<distribution>unifDist</distribution>
</variable>
</MonteCarlo>
</Samplers>

<DataObjects>
<PointSet name="placeholder"/>
<PointSet name="optOut">
<Input>x1,x2,x3</Input>
<Output>obj1,obj2</Output>
</PointSet>
<PointSet name="opt_export">
<Input>trajID</Input>
<Output>x1,x2,x3,obj1,obj2,age,batchId,rank,CD,FitnessEvaluation_obj1,FitnessEvaluation_obj2,accepted </Output><!--Modify if necessary CD,iteration,accepted,conv_AHDp-->
</PointSet>
</DataObjects>

<OutStreams>
<Print name="optOut">
<type>csv</type>
<source>optOut</source>
</Print>
<Print name="opt_export">
<type>csv</type>
<source>opt_export</source>
<clusterLabel>trajID</clusterLabel>
</Print>
<Plot name = "opt_path" subType="OptPath">
<source>opt_export</source>
<vars>x1, x2, x3, obj1, obj2</vars>
</Plot>
<Plot name="population" subType="PopulationPlot">
<source> opt_export</source>
<vars>x1, x2, x3, obj1, obj2</vars>
<index>batchId</index>
<how>png</how>
</Plot>
</OutStreams>
</Simulation>
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
<?xml version="1.0" ?>
<Simulation verbosity="debug" profile="jobs">
<TestInfo>
<name>raven/tests/framework/Optimizers/GA.MultiObjZDT1</name>
<author>Junyung Kim</author>
<created>2023-02-21</created>
<classesTested/>
<description>ZDT1 test using NSGA-II.
design variable $\vec{x} = [x1,x2,...x_n]; n here is equal to 3$

$obj_1(x) = x_1$

$g(x) = 1 + \frac{9}{n-1} \sum_{2}^{n} x_i = 1 + 4.5 * (x_2 + x_3)$

$h(obj1,g(x)) = 1 - \sqrt{\frac{obj_1}{g(x)}} = 1 - \sqrt(\frac{x_1}{1 + 4.5 * (x_2 + x_3)})$

$obj_2 = g(x) * h(obj_1,g(x))$ = [1 + 4.5 * (x_2 + x_3)] * \sqrt(x_1) * \sqrt(1 + 4.5 * (x_2 + x_3))

The analytic solution of this problem is as follows:
Pareto front:
$\vec{x}$:
$0 \leq x_1 \leq 1, x_2 = 0, x_3 = 0,$
$obj_1$:
$0 \leq obj_1 \leq 1$
$obj_2$
$1 \geq obj_1 \geq 0$

1.0 *
*
*
*
0.8 *
* o
* o
* o
0.6 * o
* o
obj_2 * o
* o
0.4 * o
* o
* o
* o
0.2 * o
* o
* o
* o
0 * o
/.......................................................................
0 0.2 0.4 0.6 0.8 1.0
obj_1 = x_1
</description>
</TestInfo>

<RunInfo>
<WorkingDir>ZDT1-static-0.0Xover-0.0Mutation</WorkingDir>
<Sequence>optimize,print</Sequence>
<batchSize>1</batchSize>
</RunInfo>

<Steps>
<MultiRun name="optimize" re-seeding="2286">
<Input class="DataObjects" type="PointSet">placeholder</Input>
<Model class="Models" type="ExternalModel">ZDT</Model>
<Optimizer class="Optimizers" type="GeneticAlgorithm">GAopt</Optimizer>
<SolutionExport class="DataObjects" type="PointSet">opt_export</SolutionExport>
<Output class="DataObjects" type="PointSet">optOut</Output>
<Output class="OutStreams" type="Print">opt_export</Output>
</MultiRun>
<IOStep name="print">
<Input class="DataObjects" type="PointSet">opt_export</Input>
<Input class="DataObjects" type="PointSet">optOut</Input>
<Output class="OutStreams" type="Print">opt_export</Output>
<Output class="OutStreams" type="Print">optOut</Output>
<Output class="OutStreams" type="Plot">opt_path</Output>
<Output class="OutStreams" type="Plot">population</Output>
</IOStep>
</Steps>

<Models>
<ExternalModel ModuleToLoad="../../../../AnalyticModels/optimizing/ZDT_model.py" name="ZDT" subType="">
<variables>x1,x2,x3,obj1,obj2</variables>
</ExternalModel>
</Models>

<Distributions>
<Uniform name='unifDist'>
<lowerBound>0</lowerBound>
<upperBound>3</upperBound>
</Uniform>
</Distributions>

<Optimizers>
<GeneticAlgorithm name="GAopt">
<samplerInit>
<limit>15</limit>
<initialSeed>42</initialSeed>
<writeSteps>every</writeSteps>
<type>min,min</type>
</samplerInit>

<GAparams>
<populationSize>10</populationSize>
<parentSelection>tournamentSelection</parentSelection>
<reproduction>
<crossover type="twoPointsCrossover">
<crossoverProb>0.0</crossoverProb>
</crossover>
<mutation type="randomMutator">
<mutationProb>0.0</mutationProb>
</mutation>
</reproduction>
<fitness type="feasibleFirst">
</fitness>
<survivorSelection>rankNcrowdingBased</survivorSelection>
</GAparams>

<!-- <convergence>
<AHDp>0.0</AHDp>
</convergence> -->

<variable name="x1">
<distribution>unifDist</distribution>
</variable>
<variable name="x2">
<distribution>unifDist</distribution>
</variable>
<variable name="x3">
<distribution>unifDist</distribution>
</variable>
<objective>obj1, obj2 </objective>
<TargetEvaluation class="DataObjects" type="PointSet">optOut</TargetEvaluation>
<Sampler class="Samplers" type="MonteCarlo">MC_samp</Sampler>
</GeneticAlgorithm>
</Optimizers>

<Samplers>
<MonteCarlo name="MC_samp">
<samplerInit>
<limit>10</limit>
<initialSeed>050877</initialSeed>
</samplerInit>
<variable name="x1">
<distribution>unifDist</distribution>
</variable>
<variable name="x2">
<distribution>unifDist</distribution>
</variable>
<variable name="x3">
<distribution>unifDist</distribution>
</variable>
</MonteCarlo>
</Samplers>

<DataObjects>
<PointSet name="placeholder"/>
<PointSet name="optOut">
<Input>x1,x2,x3</Input>
<Output>obj1,obj2</Output>
</PointSet>
<PointSet name="opt_export">
<Input>trajID</Input>
<Output>x1,x2,x3,obj1,obj2,age,batchId,rank,CD,FitnessEvaluation_obj1,FitnessEvaluation_obj2,accepted </Output><!--Modify if necessary CD,iteration,accepted,conv_AHDp-->
</PointSet>
</DataObjects>

<OutStreams>
<Print name="optOut">
<type>csv</type>
<source>optOut</source>
</Print>
<Print name="opt_export">
<type>csv</type>
<source>opt_export</source>
<clusterLabel>trajID</clusterLabel>
</Print>
<Plot name = "opt_path" subType="OptPath">
<source>opt_export</source>
<vars>x1, x2, x3, obj1, obj2</vars>
</Plot>
<Plot name="population" subType="PopulationPlot">
<source> opt_export</source>
<vars>x1, x2, x3, obj1, obj2</vars>
<index>batchId</index>
<how>png</how>
</Plot>
</OutStreams>
</Simulation>
Loading

0 comments on commit 9bb29bc

Please sign in to comment.