-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSA.hpp
45 lines (41 loc) · 964 Bytes
/
SA.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
//
// SA.hpp
// search
//
// Created by WU,MENG-TING on 2020/7/8.
// Copyright © 2020 WU,MENG-TING. All rights reserved.
//
#ifndef SA_hpp
#define SA_hpp
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <vector>
#include <ctime>
#include <cmath>
using namespace std;
class SA{
public:
SA();
SA(int bits,int iter,double temperature,double alpha);
void Initialization();
void run();
vector<int> select_neighbor(vector<int> str);
double Pa(int current,int neighbor);
void anneal();
int FitnessFunction(vector<int> str);
vector<int> get_record_bitstr(int it){return record_bitstr[it];}
int get_record_value(int it){return record_value[it];}
private:
int bits;
int iter;
double temperature;
double alpha;
vector<int> bitstr;
int value;
vector<int> best_bitstr;
int best_value;
vector<vector<int> > record_bitstr;
vector<int> record_value;
};
#endif /* SA_hpp */