Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce Policy Methods for MOEA/D-DE #293

Merged
merged 43 commits into from
Jun 18, 2021
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
9e6b3ca
Fixed minor indent
jonpsy Jun 13, 2021
c66ee3a
Make MOEA/D-DE policy based
jonpsy Jun 14, 2021
2749d31
Added decomposition policies
jonpsy Jun 14, 2021
d41c265
Added Init policies
jonpsy Jun 14, 2021
9242279
Re-configure tests
jonpsy Jun 14, 2021
e08c0c8
fix moead doc
jonpsy Jun 15, 2021
7505ecc
fix decomposition policy docs
jonpsy Jun 15, 2021
dbc24bb
moead doc fix
jonpsy Jun 15, 2021
6868e2c
restore all tests
jonpsy Jun 15, 2021
945e21a
history fix
jonpsy Jun 16, 2021
ee41faa
Tested against ZDT1
jonpsy Jun 16, 2021
6e1164e
remove uniform_init.hpp as of now
jonpsy Jun 16, 2021
cfed986
Update include/ensmallen_bits/moead/moead.hpp
jonpsy Jun 16, 2021
4692047
Update include/ensmallen_bits/moead/moead.hpp
jonpsy Jun 16, 2021
e092c4d
Update include/ensmallen_bits/moead/moead.hpp
jonpsy Jun 16, 2021
ade51c9
Update include/ensmallen_bits/moead/decomposition_policies/pbi_decomp…
jonpsy Jun 16, 2021
4ec1f2e
Update include/ensmallen_bits/moead/moead.hpp
jonpsy Jun 16, 2021
8952378
Update include/ensmallen_bits/moead/decomposition_policies/weighted_d…
jonpsy Jun 16, 2021
2c02c5f
Update include/ensmallen_bits/moead/decomposition_policies/tchebychef…
jonpsy Jun 16, 2021
9beaa5f
InitPolicy, Generate const
jonpsy Jun 16, 2021
de612d3
using DefaultMOEAD
jonpsy Jun 16, 2021
6e3e323
doc decomposition policy
jonpsy Jun 16, 2021
8d81b42
indent
jonpsy Jun 16, 2021
4997f55
add doc for bbs
jonpsy Jun 16, 2021
d02d5e4
extra doc for decomp policy
jonpsy Jun 16, 2021
77bd44b
added template doc in optimizer.md
jonpsy Jun 16, 2021
23ff190
minor fix
jonpsy Jun 16, 2021
40c9aaa
Start RDP
jonpsy Jun 16, 2021
c79f593
no need to build redundant tests
jonpsy Jun 16, 2021
7d86a46
Update include/ensmallen_bits/moead/decomposition_policies/pbi_decomp…
jonpsy Jun 16, 2021
be9f8b6
Update include/ensmallen_bits/moead/decomposition_policies/tchebychef…
jonpsy Jun 16, 2021
c1fbf16
Update include/ensmallen_bits/moead/decomposition_policies/weighted_d…
jonpsy Jun 16, 2021
79aa3f6
Update include/ensmallen_bits/moead/decomposition_policies/pbi_decomp…
jonpsy Jun 16, 2021
d7f2be2
Update include/ensmallen_bits/moead/moead.hpp
jonpsy Jun 16, 2021
955e7db
Update include/ensmallen_bits/moead/weight_init_policies/bbs_init.hpp
jonpsy Jun 16, 2021
e2b883d
Update include/ensmallen_bits/moead/moead_impl.hpp
jonpsy Jun 16, 2021
e3b865f
revert moead test
jonpsy Jun 16, 2021
d66c3d0
Merge branch 'moead+' of https://github.com/jonpsy/ensmallen into moead+
jonpsy Jun 16, 2021
91ed336
remove stackoverflow link
jonpsy Jun 16, 2021
a8b9018
use arma::diff
jonpsy Jun 16, 2021
18a4ca6
revert appveyor.yml
jonpsy Jun 16, 2021
bd6cf8a
Set bad threshold as of now.
jonpsy Jun 16, 2021
ff03b06
restore cmake
jonpsy Jun 16, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,16 @@

* Make Callback flexible for MultiObjective Optimizers
([#289](https://github.com/mlpack/ensmallen/pull/289)).

* Add ZDT Test Suite
([#273](https://github.com/mlpack/ensmallen/pull/273)).

* Add MOEA-D/DE Optimizer
([#269](https://github.com/mlpack/ensmallen/pull/269)).

* Introduce Policy Methods for MOEA/D-DE
([#293](https://github.com/mlpack/ensmallen/pull/293)).

### ensmallen 2.16.1: "Severely Dented Can Of Polyurethane"
###### 2021-03-02
* Fix test compilation issue when `ENS_USE_OPENMP` is set
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/**
* @file pbi_decomposition.hpp
* @author Nanubala Gnana Sai
*
* The Penalty Based Boundary Intersection(PBI) Decomposition policy.
jonpsy marked this conversation as resolved.
Show resolved Hide resolved
*
* ensmallen is free software; you may redistribute it and/or modify it under
* the terms of the 3-clause BSD license. You should have received a copy of
* the 3-clause BSD license along with ensmallen. If not, see
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
*/
#ifndef ENSMALLEN_MOEAD_PBI_HPP
#define ENSMALLEN_MOEAD_PBI_HPP

namespace ens {

/**
* Penalty Based Boundary Intersection (PBI) method is a weight decomposition method,
* it tries to find the intersection between bottom-most boundary of the attainable
* objective set with the reference directions.
*
* The goal is to minimize the distance between objective vectors with the ideal point
* along the reference direction. To handle equality constraints, a penalty parameter
* theta is used.
*
* For more information, see the following:
* @code
* article{zhang2007moea,
* title={MOEA/D: A multiobjective evolutionary algorithm based on decomposition},
* author={Zhang, Qingfu and Li, Hui},
* journal={IEEE Transactions on evolutionary computation},
* pages={712--731},
* year={2007}
jonpsy marked this conversation as resolved.
Show resolved Hide resolved
* @endcode
*/
class PenaltyBoundaryIntersection
{
public:
PenaltyBoundaryIntersection(const double theta = 5) :
jonpsy marked this conversation as resolved.
Show resolved Hide resolved
theta(theta)
{
/* Nothing to do. */
}

template<typename VecType>
typename VecType::elem_type Apply(const VecType& weight,
const VecType& idealPoint,
const VecType& candidateFitness)
{
typedef typename VecType::elem_type ElemType;
//! A unit vector in the same direction as the provided weight vector.
const VecType referenceDirection = weight / arma::norm(weight, 1);
//! Distance of F(x) from the idealPoint along the reference direction.
const ElemType d1 = arma::dot(candidateFitness - idealPoint, referenceDirection);
//! Length of projection line of F(x) on the reference direction.
const ElemType d2 = arma::norm(candidateFitness - (idealPoint + d1 * referenceDirection), 1);

return d1 + static_cast<ElemType>(theta) * d2;
}

private:
double theta;
};

} // namespace ens

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* @file tchebycheff_decomposition.hpp
* @author Nanubala Gnana Sai
*
* The Tchebycheff Weight Decomposition policy.
jonpsy marked this conversation as resolved.
Show resolved Hide resolved
*
* ensmallen is free software; you may redistribute it and/or modify it under
* the terms of the 3-clause BSD license. You should have received a copy of
* the 3-clause BSD license along with ensmallen. If not, see
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
*/
#ifndef ENSMALLEN_MOEAD_TCHEBYCHEFF_HPP
#define ENSMALLEN_MOEAD_TCHEBYCHEFF_HPP

namespace ens {

/**
* The Tchebycheff method works by taking the maximum of element-wise product
* between reference direction and the line connecting objective vector and
* ideal point.
*
* Under mild conditions, for each Pareto Optimal point there exists a reference
* direction such that the given point is also the optimal solution
* to this scalar objective.
*
* For more information, see the following:
* @code
* article{zhang2007moea,
* title={MOEA/D: A multiobjective evolutionary algorithm based on decomposition},
* author={Zhang, Qingfu and Li, Hui},
* journal={IEEE Transactions on evolutionary computation},
* pages={712--731},
* year={2007}
jonpsy marked this conversation as resolved.
Show resolved Hide resolved
* @endcode
*/
class Tchebycheff
{
public:
Tchebycheff()
{
/* Nothing to do. */
}

template<typename VecType>
typename VecType::elem_type Apply(const VecType& weight,
const VecType& idealPoint,
const VecType& candidateFitness)
{
return arma::max(weight % arma::abs(candidateFitness - idealPoint));
}
};

} // namespace ens

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* @file weighted_decomposition.hpp
* @author Nanubala Gnana Sai
*
* The Weighted Average Decomposition policy.
jonpsy marked this conversation as resolved.
Show resolved Hide resolved
*
* ensmallen is free software; you may redistribute it and/or modify it under
* the terms of the 3-clause BSD license. You should have received a copy of
* the 3-clause BSD license along with ensmallen. If not, see
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
*/
#ifndef ENSMALLEN_MOEAD_WEIGHTED_HPP
#define ENSMALLEN_MOEAD_WEIGHTED_HPP

namespace ens {

/**
* The Weighted average method of decomposition. The working principle is to
* minimize the dot product between reference direction and the line connecting
* objective vector and ideal point.
*
* For more information, see the following:
* @code
* article{zhang2007moea,
* title={MOEA/D: A multiobjective evolutionary algorithm based on decomposition},
* author={Zhang, Qingfu and Li, Hui},
* journal={IEEE Transactions on evolutionary computation},
* pages={712--731},
* year={2007}
jonpsy marked this conversation as resolved.
Show resolved Hide resolved
* @endcode
*/
class WeightedAverage
{
public:
WeightedAverage()
{
/* Nothing to do. */
}

template<typename VecType>
typename VecType::elem_type Apply(const VecType& weight,
const VecType& /* idealPoint */,
const VecType& candidateFitness)
{
return arma::dot(weight, candidateFitness);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That one is so easy, love it.

}
};

} // namespace ens

#endif
93 changes: 50 additions & 43 deletions include/ensmallen_bits/moead/moead.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
* @author Utkarsh Rai
* @author Nanubala Gnana Sai
*
* MOEA/D, Multi Objective Evolutionary Algorithm based on Decompositon is a
* multi objective optimization algorithm. It employs evolutionary algorithms,
* to find better solutions by iterating on the previous solutions and
* decomposition approaches, to convert the multi objective problem to a single
* objective one, to find the best Pareto Front for the given problem.
* MOEA/D-DE is a multi objective optimization algorithm. MOEA/D-DE
* uses genetic algorithms along with a set of reference directions
* to drive the population towards the Optimal Front.
*
* ensmallen is free software; you may redistribute it and/or modify it under
* the terms of the 3-clause BSD license. You should have received a copy of
Expand All @@ -18,35 +16,38 @@
#ifndef ENSMALLEN_MOEAD_MOEAD_HPP
#define ENSMALLEN_MOEAD_MOEAD_HPP

//! Decomposition policies.
#include "decomposition_policies/tchebycheff_decomposition.hpp"
#include "decomposition_policies/weighted_decomposition.hpp"
#include "decomposition_policies/pbi_decomposition.hpp"

//! Weight Init policies.
jonpsy marked this conversation as resolved.
Show resolved Hide resolved
#include "weight_init_policies/bbs_init.hpp"
namespace ens {

/**
* This class implements the MOEA/D algorithm with Differential Evolution
* crossover. Step numbers used in different parts of the implementation
* correspond to the step number used in the original algorithm by the author.
* MOEA/D-DE (Multi Objective Evolutionary Algorithm based on Decompositon -
* Differential Variant) is a multiobjective optimization algorithm. This class
* implements the said optimizer.
*
* The algorithm works by generating a candidate population from a fixed starting point.
* Reference directions are generated to guide the optimization process towards the Pareto Front.
* Further, a decomposition function is defined to decompose the problem to a scalar optimization
* objective. Utilizing genetic operators, offsprings are generated with better decomposition values
* to replace the neighboring parent solutions.
*
* For more information, see the following:
* @code
* @article{article,
* author = {Zhang, Qingfu and Li, Hui},
* year = {2008},
* pages = {712 - 731},
* title = {MOEA/D: A Multiobjective Evolutionary Algorithm Based on
* Decomposition},
* journal = {Evolutionary Computation, IEEE Transactions on},
*
* @article{4633340,
* author={H. {Li} and Q. {Zhang}},
* year={2009},
* pages={284-302},}
* title={Multiobjective Optimization Problems With Complicated Pareto Sets, MOEA/D and NSGA-II},
* journal={IEEE Transactions on Evolutionary Computation},
* @article{li2008multiobjective,
* title={Multiobjective optimization problems with complicated Pareto sets, MOEA/D and NSGA-II},
* author={Li, Hui and Zhang, Qingfu},
* journal={IEEE transactions on evolutionary computation},
* pages={284--302},
* year={2008},
jonpsy marked this conversation as resolved.
Show resolved Hide resolved
* @endcode
*
* MOEA/D can optimize arbitrary multi-objective functions. For more details,
* see the documentation on function types included with this distribution or
* on the ensmallen website.
*/
template<typename InitPolicyType = BayesianBootstrap,
typename DecompPolicyType = Tchebycheff>
jonpsy marked this conversation as resolved.
Show resolved Hide resolved
jonpsy marked this conversation as resolved.
Show resolved Hide resolved
class MOEAD {
public:
/**
Expand Down Expand Up @@ -82,7 +83,9 @@ class MOEAD {
const size_t maxReplace = 2,
const double epsilon = 1E-10,
const arma::vec& lowerBound = arma::zeros(1, 1),
const arma::vec& upperBound = arma::ones(1, 1));
const arma::vec& upperBound = arma::ones(1, 1),
const InitPolicyType initPolicy = InitPolicyType(),
const DecompPolicyType decompPolicy = DecompPolicyType());

/**
* Constructor for the MOEA/D optimizer. This constructor is provides an
Expand Down Expand Up @@ -119,7 +122,9 @@ class MOEAD {
const size_t maxReplace = 2,
const double epsilon = 1E-10,
const double lowerBound = 0,
const double upperBound = 1);
const double upperBound = 1,
const InitPolicyType initPolicy = InitPolicyType(),
const DecompPolicyType decompPolicy = DecompPolicyType());

/**
* Optimize a set of objectives. The initial population is generated
Expand Down Expand Up @@ -202,6 +207,15 @@ class MOEAD {
//! `Optimize()` has been called.
const arma::cube& ParetoFront() const { return paretoFront; }

//! Get the weight initialization policy.
const InitPolicyType& InitPolicy() const { return initPolicy; }
//! Modify the weight initialization policy.
InitPolicyType& InitPolicy() { return initPolicy; }

//! Get the weight decomposition policy.
const DecompPolicyType& DecompPolicy() const { return decompPolicy; }
//! Modify the weight decomposition policy.
DecompPolicyType& DecompPolicy() { return decompPolicy; }

private:
/**
Expand All @@ -212,8 +226,8 @@ class MOEAD {
* @return std::tuple<size_t, size_t> The chosen pair of indices.
*/
std::tuple<size_t, size_t> Mating(size_t subProblemIdx,
const arma::umat& neighborSize,
bool sampleNeighbor);
const arma::umat& neighborSize,
bool sampleNeighbor);
jonpsy marked this conversation as resolved.
Show resolved Hide resolved

/**
* Mutate the child formed by the crossover of two random members of the
Expand All @@ -232,19 +246,6 @@ class MOEAD {
const MatType& lowerBound,
const MatType& upperBound);

/**
* Decompose the multi objective problem to a single objective problem.
*
* @param subProblemWeight The Decomposition weight vector of the current subproblem.
* @param idealPoint The reference point z for a decomposition problem.
* @param candidateFitness The fitness value of the candidate.
* @return The real value obtained from the decomposed function.
*/
template<typename ElemType>
ElemType DecomposeObjectives(const arma::Col<ElemType>& subProblemWeight,
const arma::Col<ElemType>& idealPoint,
const arma::Col<ElemType>& candidateFitness);

/**
* Evaluate objectives for the elite population.
*
Expand Down Expand Up @@ -316,6 +317,12 @@ class MOEAD {
//! The set of all the Pareto optimal objective vectors.
//! Stored after Optimize() is called.
arma::cube paretoFront;

//! Policy to initialize the reference directions (weights) matrix.
InitPolicyType initPolicy;

//! Policy to decompose the weights.
DecompPolicyType decompPolicy;
};

} // namespace ens
Expand Down
Loading