Skip to content
Open
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
16 changes: 13 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
cmake_minimum_required(VERSION 3.8)
cmake_minimum_required(VERSION 3.15)
project(pdtsp)

set(EXECUTABLE_OUTPUT_PATH "./")
if(NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -O3 -m64 -march=native -fPIC")
endif()

add_definitions(
-D_REENTRANT
Expand Down Expand Up @@ -49,10 +51,18 @@ include_directories(pdprr PDP-RR)

add_executable(pdphgs ${SOURCE_FILES_HGS})
add_executable(pdprr ${SOURCE_FILES_RR})

if(DEFINED ENV{BOOST_ROOT})
set(Boost_ROOT $ENV{BOOST_ROOT})
elseif(DEFINED ENV{BOOSTROOT})
set(Boost_ROOT $ENV{BOOSTROOT})
else()
return()
endif()
file(GLOB BOOST_SEARCH_PATHS ${Boost_ROOT}/stage/lib/cmake/Boost-*)
find_path(Boost_DIR NAMES BoostConfig.cmake PATHS ${BOOST_SEARCH_PATHS})
find_package(Boost COMPONENTS program_options filesystem system regex)
if (Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
include_directories(${BOOST_INCLUDE_DIRS})

target_link_libraries(pdphgs ${Boost_LIBRARIES})
target_link_libraries(pdprr ${Boost_LIBRARIES})
Expand Down
2 changes: 1 addition & 1 deletion PDP-HGS/hgsadc/hgsadc.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "hgsadc.h"

#include <algorithm>
#include <boost/bind.hpp>
#include <boost/bind/bind.hpp>

#include "hgsadc/adcpopulation.h"
#include "utils/application.h"
Expand Down
2 changes: 1 addition & 1 deletion PDP-HGS/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ using namespace std;
int main(int argc, char* argv[]) {
boost::program_options::variables_map variablesMap = Application::initializeVariablesMap(argc, argv);

uint seed = (uint)variablesMap["seed"].as<int>();
unsigned int seed = (unsigned int)variablesMap["seed"].as<int>();
std::srand(seed);

// solve only one instance specified by the --instance cmdline argument
Expand Down
14 changes: 8 additions & 6 deletions PDP-HGS/pdp/moves/balas_simonetti/bsgraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#ifdef BALAS_SIMONETTI

#include "bsgraph.h"
#include "time.h"

#include <algorithm>
#include <cassert>
Expand All @@ -27,6 +28,7 @@

#include "pdp/pdpnode.h"
#include "pdp/pdproute.h"
#include "time.h"
#include "utils/application.h"

using namespace pdp;
Expand Down Expand Up @@ -162,18 +164,18 @@ BSGraph::BSGraph(unsigned int k, unsigned int nLocations, double **distMatrix, c
hashMultiplier =
next_prime(nLocations + 1); // +1 because depots may be duplicated (first and last stop-point)
cachedMultipliers.assign(nLocations + 1, 1);
for (uint i = 1; i < nLocations + 1; i++)
for (unsigned int i = 1; i < nLocations + 1; i++)
cachedMultipliers[i] = (cachedMultipliers[i - 1] * hashMultiplier) % BIG_PRIME;

// calculating and caching individual hash codes for each depot/client
cachedHashCodes.assign(nLocations + 1, 1);
for (uint i = 1; i < nLocations + 1; i++)
for (unsigned int i = 1; i < nLocations + 1; i++)
cachedHashCodes[i] = (cachedMultipliers[i] * (i + 1)); // % BIG_PRIME;

// calculating and caching individual hash codes for each depot/client (second
// hash function)
cachedHashCodesRev.assign(nLocations + 1, 1);
for (uint i = 1; i < nLocations + 1; i++)
for (unsigned int i = 1; i < nLocations + 1; i++)
cachedHashCodesRev[i] = (cachedHashCodesRev[i - 1] * 31 + (i + 1)); // % BIG_PRIME;

if (CACHE_RESULTS) {
Expand All @@ -194,7 +196,7 @@ BSGraph::BSGraph(unsigned int k, unsigned int nLocations, double **distMatrix, c

if (BSGRAPH_DEBUG) {
// printing number of nodes (simple check)
printf("Number of nodes per layer: %lu\n", nodes.size());
printf("Number of nodes per layer: %zu\n", nodes.size());
printf("Number of edges per layer: %u\n", nEdges);

// printing nodes and their connections
Expand Down Expand Up @@ -340,7 +342,7 @@ void BSGraph::createNodes() {

// sorting nodes according to their minK and setting their ids
stable_sort(nodes.begin(), nodes.end(), lessptr<BSNode *>());
for (uint i = 0; i < nodes.size(); i++)
for (unsigned int i = 0; i < nodes.size(); i++)
nodes[i]->id = i;
for (vector<BSNode *>::iterator nodeIt = nodes.begin(); nodeIt != nodes.end(); nodeIt++) {
BSNode *node = *nodeIt;
Expand Down Expand Up @@ -488,7 +490,7 @@ bool BSGraph::runBS(vector<int> &sequence, const int firstIndex, const int lastI
if (BSGRAPH_DEBUG) {
// calculating and printing the initial cost
double initialCost = 0;
for (uint i = 1; i < sequence.size(); i++) {
for (unsigned int i = 1; i < sequence.size(); i++) {
int prevLayer = i - 1;
int nextLayer = i == sequence.size() ? 0 : i;
initialCost += getDistance(sequence[prevLayer], sequence[nextLayer]);
Expand Down
1 change: 1 addition & 0 deletions PDP-HGS/pdp/moves/balas_simonetti/bsgraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#define BSGRAPH_H

#include <stdlib.h>
#include <time.h>

#include <list>
#include <set>
Expand Down
2 changes: 1 addition & 1 deletion PDP-HGS/pdp/moves/pdp4optmove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const char *PDP4optMove::ExtraTotalInfo() const {

const char *PDP4optMove::ExtraInfo() const {
if (countDD + countDC + countCD) {
sprintf((char *)extraInfoBuffer, "dc=%lu,cd=%lu,dd=%lu", countDC, countCD, countDD);
sprintf((char *)extraInfoBuffer, "dc=%zu,cd=%zu,dd=%zu", countDC, countCD, countDD);
return extraInfoBuffer;
} else {
return 0;
Expand Down
4 changes: 2 additions & 2 deletions PDP-HGS/pdp/moves/pdporoptmove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ size_t PDPOroptMove::ResetCount() {

const char* PDPOroptMove::ExtraTotalInfo() const {
if (countTotalFast + countTotalSlow) {
sprintf((char*)extraInfoBuffer, "fst=%lu;slw=%lu", countTotalFast, countTotalSlow);
sprintf((char*)extraInfoBuffer, "fst=%zu;slw=%zu", countTotalFast, countTotalSlow);
return extraInfoBuffer;
} else {
return nullptr;
Expand All @@ -198,7 +198,7 @@ const char* PDPOroptMove::ExtraTotalInfo() const {

const char* PDPOroptMove::ExtraInfo() const {
if (countFast + countSlow) {
sprintf((char*)extraInfoBuffer, "fst=%lu,slw=%lu", countFast, countSlow);
sprintf((char*)extraInfoBuffer, "fst=%zu,slw=%zu", countFast, countSlow);
return extraInfoBuffer;
} else {
return nullptr;
Expand Down
6 changes: 3 additions & 3 deletions PDP-HGS/pdp/pdpeducate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,17 +181,17 @@ std::string Educate::MovesLog(bool percent) const {
else {
extra = move->ExtraInfo();
if (extra == 0) {
sprintf(buff, "%lu ", move->Count());
sprintf(buff, "%zu ", move->Count());
} else {
sprintf(buff, "%lu(%s) ", move->Count(), extra);
sprintf(buff, "%zu(%s) ", move->Count(), extra);
}
}

s += buff;
}

if (!percent) {
sprintf(buff, "(EDUCATE: %lu)", educateCount);
sprintf(buff, "(EDUCATE: %zu)", educateCount);
s += buff;
}

Expand Down
2 changes: 1 addition & 1 deletion PDP-HGS/utils/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ SOFTWARE.*/
#ifndef APPLICATION_H
#define APPLICATION_H

#define TOSTR_(x...) #x
#define TOSTR_(x) #x
#define STRINGIZE_VALUE_OF(x) TOSTR_(x)

#define DEFAULT_SEED 0
Expand Down
2 changes: 1 addition & 1 deletion PDP-RR/operators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ Instance::NodeList Operators::WorstRemoval(const Instance& instance, Solution& s
}

std::sort(pickupsOrder.begin(), pickupsOrder.end(),
[&, removalCosts](int a, int b) { return removalCosts[a] < removalCosts[b]; });
[&, removalCosts](double a, double b) { return removalCosts[a] < removalCosts[b]; });

Instance::NodeList removedRequests;
for (int i = 0; i < q; i++) {
Expand Down
2 changes: 1 addition & 1 deletion PDP-RR/solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ using namespace std;
int main(int argc, char* argv[]) {
boost::program_options::variables_map variablesMap = Application::initializeVariablesMap(argc, argv);

uint seed = (uint)variablesMap["seed"].as<int>();
unsigned int seed = (unsigned int)variablesMap["seed"].as<int>();
std::srand(seed);

if (variablesMap["instance"].empty()) // solve only one instance specified by
Expand Down