26 static const char UP = 0;
27 static const char DOWN = 1;
28 static const char LEFT = 2;
49 char direction(
unsigned int i){
return dDirections[i]; }
115 static const char map[] = {
'U',
'D',
'R',
'L',
'F' };
122 return prevDirection;
126 int sign = prevDirection.
x + prevDirection.
y + prevDirection.
z;
128 struct {
char x, z; }
130 .x = (prevDirection.
x == 0),
131 .z = (prevDirection.
z == 0),
136 retval.
x = sign * isZero.x;
137 retval.y = sign * !isZero.x;
138 }
else if(dir ==
LEFT){
139 retval.x = -sign * isZero.x;
140 retval.y = -sign * !isZero.x;
141 }
else if(dir ==
UP){
142 retval.z = 1 * isZero.z;
143 retval.y = 1 * !isZero.z;
145 retval.z = -1 * isZero.z;
146 retval.y = -1 * !isZero.z;
161 for(
unsigned i = 0; i <
dVector.size(); i++){
162 if(chain[i] ==
'P')
continue;
164 for(
unsigned j = i+1; j <
dVector.size(); j++){
165 if(chain[j] ==
'P')
continue;
167 if(norm1 == 1) contacts++;
176 std::uniform_real_distribution<> randDist(0.0, 1.0);
196 stream << point <<
" ";
std::vector< char > & directions()
Vector of directions taken by the ant.
Definition: acosolution.h:41
static const char LEFT
Relative direction.
Definition: acosolution.h:28
Encapsulates a string representing an HP chain.
Definition: hpchain.h:8
void perturb_one(std::mt19937 &dRandGen)
The solution has a vector of N directions, this procedure chooses a random direction and randomizes i...
Definition: acosolution.h:175
vec3< int > bead(unsigned int i)
Gets an specific bead.
Definition: acosolution.h:46
const std::vector< vec3< int > > & vector() const
Vector of bead coordinates.
Definition: acosolution.h:37
void set_error()
Sets error to signalize existence of an error.
Definition: acosolution.h:83
std::vector< vec3< int > > dVector
Vector of bead coordinates.
Definition: acosolution.h:13
Represents a triple (x, y, z) of any type.
Definition: vec3.h:12
static vec3< int > DIRECTION_VECTOR(vec3< int > prevDirection, char dir)
Given a previous direction and a relative direction, returns the corresponding delta vector...
Definition: acosolution.h:120
std::vector< char > dDirections
Vector of directions taken by the ant.
Definition: acosolution.h:14
static const char DIR_TO_CHAR(char d)
Maps directions to characters U, D, L, R, F.
Definition: acosolution.h:114
static const char FRONT
Relative direction.
Definition: acosolution.h:30
static const char DOWN
Relative direction.
Definition: acosolution.h:27
vec3< int > previous_direction() const
Returns the relative direction between the last 2 beads.
Definition: acosolution.h:153
__device__ int norm1(int3 a)
Returns the norm 1 of an int3 (norm of the absolute value).
Definition: cuda_device_utilities.cuh:29
bool dError
May be used to indicate errors.
Definition: acosolution.h:15
T z
(x,y,z) coordinates.
Definition: vec3.h:14
static const char UP
Static constants representing relative directions.
Definition: acosolution.h:26
const std::vector< char > & directions() const
Vector of directions taken by the ant.
Definition: acosolution.h:42
std::ostream & operator<<(std::ostream &stream, const ACOSolution &sol)
Prints coordinates and directions of the solution.
Definition: acosolution.h:194
void clear_error()
Clears the internal error state.
Definition: acosolution.h:86
T x
(x,y,z) coordinates.
Definition: vec3.h:14
std::vector< vec3< int > > & vector()
Vector of bead coordinates.
Definition: acosolution.h:36
T y
(x,y,z) coordinates.
Definition: vec3.h:14
static const char RIGHT
Relative direction.
Definition: acosolution.h:29
bool has_error()
Returns current error state.
Definition: acosolution.h:80
Encapsulates a solution that is built by an ant.
Definition: acosolution.h:12
int count_contacts(const HPChain &chain) const
Returns the number of H-H contacts within the solution.
Definition: acosolution.h:158
char direction(unsigned int i)
Gets an specific direction.
Definition: acosolution.h:49
ACOSolution()
Default constructor; starts as an empty solution.
Definition: acosolution.h:97