- expressionfunction expression
C++ Type:FunctionExpression
Unit:(no unit assumed)
Controllable:No
Description:function expression
- initial_valueValue to intialize the reduction with.
C++ Type:double
Unit:(no unit assumed)
Controllable:No
Description:Value to intialize the reduction with.
- reporter_nameReporter name with vector to reduce.
C++ Type:ReporterName
Controllable:No
Description:Reporter name with vector to reduce.
ParsedVectorRealReductionReporter
Use a parsed function to iterate through a vector and reduce it to a scalar.
Overview
ParsedVectorRealReductionReporter
performs a reduction on the elements of a vector in a reporter using a parsed function expression containing only two variables, reduction_value
and indexed_value
. reduction_value
is the variable containing the reduced value and is initialized by "initial_value". indexed_value
is the current vector element being operated on by the parsed function.
Different initial conditions and parsed function expressions will provide a vector sum, vector multiplication, vector sum of squares, and max as shown in Listing 1.
Listing 1:
[Reporters<<<{"href": "../../syntax/Reporters/index.html"}>>>]
[vec_d]
type = ConstantReporter<<<{"description": "Reporter with constant values to be accessed by other objects, can be modified using transfers.", "href": "ConstantReporter.html"}>>>
real_vector_names<<<{"description": "Names for each vector of reals value."}>>> = 'vec_d'
real_vector_values<<<{"description": "Values for vectors of reals."}>>> = '1 2 3 4'
outputs<<<{"description": "Vector of output names where you would like to restrict the output of variables(s) associated with this object"}>>> = none
[]
[vector_sum]
type = ParsedVectorRealReductionReporter<<<{"description": "Use a parsed function to iterate through a vector and reduce it to a scalar.", "href": "ParsedVectorRealReductionReporter.html"}>>>
name<<<{"description": "Name of output reporter."}>>> = sum
reporter_name<<<{"description": "Reporter name with vector to reduce."}>>> = vec_d/vec_d
initial_value<<<{"description": "Value to intialize the reduction with."}>>> = 0
expression<<<{"description": "function expression"}>>> = 'reduction_value+indexed_value'
[]
[vector_sqsum]
type = ParsedVectorRealReductionReporter<<<{"description": "Use a parsed function to iterate through a vector and reduce it to a scalar.", "href": "ParsedVectorRealReductionReporter.html"}>>>
name<<<{"description": "Name of output reporter."}>>> = sqsum
reporter_name<<<{"description": "Reporter name with vector to reduce."}>>> = vec_d/vec_d
initial_value<<<{"description": "Value to intialize the reduction with."}>>> = 0
expression<<<{"description": "function expression"}>>> = 'reduction_value+indexed_value*indexed_value'
[]
[vector_multiply]
type = ParsedVectorRealReductionReporter<<<{"description": "Use a parsed function to iterate through a vector and reduce it to a scalar.", "href": "ParsedVectorRealReductionReporter.html"}>>>
name<<<{"description": "Name of output reporter."}>>> = multiply
reporter_name<<<{"description": "Reporter name with vector to reduce."}>>> = vec_d/vec_d
initial_value<<<{"description": "Value to intialize the reduction with."}>>> = 1
expression<<<{"description": "function expression"}>>> = 'reduction_value*indexed_value'
[]
[vector_max]
type = ParsedVectorRealReductionReporter<<<{"description": "Use a parsed function to iterate through a vector and reduce it to a scalar.", "href": "ParsedVectorRealReductionReporter.html"}>>>
name<<<{"description": "Name of output reporter."}>>> = max
reporter_name<<<{"description": "Reporter name with vector to reduce."}>>> = vec_d/vec_d
initial_value<<<{"description": "Value to intialize the reduction with."}>>> = -100000
expression<<<{"description": "function expression"}>>> = 'max(reduction_value,indexed_value)'
[]
[]
(modules/optimization/test/tests/reporters/vector_math/vectorMath.i)Optimization use case
ParsedVectorRealReductionReporter
and ParsedVectorVectorRealReductionReporter were created to process data cloned into a StochasticReporter
from a SamplerReporterTransfer
as shown in Listing 2. In this case, A ParsedVectorRealReductionReporter
is needed to sum each samplers objective function returned to the StochasticReporter
. This set-up allows us to optimize parameters that combine multiple forward problems created and run in parallel using the sampler system. The scalar reporter computed by ParsedVectorRealReductionReporter
is then be transferred as the objective value into GeneralOptimization.
Listing 2:
[Transfers<<<{"href": "../../syntax/Transfers/index.html"}>>>]
[setPrameters]
type = MultiAppReporterTransfer<<<{"description": "Transfers reporter data between two applications.", "href": "../transfers/MultiAppReporterTransfer.html"}>>>
to_multi_app<<<{"description": "The name of the MultiApp to transfer the data to"}>>> = model_grad
from_reporters<<<{"description": "List of the reporter names (object_name/value_name) to transfer the value from."}>>> = 'parameters/vals'
to_reporters<<<{"description": "List of the reporter names (object_name/value_name) to transfer the value to."}>>> = 'vals/vals'
execute_on<<<{"description": "The list of flag(s) indicating when this object should be executed. For a description of each flag, see https://mooseframework.inl.gov/source/interfaces/SetupInterface.html."}>>> = 'TIMESTEP_BEGIN'
[]
[ObjectivesGradients]
type = MultiAppReporterTransfer<<<{"description": "Transfers reporter data between two applications.", "href": "../transfers/MultiAppReporterTransfer.html"}>>>
from_multi_app<<<{"description": "The name of the MultiApp to receive data from"}>>> = model_grad
from_reporters<<<{"description": "List of the reporter names (object_name/value_name) to transfer the value from."}>>> = 'grad_f/grad_f obj_pp/value'
to_reporters<<<{"description": "List of the reporter names (object_name/value_name) to transfer the value to."}>>> = 'from_sub_rep/rec_vec_vec from_sub_rep/rec_vec'
distribute_reporter_vector<<<{"description": "Transfer to/from a vector reporter from/to reporters on child applications. N to 1 or 1 to N type of transfer. The number of child applications must match the size of the vector reporter"}>>> = true
[]
[]
[Reporters<<<{"href": "../../syntax/Reporters/index.html"}>>>]
[from_sub_rep]
type = ConstantReporter<<<{"description": "Reporter with constant values to be accessed by other objects, can be modified using transfers.", "href": "ConstantReporter.html"}>>>
real_vector_vector_names<<<{"description": "Names for each vector of vectors of reals value."}>>> = 'rec_vec_vec'
real_vector_vector_values<<<{"description": "Values for vectors of vectors of reals."}>>> = '0'
real_vector_names<<<{"description": "Names for each vector of reals value."}>>> = 'rec_vec'
real_vector_values<<<{"description": "Values for vectors of reals."}>>> = "0."
outputs<<<{"description": "Vector of output names where you would like to restrict the output of variables(s) associated with this object"}>>> = out
[]
[parameters]
type = ConstantReporter<<<{"description": "Reporter with constant values to be accessed by other objects, can be modified using transfers.", "href": "ConstantReporter.html"}>>>
real_vector_names<<<{"description": "Names for each vector of reals value."}>>> = 'vals'
real_vector_values<<<{"description": "Values for vectors of reals."}>>> = '0 4'
[]
[obj_sum]
type = ParsedVectorRealReductionReporter<<<{"description": "Use a parsed function to iterate through a vector and reduce it to a scalar.", "href": "ParsedVectorRealReductionReporter.html"}>>>
name<<<{"description": "Name of output reporter."}>>> = value
reporter_name<<<{"description": "Reporter name with vector to reduce."}>>> = from_sub_rep/rec_vec
initial_value<<<{"description": "Value to intialize the reduction with."}>>> = 0
expression<<<{"description": "function expression"}>>> = 'reduction_value+indexed_value'
[]
[grad_sum]
type = ParsedVectorVectorRealReductionReporter<<<{"description": "Use a parsed function to iterate through a rows of a vector of vector and reduce it to a vector.", "href": "ParsedVectorVectorRealReductionReporter.html"}>>>
name<<<{"description": "Name of output reporter."}>>> = row_sum
reporter_name<<<{"description": "Reporter name with vector of vectors to reduce."}>>> = "from_sub_rep/rec_vec_vec"
initial_value<<<{"description": "Value to intialize the reduction with."}>>> = 0
expression<<<{"description": "function expression"}>>> = 'reduction_value+indexed_value'
[]
[]
(modules/optimization/test/tests/reporters/multiExperiment/sampler_subapp.i)Input Parameters
- constant_expressionsVector of values for the constants in constant_names (can be an FParser expression)
C++ Type:std::vector<std::string>
Controllable:No
Description:Vector of values for the constants in constant_names (can be an FParser expression)
- constant_namesVector of constants used in the parsed function (use this for kB etc.)
C++ Type:std::vector<std::string>
Controllable:No
Description:Vector of constants used in the parsed function (use this for kB etc.)
- epsilon0Fuzzy comparison tolerance
Default:0
C++ Type:double
Unit:(no unit assumed)
Controllable:No
Description:Fuzzy comparison tolerance
- nameresultName of output reporter.
Default:result
C++ Type:std::string
Controllable:No
Description:Name of output reporter.
- use_tFalseMake time (t) variables available in the function expression.
Default:False
C++ Type:bool
Controllable:No
Description:Make time (t) variables available in the function expression.
Optional Parameters
- allow_duplicate_execution_on_initialFalseIn the case where this UserObject is depended upon by an initial condition, allow it to be executed twice during the initial setup (once before the IC and again after mesh adaptivity (if applicable).
Default:False
C++ Type:bool
Controllable:No
Description:In the case where this UserObject is depended upon by an initial condition, allow it to be executed twice during the initial setup (once before the IC and again after mesh adaptivity (if applicable).
- execute_onTIMESTEP_ENDThe list of flag(s) indicating when this object should be executed. For a description of each flag, see https://mooseframework.inl.gov/source/interfaces/SetupInterface.html.
Default:TIMESTEP_END
C++ Type:ExecFlagEnum
Controllable:No
Description:The list of flag(s) indicating when this object should be executed. For a description of each flag, see https://mooseframework.inl.gov/source/interfaces/SetupInterface.html.
- execution_order_group0Execution order groups are executed in increasing order (e.g., the lowest number is executed first). Note that negative group numbers may be used to execute groups before the default (0) group. Please refer to the user object documentation for ordering of user object execution within a group.
Default:0
C++ Type:int
Controllable:No
Description:Execution order groups are executed in increasing order (e.g., the lowest number is executed first). Note that negative group numbers may be used to execute groups before the default (0) group. Please refer to the user object documentation for ordering of user object execution within a group.
- force_postauxFalseForces the UserObject to be executed in POSTAUX
Default:False
C++ Type:bool
Controllable:No
Description:Forces the UserObject to be executed in POSTAUX
- force_preauxFalseForces the UserObject to be executed in PREAUX
Default:False
C++ Type:bool
Controllable:No
Description:Forces the UserObject to be executed in PREAUX
- force_preicFalseForces the UserObject to be executed in PREIC during initial setup
Default:False
C++ Type:bool
Controllable:No
Description:Forces the UserObject to be executed in PREIC during initial setup
Execution Scheduling Parameters
- control_tagsAdds user-defined labels for accessing object parameters via control logic.
C++ Type:std::vector<std::string>
Controllable:No
Description:Adds user-defined labels for accessing object parameters via control logic.
- enableTrueSet the enabled status of the MooseObject.
Default:True
C++ Type:bool
Controllable:Yes
Description:Set the enabled status of the MooseObject.
- outputsVector of output names where you would like to restrict the output of variables(s) associated with this object
C++ Type:std::vector<OutputName>
Controllable:No
Description:Vector of output names where you would like to restrict the output of variables(s) associated with this object
- use_displaced_meshFalseWhether or not this object should use the displaced mesh for computation. Note that in the case this is true but no displacements are provided in the Mesh block the undisplaced mesh will still be used.
Default:False
C++ Type:bool
Controllable:No
Description:Whether or not this object should use the displaced mesh for computation. Note that in the case this is true but no displacements are provided in the Mesh block the undisplaced mesh will still be used.
Advanced Parameters
- disable_fpoptimizerFalseDisable the function parser algebraic optimizer
Default:False
C++ Type:bool
Controllable:No
Description:Disable the function parser algebraic optimizer
- enable_ad_cacheTrueEnable caching of function derivatives for faster startup time
Default:True
C++ Type:bool
Controllable:No
Description:Enable caching of function derivatives for faster startup time
- enable_auto_optimizeTrueEnable automatic immediate optimization of derivatives
Default:True
C++ Type:bool
Controllable:No
Description:Enable automatic immediate optimization of derivatives
- enable_jitTrueEnable just-in-time compilation of function expressions for faster evaluation
Default:True
C++ Type:bool
Controllable:No
Description:Enable just-in-time compilation of function expressions for faster evaluation
- evalerror_behaviornanWhat to do if evaluation error occurs. Options are to pass a nan, pass a nan with a warning, throw a error, or throw an exception
Default:nan
C++ Type:MooseEnum
Controllable:No
Description:What to do if evaluation error occurs. Options are to pass a nan, pass a nan with a warning, throw a error, or throw an exception
Parsed Expression Advanced Parameters
- prop_getter_suffixAn optional suffix parameter that can be appended to any attempt to retrieve/get material properties. The suffix will be prepended with a '_' character.
C++ Type:MaterialPropertyName
Unit:(no unit assumed)
Controllable:No
Description:An optional suffix parameter that can be appended to any attempt to retrieve/get material properties. The suffix will be prepended with a '_' character.
- use_interpolated_stateFalseFor the old and older state use projected material properties interpolated at the quadrature points. To set up projection use the ProjectedStatefulMaterialStorageAction.
Default:False
C++ Type:bool
Controllable:No
Description:For the old and older state use projected material properties interpolated at the quadrature points. To set up projection use the ProjectedStatefulMaterialStorageAction.
Material Property Retrieval Parameters
Input Files
- (modules/optimization/test/tests/reporters/multiExperiment/sampler_subapp.i)
- (modules/optimization/examples/materialFrequency/wave1D/sampler.i)
- (modules/optimization/test/tests/optimizationreporter/bc_load_linearFunction/forward_and_adjoint.i)
- (modules/optimization/test/tests/reporters/vector_math/vectorMath.i)