Class model::FacedGraphModel
Faced Graph Model.
This is a base class for models with a cost function that can be expressed as a graph with faces.
Inherited Members
Methods
nodes()
Return a vector of all the nodes.
Declaration
const std::vector<Node>&model::FacedGraphModel<State_T, Transition_T, Cost_T>::nodes() const
node_count()
Return the number of nodes.
Declaration
size_t model::FacedGraphModel<State_T, Transition_T, Cost_T>::node_count() const
node()
Return a specific node by node ID.
Declaration
const Node&model::FacedGraphModel<State_T, Transition_T, Cost_T>::node(size_t id) const
edges()
Return a vector of all the edges.
Declaration
const std::vector<Edge>&model::FacedGraphModel<State_T, Transition_T, Cost_T>::edges() const
edge()
Return a specific edge by edge ID.
Declaration
const Edge&model::FacedGraphModel<State_T, Transition_T, Cost_T>::edge(size_t id) const
edge_count()
Return the number of edges.
Declaration
size_t model::FacedGraphModel<State_T, Transition_T, Cost_T>::edge_count() const
faces()
Return a vector of all the faces.
Declaration
const std::vector<Face>&model::FacedGraphModel<State_T, Transition_T, Cost_T>::faces() const
face()
Return a specific edge by face ID.
Declaration
const Face&model::FacedGraphModel<State_T, Transition_T, Cost_T>::face(size_t id) const
configure()
Configure the graph from input.
Declaration
void model::FacedGraphModel<State_T, Transition_T, Cost_T>::configure(const utils::Json&json) override
configure()
Declaration
void model::FacedGraphModel<State_T, Transition_T, Cost_T>::configure(Configuration_T&configuration)
calculate_cost_difference()
Partial evaluation of the cost function.
This method should calculate the difference in cost if we move from state
(=before) to the one resulting from applying transition
to state
(=after):
\Delta_{C} = C_{\mathrm{after}} - C_{\mathrm{before}}
In code:
State state = get_random_state(rng); Transition transition = get_random_transition(rng); double cost_before = calculate_cost(state); double cost_diff = calculate_cost_difference(state, transition); apply_transition(transition, state); // modify state double cost_after = calculate_cost(state); // before + diff should correspond to after
(up to double precision) assert(cost_before + cost_diff == cost_after);
Declaration
Cost_T model::FacedGraphModel<State_T, Transition_T, Cost_T>::calculate_cost_difference(const State_T&, const Transition_T&) const override
calculate_cost_difference()
Declaration
virtual Cost_T model::FacedGraphModel<State_T, Transition_T, Cost_T>::calculate_cost_difference(const State_T&state, const Transition_T&transition, const Cost_T *cost) const =0
apply_transition()
Declaration
virtual void model::FacedGraphModel<State_T, Transition_T, Cost_T>::apply_transition(const Transition_T&transition, State_T&state, Cost_T *cost) const =0
get_sweep_size()
Declaration
size_t model::FacedGraphModel<State_T, Transition_T, Cost_T>::get_sweep_size() const override
get_term_count()
Declaration
size_t model::FacedGraphModel<State_T, Transition_T, Cost_T>::get_term_count() const override
get_benchmark_properties()
Fill the graph benchmarking properties.
Declaration
utils::Structure model::FacedGraphModel<State_T, Transition_T, Cost_T>::get_benchmark_properties() const override
is_rescaled()
Declaration
bool model::FacedGraphModel<State_T, Transition_T, Cost_T>::is_rescaled() const override
rescale()
Declaration
void model::FacedGraphModel<State_T, Transition_T, Cost_T>::rescale() override
get_scale_factor()
Declaration
Cost_T model::FacedGraphModel<State_T, Transition_T, Cost_T>::get_scale_factor() const override
get_const_cost()
Declaration
Cost_T model::FacedGraphModel<State_T, Transition_T, Cost_T>::get_const_cost() const override
is_empty()
Declaration
bool model::FacedGraphModel<State_T, Transition_T, Cost_T>::is_empty() const override
collate()
Manage the coefficient collation logic for a single term with degree at most 2.
Declaration
void model::FacedGraphModel<State_T, Transition_T, Cost_T>::collate(std::map<int, double>&coefficients, const double&term_cost, const std::vector<int>&term_nodes, int node_id, const graph::FaceType&ftype) const
estimate_max_cost_diff()
Compute an upper bound to the maximum cost difference from a single state flip using the triangle inequality. Implicitly expands SLC terms in cost function to obtain a tighter bound at the cost of additional memory.
Declaration
virtual double model::FacedGraphModel<State_T, Transition_T, Cost_T>::estimate_max_cost_diff() const override
insert_val_to_bbstrees()
Declaration
virtual void model::FacedGraphModel<State_T, Transition_T, Cost_T>::insert_val_to_bbstrees(double val, std::multiset<double>&tree_A, std::multiset<double>*tree_B=nullptr) const =0
amend_collation()
Declaration
virtual void model::FacedGraphModel<State_T, Transition_T, Cost_T>::amend_collation(std::map<int, double>&coeffs, int node_id) const =0
populate_bbstrees()
Simulate the expanded form of grouped terms to collate quadratic and linear coefficients of terms including a given node ID to populate balanced binary search trees of term weights for maximum cost difference estimation. This function is used by children models to implement estimate_min_cost_diff by overriding the functions insert_val_to_bbstrees and amend_collation.
Declaration
void model::FacedGraphModel<State_T, Transition_T, Cost_T>::populate_bbstrees(int node_id, std::multiset<double>&tree_A, std::multiset<double>*tree_B=nullptr) const