Skip to content

Commit

Permalink
Add local patch of changes sent upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
coatless committed Nov 30, 2024
1 parent 66696d3 commit 33a2b63
Show file tree
Hide file tree
Showing 10 changed files with 195 additions and 197 deletions.
9 changes: 9 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
2024-11-29 James Balamuta <[email protected]>

* inst/include/ensmallen_bits/agemoea/agemoea.hpp: removed unused private field variable
* inst/include/problems/dtlz/dtlz2_function.hpp: removed unused variable.
* inst/include/problems/dtlz/dtlz4_function.hpp: ditto
* inst/include/problems/dtlz/dtlz5_function.hpp: ditto
* inst/include/problems/dtlz/dtlz6_function.hpp: ditto
* inst/include/problems/dtlz/dtlz7_function.hpp: ditto
* inst/include/problems/maf/maf5_function.hpp: ditto
* inst/include/problems/maf/maf6_function.hpp: ditto

* DESCRIPTION (Version): Release 2.22.0
* NEWS.md: Update for Ensmallen release 2.22.0
* inst/include/ensmallen_bits: Upgraded to Ensmallen 2.22.0
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
([#409](https://github.com/mlpack/ensmallen/pull/409)).
- Added IPOP and BIPOP restart mechanisms for CMA-ES.
([#403](https://github.com/mlpack/ensmallen/pull/403)).
- Addressed uninitialized variable and private field warnings
([#65](https://github.com/coatless-rpkg/rcppensmallen/pull/65))

# RcppEnsmallen 0.2.21.1.1

Expand Down
22 changes: 8 additions & 14 deletions inst/include/ensmallen_bits/agemoea/agemoea.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ class AGEMOEA
size_t idxQ,
const std::vector<size_t>& ranks,
const std::vector<typename MatType::elem_type>& survivalScore);

/**
* Normalizes the front given the extreme points in the current front.
*
Expand All @@ -363,7 +363,7 @@ class AGEMOEA
arma::Col<typename MatType::elem_type>& normalization,
const std::vector<size_t>& front,
const arma::Row<size_t>& extreme);

/**
* Get the geometry information p of Lp norm (p > 0).
*
Expand All @@ -377,7 +377,7 @@ class AGEMOEA
std::vector<arma::Col<typename MatType::elem_type> >& calculatedObjectives,
const std::vector<size_t>& front,
const arma::Row<size_t>& extreme);

/**
* Finds the pairwise Lp distance between all the points in the front.
*
Expand All @@ -395,7 +395,7 @@ class AGEMOEA

/**
* Finding the indexes of the extreme points in the front.
*
*
* @param indexes vector containing the slected indexes.
* @param calculatedObjectives The current population objectives.
* @param front The front of the current generation.
Expand All @@ -405,11 +405,11 @@ class AGEMOEA
arma::Row<size_t>& indexes,
std::vector<arma::Col<typename MatType::elem_type> >& calculatedObjectives,
const std::vector<size_t>& front);

/**
* Finding the distance of each point in the front from the line formed
* by pointA and pointB.
*
*
* @param distance The vector containing the distances of the points in the fron from the line.
* @param calculatedObjectives Reference to the current population evaluated Objectives.
* @param front The front of the current generation(indices of population).
Expand All @@ -423,10 +423,10 @@ class AGEMOEA
const std::vector<size_t>& front,
const arma::Col<typename MatType::elem_type>& pointA,
const arma::Col<typename MatType::elem_type>& pointB);

/**
* Find the Diversity score corresponding the solution S using the selected set.
*
*
* @param selected The current selected set.
* @param pairwiseDistance The current pairwise distance for the whole front.
* @param S The relative index of S being considered within the front.
Expand All @@ -452,12 +452,6 @@ class AGEMOEA
//! Probability that crossover will occur.
double crossoverProb;

//! Probability that mutation will occur.
double mutationProb;

//! Strength of the mutation.
double mutationStrength;

//! The crowding degree of the mutation. Higher value produces a mutant
//! resembling its parent.
double distributionIndex;
Expand Down
53 changes: 26 additions & 27 deletions inst/include/ensmallen_bits/problems/dtlz/dtlz2_function.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ namespace test {
* \f[
* x_M = [x_i, n - M + 1 <= i <= n]
* g(x) = \Sigma{i = n - M + 1}^n (x_i - 0.5)^2
*
* f_1(x) = 0.5 * cos(x_1 * pi * 0.5) * cos(x_2 * pi * 0.5) * ... cos(x_2 * pi * 0.5) * (1 + g(x_M))
*
* f_1(x) = 0.5 * cos(x_1 * pi * 0.5) * cos(x_2 * pi * 0.5) * ... cos(x_2 * pi * 0.5) * (1 + g(x_M))
* f_2(x) = 0.5 * cos(x_1 * pi * 0.5) * cos(x_2 * pi * 0.5) * ... sin(x_M-1 * pi * 0.5) * (1 + g(x_M))
* .
* .
Expand All @@ -35,9 +35,9 @@ namespace test {
* 0 <= x_i <= 1 for i = 1,...,n.
*
* This should be optimized to x_i = 0.5 (for all x_i in x_M), at:
*
*
* For more information, please refer to:
*
*
* @code
* @incollection{deb2005scalable,
* title={Scalable test problems for evolutionary multiobjective optimization},
Expand All @@ -62,7 +62,7 @@ namespace test {
size_t numParetoPoints;

public:

/**
* Object Constructor.
* Initializes the individual objective functions.
Expand All @@ -82,10 +82,10 @@ namespace test {
// Convenience typedef.
typedef typename MatType::elem_type ElemType;
return arma::Col<ElemType>(numVariables, 1, arma::fill::zeros);
}
}

// Get the private variables.

// Get the number of objectives.
size_t GetNumObjectives ()
{ return this -> numObjectives; }
Expand All @@ -110,20 +110,19 @@ namespace test {
*/
arma::Row<typename MatType::elem_type> g(const MatType& coords)
{
size_t k = numVariables - numObjectives + 1;

// Convenience typedef.
typedef typename MatType::elem_type ElemType;

arma::Row<ElemType> innerSum(size(coords)[1], arma::fill::zeros);

for(size_t i = numObjectives - 1; i < numVariables; i++)
{
innerSum += arma::pow((coords.row(i) - 0.5), 2);
}
innerSum += arma::pow((coords.row(i) - 0.5), 2);
}

return innerSum;
}
}

/**
* Evaluate the objectives with the given coordinate.
Expand All @@ -141,21 +140,21 @@ namespace test {
arma::Row<ElemType> value = 0.5 * (1.0 + G);
for(size_t i = 0; i < numObjectives - 1; i++)
{
objectives.row(i) = value %
objectives.row(i) = value %
arma::sin(coords.row(i) * arma::datum::pi * 0.5);
value = value % arma::cos(coords.row(i) * arma::datum::pi * 0.5);
value = value % arma::cos(coords.row(i) * arma::datum::pi * 0.5);
}
objectives.row(numObjectives - 1) = value;
return objectives;
return objectives;
}

// Individual Objective function.
// Changes based on stop variable provided.
// Changes based on stop variable provided.
struct DTLZ2Objective
{
DTLZ2Objective(size_t stop, DTLZ2& dtlz): stop(stop), dtlz(dtlz)
{/* Nothing to do here. */}
{/* Nothing to do here. */}

/**
* Evaluate one objective with the given coordinate.
*
Expand All @@ -182,8 +181,8 @@ namespace test {
}

value = value * (1.0 + dtlz.g(coords)[0]);
return value;
}
return value;
}

DTLZ2& dtlz;
size_t stop;
Expand All @@ -193,12 +192,12 @@ namespace test {
std::tuple<DTLZ2Objective, DTLZ2Objective, DTLZ2Objective> GetObjectives()
{
return std::make_tuple(objectiveF1, objectiveF2, objectiveF3);
}
}

//! Get the Reference Front.
//! Front. The implementation has been taken from pymoo.
arma::mat GetReferenceFront()
{
{
Uniform refGenerator;
arma::mat refDirs = refGenerator.Generate<arma::mat>(3, this -> numParetoPoints, 0);
arma::colvec x = arma::normalise(refDirs, 2, 1);
Expand All @@ -214,4 +213,4 @@ namespace test {
} //namespace test
} //namespace ens

#endif
#endif
49 changes: 24 additions & 25 deletions inst/include/ensmallen_bits/problems/dtlz/dtlz4_function.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ namespace test {
* \f[
* x_M = [x_i, n - M + 1 <= i <= n]
* g(x) = \Sigma{i = n - M + 1}^n (x_i - 0.5)^2
*
* f_1(x) = 0.5 * cos(x_1^alpha * pi * 0.5) * cos(x_2^alpha * pi * 0.5) * ... cos(x_2^alpha * pi * 0.5) * (1 + g(x_M))
*
* f_1(x) = 0.5 * cos(x_1^alpha * pi * 0.5) * cos(x_2^alpha * pi * 0.5) * ... cos(x_2^alpha * pi * 0.5) * (1 + g(x_M))
* f_2(x) = 0.5 * cos(x_1^alpha * pi * 0.5) * cos(x_2^alpha * pi * 0.5) * ... sin(x_M-1^alpha * pi * 0.5) * (1 + g(x_M))
* .
* .
Expand All @@ -35,9 +35,9 @@ namespace test {
* 0 <= x_i <= 1 for i = 1,...,n.
*
* This should be optimized to x_i = 0.5 (for all x_i in x_M), at:
*
*
* For more information, please refer to:
*
*
* @code
* @incollection{deb2005scalable,
* title={Scalable test problems for evolutionary multiobjective optimization},
Expand Down Expand Up @@ -85,8 +85,8 @@ namespace test {
// Convenience typedef.
typedef typename MatType::elem_type ElemType;
return arma::Col<ElemType>(numVariables, 1, arma::fill::zeros);
}
}

// Get the private variables.

// Get the number of objectives.
Expand All @@ -113,20 +113,19 @@ namespace test {
*/
arma::Row<typename MatType::elem_type> g(const MatType& coords)
{
size_t k = numVariables - numObjectives + 1;

// Convenience typedef.
typedef typename MatType::elem_type ElemType;

arma::Row<ElemType> innerSum(size(coords)[1], arma::fill::zeros);

for(size_t i = numObjectives - 1; i < numVariables; i++)
{
innerSum += arma::pow((coords.row(i) - 0.5), 2);
}
innerSum += arma::pow((coords.row(i) - 0.5), 2);
}

return innerSum;
}
}

/**
* Evaluate the objectives with the given coordinate.
Expand All @@ -144,21 +143,21 @@ namespace test {
arma::Row<ElemType> value = 0.5 * (1.0 + G);
for(size_t i = 0; i < numObjectives - 1; i++)
{
objectives.row(i) = value %
objectives.row(i) = value %
arma::sin(arma::pow(coords.row(i), alpha) * arma::datum::pi * 0.5);
value = value % arma::cos(arma::pow(coords.row(i), alpha) * arma::datum::pi * 0.5);
value = value % arma::cos(arma::pow(coords.row(i), alpha) * arma::datum::pi * 0.5);
}
objectives.row(numObjectives - 1) = value;
return objectives;
return objectives;
}

// Individual Objective function.
// Changes based on stop variable provided.
// Changes based on stop variable provided.
struct DTLZ4Objective
{
DTLZ4Objective(size_t stop, DTLZ4& dtlz): stop(stop), dtlz(dtlz)
{/* Nothing to do here.*/}
{/* Nothing to do here.*/}

/**
* Evaluate one objective with the given coordinate.
*
Expand All @@ -185,8 +184,8 @@ namespace test {
}

value = value * (1 + dtlz.g(coords)[0]);
return value;
}
return value;
}

DTLZ4& dtlz;
size_t stop;
Expand All @@ -196,12 +195,12 @@ namespace test {
std::tuple<DTLZ4Objective, DTLZ4Objective, DTLZ4Objective> GetObjectives()
{
return std::make_tuple(objectiveF1, objectiveF2, objectiveF3);
}
}

//! Get the Reference Front.
//! Front. The implementation has been taken from pymoo.
arma::mat GetReferenceFront()
{
{
Uniform refGenerator;
arma::mat refDirs = refGenerator.Generate<arma::mat>(3, this -> numParetoPoints, 0);
arma::colvec x = arma::normalise(refDirs, 2, 1);
Expand All @@ -217,4 +216,4 @@ namespace test {
} //namespace test
} //namespace ens

#endif
#endif
Loading

0 comments on commit 33a2b63

Please sign in to comment.