OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
OpalSimulation.cpp
Go to the documentation of this file.
1#include <iostream>
2#include <sstream>
3#include <cstring>
4#include <unistd.h>
5#include <sys/types.h>
6#include <sys/wait.h>
7#include <sys/stat.h>
8#include <dirent.h>
9#include <cstdlib>
10#include <vector>
11#include <ctime>
12#include <exception>
13
15
16#include "Util/SDDSReader.h"
17#include "Util/SDDSParser.h"
21
23
24#include "Expression/SumErrSq.h"
25#include "Expression/FromFile.h"
26
27#include "boost/algorithm/string.hpp"
28
29// access to OPAL lib
30#include "opal.h"
32#include "Utilities/Options.h"
33#include "Utilities/Util.h"
34
36 Expressions::Named_t constraints,
37 Param_t params, std::string name,
38 MPI_Comm comm, CmdArguments_t args,
39 std::map<std::string, std::string> uvars)
40 : Simulation(args)
41 , objectives_(objectives)
42 , constraints_(constraints)
43 , comm_(comm)
44 , id_m(-1)
45{
46 namespace fs = std::filesystem;
47
48 simTmpDir_ = args->getArg<std::string>("simtmpdir");
49 if (simTmpDir_.empty()) {
50 if(getenv("SIMTMPDIR") == nullptr) {
51 std::cout << "Environment variable SIMTMPDIR not defined!"
52 << std::endl;
53 simTmpDir_ = getenv("PWD");
54 } else
55 simTmpDir_ = getenv("SIMTMPDIR");
56 }
58
59 // prepare design variables given by the optimizer for generating the
60 // input file
61 std::vector<std::string> dict;
62 for(auto parameter : params) {
63 std::ostringstream tmp;
64 tmp.precision(15);
65 tmp << parameter.first << "=" << parameter.second;
66 dvarNames_.insert(parameter.first);
67 dict.push_back(tmp.str());
68
69 std::ostringstream value;
70 value.precision(15);
71 value << parameter.second;
72 userVariables_.insert(
73 std::pair<std::string, std::string>(parameter.first, value.str()));
74 }
75
76 /*
77 This is a copy from Comm/Splitter/ManyMasterSplit.h
78 in order to calculate the leader which is the unique ID in case
79 of more than one core per worker.
80 */
81
82 int my_rank=0;
83 MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
84 int world_size=0;
85 MPI_Comm_size(MPI_COMM_WORLD, &world_size);
86
87 unsigned num_coworkers_worker_ = 0;
88 num_coworkers_worker_ = args->getArg<size_t>("num-coworkers");
89
90 unsigned group_start = 0;
91
92 unsigned worker_group = ((my_rank % world_size) - 2) / num_coworkers_worker_;
93
94 unsigned leader_ = group_start + 2 + worker_group * num_coworkers_worker_;
95 leader_ = leader_ % world_size;
96
97 // hash the dictionary to get a short unique directory name for temporary
98 // simulation data
99 std::string hash = NativeHashGenerator::generate(dict);
100
101 std::ostringstream tmp;
102 tmp.precision(15);
103
104 tmp << simTmpDir_ << "/" << hash << "_" << leader_;
105
106 simulationDirName_ = tmp.str();
107
108 std::string tmplDir = args->getArg<std::string>("templates");
109 if (tmplDir.empty()) {
110 if(getenv("TEMPLATES") == nullptr) {
111 throw OptPilotException("OpalSimulation::OpalSimulation",
112 "Environment variable TEMPLATES not defined!");
113 }
114 tmplDir = getenv("TEMPLATES");
115 }
116 std::string tmplFile = tmplDir + "/" + simulationName_ + ".tmpl";
117 // data file is assumed to be located in the root directory
118 std::string dataFile = simulationName_ + ".data";
119
120 if (!fs::exists(tmplFile))
121 throw OptPilotException("OpalSimulation::OpalSimulation",
122 "The template file '" + tmplFile + "' doesn't exit");
123
124 for (const auto& uvar : userVariables_) {
125 uvars[uvar.first] = uvar.second;
126 }
127
128 gs_.reset(new GenerateOpalSimulation(tmplFile, dataFile, uvars));
129}
130
131
136
138
139 std::string infile = simulationDirName_ + "/" + simulationName_ + ".in";
140 struct stat fileInfo;
141
142 if(stat(infile.c_str(), &fileInfo) == 0) {
143 std::cout << "-> Simulation input file (" << infile
144 << ") already exist from previous run.." << std::endl;
145 return true;
146 }
147
148 return false;
149}
150
151
152void OpalSimulation::createSymlink_m(const std::string& path) {
153 namespace fs = std::filesystem;
154
155 for (auto &p: fs::directory_iterator(path)) {
156 fs::path source = p.path();
157 fs::path target(simulationDirName_ + "/");
158 target +=source.filename();
159
160 try {
161 fs::create_symlink(source, target);
162 } catch (fs::filesystem_error &e) {
163 std::cerr << e.what() << "\n"
164 << "in OpalSimulation::createSymlink()" << std::endl;
165 }
166 }
167}
168
169
171 CmdArguments_t args = getArgs();
172 std::string restartfile = args->getArg<std::string>("restartfile", "", false);
173
174 if (restartfile.empty()) return;
175
176 namespace fs = std::filesystem;
177 if ( !fs::exists(restartfile) ) {
178 std::cerr << "H5 file '" + restartfile + "' doesn't exist." << "\n"
179 << "in OpalSimulation::copyH5_m()" << std::endl;
180
181 return;
182 }
183
184 try {
185 fs::path srcfile(restartfile);
186 fs::path targetfile(simulationDirName_ + "/" + simulationName_ + ".h5");
187 fs::copy_file(srcfile, targetfile);
188 } catch (fs::filesystem_error &ex) {
189 std::cerr << ex.what() << "\n"
190 << "in OpalSimulation::copyH5_m()" << std::endl;
191 }
192}
193
194
196 namespace fs = std::filesystem;
197
198 CmdArguments_t args = getArgs();
199 std::string restartfile = args->getArg<std::string>("restartfile", "", false);
200
201 if ( id_m > -1 ) {
202 std::ostringstream tmp;
203 tmp << simTmpDir_ << "/" << id_m;
204 simulationDirName_ = tmp.str();
205 }
206 std::string dataDir = simulationDirName_ + "/data";
207
209 opal->setOptimizerFlag();
210
211 // linking fieldmaps + distributions
212 if (getenv("FIELDMAPS") == nullptr) {
213 throw OptPilotException("OpalSimulation::setupSimulation",
214 "Environment variable FIELDMAPS not defined!");
215 }
216
218
219 MPI_Barrier(comm_);
220
221 if (!fs::exists(simulationDirName_)) {
222 throw OptPilotException("OpalSimulation::setupSimulation",
223 "Directory '" + simulationDirName_ + "' doesn't exist");
224 }
225
226 if (!fs::exists(dataDir)) {
227 throw OptPilotException("OpalSimulation::setupSimulation",
228 "Directory '" + dataDir + "' doesn't exist");
229 }
230
231 if (!restartfile.empty() &&
232 !fs::exists(simulationDirName_ + "/" + simulationName_ + ".h5")) {
233 throw OptPilotException("OpalSimulation::setupSimulation",
234 "H5 file '" + simulationDirName_ + "/" + simulationName_ + ".h5' doesn't exist");
235 }
236}
237
239 namespace fs = std::filesystem;
240
241 int rank = 0;
242 MPI_Comm_rank(comm_, &rank);
243 if (rank != 0) return; // only one processor in comm group has to setup files
244
245 if (fs::exists(simulationDirName_)) {
246 fs::remove_all(simulationDirName_);
247 }
248
249 try {
250 fs::create_directory(simulationDirName_);
251 fs::permissions(simulationDirName_,
252 fs::perms::owner_all |
253 fs::perms::group_read |
254 fs::perms::group_exec |
255 fs::perms::others_read |
256 fs::perms::others_exec);
257
258 } catch (fs::filesystem_error &e) {
259 std::cerr << e.what() << "\n"
260 << "in OpalSimulation::setupSimulation" << std::endl;
261 return;
262 }
263
264 try {
265 std::string dataDir = simulationDirName_ + "/data";
266
267 fs::create_directory(dataDir);
268 fs::permissions(dataDir,
269 fs::perms::owner_all |
270 fs::perms::group_read |
271 fs::perms::group_exec |
272 fs::perms::others_read |
273 fs::perms::others_exec);
274
275 } catch (fs::filesystem_error &e) {
276 std::cerr << e.what() << "\n"
277 << "in OpalSimulation::setupSimulation" << std::endl;
278 return;
279 }
280
281 std::string infile = simulationDirName_ + "/" +
282 simulationName_ + ".in";
283 gs_->writeInputFile(infile);
284
285 std::string fieldmapPath = getenv("FIELDMAPS");
286 this->createSymlink_m(fieldmapPath);
287
288 if (getenv("DISTRIBUTIONS") != nullptr) {
289 std::string distPath = getenv("DISTRIBUTIONS");
290 this->createSymlink_m(distPath);
291 }
292
293 this->copyH5_m();
294}
295
297
298 // backup stdout and err file handles
299 strm_buffer_ = std::cout.rdbuf();
300 strm_err_ = std::cerr.rdbuf();
301
302 int world_pid = 0;
303 MPI_Comm_rank(MPI_COMM_WORLD, &world_pid);
304
305 std::ostringstream fname;
306 fname << "sim.out." << world_pid;
307 std::ofstream file(fname.str().c_str());
308 fname << ".err";
309 std::ofstream err(fname.str().c_str());
310
311 // and redirect stdout and err to new files
312 std::cout.rdbuf(file.rdbuf());
313 std::cerr.rdbuf(err.rdbuf());
314}
315
316
318 std::cout.rdbuf(strm_buffer_);
319 std::cerr.rdbuf(strm_err_);
320}
321
322
324 namespace fs = std::filesystem;
325
326 // make sure input file is not already existing
327 MPI_Barrier(comm_);
328 if( hasResultsAvailable() ) return;
329 MPI_Barrier(comm_);
330
332
333 pwd_ = fs::current_path().native();
334 pwd_ += "/";
335 int err = chdir(simulationDirName_.c_str());
336
337 if (err != 0) {
338 std::cout << "Cannot chdir to "
339 << simulationDirName_.c_str() << std::endl;
340 std::cout << "Continuing 1, disregarding this simulation.."
341 << std::endl;
342 return;
343 }
344
345 // setup OPAL command line options
346 std::ostringstream inputFileName;
347 inputFileName << simulationName_ << ".in";
348 char *inputfile = new char[inputFileName.str().size()+1] ;
349 strcpy(inputfile, inputFileName.str().c_str());
350 int seed = Options::seed;
351
352 CmdArguments_t args = getArgs();
353 int restartStep= args->getArg<int>("restartstep",
354 std::numeric_limits<int>::min(), false);
355 std::string restartfile = args->getArg<std::string>("restartfile", "", false);
356
357 try {
358 if ( restartStep > -2 && restartfile.empty() ) {
359 throw OpalException("OpalSimulation::run()",
360 "Restart specified but no restart H5 file available.");
361 }
362
363 char exe_name[] = "opal";
364 char nocomm[] = "--nocomminit";
365 char info[] = "--info";
366 char info0[] = "0";
367 char warn[] = "--warn";
368 char warn0[] = "0";
369 char *arg[] = { exe_name, inputfile, nocomm, info, info0, warn, warn0 };
370
371 //FIXME: this seems to crash OPAL in some cases
372 //redirectOutToFile();
373#ifdef SUPRESS_OUTPUT
374 //XXX: hack to disable output to stdout
375 std::cout.setstate(std::ios::failbit);
376#endif
377 // now we can run the simulation
378 run_opal(arg, inputFileName.str(), restartStep, Options::infoLevel, Options::warnLevel, comm_);
379
380 //restoreOut();
381#ifdef SUPRESS_OUTPUT
382 std::cout.clear();
383#endif
384
385 } catch(OpalException *ex) {
386
387 //restoreOut();
388#ifdef SUPRESS_OUTPUT
389 std::cout.clear();
390#endif
391
392 std::cerr << "Opal exception during simulation run: \n"
393 << ex->where() << "\n"
394 << ex->what() << std::endl;
395 std::cerr << "Continuing, disregarding this simulation.."
396 << std::endl;
397
398 } catch(ClassicException *ex) {
399
400 //restoreOut();
401#ifdef SUPRESS_OUTPUT
402 std::cout.clear();
403#endif
404
405 std::cerr << "Classic exception during simulation run: \n"
406 << ex->where() << "\n"
407 << ex->what() << std::endl;
408 std::cerr << "Continuing, disregarding this simulation.."
409 << std::endl;
410 } catch(std::exception &ex) {
411#ifdef SUPRESS_OUTPUT
412 std::cout.clear();
413#endif
414 std::cerr << "Exception occured during simulation run: \n"
415 << ex.what() << std::endl
416 << "Continuing, disregarding this simulation.." << std::endl;
417 } catch(...) {
418#ifdef SUPRESS_OUTPUT
419 std::cout.clear();
420#endif
421 std::cerr << "Unknown exception occured during simulation run.\n"
422 << "Continuing, disregarding this simulation.." << std::endl;
423
424 }
425
426 Options::seed = seed;
427
428 delete[] inputfile;
429 err = chdir(pwd_.c_str());
430 if (err != 0) {
431 std::cerr << "Cannot chdir to "
432 << pwd_ << std::endl;
433 }
434}
435
436
437std::map<std::string, std::vector<double> > OpalSimulation::getData(const std::vector<std::string> &statVariables) {
438 std::map<std::string, std::vector<double> > ret;
439 SDDS::SDDSParser parser(simulationDirName_ + "/" + simulationName_ + ".stat");
440 parser.run();
441 for (const std::string &var : statVariables) {
443 try {
444 column = parser.getColumnData(var);
445 } catch (SDDSParserException &e) {
446 std::cout << "failed to read data: " << e.what() << " in " << e.where() << std::endl;
447 continue;
448 }
449
450 std::vector<double> values;
451 values.reserve(column.size());
452 auto type = parser.getColumnType(var);
453 for (const auto& val: column) {
454 values.push_back(parser.getBoostVariantValue<double>(val,(int)type));
455 }
456 ret.insert(std::make_pair(var, values));
457 }
458
459 return ret;
460}
461
463
464 // std::cout << "collectResults" << std::endl;
465
466 // clear old solutions
467 requestedVars_.clear();
468
469 int err = chdir(simulationDirName_.c_str());
470 if (err != 0) {
471 std::cout << "Cannot chdir to "
472 << simulationDirName_.c_str() << std::endl;
473 std::cout << "Continuing, with cleanup.."
474 << std::endl;
475 cleanUp();
476 return;
477 }
478
479 std::string fn = simulationName_ + ".stat";
480 struct stat fileInfo;
481
482 // if no stat file, simulation parameters produced invalid bunch
483 if(stat(fn.c_str(), &fileInfo) != 0) {
484 invalidBunch();
485 } else {
486 Expressions::Named_t::iterator namedIt;
487 try {
488 for(namedIt=objectives_.begin(); namedIt!=objectives_.end(); ++namedIt) {
489 if (namedIt->first == "dummy") continue; // FIXME SamplePilot has default objective named dummy
490 Expressions::Expr_t *objective = namedIt->second;
491
492 // find out which variables we need in order to evaluate the objective
493 variableDictionary_t variable_dictionary;
494 getVariableDictionary(variable_dictionary,fn,objective);
495
496 // and evaluate the expression using the built dictionary of
497 // variable values
498 Expressions::Result_t result =
499 objective->evaluate(variable_dictionary);
500
501 std::vector<double> values;
502 values.push_back(std::get<0>(result));
503 bool is_valid = std::get<1>(result);
504
505 reqVarInfo_t tmps = {EVALUATE, values, is_valid};
506 requestedVars_.insert(
507 std::pair<std::string, reqVarInfo_t>(namedIt->first, tmps));
508
509 }
510
511 // .. and constraints
512 for(namedIt=constraints_.begin(); namedIt!=constraints_.end(); ++namedIt) {
513
514 Expressions::Expr_t *constraint = namedIt->second;
515
516 // find out which variables we need in order to evaluate the constraint
517 variableDictionary_t variable_dictionary;
518 getVariableDictionary(variable_dictionary,fn,constraint);
519
520 Expressions::Result_t result =
521 constraint->evaluate(variable_dictionary);
522
523 std::vector<double> values;
524 values.push_back(std::get<0>(result));
525 bool is_valid = std::get<1>(result);
526
527 //FIXME: hack to give feedback about values of LHS and RHS
528 std::string constr_str = constraint->toString();
529 std::vector<std::string> split;
530 boost::split(split, constr_str, boost::is_any_of("<>!="),
531 boost::token_compress_on);
532 std::string lhs_constr_str = split[0];
533 std::string rhs_constr_str = split[1];
534 boost::trim_left_if(rhs_constr_str, boost::is_any_of("="));
535
536 functionDictionary_t funcs = constraint->getRegFuncs();
537 const std::unique_ptr<Expressions::Expr_t> lhs(
538 new Expressions::Expr_t(lhs_constr_str, funcs));
539 const std::unique_ptr<Expressions::Expr_t> rhs(
540 new Expressions::Expr_t(rhs_constr_str, funcs));
541
542 Expressions::Result_t lhs_res = lhs->evaluate(variable_dictionary);
543 Expressions::Result_t rhs_res = rhs->evaluate(variable_dictionary);
544
545 values.push_back(std::get<0>(lhs_res));
546 values.push_back(std::get<0>(rhs_res));
547
548 reqVarInfo_t tmps = {EVALUATE, values, is_valid};
549 requestedVars_.insert(
550 std::pair<std::string, reqVarInfo_t>(namedIt->first, tmps));
551
552 }
553 } catch(SDDSParserException &e) {
554 std::cout << "Evaluation of objective or constraint " << namedIt->first << " threw an exception ('" << e.what() << "' in " << e.where() << ")!" << std::endl;
555 invalidBunch();
556 } catch(OptPilotException &e) {
557 std::cout << "Evaluation of objective or constraint " << namedIt->first << " threw an exception ('" << e.what() << "' in " << e.where() << ")!" << std::endl;
558 invalidBunch();
559 } catch(std::exception &e) {
560 std::cout << "Evaluation of objective or constraint " << namedIt->first << " threw an exception ('" << e.what() << "')!" << std::endl;
561 invalidBunch();
562 } catch(...) {
563 std::cout << "Evaluation of objective or constraint " << namedIt->first << " threw an exception!" << std::endl;
564 invalidBunch();
565 }
566
567 }
568
569 err = chdir(pwd_.c_str());
570 if (err != 0) {
571 std::cout << "Cannot chdir to "
572 << simulationDirName_.c_str() << std::endl;
573 }
574}
575
577 const std::string& filename,
578 const Expressions::Expr_t* const expression) {
579
580 std::set<std::string> req_vars = expression->getReqVars();
581
582 // first check if required variables are design variables
583 for (auto req_it = req_vars.begin(); req_it!=req_vars.end();) {
584 auto it = userVariables_.find(*req_it);
585 if (it==userVariables_.end()) { // not a design var
586 ++req_it;
587 continue;
588 }
589 double value = std::stod((*it).second);
590 dictionary.insert(std::pair<std::string, double>(*req_it, value));
591 req_it = req_vars.erase(req_it); // remove and update iterator to next
592 }
593
594 if(req_vars.empty()) return;
595
596 // get remaining required variable values from the stat file
597 const std::unique_ptr<SDDSReader> sddsr(new SDDSReader(filename));
598 sddsr->parseFile();
599
600 for(std::string req_var : req_vars) {
601 if(dictionary.count(req_var) != 0) continue;
602
603 double value = 0.0;
604 sddsr->getValue(-1 /*atTime*/, req_var, value);
605 dictionary.insert(std::pair<std::string, double>(req_var, value));
606 }
607}
608
610
611 for(auto namedObjective : objectives_) {
612 std::vector<double> tmp_values;
613 tmp_values.push_back(0.0);
614 reqVarInfo_t tmps = {EVALUATE, tmp_values, false};
615 requestedVars_.insert(
616 std::pair<std::string, reqVarInfo_t>(namedObjective.first, tmps));
617 }
618}
619
621 namespace fs = std::filesystem;
622 try {
623 int my_rank = 0;
624 MPI_Comm_rank(comm_, &my_rank);
625 if (my_rank == 0) {
626 fs::path p(simulationDirName_.c_str());
627 fs::remove_all(p);
628 }
629 } catch(fs::filesystem_error &ex) {
630 std::cout << "Can't remove directory '" << simulationDirName_ << "', (" << ex.what() << ")" << std::endl;
631 } catch(...) {
632 std::cout << "Can't remove directory '" << simulationDirName_ << "'" << std::endl;
633 }
634}
635
636void OpalSimulation::cleanUp(const std::vector<std::string>& keep) {
637 namespace fs = std::filesystem;
638
639 if ( keep.empty() ) {
640 // if empty we keep all files
641 return;
642 }
643
644 try {
645 int my_rank = 0;
646 MPI_Comm_rank(comm_, &my_rank);
647 if (my_rank != 0) {
648 return;
649 }
650 fs::path p(simulationDirName_.c_str());
651 {
652 fs::directory_iterator it{p};
653 while (it != fs::directory_iterator{}) {
654 std::string extension = Util::toUpper(it->path().extension().string());
655
656 // remove .
657 extension.erase(0, 1);
658
659 auto result = std::find(keep.begin(), keep.end(), extension);
660
661 if ( result == keep.end() && ! fs::is_directory(it->path())) {
662 fs::remove(it->path());
663 }
664 ++it;
665 }
666 }
667 {
668 fs::directory_iterator it{p};
669 while (it != fs::directory_iterator{}) {
670 if (fs::is_directory(it->path()) && fs::is_empty(it->path())) {
671 fs::remove(it->path());
672 }
673 ++it;
674 }
675 }
676 } catch(fs::filesystem_error &ex) {
677 std::cout << "Can't remove file in directory '" << simulationDirName_
678 << "', (" << ex.what() << ")" << std::endl;
679 } catch(...) {
680 std::cout << "Can't remove file in directory '" << simulationDirName_
681 << "'" << std::endl;
682 }
683}
int run_opal(char *[], std::string inputfile, int restartStep, int infoLevel, int warnLevel, MPI_Comm comm)
Definition opal.cpp:32
arg(a))
std::shared_ptr< CmdArguments > CmdArguments_t
@ EVALUATE
Definition Types.h:41
namedVariableCollection_t Param_t
Definition Types.h:47
const std::string name
std::map< std::string, client::function::type > functionDictionary_t
Definition Expression.h:55
std::map< std::string, double > variableDictionary_t
Definition Expression.h:54
std::map< std::string, Expressions::Expr_t * > Named_t
type of an expressions with a name
Definition Expression.h:73
std::tuple< double, bool > Result_t
Definition Expression.h:65
int warnLevel
Definition Options.cpp:32
int infoLevel
Definition Options.cpp:27
int seed
The current random seed.
Definition Options.cpp:35
std::string toUpper(const std::string &str)
Definition Util.cpp:150
std::vector< variant_t > columnData_t
Definition ast.hpp:50
The global OPAL structure.
Definition OpalData.h:49
void setOptimizerFlag()
Definition OpalData.cpp:292
static OpalData * getInstance()
Definition OpalData.cpp:196
The abstract base class for all exceptions in CLASSIC.
std::string pwd_
holds current directory (for restoring)
void invalidBunch()
mark a solution as invalid
virtual ~OpalSimulation()
std::map< std::string, std::vector< double > > getData(const std::vector< std::string > &statVariables)
void getVariableDictionary(variableDictionary_t &dictionary, const std::string &filename, const Expressions::Expr_t *const expression)
get variables for expression evaluation from SDDS file. Can throw SDDSParserException
reqVarContainer_t requestedVars_
holds solutions returned to the optimizer
void setupSimulation()
create directories, input files, fieldmaps...
void copyH5_m()
copy H5 file
void redirectOutToFile()
redirect stdout and stderr to file
std::unique_ptr< GenerateOpalSimulation > gs_
object to generate simulation input files
Expressions::Named_t objectives_
std::streambuf * strm_err_
stream buffer to redirect stderr
std::string simulationDirName_
full path of simulation directory (where simulation will be run)
std::set< std::string > dvarNames_
Expressions::Named_t constraints_
std::map< std::string, std::string > userVariables_
variable dictionary holding requested optimizer values
std::string simTmpDir_
temporary directory for simulation data (environment var SIMTMPDIR)
std::streambuf * strm_buffer_
stream buffer to redirect output
void createSymlink_m(const std::string &path)
create symbolic links
std::string simulationName_
identification of the simulation (corresponding to output filename)
bool hasResultsAvailable()
check if we already have simulated the current set of design vars
void setupFSStructure()
create directories, input files, symlinks...
void collectResults()
Parse SDDS stat file and build up requested variable dictionary.
void restoreOut()
restore stdout and stderr to default
int id_m
job id (SAMPLE command)
OpalSimulation(Expressions::Named_t objectives, Expressions::Named_t constraints, Param_t params, std::string name, MPI_Comm comm, CmdArguments_t args, std::map< std::string, std::string > uvars)
The base class for all OPAL exceptions.
virtual const std::string & what() const
Return the message string for the exception.
virtual const std::string & where() const
Return the name of the method or function which detected the exception.
functionDictionary_t getRegFuncs() const
Definition Expression.h:126
const std::string & toString() const
Definition Expression.h:124
Expressions::Result_t evaluate(const variableDictionary_t &vars)
evaluate an expression given a value dictionary of free variables
Definition Expression.h:132
const std::set< std::string > & getReqVars() const
Definition Expression.h:122
CmdArguments_t getArgs()
Definition Simulation.h:48
static std::string generate(std::vector< std::string > arguments, size_t world_pid=0)
ast::columnData_t getColumnData(const std::string &columnName)
ast::datatype getColumnType(const std::string &col_name)
Definition SDDSParser.h:69
T getBoostVariantValue(const ast::variant_t &val, int datatype) const
Convert value from boost variant (only numeric types) to a value of type T.
Definition SDDSParser.h:201