Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions mmwis/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,14 @@ target_include_directories(lib_mmwis PRIVATE ${MMWIS_INCLUDES})

add_dependencies(lib_mmwis libkaffpa)

include_directories(mmwis PRIVATE ${MMWIS_INCLUDES})

add_subdirectory(extern/struction)
option(STRUCTION_ENABLE_APPS "enable/disable struction executables")
add_subdirectory(extern/struction EXCLUDE_FROM_ALL)

add_executable(mmwis "app/mmwis.cpp" $<TARGET_OBJECTS:libkaffpa>
$<TARGET_OBJECTS:libmapping>
$<TARGET_OBJECTS:libnodeordering>
$<TARGET_OBJECTS:lib_mmwis> )
target_include_directories(mmwis PRIVATE ${MMWIS_INCLUDES})
target_link_libraries(mmwis ${OpenMP_CXX_LIBRARIES})

install(TARGETS mmwis DESTINATION bin)
Expand Down
13 changes: 8 additions & 5 deletions mmwis/extern/struction/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ set(STRUCTION_SOURCES
$<TARGET_OBJECTS:lib_mmwis>
)

add_executable(branch_reduce ${LIB_MWIS} ${STRUCTION_SOURCES} "app/branch_reduce.cpp")
add_executable(branch_reduce_convergence ${LIB_MWIS} ${STRUCTION_SOURCES} "app/branch_reduce.cpp")
add_executable(cyclic_blow_up_convergency ${LIB_MWIS} ${STRUCTION_SOURCES} "app/cyclic_blow_up_convergency.cpp")
add_executable(kernelization ${LIB_MWIS} ${STRUCTION_SOURCES} "app/kernelization.cpp")
add_executable(struction_checker ${LIB_MWIS} ${STRUCTION_SOURCES} "app/struction_checker.cpp")
if(STRUCTION_ENABLE_APPS)
add_executable(branch_reduce ${LIB_MWIS} ${STRUCTION_SOURCES} "app/branch_reduce.cpp")
add_executable(branch_reduce_convergence ${LIB_MWIS} ${STRUCTION_SOURCES} "app/branch_reduce.cpp")
add_executable(cyclic_blow_up_convergency ${LIB_MWIS} ${STRUCTION_SOURCES} "app/cyclic_blow_up_convergency.cpp")
add_executable(kernelization ${LIB_MWIS} ${STRUCTION_SOURCES} "app/kernelization.cpp")
add_executable(struction_checker ${LIB_MWIS} ${STRUCTION_SOURCES} "app/struction_checker.cpp")


target_include_directories(branch_reduce PRIVATE ${MMWIS_INCLUDES})
target_include_directories(branch_reduce PRIVATE ${STRUCTION_INCLUDES})
Expand All @@ -40,3 +42,4 @@ target_link_libraries(cyclic_blow_up_convergency LINK_PUBLIC ${LIBS})
target_link_libraries(kernelization LINK_PUBLIC ${LIBS})
target_link_libraries(struction_checker LINK_PUBLIC ${LIBS})

endif()
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ size_t branch_and_reduce_algorithm::run_ils(const ::mmwis::MISConfig& config, gr
double time_limit = 0.01*(config.time_limit - t.elapsed());
if (!config.perform_hils) {
greedy_initial_is(G, tmp_buffer);
ils local_search(config);
mmwis::ils local_search(config);
local_search.perform_ils(G, max_swaps, time_limit);
} else {
if (config.reduce_and_peel) {
Expand Down
3 changes: 2 additions & 1 deletion mmwis/lib/data_structure/mis_permutation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "macros_assertions.h"
#include "data_structure/operation_log.h"


namespace mmwis {
mis_permutation::mis_permutation() {}

mis_permutation::~mis_permutation() {}
Expand Down Expand Up @@ -383,3 +383,4 @@ bool mis_permutation::check_consistency(graph_access& G) {
endfor
return true;
}
}
3 changes: 3 additions & 0 deletions mmwis/lib/data_structure/mis_permutation.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "graph_access.h"
#include "data_structure/candidate_list.h"

namespace mmwis {

class mis_permutation {
friend class ils;
Expand Down Expand Up @@ -281,4 +282,6 @@ class mis_permutation {
void swap_nodes(unsigned int first_pos, unsigned int second_pos);
};

}

#endif
3 changes: 2 additions & 1 deletion mmwis/lib/mis/ils/ils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <cstddef>
#include <ostream>


namespace mmwis {
ils::ils(const mmwis::MISConfig &config) : config(config), local(config) {
// Set config parameters
plateau_down = 1;
Expand Down Expand Up @@ -353,4 +353,5 @@ void ils::reset() {
delete[] best_solution;
best_solution_size = 0;
}
}
}
4 changes: 2 additions & 2 deletions mmwis/lib/mis/ils/ils.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "local_search.h"
#include "graph_access.h"


namespace mmwis {
class ils {
public:
/**
Expand Down Expand Up @@ -98,5 +98,5 @@ class ils {
*/
void unwind(graph_access &G);
};

}
#endif
4 changes: 3 additions & 1 deletion mmwis/lib/mis/ils/local_search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "bucket_array.h"
#include "reductions.h"

namespace mmwis {
local_search::local_search(const mmwis::MISConfig& config) { sort_freenodes = config.sort_freenodes; }

local_search::~local_search() {}
Expand Down Expand Up @@ -397,7 +398,7 @@ local_search::Swap_1_2 local_search::find_best_swap(NodeID node, graph_access& G
best_swap = {onetight[i], onetight[j]};
// loop stops
}
}
}
}

return best_swap;
Expand Down Expand Up @@ -438,4 +439,5 @@ void local_search::sort_by_weight(graph_access& G, std::vector<NodeID>::iterator
*std::next(begin, count[G.getNodeWeight(node)]) = node;
count[G.getNodeWeight(node)]++;
}
}
}
4 changes: 4 additions & 0 deletions mmwis/lib/mis/ils/local_search.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include "data_structure/mis_permutation.h"
#include "maxNodeHeap.h"

namespace mmwis {

class local_search {
friend class ils;

Expand Down Expand Up @@ -233,4 +235,6 @@ class local_search {
void sort_by_weight(graph_access& G, std::vector<NodeID>::iterator begin, std::vector<NodeID>::iterator end);
};

}

#endif
6 changes: 3 additions & 3 deletions wmis/extern/KaHIP/lib/tools/macros_assertions.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

// A custom assertion macro that does not kill the program but prints to
// stderr instead.
//#if (defined(NDEBUG) || defined(SPEEDPROFILING))
#if (defined(NDEBUG) || defined(SPEEDPROFILING))
# define ASSERT_TRUE(x) do {} while (false);
/*#else
#else
# define ASSERT_TRUE(expression) \
do { \
if (not (expression)) { \
Expand All @@ -29,7 +29,7 @@
abort(); \
} \
} while (false)
#endif*/
#endif

// Assert: left != right.
//#ifdef NDEBUG
Expand Down
29 changes: 20 additions & 9 deletions wmis/lib/mis/kernel/branch_and_reduce_algorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ void branch_and_reduce_algorithm::compute_ils_pruning_bound() {
best_weight = status.reduction_offset + status.is_weight + run_ils(config_cpy, *local_graph, buffers[0], 1000);

cout_handler::enable_cout();
best_time = t.elapsed();
std::cout << (get_current_is_weight() + best_weight) << " [" << t.elapsed() << "]" << std::endl;
}

Expand Down Expand Up @@ -465,6 +466,7 @@ void branch_and_reduce_algorithm::branch_reduce_single_component() {
}
else if (status.n == 1) {
set(0, IS_status::included);
best_time = t.elapsed();
std::cout << (get_current_is_weight() + status.is_weight + status.reduction_offset) << " [" << t.elapsed() << "]" << std::endl;
return;
}
Expand Down Expand Up @@ -537,10 +539,12 @@ void branch_and_reduce_algorithm::branch_reduce_single_component() {
status.branching_queue.pop_back();
unset(branch_node);

if (i == 0)
break;
}
if (i == 0) {
break;
}


reverse_branching();
i = status.branching_queue.back().pos;
continue;
Expand All @@ -566,13 +570,18 @@ void branch_and_reduce_algorithm::branch_reduce_single_component() {
restore_best_local_solution();
}

bool branch_and_reduce_algorithm::run_branch_reduce() {
bool branch_and_reduce_algorithm::run_branch_reduce(bool run_initial_reductions) {
t.restart();
initial_reduce();
if(run_initial_reductions) {
initial_reduce();
}else{
global_status.modified_queue.push_back(BRANCHING_TOKEN);
}

//std::cout << "%reduction_nodes " << global_status.remaining_nodes << "\n";
//std::cout << "%reduction_offset " << global_status.is_weight + global_status.reduction_offset << "\n";
std::cout << "reduction_time " << t.elapsed() << "\n";
best_time = t.elapsed();

if (global_status.remaining_nodes == 0) {
restore_best_global_solution();
Expand Down Expand Up @@ -660,6 +669,7 @@ void branch_and_reduce_algorithm::update_best_solution() {
best_weight = current_weight;
is_ils_best_solution = false;

best_time = t.elapsed();
std::cout << (get_current_is_weight() + current_weight) << " [" << t.elapsed() << "]" << std::endl;
}
}
Expand Down Expand Up @@ -728,19 +738,19 @@ void branch_and_reduce_algorithm::restore_best_local_solution() {

void branch_and_reduce_algorithm::restore_best_global_solution() {
status = std::move(global_status);
status.modified_queue.pop_back();
status.modified_queue.pop_back();

while (!status.modified_queue.empty()) {
NodeID node = status.modified_queue.back();
status.modified_queue.pop_back();
status.modified_queue.pop_back();

if (status.node_status[node] == IS_status::folded) {
auto type = status.folded_queue.back();
status.folded_queue.pop_back();
status.reductions[global_reduction_map[type]]->apply(this);
status.folded_queue.pop_back();
status.reductions[global_reduction_map[type]]->apply(this);
}
else {
status.graph.restore_node(node);
status.graph.restore_node(node);
}
}
}
Expand Down Expand Up @@ -871,3 +881,4 @@ void branch_and_reduce_algorithm::apply_branch_reduce_solution(graph_access & G)
}
} endfor
}
double branch_and_reduce_algorithm::get_best_time() const { return best_time; }
8 changes: 6 additions & 2 deletions wmis/lib/mis/kernel/branch_and_reduce_algorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ class branch_and_reduce_algorithm {
MISConfig config;
graph_status best_solution_status;
NodeWeight best_weight = 0;
double best_time = 0;
timer t;
bool is_ils_best_solution = false;
size_t active_reduction_index;
Expand Down Expand Up @@ -194,17 +195,20 @@ class branch_and_reduce_algorithm {
void disable_cout();
void enable_cout();

NodeWeight get_current_is_weight() const;

NodeWeight get_current_is_weight() const;

public:
branch_and_reduce_algorithm(graph_access& G, const MISConfig& config, bool called_from_fold = false);

void reduce_graph();
bool run_branch_reduce();
bool run_branch_reduce(bool run_initial_reductions = true);

static size_t run_ils(const MISConfig& config, graph_access& G, sized_vector<NodeID>& tmp_buffer, size_t max_swaps);
static void greedy_initial_is(graph_access& G, sized_vector<NodeID>& tmp_buffer);


double get_best_time() const;
NodeWeight get_is_weight() const;
void reverse_reduction(graph_access & G, graph_access & reduced_G, std::vector<NodeID> & reverse_mapping);
void apply_branch_reduce_solution(graph_access & G);
Expand Down