//
// tsgenome.h - genome for solving
// time share assignment problem.
///////////////////////////////////////////////
#ifndef TSGENOME_H
#define TSGENOME_H
#include "gagenome.h"
//
// 4 condo units in building
// 16 one-week periods.
// 22 maximum occupants in building
const int MAX_UNITS = 4;
const int MAX_PERIODS = 16;
const int MAX_OWNERS = 64;
const int MAX_OCCUPANTS = 22;
//
// Owner assignment preference info.
////////////////////////////////////
struct Owner
{
int m_ownerID;
int m_occupCnt; // total family members
int m_choice[3]; // 3 preferred choices.
};
////////////////////////////////////
struct Period
{
int m_owner[MAX_UNITS];
int m_assnCnt;
int m_assnTotal;
};
////////////////////////////////////
class TSGenome:public GAGenome
{
public :
//
// List of owners and preferences.
static Owner m_owner[MAX_OWNERS] ;
//
// Period assignments.
int m_assign[MAX_OWNERS];
Period m_period[MAX_PERIODS];
int m_assnTotal ;
//
// Constructors, assignment operators.
TSGenome();
TSGenome(const TSGenome &src) {*this = src; };
TSGenome& operator = (const TSGenome& rhs);
//
// Override all genetic operators.
void Initialize();
void Mutate( double mutationFactor);
void CrossOver( GAGenome *genome);
double Evaluate();
//
// Functions for assigning, unassigne owners.
void UnassignAll();
void Assign( int owner, int period);
void Unassign( int owner);
void DoGreedyAssign(int owner);
int CalcOwnerCost(int owner, int assign);
};
#endif
End of Listing