HOG2
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
TopSpin< N, k > Class Template Reference

#include <TopSpin.h>

Inheritance diagram for TopSpin< N, k >:
Inheritance graph
[legend]
Collaboration diagram for TopSpin< N, k >:
Collaboration graph
[legend]

Public Member Functions

 TopSpin ()
 
 ~TopSpin ()
 
void SetWeighted (bool w)
 
bool GetWeighted ()
 
void SetPruneSuccessors (bool val)
 
void GetSuccessors (const TopSpinState< N > &stateID, std::vector< TopSpinState< N >> &neighbors) const
 
void GetActions (const TopSpinState< N > &stateID, std::vector< TopSpinAction > &actions) const
 
void ApplyAction (TopSpinState< N > &s, TopSpinAction a) const
 
void UndoAction (TopSpinState< N > &s, TopSpinAction a) const
 
bool InvertAction (TopSpinAction &a) const
 
void SetPattern (const std::vector< int > &pattern)
 
double AdditiveGCost (const TopSpinState< N > &s, const TopSpinAction &d)
 
OccupancyInterface< TopSpinState< N >, TopSpinAction > * GetOccupancyInfo ()
 
double HCost (const TopSpinState< N > &state1, const TopSpinState< N > &state2) const
 
double GCost (const TopSpinState< N > &state1, const TopSpinState< N > &state2) const
 
double GCost (const TopSpinState< N > &, const TopSpinAction &) const
 
bool GoalTest (const TopSpinState< N > &state, const TopSpinState< N > &goal) const
 
bool GoalTest (const TopSpinState< N > &s) const
 
void GetGoals (std::vector< TopSpinState< N >> &goals)
 
uint64_t GetActionHash (TopSpinAction act) const
 
void OpenGLDraw () const
 
void OpenGLDraw (const TopSpinState< N > &s) const
 
void OpenGLDraw (const TopSpinState< N > &l1, const TopSpinState< N > &l2, float v) const
 
void OpenGLDraw (const TopSpinState< N > &, const TopSpinAction &) const
 
void StoreGoal (TopSpinState< N > &)
 
TopSpinState< N > Get_Goal ()
 Returns stored goal state if it is stored. More...
 
virtual const std::string GetName ()
 
void ClearGoal ()
 
bool IsGoalStored () const
 
bool State_Check (const TopSpinState< N > &to_check)
 Checks that the given state is a valid state for this domain. More...
 
void PrintHStats ()
 
- Public Member Functions inherited from PermutationPuzzle::PermutationPuzzleEnvironment< TopSpinState< N >, TopSpinAction >
 PermutationPuzzleEnvironment ()
 
double HCost (const TopSpinState< N > &s) const
 
void GetStateFromHash (TopSpinState< N > &s, uint64_t hash) const
 
uint64_t GetStateHash (const TopSpinState< N > &s) const
 
TopSpinState< N > TranformToStandardGoal (const TopSpinState< N > &a, const TopSpinState< N > &b) const
 
virtual void FinishUnranking (TopSpinState< N > &s) const
 
bool Validate_Problems (std::vector< TopSpinState< N > > &puzzles)
 

Static Public Member Functions

static unsigned GetParity (TopSpinState< N > &state)
 
- Static Public Member Functions inherited from PermutationPuzzle::PermutationPuzzleEnvironment< TopSpinState< N >, TopSpinAction >
static uint64_t Hash (const TopSpinState< N > &s)
 
static bool Check_Permutation (const std::vector< int > &to_check)
 Ensures that the state contains a valid permutation. More...
 
static bool Output_Puzzles (std::vector< TopSpinState< N > > &puzzle_vector, bool write_puzz_num)
 Outputs the set of puzzles in puzzle_vector to standard output. More...
 
static bool Read_In_Permutations (const char *filename, unsigned size, unsigned max_puzzles, std::vector< std::vector< int > > &permutations, bool puzz_num_start)
 
static std::vector< int > Get_Random_Permutation (unsigned size)
 

Private Member Functions

void ComputeMovePruning ()
 
void RecursiveMovePruning (int depth, TopSpinState< N > &state)
 

Private Attributes

std::unordered_map< uint64_t, bool > pruningMap
 
std::unordered_map< uint64_t, int > pruningCostMap
 
std::vector< TopSpinActionoperators
 
std::vector< bool > movePrune
 
unsigned ** h_increment
 
TopSpinState< N > goal
 
std::vector< std::vector< int > > hDist
 
bool pattern [N]
 
std::vector< TopSpinActionhistory
 
bool pruneSuccessors
 
bool weighted
 
bool additive
 

Additional Inherited Members

- Public Attributes inherited from PermutationPuzzle::PermutationPuzzleEnvironment< TopSpinState< N >, TopSpinAction >
bool additive
 
int maxItem
 
int minPattern
 
std::vector< std::vector< uint8_t > > PDB
 
std::vector< std::vector< int > > PDB_distincts
 
std::vector< PDBTreeNodelookups
 
std::vector< std::vector< uint64_t > > factorialCache
 
MR1KPermutation mr1
 
- Protected Member Functions inherited from PermutationPuzzle::PermutationPuzzleEnvironment< TopSpinState< N >, TopSpinAction >
uint64_t Factorial (int val) const
 
uint64_t nUpperk (int n, int k) const
 Returns the value of n! / k! More...
 

Detailed Description

template<int N, int k>
class TopSpin< N, k >

Definition at line 77 of file TopSpin.h.

Constructor & Destructor Documentation

◆ TopSpin()

template<int N, int k>
TopSpin< N, k >::TopSpin

◆ ~TopSpin()

template<int N, int k>
TopSpin< N, k >::~TopSpin

Definition at line 193 of file TopSpin.h.

Member Function Documentation

◆ AdditiveGCost()

template<int N, int k>
double TopSpin< N, k >::AdditiveGCost ( const TopSpinState< N > &  s,
const TopSpinAction d 
)
virtual

◆ ApplyAction()

template<int N, int k>
void TopSpin< N, k >::ApplyAction ( TopSpinState< N > &  s,
TopSpinAction  a 
) const

Definition at line 321 of file TopSpin.h.

References TopSpinState< N >::puzzle, and swap().

◆ ClearGoal()

template<int N, int k>
void TopSpin< N, k >::ClearGoal ( )
inline

Definition at line 129 of file TopSpin.h.

◆ ComputeMovePruning()

template<int N, int k>
void TopSpin< N, k >::ComputeMovePruning
private

Definition at line 233 of file TopSpin.h.

Referenced by TopSpin< N, k >::SetPruneSuccessors().

◆ GCost() [1/2]

template<int N, int k>
double TopSpin< N, k >::GCost ( const TopSpinState< N > &  node,
const TopSpinAction act 
) const

Definition at line 368 of file TopSpin.h.

References tsCostCount, and tscosts.

◆ GCost() [2/2]

template<int N, int k>
double TopSpin< N, k >::GCost ( const TopSpinState< N > &  state1,
const TopSpinState< N > &  state2 
) const

Definition at line 385 of file TopSpin.h.

◆ Get_Goal()

template<int N, int k>
TopSpinState<N> TopSpin< N, k >::Get_Goal ( )
inline

Returns stored goal state if it is stored.

Definition at line 123 of file TopSpin.h.

References TopSpin< N, k >::goal.

◆ GetActionHash()

template<int N, int k>
uint64_t TopSpin< N, k >::GetActionHash ( TopSpinAction  act) const

Definition at line 400 of file TopSpin.h.

◆ GetActions()

template<int N, int k>
void TopSpin< N, k >::GetActions ( const TopSpinState< N > &  stateID,
std::vector< TopSpinAction > &  actions 
) const

Definition at line 301 of file TopSpin.h.

◆ GetGoals()

template<int N, int k>
void TopSpin< N, k >::GetGoals ( std::vector< TopSpinState< N >> &  goals)
inline

Definition at line 101 of file TopSpin.h.

References TopSpinState< N >::puzzle.

◆ GetName()

template<int N, int k>
const std::string TopSpin< N, k >::GetName
virtual

Definition at line 199 of file TopSpin.h.

◆ GetOccupancyInfo()

template<int N, int k>
OccupancyInterface<TopSpinState<N>, TopSpinAction>* TopSpin< N, k >::GetOccupancyInfo ( )
inline

Definition at line 94 of file TopSpin.h.

◆ GetParity()

template<int N, int k>
static unsigned TopSpin< N, k >::GetParity ( TopSpinState< N > &  state)
static

◆ GetSuccessors()

template<int N, int k>
void TopSpin< N, k >::GetSuccessors ( const TopSpinState< N > &  stateID,
std::vector< TopSpinState< N >> &  neighbors 
) const

Definition at line 288 of file TopSpin.h.

◆ GetWeighted()

template<int N, int k>
bool TopSpin< N, k >::GetWeighted ( )
inline

Definition at line 82 of file TopSpin.h.

References TopSpin< N, k >::weighted.

◆ GoalTest() [1/2]

template<int N, int k>
bool TopSpin< N, k >::GoalTest ( const TopSpinState< N > &  s) const

Definition at line 279 of file TopSpin.h.

References TopSpinState< N >::puzzle.

◆ GoalTest() [2/2]

template<int N, int k>
bool TopSpin< N, k >::GoalTest ( const TopSpinState< N > &  state,
const TopSpinState< N > &  goal 
) const

Definition at line 393 of file TopSpin.h.

◆ HCost()

template<int N, int k>
double TopSpin< N, k >::HCost ( const TopSpinState< N > &  state1,
const TopSpinState< N > &  state2 
) const

Definition at line 353 of file TopSpin.h.

◆ InvertAction()

template<int N, int k>
bool TopSpin< N, k >::InvertAction ( TopSpinAction a) const

Definition at line 346 of file TopSpin.h.

◆ IsGoalStored()

template<int N, int k>
bool TopSpin< N, k >::IsGoalStored ( ) const
inline

Definition at line 131 of file TopSpin.h.

◆ OpenGLDraw() [1/4]

template<int N, int k>
void TopSpin< N, k >::OpenGLDraw

Definition at line 406 of file TopSpin.h.

◆ OpenGLDraw() [2/4]

template<int N, int k>
void TopSpin< N, k >::OpenGLDraw ( const TopSpinState< N > &  ,
const TopSpinAction  
) const
inline

Definition at line 119 of file TopSpin.h.

◆ OpenGLDraw() [3/4]

template<int N, int k>
void TopSpin< N, k >::OpenGLDraw ( const TopSpinState< N > &  l1,
const TopSpinState< N > &  l2,
float  v 
) const

Definition at line 477 of file TopSpin.h.

◆ OpenGLDraw() [4/4]

template<int N, int k>
void TopSpin< N, k >::OpenGLDraw ( const TopSpinState< N > &  s) const

Definition at line 455 of file TopSpin.h.

References DrawTSTile(), LocalDrawCircle(), and TopSpinState< N >::puzzle.

◆ PrintHStats()

template<int N, int k>
void TopSpin< N, k >::PrintHStats ( )
inline

Definition at line 135 of file TopSpin.h.

References TopSpin< N, k >::hDist.

◆ RecursiveMovePruning()

template<int N, int k>
void TopSpin< N, k >::RecursiveMovePruning ( int  depth,
TopSpinState< N > &  state 
)
private

Definition at line 246 of file TopSpin.h.

◆ SetPattern()

template<int N, int k>
void TopSpin< N, k >::SetPattern ( const std::vector< int > &  pattern)

Definition at line 207 of file TopSpin.h.

◆ SetPruneSuccessors()

template<int N, int k>
void TopSpin< N, k >::SetPruneSuccessors ( bool  val)
inline

◆ SetWeighted()

template<int N, int k>
void TopSpin< N, k >::SetWeighted ( bool  w)
inline

Definition at line 81 of file TopSpin.h.

References TopSpin< N, k >::weighted.

◆ State_Check()

template<int N, int k>
bool TopSpin< N, k >::State_Check ( const TopSpinState< N > &  to_check)
inlinevirtual

Checks that the given state is a valid state for this domain.

Note, is not a check of solvability, just legality (ie. has the right size, dimensions). Note, this method should be a quick check that can be used for debugging purposes and so should not call Check_Permutation which is O(state size)

Implements PermutationPuzzle::PermutationPuzzleEnvironment< TopSpinState< N >, TopSpinAction >.

Definition at line 133 of file TopSpin.h.

◆ StoreGoal()

template<int N, int k>
void TopSpin< N, k >::StoreGoal ( TopSpinState< N > &  s)

Definition at line 274 of file TopSpin.h.

◆ UndoAction()

template<int N, int k>
void TopSpin< N, k >::UndoAction ( TopSpinState< N > &  s,
TopSpinAction  a 
) const

Definition at line 332 of file TopSpin.h.

References TopSpinState< N >::puzzle, and swap().

Member Data Documentation

◆ additive

template<int N, int k>
bool TopSpin< N, k >::additive
private

Definition at line 174 of file TopSpin.h.

Referenced by TopSpin< N, k >::TopSpin().

◆ goal

template<int N, int k>
TopSpinState<N> TopSpin< N, k >::goal
private

Definition at line 167 of file TopSpin.h.

Referenced by TopSpin< N, k >::Get_Goal().

◆ h_increment

template<int N, int k>
unsigned** TopSpin< N, k >::h_increment
private

Definition at line 166 of file TopSpin.h.

◆ hDist

template<int N, int k>
std::vector<std::vector<int> > TopSpin< N, k >::hDist
private

Definition at line 168 of file TopSpin.h.

Referenced by TopSpin< N, k >::PrintHStats().

◆ history

template<int N, int k>
std::vector<TopSpinAction> TopSpin< N, k >::history
mutableprivate

Definition at line 171 of file TopSpin.h.

Referenced by TopSpin< N, k >::SetPruneSuccessors().

◆ movePrune

template<int N, int k>
std::vector<bool> TopSpin< N, k >::movePrune
private

Definition at line 163 of file TopSpin.h.

◆ operators

template<int N, int k>
std::vector<TopSpinAction> TopSpin< N, k >::operators
private

Definition at line 162 of file TopSpin.h.

Referenced by TopSpin< N, k >::TopSpin().

◆ pattern

template<int N, int k>
bool TopSpin< N, k >::pattern[N]
private

Definition at line 169 of file TopSpin.h.

◆ pruneSuccessors

template<int N, int k>
bool TopSpin< N, k >::pruneSuccessors
private

Definition at line 172 of file TopSpin.h.

Referenced by TopSpin< N, k >::SetPruneSuccessors(), and TopSpin< N, k >::TopSpin().

◆ pruningCostMap

template<int N, int k>
std::unordered_map<uint64_t,int> TopSpin< N, k >::pruningCostMap
private

Definition at line 159 of file TopSpin.h.

◆ pruningMap

template<int N, int k>
std::unordered_map<uint64_t,bool> TopSpin< N, k >::pruningMap
private

Definition at line 158 of file TopSpin.h.

◆ weighted

template<int N, int k>
bool TopSpin< N, k >::weighted
private

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