-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding a test of the cluster runinfo.
- Loading branch information
1 parent
ec047b4
commit cac24f0
Showing
5 changed files
with
319 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
<Simulation verbosity="all"> | ||
<RunInfo> | ||
<JobName>Opt_Runs_o</JobName> | ||
<WorkingDir>Opt_Runs_o</WorkingDir> | ||
<Sequence>optimize, plot</Sequence> | ||
<batchSize>3</batchSize> | ||
<!-- <internalParallel>True</internalParallel> | ||
<mode>mpi<runQSUB></runQSUB></mode> | ||
<expectedTime>72:0:0</expectedTime> | ||
<clusterParameters>-P nst -j oe</clusterParameters> --> | ||
<expectedTime>72:0:0</expectedTime> | ||
<clusterParameters>-P nst</clusterParameters> | ||
<mode>mpi | ||
<runQSUB /> | ||
<memory>4g</memory> | ||
</mode> | ||
<NumMPI>3</NumMPI> | ||
<internalParallel>True</internalParallel> | ||
</RunInfo> | ||
|
||
<Steps> | ||
<MultiRun name="optimize"> | ||
<Input class="Files" type="">transfers</Input> | ||
<Input class="Files" type="raven">inner_workflow</Input> | ||
<Input class="Files" type="">heron_lib</Input> | ||
<Model class="Models" type="Code">raven</Model> | ||
<Optimizer class="Optimizers" type="FiniteDifference">cap_opt</Optimizer> | ||
<Output class="DataObjects" type="PointSet">opt_eval</Output> | ||
<SolutionExport class="DataObjects" type="PointSet">opt_soln</SolutionExport> | ||
<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> | ||
</IOStep> | ||
</Steps> | ||
|
||
<VariableGroups> | ||
<Group name="GRO_capacities">steamer_capacity, generator_capacity, electr_market_capacity, electr_flex_capacity</Group> | ||
<Group name="GRO_outer_results">mean_NPV, std_NPV, med_NPV</Group> | ||
<Group name="GRO_outer_debug_dispatch" /> | ||
<Group name="GRO_outer_debug_synthetics" /> | ||
</VariableGroups> | ||
|
||
<DataObjects> | ||
<PointSet name="opt_eval"> | ||
<Input>GRO_capacities</Input> | ||
<Output>GRO_outer_results</Output> | ||
</PointSet> | ||
<PointSet name="opt_soln"> | ||
<Input>trajID</Input> | ||
<Output>iteration, accepted, GRO_capacities, GRO_outer_results</Output> | ||
</PointSet> | ||
</DataObjects> | ||
|
||
<Models> | ||
<Code name="raven" subType="RAVEN"> | ||
<executable>/home/civet/civet/build_0/raven/raven_framework</executable> | ||
<outputDatabase>disp_results</outputDatabase> | ||
<conversion> | ||
<input source="../write_inner.py" /> | ||
</conversion> | ||
<alias type="input" variable="denoises">Samplers|MonteCarlo@name:mc_arma_dispatch|constant@name:denoises</alias> | ||
<alias type="input" variable="steamer_capacity">Samplers|MonteCarlo@name:mc_arma_dispatch|constant@name:steamer_capacity</alias> | ||
<alias type="input" variable="generator_capacity">Samplers|MonteCarlo@name:mc_arma_dispatch|constant@name:generator_capacity</alias> | ||
<alias type="input" variable="electr_market_capacity">Samplers|MonteCarlo@name:mc_arma_dispatch|constant@name:electr_market_capacity</alias> | ||
<alias type="input" variable="electr_flex_capacity">Samplers|MonteCarlo@name:mc_arma_dispatch|constant@name:electr_flex_capacity</alias> | ||
</Code> | ||
</Models> | ||
|
||
<Distributions> | ||
<Uniform name="steamer_capacity_dist"> | ||
<lowerBound>1.0</lowerBound> | ||
<upperBound>10.0</upperBound> | ||
</Uniform> | ||
<Uniform name="electr_flex_capacity_dist"> | ||
<lowerBound>-2050.0</lowerBound> | ||
<upperBound>-2000.0</upperBound> | ||
</Uniform> | ||
</Distributions> | ||
|
||
<Optimizers> | ||
<GradientDescent name="cap_opt"> | ||
<objective>mean_NPV</objective> | ||
<constant name="denoises">3</constant> | ||
<TargetEvaluation class="DataObjects" type="PointSet">opt_eval</TargetEvaluation> | ||
<samplerInit> | ||
<limit>800</limit> | ||
<writeSteps>every</writeSteps> | ||
<type>max</type> | ||
</samplerInit> | ||
<gradient> | ||
<FiniteDifference /> | ||
</gradient> | ||
<stepSize> | ||
<GradientHistory> | ||
<growthFactor>2</growthFactor> | ||
<shrinkFactor>1.5</shrinkFactor> | ||
<initialStepScale>0.2</initialStepScale> | ||
</GradientHistory> | ||
</stepSize> | ||
<acceptance> | ||
<Strict /> | ||
</acceptance> | ||
<convergence> | ||
<persistence>1</persistence> | ||
<gradient>1e-4</gradient> | ||
<objective>1e-8</objective> | ||
</convergence> | ||
<variable name="steamer_capacity"> | ||
<distribution>steamer_capacity_dist</distribution> | ||
<initial>1.45</initial> | ||
</variable> | ||
<constant name="generator_capacity">-100.0</constant> | ||
<constant name="electr_market_capacity">-2.0</constant> | ||
<variable name="electr_flex_capacity"> | ||
<distribution>electr_flex_capacity_dist</distribution> | ||
<initial>-2002.5</initial> | ||
</variable> | ||
</GradientDescent> | ||
</Optimizers> | ||
|
||
<Files> | ||
<Input name="inner_workflow" type="raven">../inner.xml</Input> | ||
<Input name="heron_lib">../heron.lib</Input> | ||
<Input name="transfers">../transfers.py</Input> | ||
</Files> | ||
|
||
<OutStreams> | ||
<Print name="opt_soln"> | ||
<type>csv</type> | ||
<source>opt_soln</source> | ||
<clusterLabel>trajID</clusterLabel> | ||
</Print> | ||
<Plot name="opt_path" subType="OptPath"> | ||
<source>opt_soln</source> | ||
<vars>GRO_capacities, mean_NPV</vars> | ||
</Plot> | ||
</OutStreams> | ||
</Simulation> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
<HERON> | ||
<TestInfo> | ||
<name>cluster_runinfo</name> | ||
<author>cogljj</author> | ||
<created>2022-08-31</created> | ||
<description> | ||
Tests that parallel can generate a runinfo block in the outer. | ||
Note that if the runinfo block is the same, the rest can be regolded. | ||
</description> | ||
<classesTested>HERON</classesTested> | ||
</TestInfo> | ||
|
||
<Case name="Opt_Runs"> | ||
<mode>opt</mode> | ||
<parallel> | ||
<runinfo> | ||
<expectedTime>72:0:0</expectedTime> | ||
<clusterParameters>-P nst</clusterParameters> | ||
<memory>4g</memory> | ||
</runinfo> | ||
</parallel> | ||
<num_arma_samples>3</num_arma_samples> | ||
<time_discretization> | ||
<time_variable>Time</time_variable> | ||
<end_time>2</end_time> | ||
<num_steps>21</num_steps> | ||
</time_discretization> | ||
<economics> | ||
<ProjectTime>3</ProjectTime> | ||
<DiscountRate>0.08</DiscountRate> | ||
<tax>0.0</tax> | ||
<inflation>0.0</inflation> | ||
<verbosity>50</verbosity> | ||
</economics> | ||
<dispatcher> | ||
<pyomo/> | ||
</dispatcher> | ||
</Case> | ||
|
||
<Components> | ||
<Component name="steamer"> | ||
<produces resource="steam" dispatch="fixed"> | ||
<capacity resource="steam"> | ||
<opt_bounds>1, 10</opt_bounds> | ||
</capacity> | ||
</produces> | ||
<economics> | ||
<lifetime>27</lifetime> | ||
</economics> | ||
</Component> | ||
|
||
<Component name="generator"> | ||
<produces resource="electricity" dispatch="independent"> | ||
<consumes>steam</consumes> | ||
<capacity resource="steam"> | ||
<fixed_value>-100</fixed_value> | ||
</capacity> | ||
<transfer> | ||
<linear> | ||
<rate resource="steam">-1</rate> | ||
<rate resource="electricity">0.5</rate> | ||
</linear> | ||
</transfer> | ||
</produces> | ||
<economics> | ||
<lifetime>27</lifetime> | ||
</economics> | ||
</Component> | ||
|
||
<Component name="electr_market"> | ||
<demands resource="electricity" dispatch="dependent"> | ||
<capacity> | ||
<fixed_value>-2</fixed_value> | ||
</capacity> | ||
</demands> | ||
<economics> | ||
<lifetime>30</lifetime> | ||
<CashFlow name="e_sales" type="repeating" taxable='True' inflation='none' mult_target='False'> | ||
<driver> | ||
<activity>electricity</activity> | ||
<multiplier>-1</multiplier> | ||
</driver> | ||
<reference_price> | ||
<fixed_value>0.5</fixed_value> | ||
</reference_price> | ||
</CashFlow> | ||
</economics> | ||
</Component> | ||
|
||
<Component name="electr_flex"> | ||
<demands resource="electricity" dispatch="dependent"> | ||
<capacity> | ||
<opt_bounds>-2e3, -2.05e3</opt_bounds> | ||
</capacity> | ||
</demands> | ||
<economics> | ||
<lifetime>30</lifetime> | ||
<CashFlow name="e_sales" type="repeating" taxable='True' inflation='none' mult_target='False'> | ||
<driver> | ||
<Function method="electric_consume">transfers</Function> | ||
<multiplier>-1</multiplier> | ||
</driver> | ||
<reference_price> | ||
<Function method="flex_price">transfers</Function> | ||
</reference_price> | ||
</CashFlow> | ||
</economics> | ||
</Component> | ||
|
||
</Components> | ||
|
||
<DataGenerators> | ||
<ARMA name='Price' variable="Signal">%HERON%/tests/integration_tests/ARMA/Sine/arma.pk</ARMA> | ||
<Function name="transfers">transfers.py</Function> | ||
</DataGenerators> | ||
|
||
</HERON> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[Tests] | ||
[./cluster_runinfo] | ||
type = HeronIntegration | ||
kind = heron_only | ||
input = heron_input.xml | ||
UnorderedXml = outer.xml | ||
[../] | ||
|
||
[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
# Copyright 2020, Battelle Energy Alliance, LLC | ||
# ALL RIGHTS RESERVED | ||
""" | ||
Implements transfer functions | ||
""" | ||
|
||
def electric_consume(data, meta): | ||
""" | ||
Provides the amount of electricity consumed. | ||
@ In, data, dict, request for data | ||
@ In, meta, dict, state information | ||
@ Out, data, dict, filled data | ||
@ In, meta, dict, state information | ||
""" | ||
activity = meta['HERON']['activity'] | ||
# TODO a get_activity method for the dispatcher -> returns object-safe activity (expression or value)? | ||
amount = -1 * activity['production']['electricity'] | ||
# NOTE multiplier is -1 in the input! | ||
data = {'driver': amount} | ||
return data, meta | ||
|
||
def flex_price(data, meta): | ||
""" | ||
Determines the price of electricity. | ||
@ In, data, dict, request for data | ||
@ In, meta, dict, state information | ||
@ Out, data, dict, filled data | ||
@ In, meta, dict, state information | ||
""" | ||
sine = meta['HERON']['RAVEN_vars']['Signal'] | ||
t = meta['HERON']['time_index'] | ||
# scale electricity consumed to flex between -1 and 1 | ||
amount = - 2 * (sine[t] - 0.5) | ||
data = {'reference_price': amount} | ||
return data, meta |