Skip to content

Commit

Permalink
Ran clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
Alberto Santini committed Dec 3, 2019
1 parent 3a7c73a commit 63554d2
Show file tree
Hide file tree
Showing 19 changed files with 115 additions and 137 deletions.
4 changes: 2 additions & 2 deletions src/AcceptanceCriteria/ConservativeWorseAccept.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ namespace mlpalns {
current_prob = S * std::exp(-lambda * T);
}
} else {
if (prob_decrease_is_linear) {
if(prob_decrease_is_linear) {
current_prob -= prob_decrease;
} else {
const auto N = this->params.max_iters - this->params.prerun_iters;
Expand Down Expand Up @@ -128,6 +128,6 @@ namespace mlpalns {
return false;
}
}
}
} // namespace mlpalns

#endif
2 changes: 1 addition & 1 deletion src/AcceptanceCriteria/DiscreetWorseAccept.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,6 @@ namespace mlpalns {

return accept;
}
}
} // namespace mlpalns

#endif
2 changes: 1 addition & 1 deletion src/AcceptanceCriteria/GreatDeluge.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,6 @@ namespace mlpalns {
last_obj_value = current_obj;
return (new_obj < water_level - eps);
}
}
} // namespace mlpalns

#endif
2 changes: 1 addition & 1 deletion src/AcceptanceCriteria/HillClimbing.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ namespace mlpalns {
bool HillClimbing<Solution>::should_accept(double, double current_obj, double new_obj, double eps, Solution&, std::mt19937&) {
return (new_obj < current_obj - eps);
}
}
} // namespace mlpalns

#endif
2 changes: 1 addition & 1 deletion src/AcceptanceCriteria/LateAcceptanceHillClimbing.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,6 @@ namespace mlpalns {

return accepted;
}
}
} // namespace mlpalns

#endif
2 changes: 1 addition & 1 deletion src/AcceptanceCriteria/NLGreatDeluge.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,6 @@ namespace mlpalns {
this->best_obj = best_obj;
return (new_obj < current_obj - eps || new_obj < water_level - eps);
}
}
} // namespace mlpalns

#endif
2 changes: 1 addition & 1 deletion src/AcceptanceCriteria/RandomWalk.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ namespace mlpalns {
bool RandomWalk<Solution>::should_accept(double, double, double, double, Solution&, std::mt19937&) {
return true;
}
}
} // namespace mlpalns

#endif
6 changes: 3 additions & 3 deletions src/AcceptanceCriteria/RecordToRecordTravel.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ namespace mlpalns {
deviation = this->params.rrt_params.start_deviation;
deviation_step =
(this->params.rrt_params.start_deviation - this->params.rrt_params.end_deviation) / (this->params.max_iters - this->params.prerun_iters);
deviation_exp_coeff =
std::pow(this->params.rrt_params.start_deviation / this->params.rrt_params.end_deviation, 1.0 / (this->params.max_iters - this->params.prerun_iters));
deviation_exp_coeff = std::pow(this->params.rrt_params.start_deviation / this->params.rrt_params.end_deviation,
1.0 / (this->params.max_iters - this->params.prerun_iters));
}

template<typename Solution>
Expand Down Expand Up @@ -97,6 +97,6 @@ namespace mlpalns {
double gap = (new_obj - best_obj) / new_obj;
return (gap < deviation - eps);
}
}
} // namespace mlpalns

#endif
2 changes: 1 addition & 1 deletion src/AcceptanceCriteria/SimulatedAnnealing.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,6 @@ namespace mlpalns {

return (dist(mt) < exp((current_obj - new_obj) / temperature) - eps);
}
}
} // namespace mlpalns

#endif
4 changes: 2 additions & 2 deletions src/AcceptanceCriteria/ThresholdAcceptance.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ namespace mlpalns {
current_threshold = S * std::exp(-lambda * T);
}
} else {
if (this->params.ta_params.threshold_decrease_is_linear) {
if(this->params.ta_params.threshold_decrease_is_linear) {
current_threshold -= threshold_decrease;
} else {
current_threshold *= threshold_exp_coeff;
Expand All @@ -97,6 +97,6 @@ namespace mlpalns {
double gap = (new_obj - current_obj) / new_obj;
return (gap < current_threshold - eps);
}
}
} // namespace mlpalns

#endif
6 changes: 3 additions & 3 deletions src/AcceptanceCriteria/WorseAccept.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ namespace mlpalns {
current_prob = S + (elapsed_time / T) * (E - S);
} else {
const auto lambda = std::log(S / T) / T;
current_prob = S * std::exp(- lambda * T);
current_prob = S * std::exp(-lambda * T);
}
} else {
if (prob_decrease_is_linear) {
if(prob_decrease_is_linear) {
current_prob -= prob_decrease;
} else {
const auto N = this->params.max_iters - this->params.prerun_iters;
Expand All @@ -99,6 +99,6 @@ namespace mlpalns {
std::uniform_real_distribution<double> dist(0.0, 1.0);
return (new_obj < current_obj - eps || dist(mt) < current_prob - eps);
}
}
} // namespace mlpalns

#endif
8 changes: 3 additions & 5 deletions src/AcceptanceCriterion.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,8 @@ namespace mlpalns {
bool preliminary_run;

/*! Basic constructor */
AcceptanceCriterion(Parameters& par) :
params(par),
timebase(par.acceptance_params_base == Parameters::AcceptanceParamsBase::Time),
preliminary_run(false) {}
AcceptanceCriterion(Parameters& par)
: params(par), timebase(par.acceptance_params_base == Parameters::AcceptanceParamsBase::Time), preliminary_run(false) {}

/*! Setter for the preliminary run flag */
void set_preliminary_run() { preliminary_run = true; }
Expand Down Expand Up @@ -84,6 +82,6 @@ namespace mlpalns {
*/
virtual bool should_accept(double best_obj, double current_obj, double new_obj, double eps, Solution& new_sol, std::mt19937& mt) = 0;
};
}
} // namespace mlpalns

#endif
8 changes: 3 additions & 5 deletions src/AlgorithmStatus.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,9 @@ namespace mlpalns {
// Whether the new sol was the new global best sol
bool new_best;

AlgorithmStatus(const Parameters& params,
Solution& new_solution,
Solution& best_solution) :
params{params}, new_solution{new_solution}, best_solution{best_solution} {}
AlgorithmStatus(const Parameters& params, Solution& new_solution, Solution& best_solution)
: params{params}, new_solution{new_solution}, best_solution{best_solution} {}
};
}
} // namespace mlpalns

#endif // ML_PALNS_ALGORITHMSTATUS_H
16 changes: 6 additions & 10 deletions src/AlgorithmVisitor.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#include "AlgorithmStatus.h"
#include "DestroyMethod.h"
#include "RepairMethod.h"
#include <vector>
#include <string>
#include <vector>

namespace mlpalns {
/**
Expand All @@ -30,19 +30,16 @@ namespace mlpalns {
* @param destroy_methods_desc A vector with string descriptions of the destroy methods.
* @param repair_methods_desc A vector with string descriptions of the repair methods.
*/
virtual void on_algorithm_start(std::vector<DestroyMethod<Solution>*>& destroy,
std::vector<RepairMethod<Solution>*>& repair,
const std::vector<std::string>& destroy_methods_desc,
const std::vector<std::string>& repair_methods_desc) = 0;
virtual void on_algorithm_start(std::vector<DestroyMethod<Solution>*>& destroy, std::vector<RepairMethod<Solution>*>& repair,
const std::vector<std::string>& destroy_methods_desc, const std::vector<std::string>& repair_methods_desc) = 0;

/**
* This method is called when the prerun (calibration run) ends.
*
* @param destroy A vector with the destroy methods.
* @param repair A vector with the repair methods.
*/
virtual void on_prerun_end(std::vector<DestroyMethod<Solution>*>& destroy,
std::vector<RepairMethod<Solution>*>& repair) = 0;
virtual void on_prerun_end(std::vector<DestroyMethod<Solution>*>& destroy, std::vector<RepairMethod<Solution>*>& repair) = 0;

/**
* This method is called at the end of every iteration.
Expand All @@ -60,14 +57,13 @@ namespace mlpalns {
* @param destroy A vector with the destroy methods.
* @param repair A vector with the repair methods.
*/
virtual void on_many_iters_without_improvement(std::vector<DestroyMethod<Solution>*>& destroy,
std::vector<RepairMethod<Solution>*>& repair) = 0;
virtual void on_many_iters_without_improvement(std::vector<DestroyMethod<Solution>*>& destroy, std::vector<RepairMethod<Solution>*>& repair) = 0;

/**
* Virtual destructor.
*/
virtual ~AlgorithmVisitor() = default;
};
}
} // namespace mlpalns

#endif // ML_PALNS_ALGORITHMVISITOR_H
4 changes: 2 additions & 2 deletions src/DestroyMethod.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#ifndef ML_PALNS_DESTROYMETHOD_H
#define ML_PALNS_DESTROYMETHOD_H

#include <random>
#include <memory>
#include <random>

namespace mlpalns {
// Destroy method
Expand All @@ -20,6 +20,6 @@ namespace mlpalns {

virtual ~DestroyMethod() = default;
};
}
} // namespace mlpalns

#endif // ML_PALNS_DESTROYMETHOD_H
2 changes: 1 addition & 1 deletion src/InitialSolutionCreator.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ namespace mlpalns {
struct InitialSolutionCreator {
virtual Solution create_initial_solution(const ProblemInstance& instance, std::mt19937& mt) = 0;
};
}
} // namespace mlpalns

#endif // ML_PALNS_INITIALSOLUTIONCREATOR_H
Loading

0 comments on commit 63554d2

Please sign in to comment.