/*
Selah Lynch solution.h July 2004
Declarations and Documentation for class Solution
class Solution:
meant to be used with genetic algorithm program
solution for connecting dots, holds the order the
index of dots to be touched
a new solution is set to random automatically
then you may reset the values/mutate as desired
you may also display it and get the distance it would
imply for a given problem argument
it can be mutated in three different ways, or set as a
child of two other solutions
independant of parallel computing and mpi
*/
#ifndef SOLN_H
#define SOLN_H
#include
#include "problem.h"
class Solution{
public:
Solution(int numpnts);
//makes a new random solution
//order is always set
Solution(Solution& s);
~Solution();
void SetAsRand();
void SetAsChild(Solution& mom,Solution& dad);
//sets the solution to values that are a child
void SetAsString(int* intstr);
//will need something for when we're mixing solutions
void SetAsEqual(Solution& s);
void MutateSwt();
//switches two points in the order of the solution
//sets the distance flag to false
//assumes random seed is different for different computers
void MutateInv();
//picks a random chunk and inverts it
void MutateRot();
//rotates a random number of times up to as many times as
//half as many points is,
//randomly right or left
void Display(ostream& o=cout);
//displays the solution
//as long as it doesnt go over three digits
void SpitOutOrder(int* intstr);
//a helper function for packing up solution data to be sent
//not safe, space to the intstr must be preallocated, this fn does
//not do that, nor does it perform any checks
double GetDist(Problem& p);
private:
int numpoints;
int *order;
bool IsGood();
//checks that order values are valid, for use in setasstring
static void check(bool b, char* mess);
//this is always set after constructor is called
};
/* Solution();
//Save those Variables, Allocate space for a solution
//Allocate space for a solution
//set flags to false
Solution(const Solution& s);
~Solution();
//Solution does NOT need to handle the deletion of pointset
void operator=(const Solution& s);
//sets to equal
void SetasRand();
//make this a random solution
//set is set flag to set
//set distance flag to false anytime we set an order
//assumes the random seed has been desynchronized
void Setas123();
void SetasIntstr(int *);
//set the order as this Intstr
//there is no check to make sure that it's a valid order
//(valid = no repeats)
void SetDistance();
//making this a separate function because it is computationally
//EXPENSIVE
void SetasChild(Solution father, Solution mother);
//sets this solution as the child of the passed father and mother
//sets the distance flag to false
//assumes random seed is different for diff computers
void MutateSwt();
//switches two points in the order of the solution
//sets the distance flag to false
//assumes random seed is different for different computers
void MutateInv();
//picks a random chunk and inverts it
void MutateRot();
//rotates a random number of times up to as many times as
//half as many points is,
//randomly right or left
void Display();
//guess what this does...
double GetDist();
//returns the distance, here so distance can't be changed
//and if distance isn't set it complains
void SpitOutOrder(int*);
//given a pointer that is an array head, it spits out integers
//to describe the point order
//not a very safe function!
private:
int* order;
double** pointset;
int numpoints;
double dist;
bool is_set, dist_set;
void check(bool b, char* mess);
};
*/
#endif