-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSudoku.hpp
48 lines (46 loc) · 1.4 KB
/
Sudoku.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef SUDOKU_H
#define SUDOKU_H
#include <vector>
#include <fstream>
class SolutionNeighbour{
int eval;
int square;
std::vector<int> neighbour;
public:
int get_eval();
int get_square();
std::vector<int> get_neighbour();
SolutionNeighbour(int sq, std::vector<int> &n, int eval);
};
class Sudoku {
private:
bool _debugMode;
unsigned _seed;
int conflicts; //
std::vector<std::vector<int> > data;
std::vector<std::vector<int> > solved;
std::vector<std::vector<int> > solution;
std::vector<std::vector<int> > solutionidx; //index of solutions in square
std::vector<SolutionNeighbour> neighbours;
std::vector<std::vector<int> > dptable;
int __get_conflicts_by_elem(int sq, int item, int val);
void __get_avial_inSQ(int sq);
int __get_conflicts();
void __update_solution();
void __calc_neighbours(bool addBad = false);
void __calc_neighbours_allperm();
void __calc_neighbours_allperm_sq(int sq, int mask, int w, int item, int max_w, std::vector<int> &sol);
std::vector<std::vector< int> > initdpTable(unsigned size);
public:
Sudoku(int size, const char* file_name, bool debugMode = false);
void randomSolution();
int evalSolution();
void printSolution();
//solving methods
//simple hill-climbing
void localSearch();
void extendedLocalSearch();
//trajectory metaheuristics
void simmulatedAnnealing(int time, double temp, std::ofstream &out); //time in millis
};
#endif