HOG2
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Private Member Functions | List of all members
PermutationPuzzle::PermutationPuzzleEnvironment< state, action > Class Template Referenceabstract

Note, assumes that state has a public vector<int> called puzzle in which the permutation is held. More...

#include <PermutationPuzzleEnvironment.h>

Collaboration diagram for PermutationPuzzle::PermutationPuzzleEnvironment< state, action >:
Collaboration graph
[legend]

Public Member Functions

 PermutationPuzzleEnvironment ()
 
double HCost (const state &s) const
 
virtual double AdditiveGCost (const state &s, const action &d)
 
void GetStateFromHash (state &s, uint64_t hash) const
 
uint64_t GetStateHash (const state &s) const
 
state TranformToStandardGoal (const state &a, const state &b) const
 
virtual void FinishUnranking (state &s) const
 
bool Validate_Problems (std::vector< state > &puzzles)
 

Static Public Member Functions

static uint64_t Hash (const state &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< state > &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)
 

Public Attributes

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

uint64_t Factorial (int val) const
 
uint64_t nUpperk (int n, int k) const
 Returns the value of n! / k! More...
 
virtual bool State_Check (const state &to_check)=0
 Checks that the given state is a valid state for this domain. More...
 

Private Member Functions

virtual double DefaultH (const state &s) const
 
void buildCaches () const
 Builds caches for nUpperk. More...
 

Detailed Description

template<class state, class action>
class PermutationPuzzle::PermutationPuzzleEnvironment< state, action >

Note, assumes that state has a public vector<int> called puzzle in which the permutation is held.

Definition at line 26 of file PermutationPuzzleEnvironment.h.

Constructor & Destructor Documentation

◆ PermutationPuzzleEnvironment()

template<class state , class action >
PermutationPuzzle::PermutationPuzzleEnvironment< state, action >::PermutationPuzzleEnvironment ( )
inline

Definition at line 59 of file PermutationPuzzleEnvironment.h.

Member Function Documentation

◆ AdditiveGCost()

template<class state , class action >
virtual double PermutationPuzzle::PermutationPuzzleEnvironment< state, action >::AdditiveGCost ( const state &  s,
const action &  d 
)
inlinevirtual

Reimplemented in TopSpin< N, k >.

Definition at line 63 of file PermutationPuzzleEnvironment.h.

◆ buildCaches()

template<class state , class action >
void PermutationPuzzle::PermutationPuzzleEnvironment< state, action >::buildCaches
private

Builds caches for nUpperk.

Definition at line 1115 of file PermutationPuzzleEnvironment.h.

◆ Check_Permutation()

template<class state , class action >
bool PermutationPuzzle::PermutationPuzzleEnvironment< state, action >::Check_Permutation ( const std::vector< int > &  to_check)
static

Ensures that the state contains a valid permutation.

That is, if the state is of size n, each of the integers from 0 to n-1 occurs exactly once.

Definition at line 1360 of file PermutationPuzzleEnvironment.h.

◆ DefaultH()

template<class state , class action >
virtual double PermutationPuzzle::PermutationPuzzleEnvironment< state, action >::DefaultH ( const state &  s) const
inlineprivatevirtual

Reimplemented in PancakePuzzle< N >, and MNPuzzle< width, height >.

Definition at line 105 of file PermutationPuzzleEnvironment.h.

◆ Factorial()

template<class state , class action >
uint64_t PermutationPuzzle::PermutationPuzzleEnvironment< state, action >::Factorial ( int  val) const
protected

Definition at line 1100 of file PermutationPuzzleEnvironment.h.

◆ FinishUnranking()

template<class state , class action >
virtual void PermutationPuzzle::PermutationPuzzleEnvironment< state, action >::FinishUnranking ( state &  s) const
inlinevirtual

Definition at line 79 of file PermutationPuzzleEnvironment.h.

◆ Get_Random_Permutation()

template<class state , class action >
std::vector< int > PermutationPuzzle::PermutationPuzzleEnvironment< state, action >::Get_Random_Permutation ( unsigned  size)
static

Definition at line 1499 of file PermutationPuzzleEnvironment.h.

◆ GetStateFromHash()

template<class state , class action >
void PermutationPuzzle::PermutationPuzzleEnvironment< state, action >::GetStateFromHash ( state &  s,
uint64_t  hash 
) const

Definition at line 1276 of file PermutationPuzzleEnvironment.h.

◆ GetStateHash()

template<class state , class action >
uint64_t PermutationPuzzle::PermutationPuzzleEnvironment< state, action >::GetStateHash ( const state &  s) const

Definition at line 1284 of file PermutationPuzzleEnvironment.h.

◆ Hash()

template<class state , class action >
static uint64_t PermutationPuzzle::PermutationPuzzleEnvironment< state, action >::Hash ( const state &  s)
inlinestatic

Definition at line 68 of file PermutationPuzzleEnvironment.h.

◆ HCost()

template<class state , class action >
double PermutationPuzzle::PermutationPuzzleEnvironment< state, action >::HCost ( const state &  s) const

Definition at line 1013 of file PermutationPuzzleEnvironment.h.

◆ nUpperk()

template<class state , class action >
uint64_t PermutationPuzzle::PermutationPuzzleEnvironment< state, action >::nUpperk ( int  n,
int  k 
) const
protected

Returns the value of n! / k!

Definition at line 1138 of file PermutationPuzzleEnvironment.h.

◆ Output_Puzzles()

template<class state , class action >
bool PermutationPuzzle::PermutationPuzzleEnvironment< state, action >::Output_Puzzles ( std::vector< state > &  puzzle_vector,
bool  write_puzz_num 
)
static

Outputs the set of puzzles in puzzle_vector to standard output.

The output is of the form "I_0 I_1 ... I_(MN - 1)" where I_K is the element in the Kth position of the puzzle. If the write_puzz_num flag is set as true, the first item of the output is the puzzle number. Puzzles are checked for validity before they are outputted. True is return if all the puzzles are valid, otherwise false is returned and the puzzles are not outputted.

Make sure all puzzles are for this environment

Definition at line 1394 of file PermutationPuzzleEnvironment.h.

◆ Read_In_Permutations()

template<class state , class action >
bool PermutationPuzzle::PermutationPuzzleEnvironment< state, action >::Read_In_Permutations ( const char *  filename,
unsigned  size,
unsigned  max_puzzles,
std::vector< std::vector< int > > &  permutations,
bool  puzz_num_start 
)
static

Definition at line 1428 of file PermutationPuzzleEnvironment.h.

◆ State_Check()

template<class state , class action >
virtual bool PermutationPuzzle::PermutationPuzzleEnvironment< state, action >::State_Check ( const state &  to_check)
protectedpure virtual

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)

Implemented in TopSpin< N, k >, PancakePuzzle< N >, and MNPuzzle< width, height >.

◆ TranformToStandardGoal()

template<class state , class action >
state PermutationPuzzle::PermutationPuzzleEnvironment< state, action >::TranformToStandardGoal ( const state &  a,
const state &  b 
) const

Definition at line 1296 of file PermutationPuzzleEnvironment.h.

◆ Validate_Problems()

template<class state , class action >
bool PermutationPuzzle::PermutationPuzzleEnvironment< state, action >::Validate_Problems ( std::vector< state > &  puzzles)

Definition at line 1524 of file PermutationPuzzleEnvironment.h.

Member Data Documentation

◆ additive

template<class state , class action >
bool PermutationPuzzle::PermutationPuzzleEnvironment< state, action >::additive

Definition at line 124 of file PermutationPuzzleEnvironment.h.

◆ factorialCache

template<class state , class action >
std::vector<std::vector<uint64_t> > PermutationPuzzle::PermutationPuzzleEnvironment< state, action >::factorialCache
mutable

Definition at line 131 of file PermutationPuzzleEnvironment.h.

◆ lookups

template<class state , class action >
std::vector<PDBTreeNode> PermutationPuzzle::PermutationPuzzleEnvironment< state, action >::lookups

Definition at line 130 of file PermutationPuzzleEnvironment.h.

◆ maxItem

template<class state , class action >
int PermutationPuzzle::PermutationPuzzleEnvironment< state, action >::maxItem

Definition at line 125 of file PermutationPuzzleEnvironment.h.

◆ minPattern

template<class state , class action >
int PermutationPuzzle::PermutationPuzzleEnvironment< state, action >::minPattern

Definition at line 125 of file PermutationPuzzleEnvironment.h.

◆ mr1

template<class state , class action >
MR1KPermutation PermutationPuzzle::PermutationPuzzleEnvironment< state, action >::mr1

◆ PDB

template<class state , class action >
std::vector<std::vector<uint8_t> > PermutationPuzzle::PermutationPuzzleEnvironment< state, action >::PDB

Definition at line 127 of file PermutationPuzzleEnvironment.h.

◆ PDB_distincts

template<class state , class action >
std::vector<std::vector<int> > PermutationPuzzle::PermutationPuzzleEnvironment< state, action >::PDB_distincts

Definition at line 129 of file PermutationPuzzleEnvironment.h.


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