-
Notifications
You must be signed in to change notification settings - Fork 16
/
ENESIM_GENERAL.cpp
110 lines (93 loc) · 3.3 KB
/
ENESIM_GENERAL.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
// (c) 2015-2020 I-GIS (www.i-gis.dk) and Thomas Mejer Hansen ([email protected])
//
// This file is part of MPSlib.
//
// MPSlib is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// MPSlib is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with MPSlib (COPYING.LESSER). If not, see <http://www.gnu.org/licenses/>.
//
#include <iomanip> // std::setprecision
#include <algorithm> // std::random_shuffle std::remove_if
#include <list>
#include "ENESIM_GENERAL.h"
#include "mpslib/IO.h"
#include "mpslib/Utility.h"
#include "mpslib/Coords3D.h"
/**
* @brief Constructors from a configuration file
*/
MPS::ENESIM_GENERAL::ENESIM_GENERAL(const std::string& configurationFile) : MPS::ENESIM(){
//std::cout << "Initialize start" << std::endl;
initialize(configurationFile);
//std::cout << "Initialize stop" << std::endl;
}
/**
* @brief Destructors
*/
MPS::ENESIM_GENERAL::~ENESIM_GENERAL(void) {
_shuffleEntropyFactor=4;
}
/**
* @brief Initialize the simulation from a configuration file
* @param configurationFile configuration file name
*/
void MPS::ENESIM_GENERAL::initialize(const std::string& configurationFile) {
//Reading configuration file
_readConfigurations(configurationFile);
//Reading data from files
_readDataFromFiles();
//Checking the TI array dimensions
_tiDimX = (int)_TI[0][0].size();
_tiDimY = (int)_TI[0].size();
_tiDimZ = (int)_TI.size();
//Define a random path to loop through TI cell
_tiPath.resize(_tiDimX * _tiDimY * _tiDimZ);
_initilizePath(_tiDimX, _tiDimY, _tiDimZ, _tiPath);
if (_shuffleTiPath) {
std::random_shuffle ( _tiPath.begin(), _tiPath.end() );
}
//Define multi threading parameters
_jobDone = false;
}
/**
* @brief Start the simulation
* Virtual function implemented from MPSAlgorithm
*/
void MPS::ENESIM_GENERAL::startSimulation(void) {
//Call parent function
MPS::MPSAlgorithm::startSimulation();
}
/**
* @brief MPS dsim simulation algorithm main function
* @param sgIdxX index X ojf a node inside the simulation grind
* @param sgIdxY index Y of a node inside the simulation grind
* @param sgIdxZ index Z of a node inside the simulation grind
* @param level multigrid level
* @return found node's value
*/
float MPS::ENESIM_GENERAL::_simulate(const int& sgIdxX, const int& sgIdxY, const int& sgIdxZ, const int& level) {
// By default do not use rejection sampler to account for soft data
float real;
real = _getRealizationFromCpdfEnesim(sgIdxX, sgIdxY, sgIdxZ, _sgIterations[sgIdxZ][sgIdxY][sgIdxX]);
return real;
}
/**
* @brief Abstract function allow acces to the beginning of each simulation of each multiple grid
* @param level the current grid level
*/
void MPS::ENESIM_GENERAL::_InitStartSimulationEachMultipleGrid(const int& level) {
//Empty for now
if (_debugMode > 1) {
std::cout << "Reloading soft data from files" << std::endl;
}
_readSoftDataFromFiles();
}