1#ifndef PARAM_OPTIMIZER_H
2#define PARAM_OPTIMIZER_H
5#include <unordered_map>
6#include <unordered_set>
46 std::size_t
operator()(
const std::pair<std::string,std::string>& k)
const noexcept {
47 std::size_t
h1 = std::hash<std::string>()(k.first);
48 std::size_t h2 = std::hash<std::string>()(k.second);
49 return h1 ^ (h2 + 0x9e3779b97f4a7c15ULL + (
h1<<6) + (
h1>>2));
93 explicit ParamOptimizer(std::vector<std::shared_ptr<BlockAccessor>> scopes);
146 void commit(
bool coalesce =
true);
158 struct OpSetParam {
BlockName block;
LhaID id; std::shared_ptr<Parameter> param; };
164 using Op = std::variant<OpSetValue, OpSetParam, OpRemove>;
174 std::vector<Op> coalesce_ops_()
const;
188 std::shared_ptr<Block> find_block_(
const BlockName& name)
const;
202 void unfreeze_all_();
211 std::vector<std::shared_ptr<BlockAccessor>> scopes_;
216 std::vector<Op> ops_;
Alias-aware façade for accessing and manipulating multiple parameter blocks.
Defines classes used to store parameters and to build derived/dependent parameter blocks.
Defines the Parameter class used to store individual physical/model parameters.
Block identifier with alias support.
Helper class to batch parameter updates on one or several BlockAccessor scopes.
void commit(bool coalesce=true)
Applies all queued operations.
void remove(const BlockName &block, const LhaID &id)
Queue a removal operation for a parameter.
void set_value(const BlockName &block, const LhaID &id, scalar_t v)
Queue a simple numerical value assignment for a parameter.
void clear()
Clears the pending operation queue without applying changes.
void set_param(const BlockName &block, const LhaID &id, std::shared_ptr< Parameter > p)
Queue a full Parameter object assignment.
double h1(double x)
Wilson special function h1 depending on x.
Hash functor for (block name, parameter id string) pairs.
std::size_t operator()(const std::pair< std::string, std::string > &k) const noexcept
Computes the hash of a pair of strings.
Represents an identifier of a LHA element, possibly containing several sub-ids.