OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
OptimizeCmd.cpp
Go to the documentation of this file.
1//
2// Class OptimizeCmd
3// The OptimizeCmd definition.
4// A OptimizeCmd definition is used to parse the parametes for the optimizer.
5//
6// Copyright (c) 2017, Christof Metzger-Kraus
7// All rights reserved
8//
9// This file is part of OPAL.
10//
11// OPAL is free software: you can redistribute it and/or modify
12// it under the terms of the GNU General Public License as published by
13// the Free Software Foundation, either version 3 of the License, or
14// (at your option) any later version.
15//
16// You should have received a copy of the GNU General Public License
17// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
18//
20#include "Optimize/Objective.h"
21#include "Optimize/Constraint.h"
23
27
28//#include "Utility/Inform.h"
29#include "Utility/IpplInfo.h"
30#include "Utility/IpplTimings.h"
31#include "Track/Track.h"
32
33#include "Pilot/Pilot.h"
35
43
44#include "Comm/CommSplitter.h"
48
50#include "Expression/FromFile.h"
51#include "Expression/SumErrSq.h"
59
60#include <map>
61#include <set>
62#include <string>
63#include <vector>
64
65extern Inform *gmsg;
66
67namespace {
68 enum {
69 INPUT,
70 OUTPUT,
71 OUTDIR,
72 OBJECTIVES,
73 DVARS,
74 CONSTRAINTS,
75 INITIALPOPULATION,
76 STARTPOPULATION,
77 NUMMASTERS,
78 NUMCOWORKERS,
79 DUMPDAT,
80 DUMPFREQ,
81 DUMPOFFSPRING,
82 NUMINDGEN,
83 MAXGENERATIONS,
84 EPSILON,
85 EXPECTEDHYPERVOL,
86 HYPERVOLREFERENCE,
87 CONVHVOLPROG,
88 ONEPILOTCONVERGE,
89 SOLSYNCH,
90 GENEMUTATIONPROBABILITY,
91 MUTATIONPROBABILITY,
92 RECOMBINATIONPROBABILITY,
93 SIMBINCROSSOVERNU,
94 INITIALOPTIMIZATION,
95 BIRTHCONTROL,
96 SIMTMPDIR,
97 TEMPLATEDIR,
98 FIELDMAPDIR,
99 DISTDIR,
100 CROSSOVER,
101 MUTATION,
102 RESTART_FILE,
103 RESTART_STEP,
104 SIZE
105 };
106}
107
109 Action(SIZE, "OPTIMIZE",
110 "The \"OPTIMIZE\" command initiates optimization.") {
112 ("INPUT", "Path to input file");
114 ("OUTPUT", "Name used in output file generation");
116 ("OUTDIR", "Name of directory used to store generation output files");
118 ("OBJECTIVES", "List of objectives to be used");
120 ("DVARS", "List of optimization variables to be used");
122 ("CONSTRAINTS", "List of constraints to be used");
123 itsAttr[INITIALPOPULATION] = Attributes::makeReal
124 ("INITIALPOPULATION", "Size of the initial population");
125 itsAttr[STARTPOPULATION] = Attributes::makeString
126 ("STARTPOPULATION", "Generation file (JSON format) to be started from (optional)", "");
127 itsAttr[NUMMASTERS] = Attributes::makeReal
128 ("NUM_MASTERS", "Number of master nodes");
129 itsAttr[NUMCOWORKERS] = Attributes::makeReal
130 ("NUM_COWORKERS", "Number processors per worker");
132 ("DUMP_DAT", "Dump old generation data format with frequency (PISA only)");
133 itsAttr[DUMPFREQ] = Attributes::makeReal
134 ("DUMP_FREQ", "Dump generation data with frequency (PISA only)");
135 itsAttr[DUMPOFFSPRING] = Attributes::makeBool
136 ("DUMP_OFFSPRING", "Dump offspring (instead of parent population), default: true");
137 itsAttr[NUMINDGEN] = Attributes::makeReal
138 ("NUM_IND_GEN", "Number of individuals in a generation (PISA only)");
139 itsAttr[MAXGENERATIONS] = Attributes::makeReal
140 ("MAXGENERATIONS", "Number of generations to run");
142 ("EPSILON", "Tolerance of hypervolume criteria, default 0.001");
143 itsAttr[EXPECTEDHYPERVOL] = Attributes::makeReal
144 ("EXPECTED_HYPERVOL", "The reference hypervolume, default 0");
145 itsAttr[HYPERVOLREFERENCE] = Attributes::makeRealArray
146 ("HYPERVOLREFERENCE", "The reference point (real array) for the hypervolume, default empty (origin)");
147 itsAttr[CONVHVOLPROG] = Attributes::makeReal
148 ("CONV_HVOL_PROG", "Converge if change in hypervolume is smaller, default 0");
149 itsAttr[ONEPILOTCONVERGE] = Attributes::makeBool
150 ("ONE_PILOT_CONVERGE", "default false");
151 itsAttr[SOLSYNCH] = Attributes::makeReal
152 ("SOL_SYNCH", "Solution exchange frequency, default 0");
153 itsAttr[GENEMUTATIONPROBABILITY] = Attributes::makeReal
154 ("GENE_MUTATION_PROBABILITY", "Mutation probability of individual gene, default: 0.5");
155 itsAttr[MUTATIONPROBABILITY] = Attributes::makeReal
156 ("MUTATION_PROBABILITY", "Mutation probability of genome, default: 0.5");
157 itsAttr[RECOMBINATIONPROBABILITY] = Attributes::makeReal
158 ("RECOMBINATION_PROBABILITY", "Probability for genes to recombine, default: 0.5");
159 itsAttr[SIMBINCROSSOVERNU] = Attributes::makeReal
160 ("SIMBIN_CROSSOVER_NU", "Simulated binary crossover, default: 2.0");
161 itsAttr[INITIALOPTIMIZATION] = Attributes::makeBool
162 ("INITIAL_OPTIMIZATION", "Optimize speed of initial generation, default: false");
163 itsAttr[BIRTHCONTROL] = Attributes::makeBool
164 ("BIRTH_CONTROL", "Enforce strict population sizes (or flexible to keep workers busy), default: false");
166 ("SIMTMPDIR", "Directory where simulations are run");
167 itsAttr[TEMPLATEDIR] = Attributes::makeString
168 ("TEMPLATEDIR", "Directory where templates are stored");
169 itsAttr[FIELDMAPDIR] = Attributes::makeString
170 ("FIELDMAPDIR", "Directory where field maps are stored");
172 ("DISTDIR", "Directory where distributions are stored", "");
174 ("CROSSOVER", "Type of cross over.", {"BLEND", "NAIVEONEPOINT", "NAIVEUNIFORM", "SIMULATEDBINARY"}, "BLEND");
176 ("MUTATION", "Type of bit mutation.", {"ONEBIT", "INDEPENDENTBIT"}, "INDEPENDENTBIT");
177 itsAttr[RESTART_FILE] = Attributes::makeString
178 ("RESTART_FILE", "H5 file to restart the OPAL simulations from (optional)", "");
179 itsAttr[RESTART_STEP] = Attributes::makeReal
180 ("RESTART_STEP", "Restart from given H5 step (optional)",
181 std::numeric_limits<int>::min());
183}
184
185OptimizeCmd::OptimizeCmd(const std::string &name, OptimizeCmd *parent):
186 Action(name, parent)
187{ }
188
191
192OptimizeCmd *OptimizeCmd::clone(const std::string &name) {
193 return new OptimizeCmd(name, this);
194}
195
197 namespace fs = std::filesystem;
198
199 auto opal = OpalData::getInstance();
200 opal->setOptimizerFlag();
201
202 fs::path inputfile(Attributes::getString(itsAttr[INPUT]));
203
204 std::vector<std::string> dvarsstr = Attributes::getStringArray(itsAttr[DVARS]);
205 std::vector<std::string> objectivesstr = Attributes::getStringArray(itsAttr[OBJECTIVES]);
206 std::vector<std::string> constraintsstr = Attributes::getStringArray(itsAttr[CONSTRAINTS]);
207 DVarContainer_t dvars;
208 Expressions::Named_t objectives;
209 Expressions::Named_t constraints;
210
211 // Setup/Configuration
213
214 // prepare function dictionary and add all available functions in
215 // expressions
218 ff = FromFile();
219 funcs.insert(std::pair<std::string, client::function::type>
220 ("fromFile", ff));
221
222 ff = SumErrSq();
223 funcs.insert(std::pair<std::string, client::function::type>
224 ("sumErrSq", ff));
225
226 ff = SDDSVariable();
227 funcs.insert(std::pair<std::string, client::function::type>
228 ("sddsVariableAt", ff));
229
230 ff = RadialPeak();
231 funcs.insert(std::pair<std::string, client::function::type>
232 ("radialPeak", ff));
233
234 ff = MaxNormRadialPeak();
235 funcs.insert(std::pair<std::string, client::function::type>
236 ("maxNormRadialPeak", ff));
237
238 ff = NumberOfPeaks();
239 funcs.insert(std::pair<std::string, client::function::type>
240 ("numberOfPeaks", ff));
241
242 ff = SumErrSqRadialPeak();
243 funcs.insert(std::pair<std::string, client::function::type>
244 ("sumErrSqRadialPeak", ff));
245
246 ff = ProbeVariable();
247 funcs.insert(std::pair<std::string, client::function::type>
248 ("probVariableWithID", ff));
249
250 std::string fname = inputfile.stem().native();
251 ff = sameSDDSVariable(fname);
252 funcs.insert(std::pair<std::string, client::function::type>
253 ("statVariableAt", ff));
254
255 ff = SeptumExpr();
256 funcs.insert(std::pair<std::string, client::function::type>
257 ("septum", ff));
258
260
261 std::vector<std::string> arguments(opal->getArguments());
262 std::vector<char*> argv;
263 std::map<unsigned int, std::string> argumentMapper({
264 {INPUT, "inputfile"},
265 {OUTPUT, "outfile"},
266 {OUTDIR, "outdir"},
267 {INITIALPOPULATION, "initialPopulation"},
268 {STARTPOPULATION, "start-population"},
269 {NUMMASTERS, "num-masters"},
270 {NUMCOWORKERS, "num-coworkers"},
271 {DUMPDAT, "dump-dat"},
272 {DUMPFREQ, "dump-freq"},
273 {DUMPOFFSPRING, "dump-offspring"},
274 {NUMINDGEN, "num-ind-gen"},
275 {MAXGENERATIONS, "maxGenerations"},
276 {EPSILON, "epsilon"},
277 {EXPECTEDHYPERVOL, "expected-hypervol"},
278 {CONVHVOLPROG, "conv-hvol-prog"},
279 {ONEPILOTCONVERGE, "one-pilot-converge"},
280 {SOLSYNCH, "sol-synch"},
281 {GENEMUTATIONPROBABILITY, "gene-mutation-probability"},
282 {MUTATIONPROBABILITY, "mutation-probability"},
283 {RECOMBINATIONPROBABILITY, "recombination-probability"},
284 {SIMBINCROSSOVERNU, "simbin-crossover-nu"},
285 {INITIALOPTIMIZATION, "initial-optimization"},
286 {BIRTHCONTROL, "birth-control"},
287 {RESTART_FILE, "restartfile"},
288 {RESTART_STEP, "restartstep"}
289 });
290
291 auto it = argumentMapper.end();
292 for (unsigned int i = 0; i < SIZE; ++ i) {
293 if ((it = argumentMapper.find(i)) != argumentMapper.end()) {
294 std::string type = itsAttr[i].getType();
295 if (type == "string") {
296 if (!Attributes::getString(itsAttr[i]).empty()) {
297 std::string argument = "--" + (*it).second + "=" + Attributes::getString(itsAttr[i]);
298 arguments.push_back(argument);
299 }
300 } else if (type == "real") {
301 if (itsAttr[i]) {
302 std::string val = std::to_string (Attributes::getReal(itsAttr[i]));
303 size_t last = val.find_last_not_of('0');
304 if (val[last] != '.') ++ last;
305 val.erase (last, std::string::npos );
306 std::string argument = "--" + (*it).second + "=" + val;
307 arguments.push_back(argument);
308 }
309 } else if (type == "logical") {
310 if (itsAttr[i]) {
311 std::string argument = "--" + (*it).second + "=" + std::to_string(Attributes::getBool(itsAttr[i]));
312 arguments.push_back(argument);
313 }
314 }
315 }
316 }
317 // sanity checks
318 if (Attributes::getString(itsAttr[INPUT]).empty()) {
319 throw OpalException("OptimizeCmd::execute",
320 "The argument INPUT has to be provided");
321 }
322 if (Attributes::getReal(itsAttr[INITIALPOPULATION]) <= 0) {
323 throw OpalException("OptimizeCmd::execute",
324 "The argument INITIALPOPULATION has to be provided");
325 }
326 if (Attributes::getReal(itsAttr[MAXGENERATIONS]) <= 0) {
327 throw OpalException("OptimizeCmd::execute",
328 "The argument MAXGENERATIONS has to be provided");
329 }
330 if (Attributes::getRealArray(itsAttr[HYPERVOLREFERENCE]).empty() == false &&
331 Attributes::getRealArray(itsAttr[HYPERVOLREFERENCE]).size() != objectivesstr.size()) {
332 throw OpalException("OptimizeCmd::execute",
333 "The hypervolume reference point should have the same dimension as the objectives");
334 }
335 if (!Attributes::getString(itsAttr[STARTPOPULATION]).empty() &&
336 Attributes::getBool( itsAttr[INITIALOPTIMIZATION]) == true) {
337 throw OpalException("OptimizeCmd::execute",
338 "No INITIAL_OPTIMIZATION possible when reading initial population from file (STARTPOPULATION)");
339 }
340 if (Attributes::getBool(itsAttr[BIRTHCONTROL]) == true &&
341 Attributes::getBool(itsAttr[INITIALOPTIMIZATION]) == true) {
342 throw OpalException("OptimizeCmd::execute",
343 "No INITIAL_OPTIMIZATION possible with BIRTH_CONTROL");
344 }
345
346 if (!Attributes::getString(itsAttr[SIMTMPDIR]).empty()) {
347 fs::path dir(Attributes::getString(itsAttr[SIMTMPDIR]));
348 if (dir.is_relative()) {
349 fs::path path = fs::path(std::string(getenv("PWD")));
350 path /= dir;
351 dir = path;
352 }
353
354 if (!fs::exists(dir)) {
355 fs::create_directory(dir);
356 }
357 std::string argument = "--simtmpdir=" + dir.native();
358 arguments.push_back(argument);
359 }
360
361 if (!Attributes::getString(itsAttr[TEMPLATEDIR]).empty()) {
362 fs::path dir(Attributes::getString(itsAttr[TEMPLATEDIR]));
363 if (dir.is_relative()) {
364 fs::path path = fs::path(std::string(getenv("PWD")));
365 path /= dir;
366 dir = path;
367 }
368
369 std::string argument = "--templates=" + dir.native();
370 arguments.push_back(argument);
371 }
372
373 if (!Attributes::getString(itsAttr[FIELDMAPDIR]).empty()) {
374 fs::path dir(Attributes::getString(itsAttr[FIELDMAPDIR]));
375 if (dir.is_relative()) {
376 fs::path path = fs::path(std::string(getenv("PWD")));
377 path /= dir;
378 dir = path;
379 }
380
381 setenv("FIELDMAPS", dir.c_str(), 1);
382 }
383
384 if (!Attributes::getString(itsAttr[DISTDIR]).empty()) {
385 fs::path dir(Attributes::getString(itsAttr[DISTDIR]));
386 if (dir.is_relative()) {
387 fs::path path = fs::path(std::string(getenv("PWD")));
388 path /= dir;
389 dir = path;
390 }
391
392 setenv("DISTRIBUTIONS", dir.c_str(), 1);
393 }
394
395
396 *gmsg << endl;
397 for (size_t i = 0; i < arguments.size(); ++ i) {
398 argv.push_back(const_cast<char*>(arguments[i].c_str()));
399 *gmsg << arguments[i] << " ";
400 }
401 *gmsg << endl;
402
403 std::set<std::string> vars; // check if all unique vars
404 for (const std::string &name: dvarsstr) {
405 Object *obj = opal->find(name);
406 DVar* dvar = dynamic_cast<DVar*>(obj);
407 if (dvar == nullptr) {
408 throw OpalException("OptimizeCmd::execute",
409 "The design variable " + name + " is not known");
410
411 }
412 std::string var = dvar->getVariable();
413 double lowerbound = dvar->getLowerBound();
414 double upperbound = dvar->getUpperBound();
415
416 DVar_t tmp = boost::make_tuple(var, lowerbound, upperbound);
417 dvars.insert(namedDVar_t(name, tmp));
418 auto ret = vars.insert(var);
419 if (ret.second == false) {
420 throw OpalException("OptimizeCmd::execute",
421 "There is already a design variable with the variable " + var + " defined");
422 }
423 }
424 std::set<std::string> objExpressions; // check if all unique objective expressions
425 for (const std::string &name: objectivesstr) {
426 Object *obj = opal->find(name);
427 Objective* objective = dynamic_cast<Objective*>(obj);
428 if (objective == nullptr) {
429 throw OpalException("OptimizeCmd::execute",
430 "The objective " + name + " is not known");
431
432 }
433 std::string expr = objective->getExpression();
434 objectives.insert(Expressions::SingleNamed_t(
435 name, new Expressions::Expr_t(expr, funcs)));
436 auto ret = objExpressions.insert(expr);
437 if (ret.second == false) {
438 throw OpalException("OptimizeCmd::execute",
439 "There is already a objective with the expression " + expr + " defined");
440 }
441 }
442 std::set<std::string> constraintExpressions; // check if all unique constraint expressions
443 for (const std::string &name: constraintsstr) {
444 Object *obj = opal->find(name);
445 Constraint* constraint = dynamic_cast<Constraint*>(obj);
446 if (constraint == nullptr) {
447 throw OpalException("OptimizeCmd::execute",
448 "The constraint " + name + " is not known");
449
450 }
451 std::string expr = constraint->getExpression();
452 constraints.insert(Expressions::SingleNamed_t(
453 name, new Expressions::Expr_t(expr, funcs)));
454 auto ret = constraintExpressions.insert(expr);
455 if (ret.second == false) {
456 throw OpalException("OptimizeCmd::execute",
457 "There is already a constraint with the expression " + expr + " defined");
458 }
459 }
460
461 {
462 std::string tmplFile = Attributes::getString(itsAttr[INPUT]);
463 size_t pos = tmplFile.find_last_of("/");
464 if(pos != std::string::npos)
465 tmplFile = tmplFile.substr(pos+1);
466 pos = tmplFile.find(".");
467 tmplFile = tmplFile.substr(0,pos);
468 tmplFile = Attributes::getString(itsAttr[TEMPLATEDIR]) + "/" + tmplFile + ".tmpl";
469
470 std::ifstream infile(tmplFile.c_str());
471
472 std::map<std::string, short> dvarCheck;
473 for (auto itr = dvars.begin(); itr != dvars.end(); ++ itr) {
474 dvarCheck.insert(std::make_pair(boost::get<0>(itr->second), 0));
475 }
476
477 while(infile.good()) {
478 std::string line;
479 std::getline(infile, line, '\n');
480
481 //XXX doing the inverse would be better
482 for(auto &check: dvarCheck) {
483 pos = line.find("_" + check.first + "_");
484 if (pos != std::string::npos &&
485 dvarCheck.find(check.first) != dvarCheck.end()) {
486 dvarCheck.at(check.first) = 1;
487 }
488 }
489 }
490 infile.close();
491
492 for (auto itr = dvarCheck.begin(); itr != dvarCheck.end(); ++ itr) {
493 if (itr->second == 0) {
494 throw OpalException("OptimizeCmd::execute()",
495 "Couldn't find the design variable '" + itr->first + "' in '" + tmplFile + "'!");
496 }
497 }
498 }
499
500 Inform *origGmsg = gmsg;
501 gmsg = 0;
502 try {
503 CmdArguments_t args(new CmdArguments(argv.size(), &argv[0]));
504
505 this->run(args, funcs, dvars, objectives, constraints);
506
507 } catch (OptPilotException &e) {
508 std::cout << "Exception caught: " << e.what() << std::endl;
509 MPI_Abort(MPI_COMM_WORLD, -100);
510 }
511 gmsg = origGmsg;
512}
513
520
527
529 std::map<std::string, CrossOver> map;
530 map["BLEND"] = CrossOver::Blend;
531 map["NAIVEONEPOINT"] = CrossOver::NaiveOnePoint;
532 map["NAIVEUNIFORM"] = CrossOver::NaiveUniform;
533 map["SIMULATEDBINARY"] = CrossOver::SimulatedBinary;
534
536
537 switch ( map[crossover] ) {
538 case CrossOver::Blend:
539 break;
542 break;
545 break;
548 break;
549 default:
550 throw OpalException("OptimizeCmd::crossoverSelection",
551 "No cross over '" + crossover + "' supported.");
552 }
553
554 return co;
555}
556
558 std::map<std::string, Mutation> map;
559 map["INDEPENDENTBIT"] = Mutation::IndependentBit;
560 map["ONEBIT"] = Mutation::OneBit;
561
563
564 switch ( map[mutation] ) {
566 break;
567 case Mutation::OneBit:
568 mut = Mutation::OneBit;
569 break;
570 default:
571 throw OpalException("OptimizeCmd::mutationSelection",
572 "No mutation '" + mutation + "' supported.");
573 }
574
575 return mut;
576}
577
579 const functionDictionary_t& funcs,
580 const DVarContainer_t& dvars,
581 const Expressions::Named_t& objectives,
582 const Expressions::Named_t& constraints)
583{
584 typedef OpalSimulation Sim_t;
585
587 typedef SocialNetworkGraph< NoCommTopology > SolPropagationGraph_t;
588
589 std::shared_ptr<Comm_t> comm(new Comm_t(args, MPI_COMM_WORLD));
590 if (comm->isWorker())
592
593 CrossOver crossover = this->crossoverSelection(Attributes::getString(itsAttr[CROSSOVER]));
594 Mutation mutation = this->mutationSelection(Attributes::getString(itsAttr[MUTATION]));
595
596
597 std::map<std::string, std::string> userVariables = OpalData::getInstance()->getVariableData();
598
599 switch ( crossover + mutation ) {
601 {
604
605 const std::unique_ptr<pilot_t> pi(new pilot_t(args, comm,
606 funcs, dvars,
607 objectives, constraints,
608 Attributes::getRealArray(itsAttr[HYPERVOLREFERENCE]),
609 true, userVariables));
610 break;
611 }
613 {
616
617 const std::unique_ptr<pilot_t> pi(new pilot_t(args, comm,
618 funcs, dvars,
619 objectives, constraints,
620 Attributes::getRealArray(itsAttr[HYPERVOLREFERENCE]),
621 true, userVariables));
622 break;
623 }
625 {
628
629 const std::unique_ptr<pilot_t> pi(new pilot_t(args, comm,
630 funcs, dvars,
631 objectives, constraints,
632 Attributes::getRealArray(itsAttr[HYPERVOLREFERENCE]),
633 true, userVariables));
634 break;
635 }
637 {
640
641 const std::unique_ptr<pilot_t> pi(new pilot_t(args, comm,
642 funcs, dvars,
643 objectives, constraints,
644 Attributes::getRealArray(itsAttr[HYPERVOLREFERENCE]),
645 true, userVariables));
646 break;
647 }
649 {
652
653 const std::unique_ptr<pilot_t> pi(new pilot_t(args, comm,
654 funcs, dvars,
655 objectives, constraints,
656 Attributes::getRealArray(itsAttr[HYPERVOLREFERENCE]),
657 true, userVariables));
658 break;
659 }
661 {
664
665 const std::unique_ptr<pilot_t> pi(new pilot_t(args, comm,
666 funcs, dvars,
667 objectives, constraints,
668 Attributes::getRealArray(itsAttr[HYPERVOLREFERENCE]),
669 true, userVariables));
670 break;
671 }
673 {
676
677 const std::unique_ptr<pilot_t> pi(new pilot_t(args, comm,
678 funcs, dvars,
679 objectives, constraints,
680 Attributes::getRealArray(itsAttr[HYPERVOLREFERENCE]),
681 true, userVariables));
682 break;
683 }
685 {
688
689 const std::unique_ptr<pilot_t> pi(new pilot_t(args, comm,
690 funcs, dvars,
691 objectives, constraints,
692 Attributes::getRealArray(itsAttr[HYPERVOLREFERENCE]),
693 true, userVariables));
694 break;
695 }
696 default:
697 throw OpalException("OptimizeCmd::run",
698 "No such cross over and mutation combination supported.");
699 }
700
701 if (comm->isWorker())
703}
@ SIZE
Definition IndexMap.cpp:174
Inform * gmsg
Definition Main.cpp:70
const double pi
Definition fftpack.cpp:894
Inform & endl(Inform &inf)
Definition Inform.cpp:42
boost::tuple< std::string, double, double > DVar_t
type of design variables
Definition Types.h:84
std::map< std::string, DVar_t > DVarContainer_t
Definition Types.h:92
std::pair< std::string, DVar_t > namedDVar_t
Definition Types.h:91
std::shared_ptr< CmdArguments > CmdArguments_t
const std::string name
std::map< std::string, client::function::type > functionDictionary_t
Definition Expression.h:56
std::map< std::string, Expressions::Expr_t * > Named_t
type of an expressions with a name
Definition Expression.h:74
Expression Expr_t
type of an expression
Definition Expression.h:63
std::pair< std::string, Expressions::Expr_t * > SingleNamed_t
Definition Expression.h:77
Attribute makeBool(const std::string &name, const std::string &help)
Make logical attribute.
double getReal(const Attribute &attr)
Return real value.
Attribute makeStringArray(const std::string &name, const std::string &help)
Create a string array attribute.
Attribute makePredefinedString(const std::string &name, const std::string &help, const std::initializer_list< std::string > &predefinedStrings)
Make predefined string attribute.
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute.
bool getBool(const Attribute &attr)
Return logical value.
Attribute makeRealArray(const std::string &name, const std::string &help)
Create real array attribute.
std::vector< double > getRealArray(const Attribute &attr)
Get array value.
std::vector< std::string > getStringArray(const Attribute &attr)
Get string array value.
std::string getString(const Attribute &attr)
Get string value.
Attribute makeString(const std::string &name, const std::string &help)
Make string attribute.
boost::function< boost::tuple< double, bool >(arguments_t)> type
Definition function.hpp:21
Action(int size, const char *name, const char *help)
Constructor for exemplars.
Definition Action.cpp:54
void registerOwnership(const AttributeHandler::OwnerType &itsClass) const
Definition Object.cpp:191
Object(int size, const char *name, const char *help)
Constructor for exemplars.
Definition Object.cpp:356
std::vector< Attribute > itsAttr
The object attributes.
Definition Object.h:216
std::map< std::string, std::string > getVariableData()
Definition OpalData.cpp:716
static void stashInstance()
Definition OpalData.cpp:212
static OpalData * getInstance()
Definition OpalData.cpp:196
static OpalData * popInstance()
Definition OpalData.cpp:223
std::string getExpression() const
Definition DVar.h:6
std::string getVariable() const
Definition DVar.cpp:37
double getUpperBound() const
Definition DVar.cpp:45
double getLowerBound() const
Definition DVar.cpp:41
std::string getExpression() const
Definition Objective.cpp:31
Concrete implementation of an Opal simulation wrapper.
virtual ~OptimizeCmd()
virtual OptimizeCmd * clone(const std::string &name)
Make clone.
CrossOver crossoverSelection(std::string crossover)
void popEnvironment()
Mutation mutationSelection(std::string mutation)
void run(const CmdArguments_t &args, const functionDictionary_t &funcs, const DVarContainer_t &dvars, const Expressions::Named_t &objectives, const Expressions::Named_t &constraints)
void stashEnvironment()
virtual void execute()
Execute the command.
OptimizeCmd()
Exemplar constructor.
Sampling method that reads design variable values from a text file.
static Track * pop()
Definition Track.cpp:83
static void stash()
Definition Track.cpp:76
The base class for all OPAL exceptions.
static void pop()
static void stash()
Definition IpplInfo.cpp:988
static void stash()
static void pop()
Definition Pilot.h:99