Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TASK] Improved TEAL search error message #14

Merged
2 commits merged into from
Sep 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions src/Cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,21 @@ def get_input_specs(cls):
input_specs.addParam('name', param_type=InputTypes.StringType, required=True,
descr=r"""the name by which this analysis should be referred within HERON.""")

mode_options = InputTypes.makeEnumType('ModeOptions', 'ModeOptionsType', ['min', 'max', 'sweep'])
desc_mode_options = r"""determines whether the ``outer'' RAVEN should perform minimization,
maximization, or a parametric study."""
econ_metrics = InputTypes.makeEnumType('EconMetrics', 'EconMetricsTypes', ['NPV', 'lcoe'])
desc_econ_metrics = r"""indicates the economic metric that should be used for the HERON analysis. For most cases, this
should be NPV."""
#mode_options = InputTypes.makeEnumType('ModeOptions', 'ModeOptionsType', ['opt', 'sweep'])
#desc_mode_options = r"""determines whether the outer RAVEN should perform optimization,
# or a parametric (``sweep'') study. \default{sweep}"""
#input_specs.addSub(InputData.parameterInputFactory('mode', contentType=mode_options,
# strictMode=True, descr=desc_mode_options))

# not yet implemented TODO
# input_specs.addSub(InputData.parameterInputFactory('mode', contentType=mode_options, strictMode=True, descr=desc_mode_options))
#econ_metrics = InputTypes.makeEnumType('EconMetrics', 'EconMetricsTypes', ['NPV', 'lcoe'])
#desc_econ_metrics = r"""indicates the economic metric that should be used for the HERON analysis. For most cases, this
# should be NPV."""
# input_specs.addSub(InputData.parameterInputFactory('metric', contentType=econ_metrics, descr=desc_econ_metrics))
# input_specs.addSub(InputData.parameterInputFactory('differential', contentType=InputTypes.BoolType, strictMode=True,
# descr=r"""(not implemented) allows differentiation between two HERON runs as a desired economic metric."""
# descr=r"""(not implemented) allows differentiation between two HERON runs as a desired
# economic metric."""

input_specs.addSub(InputData.parameterInputFactory('num_arma_samples', contentType=InputTypes.IntegerType,
descr=r"""provides the number of synthetic histories that should be considered per system configuration
in order to obtain a reasonable representation of the economic metric. Sometimes referred to as
Expand Down Expand Up @@ -407,7 +410,7 @@ def _load_template(self):
module = importlib.import_module('templates.{}'.format(template_name))
# load template, perform actions
template_class = module.Template()
template_class.loadTemplate(None, template_dir)
template_class.loadTemplate(template_dir)
return template_class

def _modify(self, templates, components, sources):
Expand Down
2 changes: 1 addition & 1 deletion src/ValuedParams.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def _load(self, comp_name, item, mode, alias_dict):
if 'opt_bounds' in given:
return 'value', item.subparts[given.index('opt_bounds')], None, None
else:
raise IOError('For "{}" in "{}", no <opt_bounds> given but in sweep mode! '.format(head_name, comp_name) +\
raise IOError('For "{}" in "{}", no <opt_bounds> given but in "opt" mode! '.format(head_name, comp_name) +\
'\nPlease provide either <fixed_value> or <opt_bounds>.')
## if we got here, then the rights nodes were not given!
raise RuntimeError(err_msg)
Expand Down
34 changes: 34 additions & 0 deletions templates/outer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,40 @@
</Grid>
</Samplers>

<Optimizers>
<GradientDescent name="cap_opt">
<objective>mean_NPV</objective>
<!-- <variable> nodes filled by HERON -->
<variable name="x">
<distribution>beale_dist</distribution>
<initial>-2</initial>
</variable>
<variable name="y">
<distribution>beale_dist</distribution>
<initial>-2</initial>
</variable>
<TargetEvaluation class="DataObjects" type="PointSet">cap_opt_eval</TargetEvaluation>
<samplerInit>
<writeSteps>every</writeSteps>
</samplerInit>
<gradient>
<FiniteDifference/>
</gradient>
<stepSize>
<GradientHistory>
<growthFactor>1.25</growthFactor>
<shrinkFactor>1.5</shrinkFactor>
</GradientHistory>
</stepSize>
<acceptance>
<Strict/>
</acceptance>
<convergence>
<gradient>1e-2</gradient>
</convergence>
</GradientDescent>
</Optimizers>

<Files>
<Input name="inner_workflow" type='raven'>inner.xml</Input>
<Input name="heron_lib">../heron.lib</Input>
Expand Down
Loading