Skip to content

Commit

Permalink
Cleaning more TODOs
Browse files Browse the repository at this point in the history
  • Loading branch information
gAldeia committed Apr 24, 2024
1 parent 5ee9393 commit c64fad7
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 19 deletions.
17 changes: 5 additions & 12 deletions src/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void Engine<T>::print_progress(float percentage)


template <ProgramType T>
void Engine<T>::calculate_stats(const Dataset& d)
void Engine<T>::calculate_stats()
{
int pop_size = 0;
for (int island=0; island<params.num_islands; ++island)
Expand Down Expand Up @@ -311,8 +311,6 @@ void Engine<T>::run(Dataset &data)

tf::Taskflow taskflow;

// TODO: get references to all classes ( so they can be captured by taskflow) (like some private getters and setters)

//std::cout << "stop criteria is ready " << std::endl;
// stop criteria
unsigned generation = 0;
Expand Down Expand Up @@ -447,18 +445,13 @@ void Engine<T>::run(Dataset &data)
auto finish_gen = subflow.emplace([&]() {
bool updated_best = this->update_best(data);

// TODO: fix this code below (if needed. this is borrowed from feat)
// if ( (use_arch || params.verbosity>1) || !logfile.empty()) {
// // set objectives to make sure they are reported in log/verbose/arch
// #pragma omp parallel for
// for (unsigned int i=0; i<pop.size(); ++i)
// pop.individuals.at(i).set_obj(params.objectives);
// }
// TODO: use_arch
if ( params.verbosity>1 || !logfile.empty()) {
calculate_stats();
}

// TODO: logger working
// logger.log("calculate stats...",2);
calculate_stats(data); // TODO: calculate stats only if archive, logstats, or verbosity (otherwise it is not used)
// TODO: calculate stats does not need dataset

// if (use_arch) // TODO: archive
// archive.update(pop,params);
Expand Down
2 changes: 1 addition & 1 deletion src/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Engine{

// outputs a progress bar, filled according to @param percentage.
void print_progress(float percentage);
void calculate_stats(const Dataset& d);
void calculate_stats();
void print_stats(std::ofstream& log, float fraction);
void log_stats(std::ofstream& log);

Expand Down
3 changes: 1 addition & 2 deletions src/eval/evaluation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ void Evaluation<T>::update_fitness(Population<T>& pop,
bool fit,
bool validation
)
{
//TODO: it could use the validation_loss
{
auto idxs = pop.get_island_indexes(island);

for (unsigned i = 0; i<idxs.size(); ++i)
Expand Down
4 changes: 2 additions & 2 deletions src/ind/fitness.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ struct Fitness {
dominated.resize(0);
}

// Hash function TODO: stop using it (i think only deap needs this)
// Hash function (deap requires individuals (and fitness by induction)
// to be hashable)
size_t hash() const {
std::size_t h = std::hash<vector<float>>{}(wvalues);
return h;
Expand All @@ -96,7 +97,6 @@ struct Fitness {
return wvalues;
}

// TODO: debug size, it is giving weird values
// Method to set values
void set_values(vector<float>& v) {
if (v.size() != weights.size()) {
Expand Down
4 changes: 2 additions & 2 deletions src/ind/individual.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class Individual{

Individual()
{
// TODO: better initialization of arguments
objectives = {"error", "complexity"};
};

Expand All @@ -45,12 +44,13 @@ class Individual{
// program = SS.make_program<T>(params, params.max_depth, params.max_size);
};

// fitness, objetives, complexity, etc. TODO: create intermediate functions to interact with fitness and program?
// fitness, objetives, complexity, etc.
void fit(Dataset& data) {
program.fit(data);
// this flag is used to avoid re-fitting an individual. the program is_fitted_ flag is used to perform checks (like in predict with weights). They are two different things and I think I;ll keep this way (individual is just a container to keep program and fitness together)
this->is_fitted_ = true;
};

auto predict(Dataset& data) { return program.predict(data); };

// TODO: predict proba and classification related methods.
Expand Down

0 comments on commit c64fad7

Please sign in to comment.