HOG2
SequenceAlignment.cpp
Go to the documentation of this file.
1 /*
2  * SequenceAlignment.cpp
3  * hog2
4  *
5  * Created by Nathan Sturtevant on 10/20/10.
6  * Copyright 2010 University of Denver. All rights reserved.
7  *
8  */
9 
10 #include "SequenceAlignment.h"
11 
12 void SequenceAlignment::GetSuccessors(const SequenceAlignmentState &nodeID, std::vector<SequenceAlignmentState> &neighbors) const
13 {
14  neighbors.resize(0);
15  if ((nodeID%d) < d-1)
16  neighbors.push_back(nodeID+1);
17  if ((nodeID/d) < d-1)
18  neighbors.push_back(nodeID+d);
19  if (((nodeID%d) < d-1) && ((nodeID/d) < d-1))
20  neighbors.push_back(nodeID+d+1);
21 }
22 
23 void SequenceAlignment::GetActions(const SequenceAlignmentState &nodeID, std::vector<SequenceAlignmentAction> &actions) const
24 {
25  if ((nodeID%d) < d-1)
26  actions.push_back(1);
27  if ((nodeID/d) < d-1)
28  actions.push_back(3);
29  if (((nodeID%d) < d-1) && ((nodeID/d) < d-1))
30  actions.push_back(2);
31 }
32 
34 {
35  assert(false);
36  return 0;
37 }
38 
40 {
41  switch (a)
42  {
43  case -3: s=s-d; break;
44  case -2: s=s-d-1; break;
45  case -1: s=s-1; break;
46  case 3: s=s+d; break;
47  case 2: s=s+d+1; break;
48  case 1: s=s+1; break;
49  default: assert(false);
50  }
51 }
52 
53 
55 {
56  s2 = s1;
57  ApplyAction(s2, a);
58 }
59 
61 { a=-a; return true; }
62 
64 { if (node1==node2) return 0; return 1; }
65 
67 { if (((node1%d) == (node2%d)) || (node1/d == node2/d)) return 1; return 1.5; }
69 { if ((act == 2)||(act == -2)) return 1.5; return 1; }
71 { return node == goal; }
72 
74 uint64_t SequenceAlignment::GetActionHash(SequenceAlignmentAction act) const { return act+3;}
SequenceAlignment::GetActions
virtual void GetActions(const SequenceAlignmentState &nodeID, std::vector< SequenceAlignmentAction > &actions) const
Definition: SequenceAlignment.cpp:23
SequenceAlignment::GoalTest
virtual bool GoalTest(const SequenceAlignmentState &node, const SequenceAlignmentState &goal) const
Definition: SequenceAlignment.cpp:70
SequenceAlignment.h
SequenceAlignment::GCost
virtual double GCost(const SequenceAlignmentState &node1, const SequenceAlignmentState &node2) const
Definition: SequenceAlignment.cpp:66
SequenceAlignment::ApplyAction
virtual void ApplyAction(SequenceAlignmentState &s, SequenceAlignmentAction a) const
Definition: SequenceAlignment.cpp:39
SequenceAlignment::GetSuccessors
virtual void GetSuccessors(const SequenceAlignmentState &nodeID, std::vector< SequenceAlignmentState > &neighbors) const
Definition: SequenceAlignment.cpp:12
SequenceAlignment::GetAction
virtual SequenceAlignmentAction GetAction(const SequenceAlignmentState &s1, const SequenceAlignmentState &s2) const
Definition: SequenceAlignment.cpp:33
SequenceAlignment::HCost
virtual double HCost(const SequenceAlignmentState &node1, const SequenceAlignmentState &node2) const
Heuristic value between two arbitrary nodes.
Definition: SequenceAlignment.cpp:63
SequenceAlignment::d
int d
Definition: SequenceAlignment.h:58
SequenceAlignment::InvertAction
virtual bool InvertAction(SequenceAlignmentAction &a) const
Definition: SequenceAlignment.cpp:60
SequenceAlignment::GetStateHash
virtual uint64_t GetStateHash(const SequenceAlignmentState &node) const
Definition: SequenceAlignment.cpp:73
SequenceAlignment::GetActionHash
virtual uint64_t GetActionHash(SequenceAlignmentAction act) const
Definition: SequenceAlignment.cpp:74
SequenceAlignmentAction
int SequenceAlignmentAction
Definition: SequenceAlignment.h:18
SequenceAlignmentState
uint64_t SequenceAlignmentState
Definition: SequenceAlignment.h:17
node
Nodes to be stored within a Graph.
Definition: Graph.h:170
SequenceAlignment::GetNextState
virtual void GetNextState(const SequenceAlignmentState &, SequenceAlignmentAction, SequenceAlignmentState &) const
Definition: SequenceAlignment.cpp:54