89 lines
2.5 KiB
C++
89 lines
2.5 KiB
C++
#include "WaveSimulation.hpp"
|
|
#include "utils.hpp"
|
|
|
|
#include <fstream>
|
|
#include <string>
|
|
|
|
void execute_simulation(std::vector<std::string> &args)
|
|
{
|
|
DEBUG("Inside execute sim");
|
|
if (args.size() < 11) {
|
|
return;
|
|
}
|
|
|
|
DEBUG("Declare sim");
|
|
WaveSimulation *sim;
|
|
if (args.size() >= 11 && args.size() < 16) {
|
|
sim = new WaveSimulation(
|
|
std::stod(args[2]), std::stod(args[3]), std::stod(args[4]),
|
|
std::stod(args[5]), std::stod(args[6]), std::stod(args[7]),
|
|
std::stod(args[8]), std::stod(args[9]), std::stod(args[10]));
|
|
}
|
|
else if (args.size() >= 16) {
|
|
sim = new WaveSimulation(
|
|
std::stod(args[2]), std::stod(args[3]), std::stod(args[4]),
|
|
std::stod(args[5]), std::stod(args[6]), std::stod(args[7]),
|
|
std::stod(args[8]), std::stod(args[9]), std::stod(args[10]),
|
|
std::stod(args[11]), std::stod(args[12]), std::stod(args[13]),
|
|
std::stod(args[14]), std::stoi(args[15]));
|
|
}
|
|
|
|
DEBUG("After instantiating sim");
|
|
if (args[0].compare("deviation") == 0) {
|
|
DEBUG("Deviation");
|
|
if (args.size() == 17) {
|
|
sim->probability_deviation(args[1], args[16].compare("false"));
|
|
}
|
|
else if (args.size() == 12) {
|
|
sim->probability_deviation(args[1], args[11].compare("false"));
|
|
}
|
|
else {
|
|
sim->probability_deviation(args[1]);
|
|
}
|
|
}
|
|
else if (args[0].compare("simulate") == 0) {
|
|
DEBUG("Simulate");
|
|
if (args.size() == 17) {
|
|
sim->simulate(args[1], args[16].compare("false"));
|
|
}
|
|
else if (args.size() == 12) {
|
|
sim->simulate(args[1], args[11].compare("false"));
|
|
}
|
|
else if (args.size() > 17) {
|
|
std::vector<double> arr;
|
|
for (size_t i = 16; i < args.size(); i++) {
|
|
arr.push_back(std::stod(args[i]));
|
|
}
|
|
sim->simulate(args[1], arr);
|
|
}
|
|
else {
|
|
sim->simulate(args[1]);
|
|
}
|
|
}
|
|
delete sim;
|
|
}
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
DEBUG("Start of main");
|
|
if (argc < 2) {
|
|
abort();
|
|
}
|
|
|
|
DEBUG("After arg check");
|
|
std::string filename = argv[1];
|
|
|
|
DEBUG("Open file");
|
|
std::ifstream infile;
|
|
infile.open(filename);
|
|
|
|
DEBUG("For line in lines");
|
|
for (std::string line; std::getline(infile, line);) {
|
|
std::vector<std::string> arr = utils::split(line, ';');
|
|
execute_simulation(arr);
|
|
}
|
|
|
|
DEBUG("Close file");
|
|
infile.close();
|
|
}
|