-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
67 lines (53 loc) · 2.07 KB
/
main.cpp
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/////////////////////////////////////////////////////
/// Mahmoud S. Shaqfa ///
/////////////////////////////////////////////////////
#include <iostream>
#include <vector>
#include <memory>
#include "types.h"
#include "population.h"
#include "randomness_generator.h"
#include <ctime>
#include <cstdlib>
#include "objective.h"
#include "vectorized_operations.h"
#include "MPSFHS.h"
#include <algorithm>
#include <time.h>
#include "MPFHS_interface.h"
#include "write_CSV.h"
int main() {
std::clock_t t1;
t1 = clock();
// Define Inputs:
bool SaveResults = false; // "true" or "false" to export CSV files
bool PlotFigures = true; // needs python3 and SavingResults activated!
UInt Dimensions = 100; // Dimensions of the problem
UInt HMS = 25; // Harmony Memory Size (Population Samples)
UInt MaxItr = 300000; // Max. Iterations
Real HMCRi = 0.75; // Initial HMCR
Real PARi = 0.15; // Initial PAR
Real HMCR_max = 0.99; // Max HMCR
Real PAR_min = 0.05; // Min PAR
Real m = 2.5; // Rehearsal Multiplier
UInt obj = 1; // [1]-> Schwefel; [2]-> Sphere
Real w1 = 1.; // Penalty Multiplier
Real w2 = 2.; // Penalty Exponent
Real Step = 0.01; // Step accuracy of the solutions
Real LBV, UBV;
// Do not Edit!
std::shared_ptr<objective> ob = nullptr;
if ((obj ==1u) == true){
LBV = -500, UBV = 500;
ob = std::make_shared<Schwefel>();
} else if((obj == 2u) == true){
LBV = -5.12, UBV = 5.12;
ob = std::make_shared<Sphere>();
}
RealVec LB(Dimensions, LBV), UB(Dimensions, UBV), Steps(Dimensions, Step);
// Start optimizing (Do Not Edit!):
std::unique_ptr<optimization> opt_init(new optimization(Dimensions, HMS, MaxItr, HMCRi, PARi,
HMCR_max, PAR_min, m, w1, w2, ob, LB, UB, Steps, SaveResults, PlotFigures));
opt_init->optimize();
std::cout << "\n\nTotal elapsed time: "<< (Real)(clock() - t1)/CLOCKS_PER_SEC<< " Sec.\n\n"<< std::endl;
}