-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptimizer.cpp
More file actions
51 lines (42 loc) · 1021 Bytes
/
Copy pathoptimizer.cpp
File metadata and controls
51 lines (42 loc) · 1021 Bytes
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
#include "optimizer.h"
std::vector<FeasibleResult> generateTemperatureSweep(
double massFlowRate,
double electricityPrice,
double emissionFactor,
double targetPerformance,
int Tmin,
int Tmax)
{
std::vector<FeasibleResult> results;
for (int T = Tmin; T <= Tmax; T++)
{
ProcessResult r =
evaluateCondition(
T,
massFlowRate,
electricityPrice,
emissionFactor);
bool feasible =
r.performance >= targetPerformance;
results.push_back({r, feasible});
}
return results;
}
bool findCostOptimalCondition(
const std::vector<FeasibleResult>& data,
ProcessResult& optimal)
{
bool found = false;
for (const auto& item : data)
{
if (!item.feasible)
continue;
if (!found ||
item.result.cost < optimal.cost)
{
optimal = item.result;
found = true;
}
}
return found;
}