Skip to content

Commit

Permalink
adding more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimmy-INL committed Mar 7, 2021
1 parent 91314f3 commit 086516c
Show file tree
Hide file tree
Showing 7 changed files with 46,622 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
<?xml version="1.0" ?>
<Simulation verbosity="debug" profile="jobs">
<TestInfo>
<name>framework/Optimizers/GA</name>
<author>MohammadAbdo</author>
<created>2020-05-16</created>
<classesTested>GeneticAlgorithm</classesTested>
<description>
This test assesses the Genetic algorithm on the Beale function.
The nominal dimensionality of the problem is 2.
The objective variable is ans.
</description>
<analytic>
This test uses Beale function, which is documented in the analytic tests documentation under
the Optimizer functions section.
</analytic>
</TestInfo>

<RunInfo>
<WorkingDir>Beale</WorkingDir>
<Sequence>optimize, print</Sequence>
<!-- <batchSize>8</batchSize>
<internalParallel>True</internalParallel> -->
<!-- <maxQueueSize>100</maxQueueSize> -->
</RunInfo>

<Steps>
<MultiRun name="optimize" >
<Input class="DataObjects" type="PointSet">placeholder</Input>
<Model class="Models" type="ExternalModel">beale</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>
</IOStep>
</Steps>

<Distributions>
<Uniform name='beale_dist'>
<lowerBound>-4.5</lowerBound>
<upperBound>4.5</upperBound>
</Uniform>
</Distributions>

<Optimizers>
<GeneticAlgorithm name="GAopt">
<samplerInit>
<limit>20</limit>
<initialSeed>42</initialSeed>
<writeSteps>every</writeSteps>
</samplerInit>

<GAparams>
<populationSize>60</populationSize>
<parentSelection>rouletteWheel</parentSelection>
<reproduction nParents="40">
<crossover type="onePointCrossover">
<crossoverProb>0.8</crossoverProb>
</crossover>
<mutation type="swapMutator">
<!-- <locs>2,5</locs> -->
<mutationProb>0.9</mutationProb>
</mutation>
</reproduction>
<fitness type="invLinear">
<a>2.0</a>
<b>1.0</b>
</fitness>
<survivorSelection>fitnessBased</survivorSelection>
</GAparams>

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

<variable name="x">
<distribution>beale_dist</distribution>
</variable>
<variable name="y">
<distribution>beale_dist</distribution>
</variable>

<objective>ans</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>60</limit>
<initialSeed>20021986</initialSeed>
</samplerInit>
<variable name="x">
<distribution>beale_dist</distribution>
</variable>
<variable name="y">
<distribution>beale_dist</distribution>
</variable>
</MonteCarlo>
</Samplers>

<Models>
<ExternalModel ModuleToLoad="../../../../../framework/AnalyticModels/optimizing/beale" name="beale" subType="">
<variables>x,y,ans</variables>
</ExternalModel>
</Models>

<DataObjects>
<PointSet name="placeholder"/>
<PointSet name="optOut">
<Input>x,y</Input>
<Output>ans</Output>
</PointSet>
<PointSet name="opt_export">
<Input>trajID</Input>
<Output>x,y,ans,age,batchId,fitness,iteration,accepted,AHDp,conv_AHDp</Output>
</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>
</OutStreams>
</Simulation>
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
<?xml version="1.0" ?>
<Simulation verbosity="debug">
<TestInfo>
<name>framework/Optimizers/GA/MinwReplacementConstrained</name>
<author>MohammadAbdo</author>
<created>2020-05-16</created>
<classesTested>GeneticAlgorithm</classesTested>
<description>
This test assesses the Genetic algorithm using on the myLocalSum function.
The nominal dimensionality of the problem is 5.
The objective variable is ans.
</description>
<analytic>
This test uses myLocalSum's function, which is documented in the analytic tests documentation under
the Optimizer functions section.
</analytic>
</TestInfo>

<RunInfo>
<WorkingDir>MaxwReplacementSphereConstrained</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">myLocalSum</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>
</IOStep>
</Steps>

<Distributions>
<UniformDiscrete name='uniform_dist_Repl_1'>
<lowerBound>1</lowerBound>
<upperBound>6</upperBound>
<strategy>withReplacement</strategy>
</UniformDiscrete>
<UniformDiscrete name='uniform_dist_woRepl_1'>
<lowerBound>1</lowerBound>
<upperBound>6</upperBound>
<strategy>withOutReplacement</strategy>
</UniformDiscrete>
</Distributions>

<Optimizers>
<GeneticAlgorithm name="GAopt">
<samplerInit>
<limit>40</limit>
<initialSeed>42</initialSeed>
<writeSteps>every</writeSteps>
<type>max</type>
</samplerInit>

<GAparams>
<populationSize>40</populationSize>
<parentSelection>rouletteWheel</parentSelection>
<reproduction nParents="20">
<crossover type="onePointCrossover">
<crossoverProb>0.8</crossoverProb>
</crossover>
<mutation type="swapMutator">
<mutationProb>0.9</mutationProb>
</mutation>
</reproduction>
<fitness type="feasibleFirst"></fitness>
<survivorSelection>fitnessBased</survivorSelection>
</GAparams>

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

<variable name="x1">
<distribution>uniform_dist_Repl_1</distribution>
</variable>

<variable name="x2">
<distribution>uniform_dist_Repl_1</distribution>
</variable>

<variable name="x3">
<distribution>uniform_dist_Repl_1</distribution>
</variable>

<objective>ans</objective>
<TargetEvaluation class="DataObjects" type="PointSet">optOut</TargetEvaluation>
<Constraint class='Functions' type='External'>constraint1</Constraint>
<Constraint class='Functions' type='External'>constraint2</Constraint>
<Sampler class="Samplers" type="MonteCarlo">MC_samp</Sampler>
</GeneticAlgorithm>
</Optimizers>

<Samplers>
<MonteCarlo name="MC_samp">
<samplerInit>
<limit>40</limit>
<initialSeed>20021986</initialSeed>
</samplerInit>
<variable name="x1">
<distribution>uniform_dist_Repl_1</distribution>
</variable>
<variable name="x2">
<distribution>uniform_dist_Repl_1</distribution>
</variable>
<variable name="x3">
<distribution>uniform_dist_Repl_1</distribution>
</variable>
</MonteCarlo>
</Samplers>

<Models>
<ExternalModel ModuleToLoad="../../../../../AnalyticModels/optimizing/myLocalSum.py" name="myLocalSum" subType="">
<variables>x1,x2,x3,ans</variables>
</ExternalModel>
</Models>

<Functions>
<External file="../../../../../AnalyticModels/optimizing/myLocalSum.py" name="constraint1">
<variables>x1,x2,x3</variables>
</External>
<External file="../../../../../AnalyticModels/optimizing/myLocalSumSphereConstraint.py" name="constraint2">
<variables>x1,x2,x3</variables>
</External>
</Functions>

<DataObjects>
<PointSet name="placeholder"/>
<PointSet name="optOut">
<Input>x1,x2,x3</Input>
<Output>ans</Output>
</PointSet>
<PointSet name="opt_export">
<Input>trajID</Input>
<Output>x1,x2,x3,ans,age,batchId,fitness,iteration,accepted,AHDp,conv_AHDp</Output>
</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>
</OutStreams>
</Simulation>
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,12 @@
<mutationProb>0.9</mutationProb>
</mutation>
</reproduction>
<fitness type="feasibleFirst">
<!-- <a>2.0</a>
<b>1.0</b> -->
</fitness>
<fitness type="feasibleFirst"></fitness>
<survivorSelection>fitnessBased</survivorSelection>
</GAparams>

<convergence>
<objective>-1</objective>
<AHDp>0.0</AHDp>
</convergence>

<variable name="x1">
Expand Down Expand Up @@ -126,7 +123,7 @@
</Models>

<Functions>
<External file="../../../../framework/AnalyticModels/optimizing/myLocalSum.py" name="constraint1">
<External file="../../../../../AnalyticModels/optimizing/myLocalSum.py" name="constraint1">
<variables>x1,x2,x3</variables>
</External>
</Functions>
Expand All @@ -139,7 +136,7 @@
</PointSet>
<PointSet name="opt_export">
<Input>trajID</Input>
<Output>x1,x2,x3,ans,age,batchId,fitness,iteration,accepted,conv_objective</Output>
<Output>x1,x2,x3,ans,age,batchId,fitness,iteration,accepted,AHDp,conv_AHDp</Output>
</PointSet>
</DataObjects>

Expand Down
Loading

0 comments on commit 086516c

Please sign in to comment.