35 #include <boost/property_tree/json_parser.hpp>
36 #include <boost/property_tree/ptree.hpp>
48 "We shouldn't get here!");
53 std::shared_ptr<SamplingMethod>
60 , sampleMethods_m(sampleMethods)
63 , objectives_m(objectives)
69 std::string resultFile = args->getArg<std::string>(
"outfile",
"output",
false);
70 std::string resultDir = args->getArg<std::string>(
"outdir",
"samples",
false);
73 std::ostringstream filename;
74 filename << resultDir <<
"/" << resultFile
78 if ( !std::filesystem::exists(resultDir) ) {
79 std::filesystem::create_directory(resultDir);
85 std::pair<double, double>
86 (boost::get<LOWER_BOUND>(itr->second),
87 boost::get<UPPER_BOUND>(itr->second)));
101 int nMasters =
args_->getArg<
int>(
"num-masters",
true);
105 "More masters than samples.");
109 int rest =
nSamples_m - nMasters * nLocSamples;
135 unsigned int jid =
static_cast<unsigned int>(length);
136 typename std::map<size_t, std::shared_ptr<Individual_t> >
::iterator it;
140 std::cout <<
"NON-EXISTING JOB with ID = " << jid <<
std::endl;
146 std::shared_ptr<Individual_t> ind = it->second;
151 ind->objectives.clear();
154 for(; itr != res.end(); ++itr) {
156 if(!itr->second.is_valid || (itr->second.value.size() > 1 && !itr->second.value[0])) {
157 ind->objectives.push_back(std::numeric_limits<double>::infinity());
160 if(itr->second.value.size() == 1)
161 ind->objectives.push_back(itr->second.value[0]);
174 std::cout <<
"(Sampler) Error: unexpected MPI_TAG: "
194 std::vector<std::string> dNames;
198 std::string dName = boost::get<VAR_NAME>(itr->second);
199 dNames.push_back(dName);
202 std::shared_ptr<Individual_t> ind = std::shared_ptr<Individual_t>(
new Individual_t(dNames));
207 std::string dName = boost::get<VAR_NAME>(itr->second);
208 int i = ind->getIndex(dName);
218 namespace pt = boost::property_tree;
222 tree.put(
"name",
"sampler");
231 std::string dvar = boost::get<VAR_NAME>(itr->second);
232 bounds <<
"[ " <<
it->first <<
", " <<
it->second <<
" ]";
233 tree.put(
"dvar-bounds." + dvar, bounds.str());
247 namespace pt = boost::property_tree;
254 if ( tree.get_optional<std::string>(
"samples") ) {
258 samples = tree.get_child(
"samples");
259 tree.erase(
"samples");
266 std::string
id = std::to_string(ind.
id);
270 std::string
name = boost::get<VAR_NAME>(itr->second);
272 samples.put(
id +
".dvar." + name, ind.
genes[i]);
278 for(
size_t i=0; i < ind.
objectives.size(); i++, expr_it++) {
279 std::string
name = expr_it->first;
282 if ( name ==
"dummy" )
285 samples.put(
id +
".obj." + name, ind.
objectives[i]);
289 tree.add_child(
"samples", samples);
290 boost::property_tree::write_json(
jsonFname_m, tree);
350 std::string dName = boost::get<VAR_NAME>(itr->second);
351 int i = ind->getIndex(dName);
353 std::pair<std::string, double>
354 (dName, ind->genes[i]));
357 size_t jid =
static_cast<size_t>(ind->id);
369 std::pair<
size_t, std::shared_ptr<Individual_t> >(jid, ind));
namedVariableCollection_t Param_t
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two distribute and or modify the software for each author s protection and we want to make certain that everyone understands that there is no warranty for this free software If the software is modified by someone else and passed we want its recipients to know that what they have is not the so that any problems introduced by others will not reflect on the original authors reputations any free program is threatened constantly by software patents We wish to avoid the danger that redistributors of a free program will individually obtain patent in effect making the program proprietary To prevent we have made it clear that any patent must be licensed for everyone s free use or not licensed at all The precise terms and conditions for distribution and modification follow GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR DISTRIBUTION AND MODIFICATION This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License The refers to any such program or and a work based on the Program means either the Program or any derivative work under copyright a work containing the Program or a portion of it
#define OPAL_PROJECT_VERSION
bounds_t dVarBounds_m
bounds on each specified gene
void createNewIndividual()
std::map< std::string, std::shared_ptr< SamplingMethod > > sampleMethods_m
std::string getGitRevision()
#define OPAL_PROJECT_NAME
std::map< std::string, DVar_t > DVarContainer_t
void bounds(const PETE_Expr< T1 > &expr, Vektor< T2, D > &minval, Vektor< T2, D > &maxval)
CmdArguments_t args_
command line arguments specified by the user
Inform & endl(Inform &inf)
std::map< std::string, Expressions::Expr_t * > Named_t
type of an expressions with a name
void postPoll()
executed after handling (if any) new request
std::string::iterator iterator
bool onMessage(MPI_Status status, size_t length)
std::map< size_t, std::shared_ptr< Individual_t > > jobmapping_m
mapping from unique job ID to individual
void dumpIndividualsToJSON()
Comm::Bundle_t comms_
communicator bundle for the optimizer
int act_sample_m
current generation
objectives_t objectives
values of objectives of an individual
std::shared_ptr< CmdArguments > CmdArguments_t
void addIndividualToJSON(const std::shared_ptr< Individual_t > &ind)
std::size_t jsonDumpFreq_m
Dumps id, design variables and bound.
#define MPI_OPT_CONVERGED_TAG
optimizer notifies pilot that optimization has converged (EXIT)
DVarContainer_t dvars_m
design variables
std::list< Individual_t > individualsToDump_m
void MPI_Recv_reqvars(reqVarContainer_t &reqvars, size_t pid, MPI_Comm comm)
Expressions::Named_t objectives_m
objectives
bundles all communicators for a specific role/pid
genes_t genes
genes of an individual
void MPI_Send_params(Param_t params, size_t pid, MPI_Comm comm)
Sampler(Expressions::Named_t objectives, Expressions::Named_t constraints, DVarContainer_t dvars, size_t dim, Comm::Bundle_t comms, CmdArguments_t args, std::vector< double > hypervolRef, int nrWorkerGroups)
int getIndex(std::string name)
virtual void initialize()
Initialization and start algorithm.
std::map< std::string, reqVarInfo_t > reqVarContainer_t
SampleIndividual Individual_t
std::queue< std::shared_ptr< Individual_t > > individuals_m
void dispatch_forward_solves()