aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
gum::learning::ScoringCache< ALLOC > Class Template Reference

a cache for caching scores and independence tests resultsCaching previously computed scores or the results of conditional independence tests is very important for learning algorithms because computing a score or an independence test requires parsing the database and this is the most time consuming operation in learning. More...

#include <agrum/tools/database/scoringCache.h>

Inherits ALLOC< NodeId >.

Public Member Functions

Constructors / Destructors
 ScoringCache (const allocator_type &alloc=allocator_type())
 default constructor More...
 
 ScoringCache (const ScoringCache< ALLOC > &from)
 copy constructor More...
 
 ScoringCache (const ScoringCache< ALLOC > &from, const allocator_type &alloc)
 copy constructor with a given allocator More...
 
 ScoringCache (ScoringCache< ALLOC > &&from)
 move constructor More...
 
 ScoringCache (ScoringCache< ALLOC > &&from, const allocator_type &alloc)
 move constructor with a given allocator More...
 
virtual ScoringCache< ALLOC > * clone () const
 virtual copy constructor More...
 
virtual ScoringCache< ALLOC > * clone (const allocator_type &alloc) const
 virtual copy constructor with a given allocator More...
 
virtual ~ScoringCache ()
 destructor More...
 
Operators
ScoringCache< ALLOC > & operator= (const ScoringCache< ALLOC > &from)
 copy operator More...
 
ScoringCache< ALLOC > & operator= (ScoringCache< ALLOC > &&from)
 move operator More...
 
Accessors / Modifiers
void insert (const IdCondSet< ALLOC > &idset, double score)
 insert a new score into the cache More...
 
void insert (IdCondSet< ALLOC > &&idset, double score)
 insert a new score into the cache More...
 
void erase (const IdCondSet< ALLOC > &idset)
 removes a score (if it exists) More...
 
bool exists (const IdCondSet< ALLOC > &idset)
 indicates whether a given score exists More...
 
double score (const IdCondSet< ALLOC > &idset)
 returns a given score More...
 
void clear ()
 removes all the stored scores More...
 
std::size_t size () const
 returns the number of scores saved in the cache More...
 
allocator_type getAllocator () const
 returns the allocator used by the translator More...
 

Public Types

using allocator_type = ALLOC< NodeId >
 type for the allocators passed in arguments of methods More...
 

Detailed Description

template<template< typename > class ALLOC = std::allocator>
class gum::learning::ScoringCache< ALLOC >

a cache for caching scores and independence tests results

Caching previously computed scores or the results of conditional independence tests is very important for learning algorithms because computing a score or an independence test requires parsing the database and this is the most time consuming operation in learning.

This class provides an efficient cache that can significantly alleviate the learning computational burden.

Definition at line 59 of file scoringCache.h.

Member Typedef Documentation

◆ allocator_type

template<template< typename > class ALLOC = std::allocator>
using gum::learning::ScoringCache< ALLOC >::allocator_type = ALLOC< NodeId >

type for the allocators passed in arguments of methods

Definition at line 62 of file scoringCache.h.

Constructor & Destructor Documentation

◆ ScoringCache() [1/5]

template<template< typename > class ALLOC = std::allocator>
gum::learning::ScoringCache< ALLOC >::ScoringCache ( const allocator_type alloc = allocator_type())

default constructor

◆ ScoringCache() [2/5]

template<template< typename > class ALLOC = std::allocator>
gum::learning::ScoringCache< ALLOC >::ScoringCache ( const ScoringCache< ALLOC > &  from)

copy constructor

◆ ScoringCache() [3/5]

template<template< typename > class ALLOC = std::allocator>
gum::learning::ScoringCache< ALLOC >::ScoringCache ( const ScoringCache< ALLOC > &  from,
const allocator_type alloc 
)

copy constructor with a given allocator

◆ ScoringCache() [4/5]

template<template< typename > class ALLOC = std::allocator>
gum::learning::ScoringCache< ALLOC >::ScoringCache ( ScoringCache< ALLOC > &&  from)

move constructor

◆ ScoringCache() [5/5]

template<template< typename > class ALLOC = std::allocator>
gum::learning::ScoringCache< ALLOC >::ScoringCache ( ScoringCache< ALLOC > &&  from,
const allocator_type alloc 
)

move constructor with a given allocator

◆ ~ScoringCache()

template<template< typename > class ALLOC = std::allocator>
virtual gum::learning::ScoringCache< ALLOC >::~ScoringCache ( )
virtual

destructor

Member Function Documentation

◆ clear()

template<template< typename > class ALLOC = std::allocator>
void gum::learning::ScoringCache< ALLOC >::clear ( )

removes all the stored scores

◆ clone() [1/2]

template<template< typename > class ALLOC = std::allocator>
virtual ScoringCache< ALLOC >* gum::learning::ScoringCache< ALLOC >::clone ( ) const
virtual

virtual copy constructor

◆ clone() [2/2]

template<template< typename > class ALLOC = std::allocator>
virtual ScoringCache< ALLOC >* gum::learning::ScoringCache< ALLOC >::clone ( const allocator_type alloc) const
virtual

virtual copy constructor with a given allocator

◆ erase()

template<template< typename > class ALLOC = std::allocator>
void gum::learning::ScoringCache< ALLOC >::erase ( const IdCondSet< ALLOC > &  idset)

removes a score (if it exists)

Parameters
idsetthe IdCondSet storing the sets of variables
Warning
If the score does not exist, nothing is done. In particular, no exception is raised

◆ exists()

template<template< typename > class ALLOC = std::allocator>
bool gum::learning::ScoringCache< ALLOC >::exists ( const IdCondSet< ALLOC > &  idset)

indicates whether a given score exists

Parameters
idsetthe IdCondSet storing the sets of variables

◆ getAllocator()

template<template< typename > class ALLOC = std::allocator>
allocator_type gum::learning::ScoringCache< ALLOC >::getAllocator ( ) const

returns the allocator used by the translator

◆ insert() [1/2]

template<template< typename > class ALLOC = std::allocator>
void gum::learning::ScoringCache< ALLOC >::insert ( const IdCondSet< ALLOC > &  idset,
double  score 
)

insert a new score into the cache

Parameters
idsetthe IdCondSet storing the sets of variables
scorethe score assigned to the IdCondSet
Exceptions
DuplicateElementexception is raised if a score for the same variables already exists

◆ insert() [2/2]

template<template< typename > class ALLOC = std::allocator>
void gum::learning::ScoringCache< ALLOC >::insert ( IdCondSet< ALLOC > &&  idset,
double  score 
)

insert a new score into the cache

Parameters
idsetthe IdCondSet storing the sets of variables
scorethe score assigned to the IdCondSet
Exceptions
DuplicateElementexception is raised if a score for the same variables already exists

◆ operator=() [1/2]

template<template< typename > class ALLOC = std::allocator>
ScoringCache< ALLOC >& gum::learning::ScoringCache< ALLOC >::operator= ( const ScoringCache< ALLOC > &  from)

copy operator

◆ operator=() [2/2]

template<template< typename > class ALLOC = std::allocator>
ScoringCache< ALLOC >& gum::learning::ScoringCache< ALLOC >::operator= ( ScoringCache< ALLOC > &&  from)

move operator

◆ score()

template<template< typename > class ALLOC = std::allocator>
double gum::learning::ScoringCache< ALLOC >::score ( const IdCondSet< ALLOC > &  idset)

returns a given score

Parameters
idsetthe IdCondSet storing the sets of variables
Exceptions
NotFoundis raised if the score is not cached

◆ size()

template<template< typename > class ALLOC = std::allocator>
std::size_t gum::learning::ScoringCache< ALLOC >::size ( ) const

returns the number of scores saved in the cache


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