ParsedVectorVectorRealReductionReporter

Use a parsed function to iterate through a rows of a vector of vector and reduce it to a vector.

Overview

ParsedVectorVectorRealReductionReporter performs a reduction across the rows of a vector of vectors contained 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. The output from ParsedVectorVectorRealReductionReporter is a column vector of the same size as the column size of the vector of vectors. The vector of vectors reporter can be thought of as containing a matrix with the parsed function expression providing the row operation. It is an error for the vectors contained in the vector of vectors to be different sizes.

Different initial conditions and parsed function expressions will provide different row operations on the the matrix. Examples are shown in Listing 1 for a matrix row sum, matrix row multiplication, matrix row sum of squares, and max across the rows of a matrix.

Listing 1:

[Reporters]
  [vec_d]
    type = ConstantReporter
    real_vector_names = 'vec_d'
    real_vector_values = '1 2 3 4'
    outputs = none
  []

  [vecvec_sum]
    type = ParsedVectorVectorRealReductionReporter
    name = sum
    reporter_name = 'dataFromVofV/v_of_v'
    initial_value = 0
    expression = 'reduction_value+indexed_value'
  []

  [vecvec_sqsum]
    type = ParsedVectorVectorRealReductionReporter
    name = sqsum
    reporter_name = 'dataFromVofV/v_of_v'
    initial_value = 0
    expression = 'reduction_value+indexed_value*indexed_value'
  []

  [vecvec_multiply]
    type = ParsedVectorVectorRealReductionReporter
    name = multiply
    reporter_name = 'dataFromVofV/v_of_v'
    initial_value = 1
    expression = 'reduction_value*indexed_value'
  []

  [vecvec_max]
    type = ParsedVectorVectorRealReductionReporter
    name = max
    reporter_name = 'dataFromVofV/v_of_v'
    initial_value = -100000
    expression = 'max(reduction_value,indexed_value)'
  []
[]
(modules/optimization/test/tests/reporters/vector_math/vectorMath.i)

Optimization use case

ParsedVectorVectorRealReductionReporter and ParsedVectorRealReductionReporter were created to process data cloned into a StochasticReporter from a SamplerReporterTransfer as shown in Listing 2. In this case, a ParsedVectorVectorRealReductionReporter is needed to sum each sampler's parameter gradient vector returned to the StochasticReporter as a vector of vectors. 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 ParsedVectorVectorRealReductionReporter is then be transferred as the objective value into GeneralOptimization.

Listing 2:

[Transfers]
  [fromForward]
    type = SamplerReporterTransfer
    from_multi_app = forward
    sampler = omega_sampler
    stochastic_reporter = storage
    from_reporter = 'obj_pp/value grad_f/grad_f'
  []

  # regular transfer of the same controllable parameters to all subapps
  [toForward]
    type = MultiAppReporterTransfer
    to_multi_app = forward
    from_reporters = 'controllable_params/vals'
    to_reporters = 'vals/vals'
    execute_on = 'TIMESTEP_BEGIN'
  []
[]

[Reporters]
  [storage]
    type = StochasticReporter
    execute_on = 'initial timestep_end'
    parallel_type = ROOT
  []
  [grad_sum]
    type = ParsedVectorVectorRealReductionReporter
    name = row_sum
    reporter_name = "storage/fromForward:grad_f:grad_f"
    initial_value = 0
    expression = 'reduction_value+indexed_value'
  []
  [obj_sum]
    type = ParsedVectorRealReductionReporter
    name = value
    reporter_name = "storage/fromForward:obj_pp:value"
    initial_value = 0
    expression = 'reduction_value+indexed_value'
  []

  [controllable_params]
    type = ConstantReporter
    real_vector_names = 'vals'
    real_vector_values = '0 4'
  []
[]
(modules/combined/test/tests/optimization/invOpt_multiExperiment/sampler_subapp.i)

Input Parameters

  • expressionfunction expression

    C++ Type:FunctionExpression

    Controllable:No

    Description:function expression

  • initial_valueValue to intialize the reduction with.

    C++ Type:double

    Controllable:No

    Description:Value to intialize the reduction with.

  • reporter_nameReporter name with vector of vectors to reduce.

    C++ Type:ReporterName

    Controllable:No

    Description:Reporter name with vector of vectors to reduce.

Required 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.)

  • execute_onTIMESTEP_ENDThe list of flag(s) indicating when this object should be executed, the available options include FORWARD, ADJOINT, HOMOGENEOUS_FORWARD, ADJOINT_TIMESTEP_BEGIN, ADJOINT_TIMESTEP_END, NONE, INITIAL, LINEAR, NONLINEAR, TIMESTEP_END, TIMESTEP_BEGIN, MULTIAPP_FIXED_POINT_END, MULTIAPP_FIXED_POINT_BEGIN, FINAL, CUSTOM.

    Default:TIMESTEP_END

    C++ Type:ExecFlagEnum

    Options:FORWARD, ADJOINT, HOMOGENEOUS_FORWARD, ADJOINT_TIMESTEP_BEGIN, ADJOINT_TIMESTEP_END, NONE, INITIAL, LINEAR, NONLINEAR, TIMESTEP_END, TIMESTEP_BEGIN, MULTIAPP_FIXED_POINT_END, MULTIAPP_FIXED_POINT_BEGIN, FINAL, CUSTOM

    Controllable:No

    Description:The list of flag(s) indicating when this object should be executed, the available options include FORWARD, ADJOINT, HOMOGENEOUS_FORWARD, ADJOINT_TIMESTEP_BEGIN, ADJOINT_TIMESTEP_END, NONE, INITIAL, LINEAR, NONLINEAR, TIMESTEP_END, TIMESTEP_BEGIN, MULTIAPP_FIXED_POINT_END, MULTIAPP_FIXED_POINT_BEGIN, FINAL, CUSTOM.

  • nameresultName of output reporter.

    Default:result

    C++ Type:std::string

    Controllable:No

    Description:Name of output reporter.

  • 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

    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.

  • 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).

  • 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.

  • disable_fpoptimizerFalseDisable the function parser algebraic optimizer

    Default:False

    C++ Type:bool

    Controllable:No

    Description:Disable the function parser algebraic optimizer

  • enableTrueSet the enabled status of the MooseObject.

    Default:True

    C++ Type:bool

    Controllable:Yes

    Description:Set the enabled status of the MooseObject.

  • 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

    Options:nan, nan_warning, error, exception

    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

  • 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

  • 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

Input Files