1 #ifndef __FIXED_PISA_NSGA2_H__
2 #define __FIXED_PISA_NSGA2_H__
26 #include <boost/smart_ptr.hpp>
27 #include <boost/chrono.hpp>
28 #include <boost/property_tree/ptree.hpp>
48 template <
class>
class CrossoverOperator
49 ,
template <
class>
class MutationOperator
72 std::vector<double> hypervolRef,
88 using individual = boost::shared_ptr<typename FixedPisaNsga2::Individual_t>;
96 virtual bool onMessage(MPI_Status status,
size_t length);
152 std::vector< std::vector<int> >
front;
265 void dumpPopulationToFile(boost::shared_ptr<Population_t>, std::ostringstream& filename,
bool dump_offspring);
266 void dumpPopulationToJSON(boost::shared_ptr<Population_t>, std::ostringstream& filename,
bool dump_offspring);
270 const size_t numDigits);
273 boost::property_tree::ptree& tree);
281 return (
int) ((double) range * (
double) rand() / (RAND_MAX + 1.0));
285 #include "Optimizer/EA/FixedPisaNsga2.tcc"
size_t lambda_m
number of parents the selector chooses
std::vector< double > hvol_ref_m
hypervolume reference point
bool birthControl_m
enforce strict population size
int dominates(individual ind_a, individual ind_b)
std::deque< unsigned int > finishedBuffer_m
buffer holding all finished job id's
std::vector< int > copies
number of individuals in the n-th front
std::vector< std::pair< double, double > > bounds_t
type of bounds for design variables
bool dump_offspring_m
dump offspring / parents flag
std::set< unsigned int > to_selector_
Successfully run IDs to go into population.
virtual bool onMessage(MPI_Status status, size_t length)
implementing poller hooks
std::vector< double > dist
Expressions::Named_t constraints_m
constraints
virtual void initialize()
Starting selection algorithm and variator PISA state machine.
boost::shared_ptr< CmdArguments > CmdArguments_t
boost::scoped_ptr< Trace > progress_
std::vector< unsigned int > parent_queue_
IDs that will make new offspring.
Variator< Individual_t, CrossoverOperator, MutationOperator > Variator_t
bool initialized_m
indicating if initial population has been created
std::map< size_t, individual > jobmapping_m
mapping from unique job ID to individual
void environmentalSelection()
std::string getStateString(PisaState_t) const
bool dump_dat_m
dump old data format
double conv_hvol_progress_
Expressions::Named_t objectives_m
objectives
boost::shared_ptr< Population_t > paretoFront_m
population of pareto-front (for final output)
Comm::Bundle_t comms_
communicator bundle for the optimizer
Implementing the Variator for the PISA state machine.
size_t exchangeSolStateFreq_m
how often do we exchange solutions with other optimizers
bounds_t dVarBounds_m
bounds on each specified gene
void runStateMachine()
executes one loop of the PISA state machine
void startSelector(std::string filename_base)
double hvol_eps_
convergence accuracy if maxGenerations not set
size_t maxGenerations_m
maximal generation (stopping criterion)
boost::chrono::system_clock::time_point run_clock_start_
Population< Individual_t > Population_t
void dumpPopulationToJSON(boost::shared_ptr< Population_t >, std::ostringstream &filename, bool dump_offspring)
An abstract class defining the interface for all optimizer components.
size_t act_gen
current generation
virtual void onStop()
enable implementation to react to STOP tag
std::map< size_t, double > fitness_
map between id and fitness (sum of front number and dist)
boost::scoped_ptr< Statistics< size_t > > statistics_
collect some statistics of rejected and accepted individuals
bool initialOptimization_m
initial population optimization flag (increases initial population)
PisaState_t
all PISA states
std::vector< unsigned int > pp_all
IDs of population.
boost::chrono::system_clock::time_point last_clock_
CmdArguments_t args_m
command line arguments specified by the user
void dumpIndividualToJSON(int id, individual &ind, boost::property_tree::ptree &tree)
std::map< std::string, DVar_t > DVarContainer_t
std::map< std::string, Expressions::Expr_t * > Named_t
type of an expressions with a name
FixedPisaNsga2(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)
void dispatch_forward_solves()
virtual void postPoll()
executed after handling (if any) new request
size_t dim_m
number of objectives
std::vector< std::vector< int > > front
individuals in each front
std::vector< Individual > SolutionState_t
type used in solution state exchange with other optimizers
boost::scoped_ptr< Variator_t > variator_m
boost::shared_ptr< typename FixedPisaNsga2::Individual_t > individual
alias for usage in template
virtual void prePoll()
executed before checking for new request
std::string file_param_descr_
file header for result files contains this parameter description
int num_workergroups_m
number of individuals running
Individual Individual_t
type of our variator
DVarContainer_t dvars_m
design variables
void dumpPopulation(boost::shared_ptr< Population_t >)
void writeVariatorCfg()
Write the variator config file.
boost::scoped_ptr< Trace > job_trace_
size_t alpha_m
size of initial population
std::string resultFile_m
result file name
bool checkParetoFront(unsigned int id)
check if individual in pareto front and add if not
PisaState_t curState_m
the current state of the state machine
bundles all communicators for a specific role/pid
std::string file_start_m
population file to be started from
virtual void setupPoll()
executed before starting polling loop
void exchangeSolutionStates()
if necessary exchange solution state with other optimizers
void toSelectorAndCommit()
passes finished individuals to the selector
void dumpIndividualToFile(int id, individual &ind, std::ofstream &file, const size_t numDigits)
void dumpPopulationToFile(boost::shared_ptr< Population_t >, std::ostringstream &filename, bool dump_offspring)