Public Member Functions | Private Types | Private Attributes | List of all members
Sudoku Class Reference

A class that encodes Sudoku's as a CSP problem. More...

Inheritance diagram for Sudoku:
Inheritance graph
[legend]

Public Member Functions

const DiscreteKeydkey (size_t i, size_t j) const
 return DiscreteKey for cell(i,j) More...
 
Key key (size_t i, size_t j) const
 return Key for cell(i,j) More...
 
void printAssignment (const DiscreteValues &assignment) const
 Print readable form of assignment. More...
 
void printDomains (const Domains &domains)
 
void printSolution () const
 solve and print solution More...
 
 Sudoku (size_t n,...)
 Constructor. More...
 
- Public Member Functions inherited from gtsam::CSP
void addAllDiff (const DiscreteKey &key1, const DiscreteKey &key2)
 Add a binary AllDiff constraint. More...
 
void addAllDiff (const DiscreteKeys &dkeys)
 Add a general AllDiff constraint. More...
 
void addSingleValue (const DiscreteKey &dkey, size_t value)
 Add a unary constraint, allowing only a single value. More...
 
CSP partiallyApply (const Domains &domains) const
 
bool runArcConsistency (const VariableIndex &index, Domains *domains) const
 Run arc consistency for all variables, return true if any domain changed. More...
 
Domains runArcConsistency (size_t cardinality, size_t maxIterations=10) const
 
- Public Member Functions inherited from gtsam::DiscreteFactorGraph
template<typename... Args>
void add (Args &&... args)
 
 DiscreteFactorGraph ()
 

map from keys to values

More...
 
template<class CONTAINER >
 DiscreteFactorGraph (const CONTAINER &factors)
 
template<class DERIVED_FACTOR >
 DiscreteFactorGraph (const FactorGraph< DERIVED_FACTOR > &graph)
 
template<typename ITERATOR >
 DiscreteFactorGraph (ITERATOR firstFactor, ITERATOR lastFactor)
 
DiscreteKeys discreteKeys () const
 Return the DiscreteKeys in this factor graph. More...
 
KeySet keys () const
 
DiscreteLookupDAG maxProduct (const Ordering &ordering) const
 Implement the max-product algorithm. More...
 
DiscreteLookupDAG maxProduct (OptionalOrderingType orderingType={}) const
 Implement the max-product algorithm. More...
 
double operator() (const DiscreteValues &values) const
 
DiscreteValues optimize (const Ordering &ordering) const
 Find the maximum probable explanation (MPE) by doing max-product. More...
 
DiscreteValues optimize (OptionalOrderingType orderingType={}) const
 Find the maximum probable explanation (MPE) by doing max-product. More...
 
void print (const std::string &s="DiscreteFactorGraph", const KeyFormatter &formatter=DefaultKeyFormatter) const override
 print More...
 
DecisionTreeFactor product () const
 
DiscreteBayesNet sumProduct (const Ordering &ordering) const
 Implement the sum-product algorithm. More...
 
DiscreteBayesNet sumProduct (OptionalOrderingType orderingType={}) const
 Implement the sum-product algorithm. More...
 
bool equals (const This &fg, double tol=1e-9) const
 
std::string markdown (const KeyFormatter &keyFormatter=DefaultKeyFormatter, const DiscreteFactor::Names &names={}) const
 Render as markdown tables. More...
 
std::string html (const KeyFormatter &keyFormatter=DefaultKeyFormatter, const DiscreteFactor::Names &names={}) const
 Render as html tables. More...
 
- Public Member Functions inherited from gtsam::FactorGraph< DiscreteFactor >
 FactorGraph (std::initializer_list< std::shared_ptr< DERIVEDFACTOR >> sharedFactors)
 
virtual ~FactorGraph ()=default
 
void reserve (size_t size)
 
IsDerived< DERIVEDFACTOR > push_back (std::shared_ptr< DERIVEDFACTOR > factor)
 Add a factor directly using a shared_ptr. More...
 
IsDerived< DERIVEDFACTOR > push_back (const DERIVEDFACTOR &factor)
 
IsDerived< DERIVEDFACTOR > emplace_shared (Args &&... args)
 Emplace a shared pointer to factor of given type. More...
 
IsDerived< DERIVEDFACTOR > add (std::shared_ptr< DERIVEDFACTOR > factor)
 add is a synonym for push_back. More...
 
std::enable_if< std::is_base_of< FactorType, DERIVEDFACTOR >::value, This >::typeoperator+= (std::shared_ptr< DERIVEDFACTOR > factor)
 Append factor to factor graph. More...
 
std::enable_if< std::is_base_of< FactorType, DERIVEDFACTOR >::value, This >::typeoperator, (std::shared_ptr< DERIVEDFACTOR > factor)
 Overload comma operator to allow for append chaining. More...
 
HasDerivedElementType< ITERATOR > push_back (ITERATOR firstFactor, ITERATOR lastFactor)
 
HasDerivedValueType< ITERATOR > push_back (ITERATOR firstFactor, ITERATOR lastFactor)
 Push back many factors with an iterator (factors are copied) More...
 
HasDerivedElementType< CONTAINER > push_back (const CONTAINER &container)
 
HasDerivedValueType< CONTAINER > push_back (const CONTAINER &container)
 Push back non-pointer objects in a container (factors are copied). More...
 
void add (const FACTOR_OR_CONTAINER &factorOrContainer)
 
Thisoperator+= (const FACTOR_OR_CONTAINER &factorOrContainer)
 
std::enable_if< std::is_base_of< This, typename CLIQUE::FactorGraphType >::value >::type push_back (const BayesTree< CLIQUE > &bayesTree)
 
FactorIndices add_factors (const CONTAINER &factors, bool useEmptySlots=false)
 
bool equals (const This &fg, double tol=1e-9) const
 Check equality up to tolerance. More...
 
size_t size () const
 
bool empty () const
 
const sharedFactor at (size_t i) const
 
sharedFactorat (size_t i)
 
std::shared_ptr< F > at (size_t i)
 
const std::shared_ptr< F > at (size_t i) const
 Const version of templated at method. More...
 
const sharedFactor operator[] (size_t i) const
 
sharedFactoroperator[] (size_t i)
 
const_iterator begin () const
 
const_iterator end () const
 
sharedFactor front () const
 
sharedFactor back () const
 
double error (const HybridValues &values) const
 
iterator begin ()
 
iterator end ()
 
virtual void resize (size_t size)
 
void remove (size_t i)
 
void replace (size_t index, sharedFactor factor)
 
iterator erase (iterator item)
 
iterator erase (iterator first, iterator last)
 
void dot (std::ostream &os, const KeyFormatter &keyFormatter=DefaultKeyFormatter, const DotWriter &writer=DotWriter()) const
 Output to graphviz format, stream version. More...
 
std::string dot (const KeyFormatter &keyFormatter=DefaultKeyFormatter, const DotWriter &writer=DotWriter()) const
 Output to graphviz format string. More...
 
void saveGraph (const std::string &filename, const KeyFormatter &keyFormatter=DefaultKeyFormatter, const DotWriter &writer=DotWriter()) const
 output to file with graphviz format. More...
 
size_t nrFactors () const
 
KeySet keys () const
 
KeyVector keyVector () const
 
bool exists (size_t idx) const
 
- Public Member Functions inherited from gtsam::EliminateableFactorGraph< DiscreteFactorGraph >
std::shared_ptr< BayesTreeTypeeliminateMultifrontal (const Ordering &ordering, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
 
std::shared_ptr< BayesTreeTypeeliminateMultifrontal (OptionalOrderingType orderingType={}, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
 
std::pair< std::shared_ptr< BayesTreeType >, std::shared_ptr< FactorGraphType > > eliminatePartialMultifrontal (const KeyVector &variables, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
 
std::pair< std::shared_ptr< BayesTreeType >, std::shared_ptr< FactorGraphType > > eliminatePartialMultifrontal (const Ordering &ordering, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
 
std::pair< std::shared_ptr< BayesNetType >, std::shared_ptr< FactorGraphType > > eliminatePartialSequential (const KeyVector &variables, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
 
std::pair< std::shared_ptr< BayesNetType >, std::shared_ptr< FactorGraphType > > eliminatePartialSequential (const Ordering &ordering, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
 
std::shared_ptr< BayesNetTypeeliminateSequential (const Ordering &ordering, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
 
std::shared_ptr< BayesNetTypeeliminateSequential (OptionalOrderingType orderingType={}, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
 
std::shared_ptr< FactorGraphTypemarginal (const KeyVector &variables, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
 
std::shared_ptr< BayesNetTypemarginalMultifrontalBayesNet (const KeyVector &variables, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
 
std::shared_ptr< BayesNetTypemarginalMultifrontalBayesNet (const KeyVector &variables, const Ordering &marginalizedVariableOrdering, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
 
std::shared_ptr< BayesNetTypemarginalMultifrontalBayesNet (const Ordering &variables, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
 
std::shared_ptr< BayesNetTypemarginalMultifrontalBayesNet (const Ordering &variables, const Ordering &marginalizedVariableOrdering, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
 
std::shared_ptr< BayesTreeTypemarginalMultifrontalBayesTree (const KeyVector &variables, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
 
std::shared_ptr< BayesTreeTypemarginalMultifrontalBayesTree (const KeyVector &variables, const Ordering &marginalizedVariableOrdering, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
 
std::shared_ptr< BayesTreeTypemarginalMultifrontalBayesTree (const Ordering &variables, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
 
std::shared_ptr< BayesTreeTypemarginalMultifrontalBayesTree (const Ordering &variables, const Ordering &marginalizedVariableOrdering, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
 

Private Types

using IJ = std::pair< size_t, size_t >
 Mapping from base i,j coordinates to discrete keys: More...
 

Private Attributes

std::map< IJ, DiscreteKeydkeys_
 
size_t n_
 Side of Sudoku, e.g. 4 or 9. More...
 

Additional Inherited Members

- Public Types inherited from gtsam::CSP
using Values = DiscreteValues
 backwards compatibility More...
 
- Public Types inherited from gtsam::DiscreteFactorGraph
using Base = FactorGraph< DiscreteFactor >
 base factor graph type More...
 
using BaseEliminateable = EliminateableFactorGraph< This >
 for elimination More...
 
using Indices = KeyVector
 
using shared_ptr = std::shared_ptr< This >
 shared_ptr to This More...
 
using This = DiscreteFactorGraph
 this class More...
 
using Values = DiscreteValues
 backwards compatibility More...
 
- Public Types inherited from gtsam::FactorGraph< DiscreteFactor >
typedef FastVector< sharedFactor >::const_iterator const_iterator
 
typedef DiscreteFactor FactorType
 factor type More...
 
typedef FastVector< sharedFactor >::iterator iterator
 
typedef std::shared_ptr< DiscreteFactorsharedFactor
 Shared pointer to a factor. More...
 
typedef sharedFactor value_type
 
- Public Types inherited from gtsam::EliminateableFactorGraph< DiscreteFactorGraph >
typedef EliminationTraitsType::BayesNetType BayesNetType
 Bayes net type produced by sequential elimination. More...
 
typedef EliminationTraitsType::BayesTreeType BayesTreeType
 Bayes tree type produced by multifrontal elimination. More...
 
typedef EliminationTraitsType::ConditionalType ConditionalType
 Conditional type stored in the Bayes net produced by elimination. More...
 
typedef std::function< EliminationResult(const FactorGraphType &, const Ordering &)> Eliminate
 The function type that does a single dense elimination step on a subgraph. More...
 
typedef std::pair< std::shared_ptr< ConditionalType >, std::shared_ptr< _FactorType > > EliminationResult
 
typedef EliminationTraits< FactorGraphTypeEliminationTraitsType
 Typedef to the specific EliminationTraits for this graph. More...
 
typedef EliminationTraitsType::EliminationTreeType EliminationTreeType
 Elimination tree type that can do sequential elimination of this graph. More...
 
typedef EliminationTraitsType::JunctionTreeType JunctionTreeType
 Junction tree type that can do multifrontal elimination of this graph. More...
 
typedef std::optional< Ordering::OrderingTypeOptionalOrderingType
 Typedef for an optional ordering type. More...
 
typedef std::optional< std::reference_wrapper< const VariableIndex > > OptionalVariableIndex
 
- Protected Member Functions inherited from gtsam::FactorGraph< DiscreteFactor >
bool isEqual (const FactorGraph &other) const
 Check exact equality of the factor pointers. Useful for derived ==. More...
 
 FactorGraph ()
 
 FactorGraph (ITERATOR firstFactor, ITERATOR lastFactor)
 
 FactorGraph (const CONTAINER &factors)
 
- Protected Attributes inherited from gtsam::FactorGraph< DiscreteFactor >
FastVector< sharedFactorfactors_
 

Detailed Description

A class that encodes Sudoku's as a CSP problem.

Definition at line 23 of file testSudoku.cpp.

Member Typedef Documentation

◆ IJ

using Sudoku::IJ = std::pair<size_t, size_t>
private

Mapping from base i,j coordinates to discrete keys:

Definition at line 27 of file testSudoku.cpp.

Constructor & Destructor Documentation

◆ Sudoku()

Sudoku::Sudoku ( size_t  n,
  ... 
)
inline

Constructor.

Definition at line 40 of file testSudoku.cpp.

Member Function Documentation

◆ dkey()

const DiscreteKey& Sudoku::dkey ( size_t  i,
size_t  j 
) const
inline

return DiscreteKey for cell(i,j)

Definition at line 32 of file testSudoku.cpp.

◆ key()

Key Sudoku::key ( size_t  i,
size_t  j 
) const
inline

return Key for cell(i,j)

Definition at line 37 of file testSudoku.cpp.

◆ printAssignment()

void Sudoku::printAssignment ( const DiscreteValues assignment) const
inline

Print readable form of assignment.

Definition at line 89 of file testSudoku.cpp.

◆ printDomains()

void Sudoku::printDomains ( const Domains domains)
inline

Definition at line 106 of file testSudoku.cpp.

◆ printSolution()

void Sudoku::printSolution ( ) const
inline

solve and print solution

Definition at line 100 of file testSudoku.cpp.

Member Data Documentation

◆ dkeys_

std::map<IJ, DiscreteKey> Sudoku::dkeys_
private

Definition at line 28 of file testSudoku.cpp.

◆ n_

size_t Sudoku::n_
private

Side of Sudoku, e.g. 4 or 9.

Definition at line 24 of file testSudoku.cpp.


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


gtsam
Author(s):
autogenerated on Fri Nov 1 2024 03:43:43