I am an idiot :)
This commit is contained in:
parent
cd382540a4
commit
d8086caa18
8
main.cpp
8
main.cpp
@ -8,7 +8,11 @@
|
||||
#endif
|
||||
|
||||
#ifndef ALPHA
|
||||
#define ALPHA 0.9999
|
||||
#define ALPHA 0.99
|
||||
#endif
|
||||
|
||||
#ifndef TEMP_MIN
|
||||
#define TEMP_MIN 10
|
||||
#endif
|
||||
|
||||
int main()
|
||||
@ -23,7 +27,7 @@ int main()
|
||||
}
|
||||
|
||||
sa::solution act = sa::solution::simulated_annealing(capacity, items,
|
||||
TEMP, ALPHA);
|
||||
TEMP, ALPHA, TEMP_MIN);
|
||||
|
||||
act.print_sol();
|
||||
}
|
||||
|
||||
6
sa.cpp
6
sa.cpp
@ -2,7 +2,8 @@
|
||||
#include <cmath>
|
||||
|
||||
auto sa::solution::simulated_annealing(int capacity, const std::vector<long long> &items,
|
||||
const double alpha, double temp)->sa::solution
|
||||
const double alpha, double temp,
|
||||
const double temp_min)->sa::solution
|
||||
{
|
||||
sa::solution best(items, capacity);
|
||||
best.randomize();
|
||||
@ -12,8 +13,7 @@ auto sa::solution::simulated_annealing(int capacity, const std::vector<long long
|
||||
std::default_random_engine eng(rdevice());
|
||||
std::uniform_real_distribution<> rand(0, 1);
|
||||
|
||||
const double temp_min = 0.30;
|
||||
while (temp < temp_min) {
|
||||
while (temp > temp_min) {
|
||||
sa::solution neighbor(prev);
|
||||
neighbor.setneighbor();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user