Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
ParamOptimizer Class Reference

Helper class to batch parameter updates on one or several BlockAccessor scopes. More...

#include <ParamOptimizer.h>

Public Member Functions

 ParamOptimizer (std::shared_ptr< BlockAccessor > scope)
 Constructs a ParamOptimizer operating on a single BlockAccessor scope.
 
 ParamOptimizer (std::vector< std::shared_ptr< BlockAccessor > > scopes)
 Constructs a ParamOptimizer operating on multiple BlockAccessor scopes.
 
void set_value (const BlockName &block, const LhaID &id, scalar_t v)
 Queue a simple numerical value assignment for a parameter.
 
void set_param (const BlockName &block, const LhaID &id, std::shared_ptr< Parameter > p)
 Queue a full Parameter object assignment.
 
void remove (const BlockName &block, const LhaID &id)
 Queue a removal operation for a parameter.
 
void commit (bool coalesce=true)
 Applies all queued operations.
 
void clear ()
 Clears the pending operation queue without applying changes.
 

Detailed Description

Helper class to batch parameter updates on one or several BlockAccessor scopes.

ParamOptimizer is designed to:

  • Queue operations on parameters (set value, set full Parameter, remove).
  • Optionally coalesce multiple operations on the same (block, id) into the last one.
  • Apply all operations in a single commit, with:
    • freezing of all involved blocks before changes,
    • performing assignments / stores / removals,
    • a single notification per block when new parameters are stored,
    • unfreezing at the end.

Typical usage:

auto ba = Parameters::GetInstance(ParameterType::SM)->get_block_accessor();
opt.set_value("MASS", LhaID(5), 4.8);
opt.set_value("MASS", LhaID(6), 173.0);
opt.commit(); // applies changes, notifies dependents
Helper class to batch parameter updates on one or several BlockAccessor scopes.
static std::shared_ptr< Parameters > GetInstance(ParameterType id=ParameterType::SM)
Returns the singleton-like repository for a given parameter type.
Represents an identifier of a LHA element, possibly containing several sub-ids.
Definition LhaID.h:56

Definition at line 75 of file ParamOptimizer.h.

Constructor & Destructor Documentation

◆ ParamOptimizer() [1/2]

ParamOptimizer::ParamOptimizer ( std::shared_ptr< BlockAccessor scope)
explicit

Constructs a ParamOptimizer operating on a single BlockAccessor scope.

Parameters
scopeShared pointer to the BlockAccessor to be modified.

Definition at line 3 of file ParamOptimizer.cpp.

◆ ParamOptimizer() [2/2]

ParamOptimizer::ParamOptimizer ( std::vector< std::shared_ptr< BlockAccessor > >  scopes)
explicit

Constructs a ParamOptimizer operating on multiple BlockAccessor scopes.

This is useful when parameters are distributed over several BlockAccessor instances (for example, several Parameters objects) but blocks must remain unambiguous (a given block name must resolve to the same Block in all scopes where it appears).

Parameters
scopesVector of shared pointers to BlockAccessor scopes.

Definition at line 5 of file ParamOptimizer.cpp.

Member Function Documentation

◆ clear()

void ParamOptimizer::clear ( )

Clears the pending operation queue without applying changes.

Definition at line 85 of file ParamOptimizer.cpp.

◆ commit()

void ParamOptimizer::commit ( bool  coalesce = true)

Applies all queued operations.

The algorithm is:

  • Freeze all blocks in all scopes.
  • Coalesce operations if requested (only the last op per (block, id) is kept).
  • For each operation:
    • If it is a SetValue / SetParam and the parameter already existed, use Block::assign.
    • If it is a SetValue / SetParam on a new parameter, use Block::store and mark the block for notification.
    • If it is a Remove and the parameter existed initially, remove it (Block::remove).
  • Notify observers once per block that received new parameters.
  • Unfreeze all blocks.
  • Clear the internal operation queue.
Parameters
coalesceIf true (default), only the last operation per (block, id) is applied.

Definition at line 18 of file ParamOptimizer.cpp.

◆ remove()

void ParamOptimizer::remove ( const BlockName block,
const LhaID id 
)

Queue a removal operation for a parameter.

If the parameter does not exist initially in the block, the operation is ignored.

Parameters
blockName of the block.
idLHA identifier of the parameter to remove.

Definition at line 14 of file ParamOptimizer.cpp.

◆ set_param()

void ParamOptimizer::set_param ( const BlockName block,
const LhaID id,
std::shared_ptr< Parameter p 
)

Queue a full Parameter object assignment.

If the parameter already exists, it will be overwritten (via Block::assign). Otherwise, it will be stored (via Block::store).

Parameters
blockName of the block.
idLHA identifier of the parameter.
pShared pointer to the Parameter object to use.

Definition at line 11 of file ParamOptimizer.cpp.

◆ set_value()

void ParamOptimizer::set_value ( const BlockName block,
const LhaID id,
scalar_t  v 
)

Queue a simple numerical value assignment for a parameter.

If the parameter already exists, it will be updated. Otherwise, it will be created as a new Parameter with zero uncertainties.

Parameters
blockName of the block.
idLHA identifier of the parameter.
vNew value to set.

Definition at line 8 of file ParamOptimizer.cpp.


The documentation for this class was generated from the following files: