params.c

来自「一遗传算法的例子源程序」· C语言 代码 · 共 44 行

C
44
字号
#include "lithos.h"

int population = 100;
int maxSize = 1000;
int maxMemory = 1000;
int maxTime = 10000;
int maxMoves = 1000;
int overselectionRate = 2;
int tournamentSize = 4;
int crossoverRate = 50;
int mutationRate = 50;
int autosaveFrequency = 100;
int logFrequency = 1;

void readParameters(FILE *f)
{
	population = readInt(f);
	maxSize = readInt(f);
	maxMemory = readInt(f);
	maxTime = readInt(f);
	maxMoves = readInt(f);
	overselectionRate = readInt(f);
	tournamentSize = readInt(f);
	crossoverRate = readInt(f);
	mutationRate = readInt(f);
	autosaveFrequency = readInt(f);
	logFrequency = readInt(f);
}

void writeParameters(FILE *f)
{
	writeCommentedInt(f, "Population", population);
	writeCommentedInt(f, "Max Size", maxSize);
	writeCommentedInt(f, "Max Memory", maxMemory);
	writeCommentedInt(f, "Max Time", maxTime);
	writeCommentedInt(f, "Max Moves", maxMoves);
	writeCommentedInt(f, "Overselection Rate", overselectionRate);
	writeCommentedInt(f, "Tournament Size", tournamentSize);
	writeCommentedInt(f, "Crossover Rate", crossoverRate);
	writeCommentedInt(f, "Mutation Rate", mutationRate);
	writeCommentedInt(f, "Autosave Frequency", autosaveFrequency);
	writeCommentedInt(f, "Log Frequency", logFrequency);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?