-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
130 lines (115 loc) · 3.44 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#include "sim_funcs.hpp"
#include <iostream>
#include <stdlib.h>
#include <time.h>
#include "funcs.hpp"
using namespace std;
int main(int argc, char* argv[])
{
tic();
srand(time(NULL));
if (argc != 6)
{
cout << "Wrong number of inputs. Usage:" << endl;
cout << argv[0] << " ";
cout << "GENERATIONS RUNS POPSIZE USE_D STATEMODE" << endl;
cout << "STATEMODE: 0 - random, 1 - simple constraint, 2 - experimental, 3 - 2, but with ""upate""" << endl;
return -1;
}
int numGens = atoi(argv[1]);
int numRuns = atoi(argv[2]);
int popSize = atoi(argv[3]);;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
int D = atoi(argv[4]);
int stateMode = atoi(argv[5]);
if (stateMode > 3)
cout << "StateMode " << stateMode << " probably doesn't exist yet... BEWARE!" << endl;
// const quad death deathplus lin none
sPenalty penalty;
penalty.Mode = "quad";
penalty.quadMin = 100;
penalty.quadMax = 100;
penalty.quadtrunc = -100;
penalty.Const = 100;
penalty.death = -100;
penalty.lin = -1000;
penalty.failure = -100;
run_experiment(penalty, numGens, numRuns, popSize, D, stateMode);
/*
sData data = load_data();
cv::Mat actions = (cv::Mat_<double>(13, 1) << 0, 0, 0, 0, 1, 0.2, 0.3, 0.23, 0.52, 0.01, 2, 0.89, 0.91);
sMaterial mat = {
.Type = 2,
.Ymod = 100,
.Sut = 620,
.Sy = 500,
.Dens = 4507,
.Cost = 8.848*100000
};
double Length = 0.3217, Dia = 0.00635, Thick = 0.001651;
sBattery battery = {
.Cell = {
.Cost = 7.97,
.Cap = 5,
.C = 20,
.Mass = 0.114
},
.sConfigs = 3,
.pConfigs = 1,
.Cost = 23.91,
.Mass = 0.342,
.Volt = 11.1,
.Cap = 5,
.C = 20,
.Imax = 100,
.Energy = 1.998*100000
};
sMotor motor = design_motor(actions, data.motorData);
sProp prop = {
.diameter = 0.4064,
.angleRoot = 20,
.angleTip = 30,
.chordRoot = 0.00254,
.chordTip = 0.00508,
.mass = 2.808*1/10000.0,
.cost = 0.00417
};
sFoil foil = design_foil(actions, data.foilData);
sRod rod = create_rod(mat, Length, Dia, Thick);
sSys sys = design_sys(battery, motor, foil, prop, rod);
write_propfile(prop, foil);
sHover hover = calc_hover(sys);
cout << calc_constraints(sys, hover, hover.failure) << endl;
sPerf hover = {
(cv::Mat_<double>(1, 1) << 0),
(cv::Mat_<double>(1, 1) << 5095),
(cv::Mat_<double>(1, 1) << 0),
(cv::Mat_<double>(1, 1) << 7.148),
(cv::Mat_<double>(1, 1) << 0.8145),
(cv::Mat_<double>(1, 1) << 434.6),
(cv::Mat_<double>(1, 1) << 13.867),
(cv::Mat_<double>(1, 1) << 35.3175),
(cv::Mat_<double>(1, 1) << 0.8873),
(cv::Mat_<double>(1, 1) << 0),
(cv::Mat_<double>(1, 1) << 0),
(cv::Mat_<double>(1, 1) << 0.01306),
(cv::Mat_<double>(1, 1) << 0.008369),
(cv::Mat_<double>(1, 1) << 10.84),
(cv::Mat_<double>(1, 1) << 0),
(cv::Mat_<double>(1, 1) << 489.7),
(cv::Mat_<double>(1, 1) << 0),
(cv::Mat_<double>(1, 1) << 1.1685),
(cv::Mat_<double>(1, 1) << 0.765),
0
};
cv::Mat constraints = calc_constraints(sys, hover, 0);
cout << constraints << endl;
*/
/*
sData data = load_data();
cv::Mat actions = (cv::Mat_<double>(13, 1) << 0, 0, 0, 4, 3, 0.2, 0.3, 0.23, 0.52, 0.01, 2, 0.89, 0.91);
sProp prop = design_prop(actions, data.foilData);
sRod component = design_rod(actions, data.matData, prop);
*/
double elapsed = toc();
cout << "Elapsed time: " << elapsed << endl;
}