📄 genotype.h
字号:
//// genotype.h - Used for the Genetic Grouping Algorithm//// author: J.I.v.Hemert// last updated : 07-11-1997//// This file contains the class GenotypeC. It features the three genetic// operators; crossover, mutation and inversion. Some functions to print// out genos, a copy function and a function to get the fitness of a geno.//#ifndef GENOTYPE_H#define GENOTYPE_H#define UNCOLORED -1#define ELIMINATED -1#define MAXOBJECTS 2000#include <MLCG.h>#include <iostream.h>#include <iomanip.h>#include <stdio.h>#include "problem.h"#include "stack.h"enum ErrorsT { none, duplicatecolor, badcoloring, illegalcolorused};enum ColoringT{ undefined, firstfit, smallfirst, largefirst};typedef int ObjectT;typedef int GroupT;class GenotypeC{ public: GenotypeC () {}; void Initialize (int numberofobjects, double allelemutationprobability, int k_coloring, ColoringT coloringalgorithm); void Evaluate (); void Mutation (); void Inversion (); void Crossover (GenotypeC &, GenotypeC &, GenotypeC &); void Print (ofstream & output); void Print (); double GetColorsUsed (); double GetFitness (); void Copy (GenotypeC &); ErrorsT IsValid (int & object); private: int idtag; // unique number double fitness; // current fitness int nrofobjects; // number of objects int nrofgroups; // number of groups int nrofcolors; // number of colors in problem double allelemutationprob; // chance group is deleted in mutation ColoringT coloringused; // what algo to use for coloring nodes ObjectT objects[MAXOBJECTS]; // holds objects GroupT groups[MAXOBJECTS]; // holds groups int ViolatedConstraints (int object); // how many constraints a coloring violates void ColorObject (int object); // color an object with an algorithm void ColorObject_FirstFit (int object); // uses First-Fit for algo void ColorObject_OrderedColoring (int object); // uses Smallest- or Largest-First void InsertGroup (GroupT parentgroups [], int cp1, int cp2, int position); void CompactGroupPart (); // After eliminating groups fix the grouppart};#endif// eof genotype.h
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -