Repository: idaholab/HERON (language: python)

Issue:
[DEFECT] "Final" not written to CSV
--------
Defect Description
--------

When running optimization problems in HERON, the final accepted point (with the "final" condition in the "accepted" column) is not written to the optimization path CSV.

This occurs because the CSV writing is performed within the MultiRun loop, but the final accepted point is calculated and added to the data object as a result of finalizing the Sampler, after which RAVEN does not re-run the OutStreams.

This might be fixed by adding a Print to the Plot step for optimization in outer.xml.

----------------
For Change Control Board: Issue Review
----------------
This review should occur before any development is performed as a response to this issue.
- [x] 1. Is it tagged with a type: defect or task?
- [x] 2. Is it tagged with a priority: critical, normal or minor?
- [x] 3. If it will impact requirements or requirements tests, is it tagged with requirements?
- [x] 4. If it is a defect, can it cause wrong results for users? If so an email needs to be sent to the users.
- [x] 5. Is a rationale provided? (Such as explaining why the improvement is needed or why current code is wrong.)

-------
For Change Control Board: Issue Closure
-------
This review should occur when the issue is imminently going to be closed.
- [x] 1. If the issue is a defect, is the defect fixed?
- [x] 2. If the issue is a defect, is the defect tested for in the regression test system?  (If not explain why not.)
- [x] 3. If the issue can impact users, has an email to the users group been written (the email should specify if the defect impacts stable or master)?
- [x] 4. If the issue is a defect, does it impact the latest release branch? If yes, is there any issue tagged with release (create if needed)?
- [x] 5. If the issue is being closed without a pull request, has an explanation of why it is being closed been provided?



Discussion / hints:

Fix patch:
diff --git a/templates/outer.xml b/templates/outer.xml
index 2f5a12fb..0f7c4fca 100644
--- a/templates/outer.xml
+++ b/templates/outer.xml
@@ -25,8 +25,9 @@
       <Output         class='OutStreams'  type='Print'           >opt_soln</Output>
     </MultiRun>
     <IOStep name="plot">
-      <Input class="DataObjects" type="PointSet">opt_soln</Input>
-      <Output class='OutStreams' type='Plot'>opt_path</Output>
+      <Input  class='DataObjects' type='PointSet'>opt_soln</Input>
+      <Output class='OutStreams'  type='Plot'    >opt_path</Output>
+      <Output class='OutStreams'  type='Print'   >opt_soln</Output>
     </IOStep>
   </Steps>
 


Test patch:
diff --git a/tests/integration_tests/mechanics/multirun_sweep_opt/gold/Runs_o/opt_soln_0.csv b/tests/integration_tests/mechanics/multirun_sweep_opt/gold/Runs_o/opt_soln_0.csv
index a7c35eca..009c6316 100644
--- a/tests/integration_tests/mechanics/multirun_sweep_opt/gold/Runs_o/opt_soln_0.csv
+++ b/tests/integration_tests/mechanics/multirun_sweep_opt/gold/Runs_o/opt_soln_0.csv
@@ -4,3 +4,5 @@ iteration,accepted,source_capacity,sink_capacity,mean_NPV,std_NPV,med_NPV
 2.0,accepted,1.45,-2.0,7820.12386397,1.11389897155e-12,7820.12386397
 3.0,accepted,1.85,-2.0,9978.20777236,0.0,9978.20777236
 4.0,accepted,2.0,-2.0,10787.5312585,0.0,10787.5312585
+5.0,accepted,2.0,-2.0,10787.5312585,0.0,10787.5312585
+5.0,final,2.0,-2.0,10787.5312585,0.0,10787.5312585
diff --git a/tests/integration_tests/mechanics/optimization_settings/gold/Opt_Runs_o/opt_soln_0.csv b/tests/integration_tests/mechanics/optimization_settings/gold/Opt_Runs_o/opt_soln_0.csv
index 5b0637ae..fd26ed6e 100644
--- a/tests/integration_tests/mechanics/optimization_settings/gold/Opt_Runs_o/opt_soln_0.csv
+++ b/tests/integration_tests/mechanics/optimization_settings/gold/Opt_Runs_o/opt_soln_0.csv
@@ -7,3 +7,5 @@ iteration,accepted,steamer_capacity,generator_capacity,electr_market_capacity,el
 5.0,accepted,10.0,-100.0,-2.0,-2002.5,-77.7220918115,77.7220918232,1.21349097015e-08,77.7220918256
 6.0,accepted,10.0,-100.0,-2.0,-2002.5,-77.7220918115,77.7220918232,1.21349097015e-08,77.7220918256
 7.0,accepted,10.0,-100.0,-2.0,-2002.5,-77.7220918115,77.7220918232,1.21349097015e-08,77.7220918256
+8.0,accepted,10.0,-100.0,-2.0,-2002.5,-77.7220918115,77.7220918232,1.21349097015e-08,77.7220918256
+8.0,final,10.0,-100.0,-2.0,-2002.5,-77.7220918115,77.7220918232,1.21349097015e-08,77.7220918256
diff --git a/tests/integration_tests/workflows/production_flex_opt/gold/Opt_Runs_o/opt_soln_0.csv b/tests/integration_tests/workflows/production_flex_opt/gold/Opt_Runs_o/opt_soln_0.csv
index 2b9562a0..07b7831c 100644
--- a/tests/integration_tests/workflows/production_flex_opt/gold/Opt_Runs_o/opt_soln_0.csv
+++ b/tests/integration_tests/workflows/production_flex_opt/gold/Opt_Runs_o/opt_soln_0.csv
@@ -3,3 +3,5 @@ iteration,accepted,steamer_capacity,generator_capacity,electr_market_capacity,el
 1.0,accepted,3.99558441227,-100.0,-2.0,-2002.5,62.665790811,7.47587185876e-09,62.6657908142
 2.0,accepted,6.54116882454,-100.0,-2.0,-2002.5,69.0824804038,3.94466916627e-09,69.0824804034
 3.0,accepted,10.0,-100.0,-2.0,-2002.5,77.7220918232,1.21349097015e-08,77.7220918256
+4.0,accepted,10.0,-100.0,-2.0,-2002.5,77.7220918232,1.21349097015e-08,77.7220918256
+4.0,final,10.0,-100.0,-2.0,-2002.5,77.7220918232,1.21349097015e-08,77.7220918256