Skip to content

Commit

Permalink
fix(moBinaryPartition): finalize integration in <mo>
Browse files Browse the repository at this point in the history
  • Loading branch information
nojhan committed Sep 10, 2024
1 parent e23151d commit cf086ea
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 9 deletions.
5 changes: 4 additions & 1 deletion mo/src/mo.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@
#include <problems/permutation/moTwoOptExNeighbor.h>
#include <problems/permutation/moTwoOptExNeighborhood.h>

#include <problems/partition/moBinaryPartition.h>
#include <problems/partition/moBinaryPartitionSwapNeighbor.h>
#include <problems/partition/moBinaryPartitionSwapNeighborhood.h>

//#include <problems/eval/moMaxSATincrEval.h>
//#include <problems/eval/moOneMaxIncrEval.h>
//#include <problems/eval/moQAPIncrEval.h>
Expand All @@ -193,7 +197,6 @@
//#include <problems/eval/moUBQPBitsIncrEval.h>
//#include <problems/eval/moNKlandscapesIncrEval.h>


#include <sampling/moAdaptiveWalkSampling.h>
#include <sampling/moAutocorrelationSampling.h>
#include <sampling/moDensityOfStatesSampling.h>
Expand Down
12 changes: 10 additions & 2 deletions mo/src/problems/partition/moBinaryPartition.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ class moBinaryPartition : public EO<FitT>
* @note In debug mode, double check that elements were actually moved.
*/
void select(const size_t atom) {
assert(not selected.contains(atom));
#if __cplusplus >= 202002L
assert(not selected.contains(atom));
#else
assert(selected.count(atom) == 0);
#endif

#ifndef NDEBUG
size_t has_erased =
Expand All @@ -98,7 +102,11 @@ class moBinaryPartition : public EO<FitT>
* @note In debug mode, double check that elements were actually moved.
*/
void reject(const size_t atom) {
assert(not rejected.contains(atom));
#if __cplusplus >= 202002L
assert(not rejected.contains(atom));
#else
assert(rejected.count(atom) == 0);
#endif

#ifndef NDEBUG
size_t has_erased =
Expand Down
1 change: 0 additions & 1 deletion mo/src/problems/partition/moBinaryPartitionSwapNeighbor.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include <utility>

#include <mo>

#include "moBinaryPartition.h"

/** Stable neighbor for a binary partition.
Expand Down
9 changes: 7 additions & 2 deletions mo/src/problems/partition/moBinaryPartitionSwapNeighborhood.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,13 @@ class moBinaryPartitionSwapNeighborhood : public moNeighborhood<moBinaryPartitio
// << " from: " << from
// << std::endl;

assert( from.rejected.contains(selected(from,i_select)) );
assert( from.selected.contains(rejected(from,j_reject)) );
#if __cplusplus >= 202002L
assert( from.rejected.contains(selected(from,i_select)) );
assert( from.selected.contains(rejected(from,j_reject)) );
#else
assert( from.rejected.count(selected(from,i_select)) > 0 );
assert( from.selected.count(rejected(from,j_reject)) > 0 );
#endif
assert( selected(from,i_select) != rejected(from,j_reject) );

// Implant this move in the neighbor.
Expand Down
1 change: 1 addition & 0 deletions mo/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ set (TEST_LIST
t-moIndexedVectorTabuList
# t-moRndIndexedVectorTabuList
t-moDynSpanCoolingSchedule
t-moBinaryPartition
)

######################################################################################
Expand Down
4 changes: 1 addition & 3 deletions mo/test/t-moBinaryPartition.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@

#include <frictionless/moBinaryPartition.h>
#include <frictionless/moBinaryPartitionSwapNeighbor.h>
#include <frictionless/moBinaryPartitionSwapNeighborhood.h>
#include <mo>

int main()
{
Expand Down

0 comments on commit cf086ea

Please sign in to comment.