本文整理汇总了C++中Sudoku::GetFitness方法的典型用法代码示例。如果您正苦于以下问题:C++ Sudoku::GetFitness方法的具体用法?C++ Sudoku::GetFitness怎么用?C++ Sudoku::GetFitness使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sudoku
的用法示例。
在下文中一共展示了Sudoku::GetFitness方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
/**
* If no arguments are passed, try to search for launch file to run accordingly, otherwise blank sudoku with just hill climbing
* otherwise one can pass '1' or 'file' followed by filename of the launch file to run this solver (See ReadMe)
* or one can pass '2' or 'args' followed by arguments in the predefined order to run solver solver (See ReadMe)
*/
int main(int argCount, char** argValues)
{
/** Initializing Variables with default values **/
Sudoku sudoku;
iterationCount = 0;
temperature = 0;
temperatureDropConstant = 0;
temperatureDropIterations = 1;
unsigned int seed = time(NULL);
string filename;
SimulationType simType;
//cout << argCount << endl;
//checking input arguments
if(argCount > 2)
{
string input = argValues[1];
if(input[0] == '1' || input.compare("file") == 0 )
{
//cout<< "lq\n"<< input[1];
ReadFromFile( argValues[2], filename, simType, seed );
sudoku = Sudoku(filename, seed);
}
else if(input[0] == '2' || input.compare("args") == 0)
{
ReadFromArgs(argCount, argValues, filename, simType, seed);
sudoku = Sudoku(filename, seed);
}
else
{
simType = HILL_CLIMBING;
}
}
else
{
ifstream launchFileReader(launchFile);
if(launchFileReader.is_open())
{
launchFileReader.close();
ReadFromFile(launchFile, filename, simType, seed );
//cout << filename << " - " << simType << endl;
sudoku = Sudoku(filename, seed);
}
else
{
simType = HILL_CLIMBING;
}
}
cout<<"Sudoku (from input file)"<<endl;
sudoku.PrintSudoku();
sudoku.calculateFitness();
cout<<"Fitness = " << sudoku.GetFitness() << endl << endl << endl;
cout<<"Sudoku (Initialized)"<<endl;
sudoku.fillSudoku();
sudoku.PrintSudoku();
sudoku.calculateFitness();
cout<<"Fitness = " << sudoku.GetFitness() << endl << endl << endl;
//HillClimbing(sudoku, seed);
//SimulatedAnnealing(sudoku, seed);
switch (simType)
{
case (SIMULATED_ANNEALING): SimulatedAnnealing(sudoku,seed);
break;
case (HILL_CLIMBING_PROBABILITY): HillClimbingProbability(sudoku,seed);
break;
case (HILL_CLIMBING):
default:
HillClimbing(sudoku,seed);
}
return 0;
}