-
Notifications
You must be signed in to change notification settings - Fork 0
/
FactorySim.cpp
47 lines (33 loc) · 1.33 KB
/
FactorySim.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
#include <vector>
#include "FactoryManager.hpp"
#include "Warehouse.hpp"
#include "VehicleManager.hpp"
int main()
{
static constexpr unsigned int N = 75; // > 50
static constexpr unsigned int M = 125; // > 100
static constexpr unsigned int FactoryCount = 5; // > 3
static constexpr unsigned int RunSimulationInHours = 500;
FactoryManager FactoryManager(FactoryCount, N);
int WarehouseCapacity = M * FactoryManager.GetFactoriesProduction();
Warehouse Warehouse(WarehouseCapacity);
VehicleManager VehicleManager(FactoryManager.GetFactoriesMaxWeightProduction());
for (size_t i = 0; i < RunSimulationInHours; i++)
{
std::cout << "\nRunning hour " << i + 1 << "\n";
std::vector<FactoryManager::FactoryProduction> FactoryProduction;
// Multithreaded
FactoryManager.GatherProducts(FactoryProduction);
if (Warehouse.IsCloseToFull())
{
// Multithreaded
Warehouse.DispatchVehicles(VehicleManager);
}
for(auto& Production : FactoryProduction)
{
std::cout << "Filling storage with " << Production.ProducedProducts.size() << " products from factory " << Production.FactoryName << "\n";
Warehouse.FillStorage(Production.ProducedProducts);
}
}
VehicleManager.PrintAverages();
}