- Removed preserveDiversity for now
- ALL TESTS PASSED!!!
This commit is contained in:
@@ -308,31 +308,22 @@ MOEAD::MatingSelection(const size_t popIdx,
|
||||
size_t k, l;
|
||||
assert(neighborSize > 1u);
|
||||
|
||||
if (sampleNeighbor)
|
||||
k = sampleNeighbor
|
||||
? neighborIndices(
|
||||
arma::randi(arma::distr_param(0, neighborSize - 1u)), popIdx)
|
||||
: arma::randi(arma::distr_param(0, populationSize - 1u));
|
||||
|
||||
l = sampleNeighbor
|
||||
? neighborIndices(
|
||||
arma::randi(arma::distr_param(0, neighborSize - 1u)), popIdx)
|
||||
: arma::randi(arma::distr_param(0, populationSize - 1u));
|
||||
|
||||
if (k == l)
|
||||
{
|
||||
k = neighborIndices(
|
||||
arma::randi(arma::distr_param(0, neighborSize - 1u)), popIdx);
|
||||
l = neighborIndices(
|
||||
arma::randi(arma::distr_param(0, neighborSize - 1u)), popIdx);
|
||||
if (k == l)
|
||||
{
|
||||
if (k == neighborSize - 1u)
|
||||
--k;
|
||||
else
|
||||
++k;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
k = arma::randi(arma::distr_param(0, populationSize - 1u));
|
||||
l = arma::randi(arma::distr_param(0, populationSize - 1u));
|
||||
if (k == l)
|
||||
{
|
||||
if (k == populationSize - 1u)
|
||||
--k;
|
||||
else
|
||||
else
|
||||
++k;
|
||||
}
|
||||
}
|
||||
|
||||
return std::make_tuple(k, l);
|
||||
|
||||
@@ -43,7 +43,7 @@ TEST_CASE("MOEADSchafferN1Test", "[MOEADTest]")
|
||||
const double strength = 1e-3;
|
||||
|
||||
MOEAD opt(150, // population size
|
||||
10, // num generations
|
||||
2000, // num generations
|
||||
0.6, // cross over prob
|
||||
0.7, // mutation prob
|
||||
strength, // mutation strength
|
||||
@@ -52,7 +52,6 @@ TEST_CASE("MOEADSchafferN1Test", "[MOEADTest]")
|
||||
0.5, //neighbor prob
|
||||
0.8, //differential weight
|
||||
10, //maxreplace,
|
||||
true, //Preserve diversity
|
||||
lowerBound, //lower bound
|
||||
upperBound //upper bound
|
||||
);
|
||||
@@ -106,7 +105,7 @@ TEST_CASE("MOEADSchafferN1VectorBoundsTest", "[MOEADTest]")
|
||||
arma::vec upperBound = {1000};
|
||||
const double strength = 1e-3;
|
||||
MOEAD opt(150, // population size
|
||||
10, // num generations
|
||||
2000, // num generations
|
||||
0.6, // cross over prob
|
||||
0.7, // mutation prob
|
||||
strength, // mutation strength
|
||||
@@ -115,7 +114,6 @@ TEST_CASE("MOEADSchafferN1VectorBoundsTest", "[MOEADTest]")
|
||||
0.5, //neighbor prob
|
||||
0.8, //differential weight
|
||||
10, //maxreplace,
|
||||
true, //Preserve diversity
|
||||
lowerBound, //lower bound
|
||||
upperBound //upper bound
|
||||
);
|
||||
@@ -168,7 +166,7 @@ TEST_CASE("MOEADFonsecaFlemingTest", "[MOEADTest]")
|
||||
const double expectedUpperBound = 1.0 / sqrt(3);
|
||||
|
||||
MOEAD opt(150, // population size
|
||||
10, // num generations
|
||||
2000, // num generations
|
||||
0.6, // cross over prob
|
||||
0.7, // mutation prob
|
||||
strength, // mutation strength
|
||||
@@ -177,7 +175,6 @@ TEST_CASE("MOEADFonsecaFlemingTest", "[MOEADTest]")
|
||||
0.5, //neighbor prob
|
||||
0.8, //differential weight
|
||||
10, //maxreplace,
|
||||
true, //Preserve diversity
|
||||
lowerBound, //lower bound
|
||||
upperBound //upper bound
|
||||
);
|
||||
@@ -196,7 +193,6 @@ TEST_CASE("MOEADFonsecaFlemingTest", "[MOEADTest]")
|
||||
double valX = arma::as_scalar(solution(0));
|
||||
double valY = arma::as_scalar(solution(1));
|
||||
double valZ = arma::as_scalar(solution(2));
|
||||
std::cout<<valX<<" "<<valY<<" "<<valZ<<"\n";
|
||||
|
||||
if (!InBounds(valX, expectedLowerBound, expectedUpperBound) ||
|
||||
!InBounds(valY, expectedLowerBound, expectedUpperBound) ||
|
||||
@@ -221,7 +217,7 @@ TEST_CASE("MOEADFonsecaFlemingVectorBoundsTest", "[MOEADTest]")
|
||||
const double expectedLowerBound = -1.0 / sqrt(3);
|
||||
const double expectedUpperBound = 1.0 / sqrt(3);
|
||||
MOEAD opt(150, // population size
|
||||
10, // num generations
|
||||
2000, // num generations
|
||||
0.6, // cross over prob
|
||||
0.7, // mutation prob
|
||||
strength, // mutation strength
|
||||
@@ -230,7 +226,6 @@ TEST_CASE("MOEADFonsecaFlemingVectorBoundsTest", "[MOEADTest]")
|
||||
0.5, //neighbor prob
|
||||
0.8, //differential weight
|
||||
10, //maxreplace,
|
||||
true, //Preserve diversity
|
||||
lowerBound, //lower bound
|
||||
upperBound //upper bound
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user