Initial import.

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1986 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
boufaras 2010-11-03 10:21:45 +00:00
commit f1f07fe2a8
48 changed files with 6126 additions and 0 deletions

11
ParadisEO-GPU/.project Normal file
View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>ParadisEO-GPU</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>

5
ParadisEO-GPU/AUTHORS Normal file
View file

@ -0,0 +1,5 @@
Authors:
Boufaras Karima
Thé Van Luong

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,79 @@
# James Bigler, NVIDIA Corp (nvidia.com - jbigler)
# Abe Stephens, SCI Institute -- http://www.sci.utah.edu/~abe/FindCuda.html
#
# Copyright (c) 2008 - 2009 NVIDIA Corporation. All rights reserved.
#
# Copyright (c) 2007-2009
# Scientific Computing and Imaging Institute, University of Utah
#
# This code is licensed under the MIT License. See the FindCUDA.cmake script
# for the text of the license.
# The MIT License
#
# License for the specific language governing rights and limitations under
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#
#######################################################################
# This converts a file written in makefile syntax into one that can be included
# by CMake.
file(READ ${input_file} depend_text)
if (${depend_text} MATCHES ".+")
# message("FOUND DEPENDS")
# Remember, four backslashes is escaped to one backslash in the string.
string(REGEX REPLACE "\\\\ " " " depend_text ${depend_text})
# This works for the nvcc -M generated dependency files.
string(REGEX REPLACE "^.* : " "" depend_text ${depend_text})
string(REGEX REPLACE "[ \\\\]*\n" ";" depend_text ${depend_text})
set(dependency_list "")
foreach(file ${depend_text})
string(REGEX REPLACE "^ +" "" file ${file})
if(NOT IS_DIRECTORY ${file})
# If softlinks start to matter, we should change this to REALPATH. For now we need
# to flatten paths, because nvcc can generate stuff like /bin/../include instead of
# just /include.
get_filename_component(file_absolute "${file}" ABSOLUTE)
list(APPEND dependency_list "${file_absolute}")
endif(NOT IS_DIRECTORY ${file})
endforeach(file)
else()
# message("FOUND NO DEPENDS")
endif()
# Remove the duplicate entries and sort them.
list(REMOVE_DUPLICATES dependency_list)
list(SORT dependency_list)
foreach(file ${dependency_list})
set(cuda_nvcc_depend "${cuda_nvcc_depend} \"${file}\"\n")
endforeach()
file(WRITE ${output_file} "# Generated by: make2cmake.cmake\nSET(CUDA_NVCC_DEPEND\n ${cuda_nvcc_depend})\n\n")

View file

@ -0,0 +1,112 @@
# James Bigler, NVIDIA Corp (nvidia.com - jbigler)
# Abe Stephens, SCI Institute -- http://www.sci.utah.edu/~abe/FindCuda.html
#
# Copyright (c) 2008 - 2009 NVIDIA Corporation. All rights reserved.
#
# Copyright (c) 2007-2009
# Scientific Computing and Imaging Institute, University of Utah
#
# This code is licensed under the MIT License. See the FindCUDA.cmake script
# for the text of the license.
# The MIT License
#
# License for the specific language governing rights and limitations under
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#
#######################################################################
# Parses a .cubin file produced by nvcc and reports statistics about the file.
file(READ ${input_file} file_text)
if (${file_text} MATCHES ".+")
# Remember, four backslashes is escaped to one backslash in the string.
string(REGEX REPLACE ";" "\\\\;" file_text ${file_text})
string(REGEX REPLACE "\ncode" ";code" file_text ${file_text})
list(LENGTH file_text len)
foreach(line ${file_text})
# Only look at "code { }" blocks.
if(line MATCHES "^code")
# Break into individual lines.
string(REGEX REPLACE "\n" ";" line ${line})
foreach(entry ${line})
# Extract kernel names.
if (${entry} MATCHES "[^g]name = ([^ ]+)")
string(REGEX REPLACE ".* = ([^ ]+)" "\\1" entry ${entry})
# Check to see if the kernel name starts with "_"
set(skip FALSE)
# if (${entry} MATCHES "^_")
# Skip the rest of this block.
# message("Skipping ${entry}")
# set(skip TRUE)
# else (${entry} MATCHES "^_")
message("Kernel: ${entry}")
# endif (${entry} MATCHES "^_")
endif(${entry} MATCHES "[^g]name = ([^ ]+)")
# Skip the rest of the block if necessary
if(NOT skip)
# Registers
if (${entry} MATCHES "reg([ ]+)=([ ]+)([^ ]+)")
string(REGEX REPLACE ".*([ ]+)=([ ]+)([^ ]+)" "\\3" entry ${entry})
message("Registers: ${entry}")
endif()
# Local memory
if (${entry} MATCHES "lmem([ ]+)=([ ]+)([^ ]+)")
string(REGEX REPLACE ".*([ ]+)=([ ]+)([^ ]+)" "\\3" entry ${entry})
message("Local: ${entry}")
endif()
# Shared memory
if (${entry} MATCHES "smem([ ]+)=([ ]+)([^ ]+)")
string(REGEX REPLACE ".*([ ]+)=([ ]+)([^ ]+)" "\\3" entry ${entry})
message("Shared: ${entry}")
endif()
if (${entry} MATCHES "^}")
message("")
endif()
endif(NOT skip)
endforeach(entry)
endif(line MATCHES "^code")
endforeach(line)
else()
# message("FOUND NO DEPENDS")
endif()

View file

@ -0,0 +1,280 @@
# James Bigler, NVIDIA Corp (nvidia.com - jbigler)
#
# Copyright (c) 2008 - 2009 NVIDIA Corporation. All rights reserved.
#
# This code is licensed under the MIT License. See the FindCUDA.cmake script
# for the text of the license.
# The MIT License
#
# License for the specific language governing rights and limitations under
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
##########################################################################
# This file runs the nvcc commands to produce the desired output file along with
# the dependency file needed by CMake to compute dependencies. In addition the
# file checks the output of each command and if the command fails it deletes the
# output files.
# Input variables
#
# verbose:BOOL=<> OFF: Be as quiet as possible (default)
# ON : Describe each step
#
# build_configuration:STRING=<> Typically one of Debug, MinSizeRel, Release, or
# RelWithDebInfo, but it should match one of the
# entries in CUDA_HOST_FLAGS. This is the build
# configuration used when compiling the code. If
# blank or unspecified Debug is assumed as this is
# what CMake does.
#
# generated_file:STRING=<> File to generate. This argument must be passed in.
#
# generated_cubin_file:STRING=<> File to generate. This argument must be passed
# in if build_cubin is true.
if(NOT generated_file)
message(FATAL_ERROR "You must specify generated_file on the command line")
endif()
# Set these up as variables to make reading the generated file easier
set(CMAKE_COMMAND "@CMAKE_COMMAND@")
set(source_file "@source_file@")
set(NVCC_generated_dependency_file "@NVCC_generated_dependency_file@")
set(cmake_dependency_file "@cmake_dependency_file@")
set(CUDA_make2cmake "@CUDA_make2cmake@")
set(CUDA_parse_cubin "@CUDA_parse_cubin@")
set(build_cubin @build_cubin@)
# We won't actually use these variables for now, but we need to set this, in
# order to force this file to be run again if it changes.
set(generated_file_path "@generated_file_path@")
set(generated_file_internal "@generated_file@")
set(generated_cubin_file_internal "@generated_cubin_file@")
set(CUDA_NVCC_EXECUTABLE "@CUDA_NVCC_EXECUTABLE@")
set(CUDA_NVCC_FLAGS "@CUDA_NVCC_FLAGS@;;@CUDA_WRAP_OPTION_NVCC_FLAGS@")
@CUDA_NVCC_FLAGS_CONFIG@
set(nvcc_flags "@nvcc_flags@")
set(CUDA_NVCC_INCLUDE_ARGS "@CUDA_NVCC_INCLUDE_ARGS@")
set(format_flag "@format_flag@")
if(build_cubin AND NOT generated_cubin_file)
message(FATAL_ERROR "You must specify generated_cubin_file on the command line")
endif()
# This is the list of host compilation flags. It C or CXX should already have
# been chosen by FindCUDA.cmake.
@CUDA_HOST_FLAGS@
# Take the compiler flags and package them up to be sent to the compiler via -Xcompiler
set(nvcc_host_compiler_flags "")
# If we weren't given a build_configuration, use Debug.
if(NOT build_configuration)
set(build_configuration Debug)
endif()
string(TOUPPER "${build_configuration}" build_configuration)
#message("CUDA_NVCC_HOST_COMPILER_FLAGS = ${CUDA_NVCC_HOST_COMPILER_FLAGS}")
foreach(flag ${CMAKE_HOST_FLAGS} ${CMAKE_HOST_FLAGS_${build_configuration}})
# Extra quotes are added around each flag to help nvcc parse out flags with spaces.
set(nvcc_host_compiler_flags "${nvcc_host_compiler_flags},\"${flag}\"")
endforeach()
if (nvcc_host_compiler_flags)
set(nvcc_host_compiler_flags "-Xcompiler" ${nvcc_host_compiler_flags})
endif()
#message("nvcc_host_compiler_flags = \"${nvcc_host_compiler_flags}\"")
# Add the build specific configuration flags
list(APPEND CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS_${build_configuration}})
if(DEFINED CCBIN)
set(CCBIN -ccbin "${CCBIN}")
endif()
# cuda_execute_process - Executes a command with optional command echo and status message.
#
# status - Status message to print if verbose is true
# command - COMMAND argument from the usual execute_process argument structure
# ARGN - Remaining arguments are the command with arguments
#
# CUDA_result - return value from running the command
#
# Make this a macro instead of a function, so that things like RESULT_VARIABLE
# and other return variables are present after executing the process.
macro(cuda_execute_process status command)
set(_command ${command})
if(NOT _command STREQUAL "COMMAND")
message(FATAL_ERROR "Malformed call to cuda_execute_process. Missing COMMAND as second argument. (command = ${command})")
endif()
if(verbose)
execute_process(COMMAND "${CMAKE_COMMAND}" -E echo -- ${status})
# Now we need to build up our command string. We are accounting for quotes
# and spaces, anything else is left up to the user to fix if they want to
# copy and paste a runnable command line.
set(cuda_execute_process_string)
foreach(arg ${ARGN})
# If there are quotes, excape them, so they come through.
string(REPLACE "\"" "\\\"" arg ${arg})
# Args with spaces need quotes around them to get them to be parsed as a single argument.
if(arg MATCHES " ")
list(APPEND cuda_execute_process_string "\"${arg}\"")
else()
list(APPEND cuda_execute_process_string ${arg})
endif()
endforeach()
# Echo the command
execute_process(COMMAND ${CMAKE_COMMAND} -E echo ${cuda_execute_process_string})
endif(verbose)
# Run the command
execute_process(COMMAND ${ARGN} RESULT_VARIABLE CUDA_result )
endmacro()
# Delete the target file
cuda_execute_process(
"Removing ${generated_file}"
COMMAND "${CMAKE_COMMAND}" -E remove "${generated_file}"
)
# For CUDA 2.3 and below, -G -M doesn't work, so remove the -G flag
# for dependency generation and hope for the best.
set(depends_CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS}")
set(CUDA_VERSION @CUDA_VERSION@)
if(CUDA_VERSION VERSION_LESS "3.0")
cmake_policy(PUSH)
# CMake policy 0007 NEW states that empty list elements are not
# ignored. I'm just setting it to avoid the warning that's printed.
cmake_policy(SET CMP0007 NEW)
# Note that this will remove all occurances of -G.
list(REMOVE_ITEM depends_CUDA_NVCC_FLAGS "-G")
cmake_policy(POP)
endif()
# nvcc doesn't define __CUDACC__ for some reason when generating dependency files. This
# can cause incorrect dependencies when #including files based on this macro which is
# defined in the generating passes of nvcc invokation. We will go ahead and manually
# define this for now until a future version fixes this bug.
set(CUDACC_DEFINE -D__CUDACC__)
# Generate the dependency file
cuda_execute_process(
"Generating dependency file: ${NVCC_generated_dependency_file}"
COMMAND "${CUDA_NVCC_EXECUTABLE}"
-M
${CUDACC_DEFINE}
"${source_file}"
-o "${NVCC_generated_dependency_file}"
${CCBIN}
${nvcc_flags}
${nvcc_host_compiler_flags}
${depends_CUDA_NVCC_FLAGS}
-DNVCC
${CUDA_NVCC_INCLUDE_ARGS}
)
if(CUDA_result)
message(FATAL_ERROR "Error generating ${generated_file}")
endif()
# Generate the cmake readable dependency file to a temp file. Don't put the
# quotes just around the filenames for the input_file and output_file variables.
# CMake will pass the quotes through and not be able to find the file.
cuda_execute_process(
"Generating temporary cmake readable file: ${cmake_dependency_file}.tmp"
COMMAND "${CMAKE_COMMAND}"
-D "input_file:FILEPATH=${NVCC_generated_dependency_file}"
-D "output_file:FILEPATH=${cmake_dependency_file}.tmp"
-P "${CUDA_make2cmake}"
)
if(CUDA_result)
message(FATAL_ERROR "Error generating ${generated_file}")
endif()
# Copy the file if it is different
cuda_execute_process(
"Copy if different ${cmake_dependency_file}.tmp to ${cmake_dependency_file}"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${cmake_dependency_file}.tmp" "${cmake_dependency_file}"
)
if(CUDA_result)
message(FATAL_ERROR "Error generating ${generated_file}")
endif()
# Delete the temporary file
cuda_execute_process(
"Removing ${cmake_dependency_file}.tmp and ${NVCC_generated_dependency_file}"
COMMAND "${CMAKE_COMMAND}" -E remove "${cmake_dependency_file}.tmp" "${NVCC_generated_dependency_file}"
)
if(CUDA_result)
message(FATAL_ERROR "Error generating ${generated_file}")
endif()
# Generate the code
cuda_execute_process(
"Generating ${generated_file}"
COMMAND "${CUDA_NVCC_EXECUTABLE}"
"${source_file}"
${format_flag} -o "${generated_file}"
${CCBIN}
${nvcc_flags}
${nvcc_host_compiler_flags}
${CUDA_NVCC_FLAGS}
-DNVCC
${CUDA_NVCC_INCLUDE_ARGS}
)
if(CUDA_result)
# Since nvcc can sometimes leave half done files make sure that we delete the output file.
cuda_execute_process(
"Removing ${generated_file}"
COMMAND "${CMAKE_COMMAND}" -E remove "${generated_file}"
)
message(FATAL_ERROR "Error generating file ${generated_file}")
else()
if(verbose)
message("Generated ${generated_file} successfully.")
endif()
endif()
# Cubin resource report commands.
if( build_cubin )
# Run with -cubin to produce resource usage report.
cuda_execute_process(
"Generating ${generated_cubin_file}"
COMMAND "${CUDA_NVCC_EXECUTABLE}"
"${source_file}"
${CUDA_NVCC_FLAGS}
${nvcc_flags}
${CCBIN}
${nvcc_host_compiler_flags}
-DNVCC
-cubin
-o "${generated_cubin_file}"
${CUDA_NVCC_INCLUDE_ARGS}
)
# Execute the parser script.
cuda_execute_process(
"Executing the parser script"
COMMAND "${CMAKE_COMMAND}"
-D "input_file:STRING=${generated_cubin_file}"
-P "${CUDA_parse_cubin}"
)
endif( build_cubin )

View file

@ -0,0 +1,132 @@
######################################################################################
### 0) Set your application properties
######################################################################################
# check cmake version compatibility
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
# Here define your project name
PROJECT(Paradiseo-GPU)
SET(PACKAGE_BUGREPORT "paradiseo-help@lists.gforge.inria.fr" CACHE STRING "Package bug report" FORCE)
SET(PACKAGE_NAME "ParadisEO-GPU - Moving Objects GPU" CACHE STRING "Package name" FORCE)
SET(PACKAGE_STRING "ParadisEO-GPU 1.0" CACHE STRING "GPU Package string full name" FORCE)
SET(PACKAGE_VERSION "1.0" CACHE STRING "Package version" FORCE)
SET(GLOBAL_VERSION "1.0" CACHE STRING "Global version" FORCE)
SET(VERSION "1.0.0" CACHE STRING "Version" FORCE)
# regular expression checking
INCLUDE_REGULAR_EXPRESSION("^.*$" "^$")
# set a language for the entire project.
ENABLE_LANGUAGE(CXX)
ENABLE_LANGUAGE(C)
######################################################################################
##########################################
# Find Cuda package #
##########################################
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake/cuda" ${CMAKE_MODULE_PATH})
find_package(CUDA QUIET REQUIRED)
# Check if CUDA was found
if (CUDA_FOUND)
message("CUDA found")
else()
message("CUDA not found")
endif()
######################################################################################
### 1) Include the install configuration file where are defined the main variables
######################################################################################
INCLUDE(${CMAKE_SOURCE_DIR}/install.cmake)
######################################################################################
######################################################################################
### 2) Include the sources
######################################################################################
##########################################
# Include required modules & utilities #
##########################################
INCLUDE(CMakeBackwardCompatibilityCXX)
INCLUDE(FindDoxygen)
INCLUDE(CheckLibraryExists)
INCLUDE(Dart OPTIONAL)
# Set a special flag if the environment is windows (should do the same in a config.g file)
IF (WIN32)
ADD_DEFINITIONS(-D_WINDOWS=1)
ENDIF (WIN32)
######################################################################################
#########################
# Manage the build type #
#########################
# the user should choose the build type on windows environments,excepted under cygwin (default=none)
SET(CMAKE_DEFAULT_BUILD_TYPE "Release" CACHE STRING "Variable that stores the default CMake build type" FORCE)
FIND_PROGRAM(MEMORYCHECK_COMMAND
NAMES purify valgrind
PATHS
"/usr/local/bin /usr/bin [HKEY_LOCAL_MACHINE\\SOFTWARE\\Rational Software\\Purify\\Setup;InstallFolder]"
DOC "Path to the memory checking command, used for memory error detection.")
IF(NOT CMAKE_BUILD_TYPE)
SET( CMAKE_BUILD_TYPE
${CMAKE_DEFAULT_BUILD_TYPE} CACHE STRING
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
FORCE)
ENDIF(NOT CMAKE_BUILD_TYPE)
IF(WIN32 AND NOT CYGWIN)
IF(CMAKE_CXX_COMPILER MATCHES cl)
IF(NOT WITH_SHARED_LIBS)
IF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
SET(CMAKE_CXX_FLAGS "/nologo /Gy")
SET(CMAKE_CXX_FLAGS_DEBUG "/W3 /MTd /Z7 /Od")
SET(CMAKE_CXX_FLAGS_RELEASE "/w /MT /O2 /wd4530")
SET(CMAKE_CXX_FLAGS_MINSIZEREL "/MT /O2")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MTd /Z7 /Od")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:CONSOLE")
ENDIF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
ENDIF(NOT WITH_SHARED_LIBS)
ENDIF(CMAKE_CXX_COMPILER MATCHES cl)
ELSE(WIN32 AND NOT CYGWIN)
IF(CMAKE_COMPILER_IS_GNUCXX)
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g -fprofile-arcs -ftest-coverage -Wall -Wextra -Wno-unused-parameter")
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
SET(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -O6")
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
ENDIF(WIN32 AND NOT CYGWIN)
IF(CMAKE_BUILD_TYPE MATCHES Debug)
ADD_DEFINITIONS(-DCMAKE_VERBOSE_MAKEFILE=ON)
ENDIF(CMAKE_BUILD_TYPE MATCHES Debug)
EXECUTE_PROCESS(
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${PARADISEO_GPU_SRC_DIR}/CTestCustom.cmake
${PARADISEO_GPU_BIN_DIR}/CTestCustom.cmake)
##########################################################################################################################################
######################################################################################
### 3) Link the librairies for your executable
######################################################################################
ADD_SUBDIRECTORY(doc)
ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(test)
ADD_SUBDIRECTORY(tutoriel)
######################################################################################

View file

@ -0,0 +1,7 @@
set(CTEST_PROJECT_NAME "ParadisEO")
set(CTEST_NIGHTLY_START_TIME "00:00:00 EST")
set(CTEST_DROP_METHOD "http")
set(CTEST_DROP_SITE "cdash.inria.fr")
set(CTEST_DROP_LOCATION "/CDash/submit.php?project=ParadisEO")
set(CTEST_DROP_SITE_CDASH TRUE)

View file

@ -0,0 +1,9 @@
SET(CTEST_CUSTOM_COVERAGE_EXCLUDE
${CTEST_CUSTOM_COVERAGE_EXCLUDE}
"test/"
"paradiseo-eo/"
"paradiseo-mo/"
"paradiseo-moeo/"
"problems/"
"tutorial/"
)

37
ParadisEO-GPU/README.txt Normal file
View file

@ -0,0 +1,37 @@
This package contains the source for ParadisEO-GPU problems.
# Step 1 - Configuration
------------------------
Edit the "install.cmake" file by entering the FULL PATH of :
-"ParadisEO_PATH" where Paradiseo directory has been installed in your host.
-"ParadisEO-GPU_PATH" where ParadisEO-GPU package has been decompressed in your host.
-"CUDA_PATH" where CUDA has been installed in your host.
-"NVIDIA_PATH" where NVIDIA has been installed in your host.
# Step 2 - Build process
------------------------
ParadisEO is assumed to be compiled. To download ParadisEO, please visit http://paradiseo.gforge.inria.fr/.
Go to the ParadisEO-GPU/build/ directory and lunch cmake:
(Unix) > cmake .. -DENABLE_CMAKE_TESTING=TRUE -DCMAKE_BUILD_TYPE=Debug
# Step 3 - Compilation
----------------------
In the ParadisEO-GPU/build/ directory:
(Unix) > make
# Step 4 - Execution
---------------------
A toy example is given to test the components. You can run these tests as following.
To define problem-related components for your own problem, please refer to the tutorials available on the website : http://paradiseo.gforge.inria.fr/.
In the ParadisEO-GPU/build/ directory:
(Unix) > ctest -D ExperimentalStart -D ExperimentalBuild -D ExperimentalTest -D ExperimentalSubmit
In the directory "tutorial", there is an example of One Max problem which illustrate how to use this package.
# Documentation
---------------
The API-documentation is available in doc/html/index.html

View file

@ -0,0 +1,25 @@
##########################################################################################
### Doc generation using Doxygen
##########################################################################################
IF (DOXYGEN_FOUND)
SET(DOC_DIR ${CMAKE_BINARY_DIR}/doc CACHE PATH "GPU documentation directory")
SET(GPU_DOC_CONFIG_FILE "doxyfile" CACHE PATH "GPU documentation configuration file")
# define the doc target
IF (DOXYGEN_EXECUTABLE)
ADD_CUSTOM_TARGET(doc
COMMAND ${DOXYGEN_EXECUTABLE} ${GPU_DOC_CONFIG_FILE}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
ENDIF (DOXYGEN_EXECUTABLE)
# configure doxyfile file
CONFIGURE_FILE("${CMAKE_SOURCE_DIR}/doc/${GPU_DOC_CONFIG_FILE}.cmake"
"${CMAKE_BINARY_DIR}/doc/${GPU_DOC_CONFIG_FILE}")
ELSE (DOXYGEN_FOUND)
MESSAGE(STATUS "Unable to generate the documentation, Doxygen package not found")
ENDIF (DOXYGEN_FOUND)
##########################################################################################

View file

@ -0,0 +1,240 @@
# Doxyfile 1.5.1
#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------
PROJECT_NAME = @PACKAGE_NAME@
PROJECT_NUMBER = @PACKAGE_VERSION@
OUTPUT_DIRECTORY = @CMAKE_BINARY_DIR@/doc
CREATE_SUBDIRS = NO
OUTPUT_LANGUAGE = English
BRIEF_MEMBER_DESC = YES
REPEAT_BRIEF = YES
ABBREVIATE_BRIEF = "The $name class" \
"The $name widget" \
"The $name file" \
is \
provides \
specifies \
contains \
represents \
a \
an \
the
ALWAYS_DETAILED_SEC = NO
INLINE_INHERITED_MEMB = NO
FULL_PATH_NAMES = NO
STRIP_FROM_PATH = @CMAKE_SOURCE_DIR@
STRIP_FROM_INC_PATH =
SHORT_NAMES = NO
JAVADOC_AUTOBRIEF = YES
MULTILINE_CPP_IS_BRIEF = NO
DETAILS_AT_TOP = NO
INHERIT_DOCS = YES
SEPARATE_MEMBER_PAGES = NO
TAB_SIZE = 8
ALIASES =
OPTIMIZE_OUTPUT_FOR_C = NO
OPTIMIZE_OUTPUT_JAVA = NO
BUILTIN_STL_SUPPORT = NO
DISTRIBUTE_GROUP_DOC = NO
SUBGROUPING = YES
#---------------------------------------------------------------------------
# Build related configuration options
#---------------------------------------------------------------------------
EXTRACT_ALL = YES
EXTRACT_PRIVATE = YES
EXTRACT_STATIC = YES
EXTRACT_LOCAL_CLASSES = YES
EXTRACT_LOCAL_METHODS = YES
HIDE_UNDOC_MEMBERS = YES
HIDE_UNDOC_CLASSES = YES
HIDE_FRIEND_COMPOUNDS = NO
HIDE_IN_BODY_DOCS = NO
INTERNAL_DOCS = NO
CASE_SENSE_NAMES = YES
HIDE_SCOPE_NAMES = NO
SHOW_INCLUDE_FILES = YES
INLINE_INFO = YES
SORT_MEMBER_DOCS = NO
SORT_BRIEF_DOCS = NO
SORT_BY_SCOPE_NAME = NO
GENERATE_TODOLIST = YES
GENERATE_TESTLIST = YES
GENERATE_BUGLIST = YES
GENERATE_DEPRECATEDLIST= YES
ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
SHOW_USED_FILES = YES
SHOW_DIRECTORIES = NO
FILE_VERSION_FILTER =
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
#---------------------------------------------------------------------------
QUIET = YES
WARNINGS = NO
WARN_IF_UNDOCUMENTED = NO
WARN_IF_DOC_ERROR = YES
WARN_NO_PARAMDOC = NO
WARN_FORMAT = "$file:$line: $text"
WARN_LOGFILE =
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = @CMAKE_SOURCE_DIR@
FILE_PATTERNS = *.cu \
*.cpp \
*.h \
NEWS README
RECURSIVE = YES
EXCLUDE =
EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS =
EXAMPLE_PATH =
EXAMPLE_PATTERNS = *
EXAMPLE_RECURSIVE = NO
IMAGE_PATH =
INPUT_FILTER =
FILTER_PATTERNS =
FILTER_SOURCE_FILES = NO
#---------------------------------------------------------------------------
# configuration options related to source browsing
#---------------------------------------------------------------------------
SOURCE_BROWSER = YES
INLINE_SOURCES = NO
STRIP_CODE_COMMENTS = YES
REFERENCED_BY_RELATION = YES
REFERENCES_RELATION = YES
REFERENCES_LINK_SOURCE = YES
USE_HTAGS = NO
VERBATIM_HEADERS = YES
#---------------------------------------------------------------------------
# configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
ALPHABETICAL_INDEX = YES
COLS_IN_ALPHA_INDEX = 3
IGNORE_PREFIX =
#moeo
#---------------------------------------------------------------------------
# configuration options related to the HTML output
#---------------------------------------------------------------------------
GENERATE_HTML = YES
HTML_OUTPUT = html
HTML_FILE_EXTENSION = .html
HTML_HEADER =
HTML_FOOTER =
HTML_STYLESHEET =
HTML_ALIGN_MEMBERS = YES
GENERATE_HTMLHELP = NO
CHM_FILE =
HHC_LOCATION =
GENERATE_CHI = NO
BINARY_TOC = NO
TOC_EXPAND = NO
DISABLE_INDEX = NO
ENUM_VALUES_PER_LINE = 4
GENERATE_TREEVIEW = YES
TREEVIEW_WIDTH = 250
#---------------------------------------------------------------------------
# configuration options related to the LaTeX output
#---------------------------------------------------------------------------
GENERATE_LATEX = YES
LATEX_OUTPUT = latex
LATEX_CMD_NAME = latex
MAKEINDEX_CMD_NAME = makeindex
COMPACT_LATEX = NO
PAPER_TYPE = a4wide
EXTRA_PACKAGES =
LATEX_HEADER =
PDF_HYPERLINKS = NO
USE_PDFLATEX = NO
LATEX_BATCHMODE = NO
LATEX_HIDE_INDICES = NO
#---------------------------------------------------------------------------
# configuration options related to the RTF output
#---------------------------------------------------------------------------
GENERATE_RTF = NO
RTF_OUTPUT = rtf
COMPACT_RTF = NO
RTF_HYPERLINKS = NO
RTF_STYLESHEET_FILE =
RTF_EXTENSIONS_FILE =
#---------------------------------------------------------------------------
# configuration options related to the man page output
#---------------------------------------------------------------------------
GENERATE_MAN = YES
MAN_OUTPUT = man
MAN_EXTENSION = .3
MAN_LINKS = NO
#---------------------------------------------------------------------------
# configuration options related to the XML output
#---------------------------------------------------------------------------
GENERATE_XML = NO
XML_OUTPUT = xml
XML_SCHEMA =
XML_DTD =
XML_PROGRAMLISTING = YES
#---------------------------------------------------------------------------
# configuration options for the AutoGen Definitions output
#---------------------------------------------------------------------------
GENERATE_AUTOGEN_DEF = NO
#---------------------------------------------------------------------------
# configuration options related to the Perl module output
#---------------------------------------------------------------------------
GENERATE_PERLMOD = NO
PERLMOD_LATEX = NO
PERLMOD_PRETTY = YES
PERLMOD_MAKEVAR_PREFIX =
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = NO
EXPAND_ONLY_PREDEF = NO
SEARCH_INCLUDES = YES
INCLUDE_PATH =
INCLUDE_FILE_PATTERNS =
PREDEFINED =
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------
# Configuration::additions related to external references
#---------------------------------------------------------------------------
TAGFILES = @PARADISEO_EO_BIN_DIR@/doc/eo.doxytag=http://eodev.sourceforge.net/eo/doc/html \
@PARADISEO_MO_BIN_DIR@/doc/mo.doxytag=http://paradiseo.gforge.inria.fr/addon/paradiseo-mo/doc/
GENERATE_TAGFILE = @CMAKE_BINARY_DIR@/doc/mogpu.doxytag
ALLEXTERNALS = NO
EXTERNAL_GROUPS = YES
PERL_PATH = /usr/bin/perl
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
CLASS_DIAGRAMS = YES
HIDE_UNDOC_RELATIONS = YES
HAVE_DOT = YES
CLASS_GRAPH = YES
COLLABORATION_GRAPH = YES
GROUP_GRAPHS = YES
UML_LOOK = YES
TEMPLATE_RELATIONS = YES
INCLUDE_GRAPH = YES
INCLUDED_BY_GRAPH = YES
CALL_GRAPH = NO
CALLER_GRAPH = NO
GRAPHICAL_HIERARCHY = YES
DIRECTORY_GRAPH = YES
DOT_IMAGE_FORMAT = png
DOT_PATH =
DOTFILE_DIRS =
DOT_GRAPH_MAX_NODES = 50
MAX_DOT_GRAPH_DEPTH = 10
DOT_TRANSPARENT = NO
DOT_MULTI_TARGETS = NO
GENERATE_LEGEND = YES
DOT_CLEANUP = YES
#---------------------------------------------------------------------------
# Configuration::additions related to the search engine
#---------------------------------------------------------------------------
SEARCHENGINE = YES

58
ParadisEO-GPU/doc/index.h Normal file
View file

@ -0,0 +1,58 @@
/** @mainpage Welcome ParadisEO GPU
@section intro Introduction
ParadisEO-GPU is a white-box object-oriented generic framework dedicated to the flexible design of local search algorithms on GPU (hill-climbing, tabu search ...)
@section tutorials Tutorials
Tutorials for ParadisEO-GPU are available in the "Tutorials section" of the <a href="http://paradiseo.gforge.inria.fr/index.php?n=Doc.Tutorials">ParadisEO tutorials</a>.
@section install Installation
The installation procedure of the package is detailed in the "README.txt" file located in the top-directory of the source-tree.
@section design Design
For an introduction to the design of ParadisEO,
you can look at the <a href="http://paradiseo.gforge.inria.fr">ParadisEO website</a>.
@section LICENSE
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
/** @page webpages Related webpages
- ParadisEO <a href="http://paradiseo.gforge.inria.fr">homepage</a>
- INRIA GForge <a href="http://gforge.inria.fr/projects/paradiseo/">project page</a>
- Fore any questions, please contact paradiseo-help@lists.gforge.inria.fr
*/

View file

@ -0,0 +1,43 @@
#########################################################################################################
# 1) ParadisEO-GPU install: SIMPLE Configuration
#########################################################################################################
# Here, just specify PARADISEO_DIR : the directory where ParadisEO has been installed
SET(PARADISEO_DIR "/home/mia/workspace/trunk" CACHE PATH "ParadisEO directory" FORCE)
# Here, just specify CUDA_DIR : the directory where CUDA has been installed
SET(CUDA_DIR "/usr/local/cuda" CACHE PATH "CUDA directory" FORCE)
# Here, just specify NVIDIA_DIR : the directory where NVIDIA header has been installed
SET(NVIDIA_DIR "/home/mia/NVIDIA_GPU_Computing_SDK" CACHE PATH "NVIDIA directory" FORCE)
# Here, just specify GPU_DIR : the directory where package Paradiseo GPU has been extrated
SET(PARADISEO_GPU_DIR "/home/mia/workspace/ParadisEO-GPU" CACHE PATH "ParadisEO-GPU directory" FORCE)
#########################################################################################################
# 2) ParadisEO-GPU install: ADVANCED Configuration
#########################################################################################################
SET(NVIDIA_SRC_DIR "${NVIDIA_DIR}/C/common/inc" CACHE PATH "NVIDIA source directory" FORCE)
SET(NVIDIA_LIB_DIR "${NVIDIA_DIR}/C/lib" CACHE PATH "NVIDIA library directory" FORCE)
SET(CUDA_SRC_DIR "${CUDA_DIR}/include" CACHE PATH "CUDA source directory" FORCE)
SET(CUDA_LIB_DIR "${CUDA_DIR}/lib" CACHE PATH "CUDA library directory" FORCE)
SET(PARADISEO_EO_SRC_DIR "${PARADISEO_DIR}/paradiseo-eo" CACHE PATH "ParadisEO-EO source directory" FORCE)
SET(PARADISEO_EO_BIN_DIR "${PARADISEO_DIR}/paradiseo-eo/build" CACHE PATH "ParadisEO-EO binary directory" FORCE)
SET(PARADISEO_MO_SRC_DIR "${PARADISEO_DIR}/paradiseo-mo" CACHE PATH "ParadisEO-MO source directory" FORCE)
SET(PARADISEO_MO_BIN_DIR "${PARADISEO_DIR}/paradiseo-mo/build" CACHE PATH "ParadisEO-MO binary directory" FORCE)
SET(PARADISEO_MOEO_SRC_DIR "${PARADISEO_DIR}/paradiseo-moeo" CACHE PATH "ParadisEO-MOEO source directory" FORCE)
SET(PARADISEO_MOEO_BIN_DIR "${PARADISEO_DIR}/paradiseo-moeo/build" CACHE PATH "ParadisEO-MOEO binary directory" FORCE)
SET(PARADISEO_PEO_SRC_DIR "${PARADISEO_DIR}/paradiseo-peo" CACHE PATH "ParadisEO-PEO source directory" FORCE)
SET(PARADISEO_PEO_BIN_DIR "${PARADISEO_DIR}/paradiseo-peo/build" CACHE PATH "ParadisEO-PEO binary directory" FORCE)
SET(PARADISEO_GPU_SRC_DIR "${PARADISEO_GPU_DIR}/src" CACHE PATH "ParadisEO-GPU source directory" FORCE)
SET(PARADISEO_GPU_BIN_DIR "${PARADISEO_GPU_DIR}/build" CACHE PATH "ParadisEO-GPU binary directory" FORCE)
SET(PARADISEO_PROBLEMS_SRC_DIR "${PARADISEO_DIR}/problems" CACHE PATH "ParadisEO-problems source directory" FORCE)
#########################################################################################################

View file

@ -0,0 +1,107 @@
/*
<moCudaBitVector.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Karima Boufaras, Thé Van LUONG
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef _moCudaBitVector_H_
#define _moCudaBitVector_H_
#include <cudaType/moCudaVector.h>
/**
* Implementation of Bit vector representation on CUDA.
*/
template<class Fitness>
class moCudaBitVector: public moCudaVector<bool, Fitness> {
public:
using moCudaVector<bool, Fitness>::vect;
using moCudaVector<bool, Fitness>::N;
/**
* Default constructor.
*/
moCudaBitVector() :
moCudaVector<bool, Fitness> () {
}
/**
*Constructor.
*@param _size The neighborhood size.
*/
moCudaBitVector(unsigned _size) {
N = _size;
vect = new bool[_size];
create();
}
/**
*Constructor.
*@param _size The neighborhood size.
*@param _b Value to assign to vector.
*/
moCudaBitVector(unsigned _size, bool _b) {
N = _size;
vect = new bool[_size];
for (unsigned i = 0; i < _size; i++)
vect[i] = _b;
}
/**
*Initializer of random bit vector.
*/
void create() {
for (unsigned i = 0; i < N; i++) {
vect[i] = (bool) round((float) rand() / RAND_MAX);
}
}
};
#endif

View file

@ -0,0 +1,114 @@
/*
<moCudaIntVector.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Karima Boufaras, Thé Van LUONG
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef _moCudaIntVector_H_
#define _moCudaIntVector_H_
#include <cudaType/moCudaVector.h>
/**
* Implementation of integer vector representation on CUDA.
*/
template<class Fitness>
class moCudaIntVector: public moCudaVector<int, Fitness> {
public:
using moCudaVector<int, Fitness>::vect;
using moCudaVector<int, Fitness>::N;
/**
* Default constructor.
*/
moCudaIntVector() :
moCudaVector<int, Fitness> () {
}
/**
*Constructor.
*@param _size The neighborhood size.
*/
moCudaIntVector(unsigned _size) {
N = _size;
vect = new int[_size];
create();
}
/**
*Assignment operator
*@param _vector The vector passed to the function determine the new content.
*@return a new vector.
*/
virtual moCudaIntVector& operator=(const moCudaIntVector & _vector) {
N = _vector.N;
vect = new int[N];
for (unsigned i = 0; i < N; i++)
vect[i] = _vector.vect[i];
fitness(_vector.fitness());
return (*this);
}
/**
*Initializer of random integer vector.
*/
void create() {
unsigned random;
int temp;
for (unsigned i = 0; i < N; i++)
vect[i] = i;
// we want a random permutation so we shuffle
for (unsigned i = 0; i < N; i++) {
random = rand() % (N - i) + i;
temp = vect[i];
vect[i] = vect[random];
vect[random] = temp;
}
}
};
#endif

View file

@ -0,0 +1,150 @@
/*
<moCudaVector.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Thé Van LUONG, Karima Boufaras
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef _moCudaVector_H_
#define _moCudaVector_H_
#include <eo>
/**
* Implementation of vector representation on CUDA.
*/
template<class ElemT, class Fitness>
class moCudaVector: public EO<Fitness> {
public:
typedef ElemT ElemType;
ElemType * vect;
unsigned N;
/**
* Default constructor.
*/
moCudaVector() :
N(1) {
}
/**
*Constructor.
*@param _size The neighborhood size.
*/
moCudaVector(unsigned _size) {
N = _size;
vect = new ElemType[_size];
create();
}
/**
* Destructor.
*/
~moCudaVector() {
if (N > 1)
delete[] vect;
}
/**
*How to fill the vector.
*/
virtual void create() {
}
/**
*Assignment operator
*@param _vector The vector passed to the function determine the new content.
*@return a new vector.
*/
virtual moCudaVector& operator=(const moCudaVector & _vector) {
N = _vector.N;
vect = new ElemType[N];
for (unsigned i = 0; i < N; i++)
vect[i] = _vector.vect[i];
fitness(_vector.fitness());
return (*this);
}
/**
*An accessor read only on the i'th element of the vector (function inline can be called from host or device).
*@param
*_i The i'th element of vector.
*@return
*The i'th element of the vector for read only
*/
inline __host__ __device__ const ElemType & operator[](unsigned _i) const {
return vect[_i];
}
/**
*An accessor read-write on the i'th element of the vector(function inline can be called from host or device).
*@param _i The i'th element of the vector.
*@return The i'th element of the vector for read-write
*/
inline __host__ __device__ ElemType & operator[](unsigned _i) {
return vect[_i];
}
/**
*Function inline to get the size of vector, called from host and device.
*@return The vector size's
*/
inline __host__ __device__ unsigned size() {
return N;
}
};
#endif

View file

@ -0,0 +1,128 @@
/*
<moCudaEval.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Karima Boufaras, Thé Van LUONG
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef moCudaEval_H
#define moCudaEval_H
#include <eval/moEval.h>
/**
* Abstract class for evaluation on GPU
*/
template<class Neighbor>
class moCudaEval: public moEval<Neighbor> {
public:
/**
* Define type of a solution corresponding to Neighbor
*/
typedef typename Neighbor::EOT EOT;
typedef typename EOT::Fitness Fitness;
/**
* Constructor
* @param
* _neighborhoodSize the size of the neighborhood
*/
moCudaEval(unsigned int _neighborhoodSize) {
neighborhoodSize = _neighborhoodSize;
host_FitnessArray = new Fitness[neighborhoodSize];
cudaMalloc((void**) &device_FitnessArray, neighborhoodSize
* sizeof(Fitness));
kernel_Dim=neighborhoodSize/BLOCK_SIZE+((neighborhoodSize%BLOCK_SIZE==0)?0:1);
}
/**
* Destructor
*/
~moCudaEval() {
delete[] host_FitnessArray;
cudaFree(device_FitnessArray);
cudaFree(&device_solution);
}
/**
* Set fitness of a solution neighbors
*@param _sol the solution which generate the neighborhood
*@param _neighbor the current neighbor
*/
void operator()(EOT & _sol, Neighbor & _neighbor) {
_neighbor.fitness(host_FitnessArray[_neighbor.index()]);
/*std::cout << _sol.fitness() << " -host_FitnessArray["
<< _neighbor.index() << "]= "
<< host_FitnessArray[_neighbor.index()] << std::endl;*/
}
/**
* Compute fitness for all solution neighbors in device
* @param
* _sol the solution which generate the neighborhood
*/
virtual void neighborhoodEval(EOT & _sol, unsigned * _mapping,
unsigned _Kswap) {
}
/**
* Compute fitness for all solution neighbors in device
* @param
* _sol the solution which generate the neighborhood
*/
virtual void neighborhoodEval(EOT & _sol)=0;
protected:
//the host array to save all neighbors fitness
Fitness * host_FitnessArray;
//the device array to save neighbors fitness computed in device
Fitness * device_FitnessArray;
//the device solution
EOT device_solution;
//the size of neighborhood
unsigned int neighborhoodSize;
//Cuda kernel dimension
int kernel_Dim;
};
#endif

View file

@ -0,0 +1,78 @@
/*
<moCudaEvalFunc.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Thé Van LUONG, Karima Boufaras
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef __moCudaEvalFunc_H
#define __moCudaEvalFunc_H
/**
* Abstract class for Incremental evaluation of neighbor
*/
template<class Neighbor>
class moCudaEvalFunc {
public:
/**
* Define type of a solution corresponding to Neighbor
*/
typedef typename Neighbor::EOT EOT;
typedef typename EOT::Fitness Fitness;
/**
* Constructor
*/
moCudaEvalFunc() {
}
/**
* Destructor
*/
~moCudaEvalFunc() {
}
/**
*Virtual functor to compute fitness of a solution neighbor
*@param _solution the solution which generate the neighborhood
*@param _fitness the current solution fitness
*@param _id the index neighbor
*/
virtual inline __host__ __device__ Fitness operator() (EOT & _solution,Fitness _fitness, unsigned _id)=0;
};
#endif

View file

@ -0,0 +1,121 @@
/*
<moCudaKswapEval.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Karima Boufaras, Thé Van LUONG
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef moCudaKswapEval_H
#define moCudaKswapEval_H
#include <eval/moCudaEval.h>
#include <eval/moCudakernelEval.h>
/**
* class for the cuda evaluation
*/
template<class Neighbor, class IncrementEval>
class moCudaKswapEval: public moCudaEval<Neighbor> {
public:
/**
* Define type of a solution corresponding to Neighbor
*/
typedef typename Neighbor::EOT EOT;
/**
* Define type of a vector corresponding to Solution
*/
typedef typename EOT::ElemType T;
/**
* Define type of a fitness corresponding to Solution
*/
typedef typename EOT::Fitness Fitness;
using moCudaEval<Neighbor>::neighborhoodSize;
using moCudaEval<Neighbor>::host_FitnessArray;
using moCudaEval<Neighbor>::device_FitnessArray;
using moCudaEval<Neighbor>::device_solution;
using moCudaEval<Neighbor>::kernel_Dim;
/**
* Constructor
* @param _neighborhoodSize the size of the neighborhood
* @param _incrEval the incremental evaluation
*/
moCudaKswapEval(unsigned _neighborhoodSize, IncrementEval & _incrEval) :
moCudaEval<Neighbor> (_neighborhoodSize), incrEval(_incrEval) {
}
/**
* Compute fitness for all solution neighbors in device
* @param _sol the solution which generate the neighborhood
*/
virtual void neighborhoodEval(EOT & _sol) {
}
/**
* Compute fitness for all solution neighbors in device
* @param _sol the solution which generate the neighborhood
* @param _mapping the array of indices mapping
* @param _Kswap the number of swap
*/
void neighborhoodEval(EOT & _sol, unsigned * _mapping, unsigned _Kswap) {
// the solution vector size
unsigned _size = _sol.size();
// Get Current solution fitness
Fitness fitness = _sol.fitness();
//Allocate the space for solution in the global memory of device
cudaMalloc((void**) &device_solution.vect, _size * sizeof(T));
//Copy the solution vector from the host to device
cudaMemcpy(device_solution.vect, _sol.vect, _size * sizeof(T),
cudaMemcpyHostToDevice);
//Launch the Kernel to compute all neighbors fitness
kernelKswap<EOT,Fitness,Neighbor,IncrementEval><<<kernel_Dim,BLOCK_SIZE >>>(incrEval,device_solution,device_FitnessArray,fitness,neighborhoodSize,_mapping,_Kswap);
//Copy the result from device to host
cudaMemcpy(host_FitnessArray, device_FitnessArray, neighborhoodSize
* sizeof(Fitness), cudaMemcpyDeviceToHost);
}
protected:
IncrementEval & incrEval;
};
#endif

View file

@ -0,0 +1,113 @@
/*
<moCudaVectorEval.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Karima Boufaras, Thé Van LUONG
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef moCudaVectorEval_H
#define moCudavectorEval_H
#include <eval/moCudaEval.h>
#include <eval/moCudakernelEval.h>
/**
* class for the cuda evaluation
*/
template<class Neighbor, class IncrementEval>
class moCudaVectorEval: public moCudaEval<Neighbor> {
public:
/**
* Define type of a solution corresponding to Neighbor
*/
typedef typename Neighbor::EOT EOT;
/**
* Define type of a vector corresponding to Solution
*/
typedef typename EOT::ElemType T;
/**
* Define type of a fitness corresponding to Solution
*/
typedef typename EOT::Fitness Fitness;
using moCudaEval<Neighbor>::neighborhoodSize;
using moCudaEval<Neighbor>::host_FitnessArray;
using moCudaEval<Neighbor>::device_FitnessArray;
using moCudaEval<Neighbor>::device_solution;
using moCudaEval<Neighbor>::kernel_Dim;
/**
* Constructor
* @param _neighborhoodSize the size of the neighborhood
* @param _incrEval the incremental evaluation
*/
moCudaVectorEval(unsigned _neighborhoodSize, IncrementEval & _incrEval) :
moCudaEval<Neighbor> (_neighborhoodSize), incrEval(_incrEval) {
}
/**
* Compute fitness for all solution neighbors in device
* @param _sol the solution which generate the neighborhood
*/
virtual void neighborhoodEval(EOT & _sol) {
// the solution vector size
unsigned _size = _sol.size();
// Get Current solution fitness
Fitness fitness = _sol.fitness();
//Allocate the space for solution in the global memory of device
cudaMalloc((void**) &device_solution.vect, _size * sizeof(T));
//Copy the solution vector from the host to device
cudaMemcpy(device_solution.vect, _sol.vect, _size * sizeof(T),
cudaMemcpyHostToDevice);
//Launch the Kernel to compute all neighbors fitness
kernelEval<EOT,Fitness,Neighbor,IncrementEval><<<kernel_Dim,BLOCK_SIZE >>>(incrEval,device_solution,device_FitnessArray,fitness,neighborhoodSize);
//Copy the result from device to host
cudaMemcpy(host_FitnessArray, device_FitnessArray, neighborhoodSize
* sizeof(Fitness), cudaMemcpyDeviceToHost);
}
protected:
IncrementEval & incrEval;
};
#endif

View file

@ -0,0 +1,96 @@
/*
<moCudakernelEval.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Karima Boufaras, Thé Van LUONG
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef __moCudakernelEval_H
#define __moCudakernelEval_H
/**
* The kernel function called from the host and executed in device to compute all neighbors fitness at one time
* @param _eval how to evaluate each neighbor
* @param _solution representation of one max problem solution
* @param _allFitness Array of Fitness type to save all neighbors fitness
* @param _fitness the current solution fitness
* @param _neighborhoodsize the size of the neighborhood
*/
template<class EOT, class Fitness, class Neighbor, class IncrementEval>
__global__ void kernelEval(IncrementEval _eval, EOT _solution, Fitness* _allFitness,
Fitness _fitness, unsigned _neighborhoodsize) {
// The thread identifier within a grid block's
int id = blockIdx.x * blockDim.x + threadIdx.x;
// In this representation each id identify one and only one neighbor in neighborhood
if (id < _neighborhoodsize) {
//Compute fitness for id'th neighbor
_allFitness[id] = _eval(_solution, _fitness, id);
}
}
/**
* The kernel function called from the host and executed in device to compute all neighbors fitness at one time
* @param _eval how to evaluate each neighbor
* @param _solution representation of one max problem solution
* @param _allFitness Array of Fitness type to save all neighbors fitness
* @param _fitness the current solution fitness
* @param _neighborhoodsize the size of the neighborhood
*/
template<class EOT, class Fitness, class Neighbor, class IncrementEval>
__global__ void kernelKswap(IncrementEval _eval, EOT _solution, Fitness* _allFitness,
Fitness _fitness, unsigned _neighborhoodsize, unsigned * _mapping,unsigned _Kswap) {
// The thread identifier within a grid block's
int id = blockIdx.x * blockDim.x + threadIdx.x;
unsigned tmp;
unsigned i;
unsigned index;
// In this representation each id identify one and only one neighbor in neighborhood
if (id < _neighborhoodsize) {
tmp=_fitness;
for(i=0;i<=_Kswap;i++){
index=_mapping[id + i * _neighborhoodsize];
tmp= _eval(_solution, tmp, index);
}
_allFitness[id]=tmp;
}
}
#endif

View file

@ -0,0 +1,82 @@
/*
<moCudaAllocator.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Boufaras Karima, Thé Van Luong
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef _moCudaAllocator_H_
#define _moCudaAllocator_H_
// CUDA includes
#include <cutil.h>
/**
* class for allocation data on GPU global memory
*/
template<typename T>
class moCudaAllocator {
public:
/**
* Constructor
*/
moCudaAllocator() {
}
/**
*Allocate data on GPU global memory
*@param _data the data to allocate on GPU global memory
*@param _dataSize the size of data to allocate on GPU memory
*/
void operator()(T* & _data, unsigned _dataSize) {
//Allocate data in GPU memory
CUDA_SAFE_CALL(cudaMalloc((void**) &_data, _dataSize * sizeof(T)));
// Check if data allocation was successfuly done
CUT_CHECK_ERROR("Allocation of data on GPU global memory failed");
}
/**
* Destructor
*/
~moCudaAllocator() {
}
};
#endif

View file

@ -0,0 +1,106 @@
/*
<moCudaCopy.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Boufaras Karima, Thé Van Luong
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef _moCudaCopy_H_
#define _moCudaCopy_H_
// CUDA includes
#include <cutil.h>
/**
* class to copy data from CPU memory to GPU global memory and vice versa
*/
template<typename T>
class moCudaCopy {
public:
/**
* Constructor
*/
moCudaCopy() {
}
/**
*Copy data from CPU memory to GPU global memory (default copy)
*@param _data the data representation where the data will be copied
*@param _dataTocpy the data to copy from CPU memory to GPU memory
*@param _dataSize the size of data to copy
*/
void operator()(T* & _data, T * _dataTocpy, unsigned _dataSize) {
//copy data from CPU memeory to GPU memory
CUDA_SAFE_CALL(cudaMemcpy(_data, _dataTocpy, _dataSize * sizeof(T),
cudaMemcpyHostToDevice));
// Check if data was successfuly copied
CUT_CHECK_ERROR("Copy of data from CPU to GPU global memory failed");
}
/**
*Copy data from CPU memory to GPU global memory and vice versa
*@param _data the data representation where the data will be copied
*@param _dataTocpy the data to copy from CPU memory to GPU memory and vice versa
*@param _dataSize the size of data to copy
*@param _HostToDevice the direction of copy(true if copy will be done from CPU memory to GPU memory)
*/
void operator()(T* & _data, T * _dataTocpy, unsigned _dataSize,
bool _HostToDevice) {
if (_HostToDevice) {
//copy data from CPU memory to GPU memory
CUDA_SAFE_CALL(cudaMemcpy(_data, _dataTocpy, _dataSize * sizeof(T),
cudaMemcpyHostToDevice));
// Check if data was successfuly copied
CUT_CHECK_ERROR("Copy of data from CPU to GPU global memory failed");
} else {
cudaMemcpy(_data, _dataTocpy, _dataSize * sizeof(T),
cudaMemcpyDeviceToHost);
// Check if data was successfuly copied from GPU memory to CPU memory
CUT_CHECK_ERROR("Copy of data from GPU global memory to CPU failed");
}
}
~moCudaCopy() {
}
};
#endif

View file

@ -0,0 +1,82 @@
/*
<moCudaDesallocator.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Boufaras Karima, Thé Van Luong
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef _moCudaDesallocator_H_
#define _moCudaDesallocator_H_
// CUDA includes
#include <cutil.h>
/**
* class for allocation data on GPU global memory
*/
template<typename T>
class moCudaDesallocator {
public:
/**
* Constructor
*/
moCudaDesallocator() {
}
/**
*Desallocate data on GPU global memory
*@param _data the data to allocate on GPU global memory
*@param _dataSize the size of data to allocate on GPU memory
*/
void operator()(T* & _data) {
//Allocate data in GPU memory
CUDA_SAFE_CALL(cudaFree(_data));
// Check if data allocation was successfuly done
CUT_CHECK_ERROR("Desallocation of data on GPU global memory failed");
}
/**
* Destructor
*/
~moCudaDesallocator() {
}
};
#endif

View file

@ -0,0 +1,106 @@
/*
<moCudaBitFlippingNeighbor.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Boufaras Karima, Thé Van Luong
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can ue,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef _moCudaBitFlippingNeighbor_h
#define _moCudaBitFlippingNeighbor_h
#include <neighborhood/moCudaKswapNeighbor.h>
/**
* Inversion of N bits
*/
template<class EOT, class Fitness = typename EOT::Fitness>
class moCudaBitFlippingNeighbor: public moCudaKswapNeighbor<EOT> {
using moCudaKswapNeighbor<EOT>::indices;
using moCudaKswapNeighbor<EOT>::Kswap;
using moCudaKswapNeighbor<EOT>::size;
public:
/**
*Default Constructor
*/
moCudaBitFlippingNeighbor() :
moCudaKswapNeighbor() {
}
/**
* Constructor
* @param _Kflip the number of bit to flip
*/
moCudaBitFlippingNeighbor(unsigned int _Kflip) :
moCudaKswapNeighbor(_Kflip) {
}
/**
* Apply the K-Flip in solution
* @param _solution the solution to move
*/
virtual void move(EOT& _solution) {
size = _solution.size();
if (!Kswap) {
_solution[indices[Kswap]] = !_solution[indices[Kswap]];
} else {
for (unsigned int i = 0; i <= Kswap; i++) {
_solution[indices[i]] = !_solution[indices[i]];
std::cout << "indices[" << i << "]= " << indices[i]
<< std::endl;
}
}
_solution.invalidate();
}
/**
* apply the K-Flip to restore the solution (use by moFullEvalByModif)
* @param _solution the solution to move back
*/
virtual void moveBack(EOT& _solution) {
move(_solution);
}
/**
* Return the class name.
* @return the class name as a std::string
*/
virtual std::string className() const {
return "moCudaBitFlippingNeighbor";
}
};
#endif

View file

@ -0,0 +1,121 @@
/*
<CudaBitNeighbor.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Jerémie Humeau, Boufaras Karima, Thé Van LUONG
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef _moCudaBitNeighbor_h
#define _moCudaBitNeighbor_h
#include <neighborhood/moBackableNeighbor.h>
#include <neighborhood/moIndexNeighbor.h>
/**
* Neighbor related to a solution vector of EOT (type)
*/
template<class EOT, class Fitness = typename EOT::Fitness>
class moCudaBitNeighbor: public moBackableNeighbor<EOT, Fitness> ,
public moIndexNeighbor<EOT, Fitness> {
public:
using moBackableNeighbor<EOT, Fitness>::fitness;
using moIndexNeighbor<EOT, Fitness>::key;
/**
* move the solution
* @param
* _solution the solution to move
*/
virtual void move(EOT & _solution) {
_solution[key] = !_solution[key];
}
/**
* move back the solution (useful for the evaluation by modif)
* @param
* _solution the solution to move back
*/
virtual void moveBack(EOT & _solution) {
_solution[key] = !_solution[key];
}
/**
* Return the class name.
* @return the class name as a std::string
*/
virtual std::string className() const {
return "moCudaBitNeighbor";
}
/**
* Read object.\
* Calls base class, just in case that one had something to do.
* The read and print methods should be compatible and have the same format.
* In principle, format is "plain": they just print a number
* @param _is a std::istream.
* @throw runtime_std::exception If a valid object can't be read.
*/
virtual void readFrom(std::istream& _is) {
std::string fitness_str;
int pos = _is.tellg();
_is >> fitness_str;
if (fitness_str == "INVALID") {
throw std::runtime_error("invalid fitness");
} else {
Fitness repFit;
_is.seekg(pos);
_is >> repFit;
_is >> key;
fitness(repFit);
}
}
/**
* Write object. Called printOn since it prints the object _on_ a stream.
* @param _os A std::ostream.
*/
virtual void printOn(std::ostream& _os) const {
_os << fitness() << ' ' << key << std::endl;
}
};
#endif

View file

@ -0,0 +1,115 @@
/*
<moKswapNeighborhood.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Boufaras Karima, Thé Van Luong
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can ue,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef _moCudaKswapNeighborhood_h
#define _moCudaKswapNeighborhood_h
#include <neighborhood/moKswapNeighborhood.h>
#include <eval/moCudaEval.h>
/**
* K-Swap Neighborhood
*/
template<class N>
class moCudaKswapNeighborhood: public moKswapNeighborhood<N> {
public:
typedef N Neighbor;
typedef typename Neighbor::EOT EOT;
using moKswapNeighborhood<Neighbor>::neighborhoodSize;
using moKswapNeighborhood<Neighbor>::currentIndex;
using moKswapNeighborhood<Neighbor>::indices;
using moKswapNeighborhood<Neighbor>::mapping;
using moKswapNeighborhood<Neighbor>::Kswap;
using moKswapNeighborhood<Neighbor>::size;
using moKswapNeighborhood<Neighbor>::mutex;
/**
* Constructor
* @param _size the size of solution
* @param _size the solution size
* @param _Kswap the number of swap
* @param _eval show how to evaluate neighborhood of a solution at one time
*/
moCudaKswapNeighborhood(unsigned int _size, unsigned int _Kswap,
moCudaEval<Neighbor>& _eval) :
moKswapNeighborhood<Neighbor> (_size, _Kswap), eval(_eval) {
sendMapping = true;
cudaMalloc((void**) &device_Mapping, sizeof(unsigned int)
* neighborhoodSize * (Kswap + 1));
}
;
/**
*Destructor
*/
~moCudaKswapNeighborhood() {
cudaFree(device_Mapping);
}
/**
* Initialization of the neighborhood
* @param _solution the solution to explore
* @param _current the first neighbor
*/
virtual void init(EOT& _solution, Neighbor& _current) {
moKswapNeighborhood<Neighbor>::init(_solution, _current);
if (sendMapping) {
cudaMemcpy(device_Mapping, mapping, (Kswap + 1) * neighborhoodSize * sizeof(unsigned int),
cudaMemcpyHostToDevice);
sendMapping = false;
}
//Compute all neighbors fitness at one time
eval.neighborhoodEval(_solution, device_Mapping, Kswap);
}
/**
* Return the class Name
* @return the class name as a std::string
*/
virtual std::string className() const {
return "moCudaKSwapNeighborhood";
}
protected:
moCudaEval<Neighbor>& eval;
bool sendMapping;
unsigned int * device_Mapping;
};
#endif

View file

@ -0,0 +1,96 @@
/*
<moCudaOrderNeighborhood.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Jerémie Humeau, Thé Van LUONG, Karima Boufaras
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef _moCudaOrderNeighborhood_h
#define _moCudaOrderNeighborhood_h
#include <neighborhood/moOrderNeighborhood.h>
#include <eval/moCudaEval.h>
/**
* An ordered neighborhood with parallel evaluation
*/
template<class N>
class moCudaOrderNeighborhood: public moOrderNeighborhood<N> {
public:
/**
* Define type of a solution corresponding to Neighbor
*/
typedef N Neighbor;
typedef typename Neighbor::EOT EOT;
using moOrderNeighborhood<Neighbor>::neighborhoodSize;
using moOrderNeighborhood<Neighbor>::currentIndex;
/**
* Constructor
* @param _neighborhoodSize the size of the neighborhood
* @param _eval show how to evaluate neighborhood of a solution at one time
*/
moCudaOrderNeighborhood(unsigned int _neighborhoodSize,
moCudaEval<Neighbor>& _eval) :
moOrderNeighborhood<Neighbor> (_neighborhoodSize), eval(_eval) {
}
/**
* Initialization of the neighborhood
*@param _solution the solution to explore
*@param _neighbor the first neighbor
*/
virtual void init(EOT & _solution, Neighbor & _neighbor) {
moOrderNeighborhood<Neighbor>::init(_solution, _neighbor);
//Compute all neighbors fitness at one time
eval.neighborhoodEval(_solution);
}
/**
* Return the class name.
* @return the class name as a std::string
*/
virtual std::string className() const {
return "moCudaOrderNeighborhood";
}
protected:
moCudaEval<Neighbor>& eval;
};
#endif

View file

@ -0,0 +1,88 @@
/*
<moCudaRndWithReplNeighborhood.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Jerémie Humeau, Karima Boufaras, Thé Van LUONG
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef _moCudaRndWithReplNeighborhood_h
#define _moCudaRndWithReplNeighborhood_h
#include <neighborhood/moRndWithReplNeighborhood.h>
#include <eval/moCudaEval.h>
/**
* A Random With replacement Neighborhood with parallel evaluation
*/
template<class Neighbor>
class moCudaRndWithReplNeighborhood: public moRndWithReplNeighborhood<Neighbor> {
public:
/**
* Define type of a solution corresponding to Neighbor
*/
typedef typename Neighbor::EOT EOT;
using moRndWithReplNeighborhood<Neighbor>::neighborhoodSize;
/**
* Constructor
* @param _neighborhoodSize the size of the neighborhood
* @param _eval show how to evaluate neighborhood of a solution at one time
*/
moCudaRndWithReplNeighborhood(unsigned int _neighborhoodSize, moCudaEval<
Neighbor>& _eval) :
moRndWithReplNeighborhood<Neighbor> (_neighborhoodSize), eval(_eval) {
}
/**
* Initialization of the neighborhood
* @param _solution the solution to explore
* @param _neighbor the first neighbor
*/
virtual void init(EOT & _solution, Neighbor & _neighbor) {
moRndWithReplNeighborhood<Neighbor>::init(_solution, _neighbor);
//Compute all neighbors fitness at one time
eval.neighborhoodEval(_solution);
}
/**
* Return the class Name
* @return the class name as a std::string
*/
virtual std::string className() const {
return "moCudaRndWithReplNeighborhood";
}
protected:
moCudaEval<Neighbor>& eval;
};
#endif

View file

@ -0,0 +1,90 @@
/*
<moCudaRndWithoutReplNeighborhood.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Jerémie Humeau, Boufaras Karima, Thé Van LUONG
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef _moCudaRndWithoutReplNeighborhood_h
#define _moCudaRndWithoutReplNeighborhood_h
#include <neighborhood/moRndWithoutReplNeighborhood.h>
#include <eval/moCudaEval.h>
/**
* A Random without replacement Neighborhood with parallel evaluation
*/
template<class Neighbor>
class moCudaRndWithoutReplNeighborhood: public moRndWithoutReplNeighborhood<Neighbor> {
public:
/**
* Define type of a solution corresponding to Neighbor
*/
typedef typename Neighbor::EOT EOT;
using moRndWithoutReplNeighborhood<Neighbor>::neighborhoodSize;
using moRndWithoutReplNeighborhood<Neighbor>::maxIndex;
using moRndWithoutReplNeighborhood<Neighbor>::indexVector;
/**
* Constructor
* @param _neighborhoodSize the size of the neighborhood
* @param _eval show how to evaluate neighborhood of a solution at one time
*/
moCudaRndWithoutReplNeighborhood(unsigned int _neighborhoodSize,moCudaEval<
Neighbor>& _eval) :
moRndWithoutReplNeighborhood<Neighbor> (_neighborhoodSize),eval(_eval) {
for (unsigned int i = 0; i < neighborhoodSize; i++)
indexVector.push_back(i);
}
/**
* Initialization of the neighborhood
* @param _solution the solution to explore
* @param _neighbor the first neighbor
*/
virtual void init(EOT & _solution, Neighbor & _neighbor) {
moRndWithoutReplNeighborhood<Neighbor>::init(_solution, _neighbor);
//Compute all neighbors fitness at one time
eval.neighborhoodEval(_solution);
}
/**
* Return the class Name
* @return the class name as a std::string
*/
virtual std::string className() const {
return "moCudaRndWithoutReplNeighborhood";
}
protected:
moCudaEval<Neighbor>& eval;
};
#endif

View file

@ -0,0 +1,116 @@
/*
<moCudaTimer.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Thé Van LUONG, Karima Boufaras
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef _moCudaTimer_H_
#define _moCudaTimer_H_
// CUDA Utility Tools
#include <cutil.h>
/**
* To compute execution time
*/
class moCudaTimer {
public:
unsigned int timer;
/**
* Constructor
*/
moCudaTimer() {
timer = 0;
//Create timer
cutCreateTimer(&timer);
}
/**
* Destructor
*/
~moCudaTimer() {
}
/**
* to start compute execution time
*/
void start() {
// Start timer
cutStartTimer(timer);
}
/**
* to stop compute execution time
*/
void stop() {
// Stop timer
cutStopTimer(timer);
}
/**
* to get timer value in ms
* @return execution time in ms
*/
double getTime() {
// get time
return cutGetTimerValue(timer);
}
/**
* to delete timer
*/
void deleteTimer() {
//Delete timer
cutDeleteTimer(timer);
}
};
#endif

View file

@ -0,0 +1,79 @@
/*
<EvalOneMax.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Karima Boufaras, Thé Van LUONG
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef __EvalOneMax
#define __EvalOneMax
/**
* Full Evaluation of the solution
*/
template<class EOT>
class EvalOneMax: public eoEvalFunc<EOT> {
public:
/**
* Constructor
*/
EvalOneMax() {
}
/**
* Destructor
*/
~EvalOneMax(void) {
}
/**
* Full evaluation of the solution
* @param _bitVector the solution to evaluate
*/
void operator()(EOT & _bitVector) {
unsigned sum = 0;
for (unsigned i = 0; i < _bitVector.size(); i++)
sum += _bitVector[i];
//set the solution fitness
_bitVector.fitness(sum);
}
};
#endif

View file

@ -0,0 +1,90 @@
/*
<OneMaxIncrEval.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Karima Boufaras, Thé Van LUONG
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef __OneMaxIncrEval_H
#define __OneMaxIncrEval_H
#include <eval/moCudaEvalFunc.h>
/**
* Incremental Evaluation of OneMax
*/
template<class Neighbor>
class OneMaxIncrEval: public moCudaEvalFunc<Neighbor> {
public:
typedef typename Neighbor::EOT EOT;
typedef typename EOT::Fitness Fitness;
/**
* Constructor
*/
OneMaxIncrEval() {
}
/**
* Destructor
*/
~OneMaxIncrEval() {
}
/**
* Incremental evaluation of the solution(function inline can be called from host or device)
* @param _bitVector the solution to evaluate
* @param _fitness the fitness of the current solution
* @param _id the index of solution neighbor
*/
inline __host__ __device__ Fitness operator() (EOT & _bitVector,Fitness _fitness, unsigned _id) {
Fitness tmp;
if (_bitVector[_id] == 0)
tmp= _fitness+1;
else
tmp= _fitness-1;
return tmp;
}
};
#endif

View file

@ -0,0 +1,73 @@
###############################################################################
##
## CMakeLists file for OneMax Example/test
##
###############################################################################
######################################################################################
### 1) Include the sources
######################################################################################
INCLUDE_DIRECTORIES(
# include CUDA source directory
${CUDA_SRC_DIR}
# include NVIDIA source directory
${NVIDIA_SRC_DIR}
# include EO source directory
${PARADISEO_EO_SRC_DIR}/src
# include MO source directory
${PARADISEO_MO_SRC_DIR}/src
# include problems directory
${PARADISEO_PROBLEMS_SRC_DIR}
# include GPU directory
${PARADISEO_GPU_SRC_DIR}
# include your source directory
${CMAKE_CURRENT_SOURCE_DIR}/../src
)
######################################################################################
### 2) Specify where CMake can find the libraries
######################################################################################
LINK_DIRECTORIES(${PARADISEO_EO_BIN_DIR}/lib ${NVIDIA_LIB_DIR} ${CUDA_LIB_DIR} )
######################################################################################
######################################################################################
### 3) Define your targets and link the librairies
######################################################################################
SET (TEST_LIST
t-memory
t-moCudaBitVector
t-moCudaIntVector
t-moCudaBitNeighbor
t-OneMaxIncrEval
t-EvalOneMax
# t-moCudaKswapNeighborhood
)
FOREACH (test ${TEST_LIST})
SET ("T_${test}_SOURCES" "${test}.cu")
ENDFOREACH (test)
IF(ENABLE_CMAKE_TESTING)
# Add the tests
FOREACH (test ${TEST_LIST})
CUDA_ADD_EXECUTABLE(${test} ${T_${test}_SOURCES})
ADD_TEST(${test} ${test})
ENDFOREACH (test)
# Link the librairies
FOREACH (test ${TEST_LIST})
TARGET_LINK_LIBRARIES(${test} ga es eoutils eo)
ENDFOREACH (test)
ENDIF(ENABLE_CMAKE_TESTING)
######################################################################################

View file

@ -0,0 +1,67 @@
/*
<t-EvalOneMax.cu>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Karima Boufaras, Thé Van LUONG
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include <cstdlib>
#include <cassert>
#include <iostream>
#include <cudaType/moCudaBitVector.h>
#include <problems/eval/EvalOneMax.h>
typedef moCudaBitVector<eoMaximizingFitness> Solution;
int main() {
std::cout << "[t-EvalOneMax] => START" << std::endl;
Solution sol(5);
EvalOneMax<Solution> eval;
int sum=0;
eval(sol);
for(int i=0;i<5;i++){
sum+=sol[i];
sol[i]=0;
}
assert((int)(sol.fitness())==sum);
eval(sol);
assert((int)(sol.fitness())==0);
std::cout << "[t-EvalOneMax] => OK" << std::endl;
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,84 @@
/*
<t-OneMaxIncrEval.cu>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Karima Boufaras, Thé Van LUONG
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include <cstdlib>
#include <cassert>
#include <iostream>
#include <neighborhood/moCudaBitNeighbor.h>
#include <cudaType/moCudaBitVector.h>
#include <problems/eval/EvalOneMax.h>
#include <problems/eval/OneMaxIncrEval.h>
typedef moCudaBitVector<eoMaximizingFitness> Solution;
typedef moCudaBitNeighbor <Solution,eoMaximizingFitness> Neighbor;
int main() {
std::cout << "[t-OneMaxIncrEval] => START" << std::endl;
Solution sol(5);
EvalOneMax<Solution> eval;
OneMaxIncrEval<Neighbor> incr_eval;
int sum=0;
int fitness=0;
eval(sol);
for(int i=0;i<5;i++){
sum+=sol[i];
sol[i]=0;
}
assert((int)(sol.fitness())==sum);
eval(sol);
assert((int)(sol.fitness())==0);
fitness=incr_eval(sol,fitness,0);
sol[0]=1;
eval(sol);
assert((int)(sol.fitness())==1);
fitness=incr_eval(sol,fitness,0);
sol[0]=0;
eval(sol);
assert((int)(sol.fitness())==0);
std::cout << "[t-OneMaxIncrEval] => OK" << std::endl;
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,91 @@
/*
<t-memory.cu>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Thé Van LUONG, Karima Boufaras
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include <cstdlib>
#include <cassert>
#include <iostream>
#include <memory/moCudaAllocator.h>
#include <memory/moCudaDesallocator.h>
#include <memory/moCudaCopy.h>
int main() {
std::cout << "[t-memory] => START" << std::endl;
//test constructor
int * h_data;
int * cpy_data;
int * d_data;
moCudaAllocator<int> alloc;
moCudaDesallocator<int> desalloc;
moCudaCopy<int> cpy;
int i=0;
//data allocation
h_data= new int[5];
cpy_data= new int[5];
alloc(d_data,5);
for(i=0;i<5;i++)
h_data[i]=i;
//test default way of copy from host to device
cpy(d_data,h_data,5);
//test copy from device to host
cpy(cpy_data,d_data,5,0);
i=0;
for(i=0;i<5;i++)
assert(cpy_data[i]==i);
for(i=0;i<5;i++)
h_data[i]=i*2;
//test copy from host to device
cpy(d_data,h_data,5,1);
//test copy from device to host
cpy(cpy_data,d_data,5,0);
i=0;
for(i=0;i<5;i++)
assert(cpy_data[i]==i*2);
desalloc(d_data);
std::cout << "[t-memory] => OK" << std::endl;
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,71 @@
/*
<t-moCudaBitNeighbor.cu>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Thé Van LUONG, Karima Boufaras
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include <cstdlib>
#include <cassert>
#include <iostream>
#include <cudaType/moCudaBitVector.h>
#include <neighborhood/moCudaBitNeighbor.h>
typedef moCudaBitVector<eoMaximizingFitness> Solution;
typedef moCudaBitNeighbor<Solution,eoMaximizingFitness> Neighbor;
int main() {
std::cout << "[t-moCudaBitNeighbor] => START" << std::endl;
//test constructor
Neighbor test1, test2;
test1.fitness(3);
//test operateur d'affectation
test2=test1;
assert(test1.fitness()==test2.fitness());
//test operateur de copy
Neighbor test3(test1);
assert(test1.fitness()==test3.fitness());
test1.printOn(std::cout);
test2.printOn(std::cout);
test3.printOn(std::cout);
assert(test1.className()=="moCudaBitNeighbor");
std::cout << "[t-moCudaBitNeighbor] => OK" << std::endl;
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,94 @@
/*
<t-moCudaBitVector.cu>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Thé Van LUONG, Karima Boufaras
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include <cstdlib>
#include <cassert>
#include <iostream>
#include <cudaType/moCudaBitVector.h>
#include <problems/eval/EvalOneMax.h>
#include <eo>
typedef moCudaBitVector<eoMaximizingFitness> Solution;
int main() {
std::cout << "[t-moCudaBitVector] => START" << std::endl;
EvalOneMax<Solution> eval;
//verif default constructor
Solution sol;
assert(sol.size()==1);
//verif constructor of random vector
Solution sol1(5);
assert(sol1.size()==5);
//verif bool
for(int i=0;i<5;i++)
assert((sol1[i]==0)||(sol1[i]==1));
//test oneMax eval function
eval(sol1);
eoMaximizingFitness sum=0;
for(int i=0;i<5;i++)
sum=sol1[i]+sum;
assert(sol1.fitness()==sum);
//verif constructor of constant vector
Solution sol2(4,1);
assert(sol2.size()==4);
for(int i=0;i<4;i++)
assert(sol2[i]==1);
eval(sol2);
assert(sol2.fitness()==4);
//verif accessor
sol2[3]=0;
assert(sol2[3]==0);
eval(sol2);
assert(sol2.fitness()==3);
//verif operator =
sol2=sol1;
assert(sol1.size()==sol2.size());
assert(sol1.fitness()==sol2.fitness());
for(int i=0;i<5;i++)
assert(sol1[i]==sol2[i]);
std::cout << "[t-moCudaBitVector] => OK" << std::endl;
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,70 @@
/*
<t-moCudaIntVector.cu>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Thé Van LUONG, Karima Boufaras
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include <cstdlib>
#include <cassert>
#include <iostream>
#include <cudaType/moCudaIntVector.h>
#include <eo>
typedef moCudaIntVector<eoMaximizingFitness> Solution;
int main() {
std::cout << "[t-moCudaIntVector] => START" << std::endl;
//verif constructor
Solution sol;
Solution sol1(5);
Solution sol2(3);
assert(sol.size()==1);
assert(sol1.size()==5);
assert(sol2.size()==3);
//verif discret vector
for(int i=0;i<5;i++)
assert((sol1[i]>=0)||(sol1[i]<5));
//verif discret vector
for(int i=0;i<3;i++)
assert((sol2[i]>=0)||(sol2[i]<3));
std::cout << "[t-moCudaIntVector] => OK" << std::endl;
return EXIT_SUCCESS;
}

View file

@ -0,0 +1 @@
ADD_SUBDIRECTORY(OneMax)

View file

@ -0,0 +1,60 @@
###############################################################################
##
## CMakeLists file for OneMax Example/application
##
###############################################################################
######################################################################################
### 1) Include the sources
######################################################################################
INCLUDE_DIRECTORIES(
# include CUDA source directory
${CUDA_SRC_DIR}
# include NVIDIA source directory
${NVIDIA_SRC_DIR}
# include EO source directory
${PARADISEO_EO_SRC_DIR}/src
# include MO source directory
${PARADISEO_MO_SRC_DIR}/src
# include problems directory
${PARADISEO_PROBLEMS_SRC_DIR}
# include GPU directory
${PARADISEO_GPU_SRC_DIR}
# include your source directory
${CMAKE_CURRENT_SOURCE_DIR}/../src
)
######################################################################################
######################################################################################
### 2) Specify where CMake can find the libraries
######################################################################################
LINK_DIRECTORIES(${PARADISEO_EO_BIN_DIR}/lib ${NVIDIA_LIB_DIR} ${CUDA_LIB_DIR} )
######################################################################################
######################################################################################
### 3) Define your targets and link the librairies
######################################################################################
#CUDA_ADD_EXECUTABLE(Cutest test.cu)
CUDA_ADD_EXECUTABLE(CutestFirstImpr testFirstImpr.cu)
CUDA_ADD_EXECUTABLE(CutestNeutralHC testNeutralHC.cu)
CUDA_ADD_EXECUTABLE(CutestSimpleHC testSimpleHC.cu)
CUDA_ADD_EXECUTABLE(CutestSimpleTS testSimpleTS.cu)
CUDA_ADD_EXECUTABLE(CutestSimulatedAnnealing testSimulatedAnnealing.cu)
CUDA_ADD_EXECUTABLE(CutestKswapHC testKswapHC.cu)
#TARGET_LINK_LIBRARIES(Cutest eoutils ga eo libcutil.a)
TARGET_LINK_LIBRARIES(CutestFirstImpr eoutils ga eo libcutil.a)
TARGET_LINK_LIBRARIES(CutestNeutralHC eoutils ga eo libcutil.a)
TARGET_LINK_LIBRARIES(CutestSimpleHC eoutils ga eo libcutil.a)
TARGET_LINK_LIBRARIES(CutestSimpleTS eoutils ga eo libcutil.a)
TARGET_LINK_LIBRARIES(CutestSimulatedAnnealing eoutils ga eo libcutil.a)
TARGET_LINK_LIBRARIES(CutestKswapHC eoutils ga eo libcutil.a)
######################################################################################

View file

@ -0,0 +1,222 @@
//Init the number of threads per block
#define BLOCK_SIZE 128
#include <iostream>
#include <stdlib.h>
using namespace std;
// The general include for eo
#include <eo>
#include <ga.h>
// Fitness function
#include <problems/eval/EvalOneMax.h>
// Cuda Fitness function
#include <eval/moCudaVectorEval.h>
#include <problems/eval/OneMaxIncrEval.h>
// One Max solution
#include <cudaType/moCudaBitVector.h>
//To compute execution time
#include <performance/moCudaTimer.h>
// One Max neighbor
#include <neighborhood/moCudaBitNeighbor.h>
// One Max ordered neighborhood
#include <neighborhood/moCudaOrderNeighborhood.h>
// The Solution and neighbor comparator
#include <comparator/moNeighborComparator.h>
#include <comparator/moSolNeighborComparator.h>
// The continuator
#include <continuator/moTrueContinuator.h>
// Local search algorithm
#include <algo/moLocalSearch.h>
// First improvment algorithm
#include <algo/moFirstImprHC.h>
// The First Improvment algorithm explorer
#include <explorer/moFirstImprHCexplorer.h>
// REPRESENTATION
typedef moCudaBitVector<eoMaximizingFitness> solution;
typedef moCudaBitNeighbor <solution,eoMaximizingFitness> Neighbor;
typedef moCudaOrderNeighborhood<Neighbor> Neighborhood;
void main_function(int argc, char **argv)
{
/* =========================================================
*
* Parameters
*
* ========================================================= */
// First define a parser from the command-line arguments
eoParser parser(argc, argv);
// For each parameter, define Parameter, read it through the parser,
// and assign the value to the variable
// seed
eoValueParam<uint32_t> seedParam(time(0), "seed", "Random number seed", 'S');
parser.processParam( seedParam );
unsigned seed = seedParam.value();
// description of genotype
eoValueParam<unsigned int> vecSizeParam(8, "vecSize", "Genotype size", 'V');
parser.processParam( vecSizeParam, "Representation" );
unsigned vecSize = vecSizeParam.value();
// the name of the "status" file where all actual parameter values will be saved
string str_status = parser.ProgramName() + ".status"; // default value
eoValueParam<string> statusParam(str_status.c_str(), "status", "Status file");
parser.processParam( statusParam, "Persistence" );
// do the following AFTER ALL PARAMETERS HAVE BEEN PROCESSED
// i.e. in case you need parameters somewhere else, postpone these
if (parser.userNeedsHelp()) {
parser.printHelp(cout);
exit(1);
}
if (statusParam.value() != "") {
ofstream os(statusParam.value().c_str());
os << parser;// and you can use that file as parameter file
}
/* =========================================================
*
* Random seed
*
* ========================================================= */
//reproducible random seed: if you don't change SEED above,
// you'll aways get the same result, NOT a random run
rng.reseed(seed);
int seed1=time(0);
srand(seed1);
/* =========================================================
*
* Initilisation of the solution
*
* ========================================================= */
solution sol(vecSize);
if(vecSize<64)
for(unsigned i=0;i<vecSize;i++) cout<<sol[i]<<" ";
cout<<endl;
/* =========================================================
*
* Eval fitness function
*
* ========================================================= */
EvalOneMax<solution> eval;
/* =========================================================
*
* Evaluation of a solution neighbor's
*
* ========================================================= */
OneMaxIncrEval<Neighbor> incr_eval;
moCudaVectorEval<Neighbor,OneMaxIncrEval<Neighbor> > cueval(vecSize,incr_eval);
/* =========================================================
*
* Comparator of solutions and neighbors
*
* ========================================================= */
moNeighborComparator<Neighbor> comparator;
moSolNeighborComparator<Neighbor> solComparator;
/* =========================================================
*
* a solution neighborhood
*
* ========================================================= */
Neighborhood neighborhood(vecSize,cueval);
/* =========================================================
*
* An explorer of solution neighborhood's
*
* ========================================================= */
moFirstImprHCexplorer<Neighbor> explorer(neighborhood, cueval, comparator, solComparator);
/* =========================================================
*
* The local search algorithm
*
* ========================================================= */
// True continuator <=> Always continue
moTrueContinuator<Neighbor> continuator;
moLocalSearch<Neighbor> localSearch(explorer,continuator, eval);
/* =========================================================
*
* The First improvment algorithm
*
* ========================================================= */
moFirstImprHC<Neighbor> firstImprHC(neighborhood,eval,cueval);
/* =========================================================
*
* Execute the local search from random sollution
*
* ========================================================= */
//Can be eval here, else it will be done at the beginning of the localSearch
eval(sol);
std::cout << "initial: " << sol.fitness()<< std::endl;
moCudaTimer timer;
timer.start();
localSearch(sol);
timer.stop();
printf("CUDA execution time = %f ms\n",timer.getTime());
timer.deleteTimer();
std::cout << "final: " << sol.fitness() << std::endl;
/* =========================================================
*
* Execute the first improvment from random sollution
*
* ========================================================= */
solution sol1(vecSize);
if(vecSize<64)
for(unsigned i=0;i<vecSize;i++) cout<<sol1[i]<<" ";
cout<<endl;
cout<<endl;
eval(sol1);
std::cout << "initial: " << sol1.fitness()<< std::endl;
moCudaTimer timer1;
timer1.start();
firstImprHC(sol1);
timer1.stop();
printf("CUDA execution time = %f ms\n",timer1.getTime());
timer1.deleteTimer();
std::cout << "final: " << sol1.fitness() << std::endl;
}
// A main that catches the exceptions
int main(int argc, char **argv)
{
try{
main_function(argc, argv);
}
catch(exception& e){
cout << "Exception: " << e.what() << '\n';
}
return 1;
}

View file

@ -0,0 +1,180 @@
//Init the number of threads per block
#define BLOCK_SIZE 128
#include <iostream>
#include <stdlib.h>
using namespace std;
// The general include for eo
#include <eo>
#include <ga.h>
// Fitness function
#include <problems/eval/EvalOneMax.h>
// Cuda Fitness function
#include <eval/moCudaVectorEval.h>
#include <problems/eval/OneMaxIncrEval.h>
// One Max solution
#include <cudaType/moCudaBitVector.h>
//To compute execution time
#include <performance/moCudaTimer.h>
// One Max neighbor
#include <neighborhood/moCudaBitNeighbor.h>
// One Max ordered neighborhood
#include <neighborhood/moCudaOrderNeighborhood.h>
// The Solution and neighbor comparator
#include <comparator/moNeighborComparator.h>
#include <comparator/moSolNeighborComparator.h>
// The continuator
#include <continuator/moTrueContinuator.h>
// Simple HC algorithm
#include <algo/moNeutralHC.h>
// REPRESENTATION
typedef moCudaBitVector<eoMaximizingFitness> solution;
typedef moCudaBitNeighbor <solution,eoMaximizingFitness> Neighbor;
typedef moCudaOrderNeighborhood<Neighbor> Neighborhood;
void main_function(int argc, char **argv)
{
/* =========================================================
*
* Parameters
*
* ========================================================= */
// First define a parser from the command-line arguments
eoParser parser(argc, argv);
// For each parameter, define Parameter, read it through the parser,
// and assign the value to the variable
// seed
eoValueParam<uint32_t> seedParam(time(0), "seed", "Random number seed", 'S');
parser.processParam( seedParam );
unsigned seed = seedParam.value();
// description of genotype
eoValueParam<unsigned int> vecSizeParam(8, "vecSize", "Genotype size", 'V');
parser.processParam( vecSizeParam, "Representation" );
unsigned vecSize = vecSizeParam.value();
//nbStep maximum step to do
eoValueParam<unsigned int> nbStepParam(10, "nbStep", "maximum number of step", 'N');
parser.processParam( nbStepParam, "numberStep" );
unsigned nbStep = nbStepParam.value();
// the name of the "status" file where all actual parameter values will be saved
string str_status = parser.ProgramName() + ".status"; // default value
eoValueParam<string> statusParam(str_status.c_str(), "status", "Status file");
parser.processParam( statusParam, "Persistence" );
// do the following AFTER ALL PARAMETERS HAVE BEEN PROCESSED
// i.e. in case you need parameters somewhere else, postpone these
if (parser.userNeedsHelp()) {
parser.printHelp(cout);
exit(1);
}
if (statusParam.value() != "") {
ofstream os(statusParam.value().c_str());
os << parser;// and you can use that file as parameter file
}
/* =========================================================
*
* Random seed
*
* ========================================================= */
//reproducible random seed: if you don't change SEED above,
// you'll aways get the same result, NOT a random run
rng.reseed(seed);
/* =========================================================
*
* Initilisation of the solution
*
* ========================================================= */
solution sol(vecSize);
if(vecSize<64)
for(unsigned i=0;i<vecSize;i++) cout<<sol[i]<<" ";
cout<<endl;
/* =========================================================
*
* Eval fitness function
*
* ========================================================= */
EvalOneMax<solution> eval;
/* =========================================================
*
* Evaluation of a solution neighbor's
*
* ========================================================= */
OneMaxIncrEval<Neighbor> incr_eval;
moCudaVectorEval<Neighbor,OneMaxIncrEval<Neighbor> > cueval(vecSize,incr_eval);
/* =========================================================
*
* Comparator of solutions and neighbors
*
* ========================================================= */
moNeighborComparator<Neighbor> comparator;
moSolNeighborComparator<Neighbor> solComparator;
/* =========================================================
*
* a solution neighborhood
*
* ========================================================= */
Neighborhood neighborhood(vecSize,cueval);
/* =========================================================
*
* The simple Hill Climbing algorithm
*
* ========================================================= */
//True continuator <=> Always continue
moTrueContinuator<Neighbor> continuator;
moNeutralHC<Neighbor> neutralHC(neighborhood,eval,cueval,nbStep,continuator);
/* =========================================================
*
* Execute the neutralHill climbing from random sollution
*
* ========================================================= */
eval(sol);
std::cout << "initial: " << sol.fitness()<< std::endl;
moCudaTimer timer;
timer.start();
neutralHC(sol);
timer.stop();
printf("CUDA execution time = %f ms\n",timer.getTime());
timer.deleteTimer();
std::cout << "final: " << sol.fitness() << std::endl;
}
// A main that catches the exceptions
int main(int argc, char **argv)
{
try{
main_function(argc, argv);
}
catch(exception& e){
cout << "Exception: " << e.what() << '\n';
}
return 1;
}

View file

@ -0,0 +1,222 @@
//Init the number of threads per block
#define BLOCK_SIZE 128
#include <iostream>
#include <stdlib.h>
using namespace std;
// The general include for eo
#include <eo>
#include <ga.h>
// Fitness function
#include <problems/eval/EvalOneMax.h>
// Cuda Fitness function
#include <eval/moCudaVectorEval.h>
#include <problems/eval/OneMaxIncrEval.h>
// One Max solution
#include <cudaType/moCudaBitVector.h>
// One Max neighbor
#include <neighborhood/moCudaBitNeighbor.h>
//To compute execution time
#include <performance/moCudaTimer.h>
// One Max ordered neighborhood
#include <neighborhood/moCudaOrderNeighborhood.h>
// The Solution and neighbor comparator
#include <comparator/moNeighborComparator.h>
#include <comparator/moSolNeighborComparator.h>
// The continuator
#include <continuator/moTrueContinuator.h>
// Local search algorithm
#include <algo/moLocalSearch.h>
// Simple HC algorithm
#include <algo/moSimpleHC.h>
// The simple HC algorithm explorer
#include <explorer/moSimpleHCexplorer.h>
// REPRESENTATION
typedef moCudaBitVector<eoMaximizingFitness> solution;
typedef moCudaBitNeighbor <solution> Neighbor;
typedef moCudaOrderNeighborhood<Neighbor> Neighborhood;
void main_function(int argc, char **argv)
{
/* =========================================================
*
* Parameters
*
* ========================================================= */
// First define a parser from the command-line arguments
eoParser parser(argc, argv);
// For each parameter, define Parameter, read it through the parser,
// and assign the value to the variable
// seed
eoValueParam<uint32_t> seedParam(time(0), "seed", "Random number seed", 'S');
parser.processParam( seedParam );
unsigned seed = seedParam.value();
// description of genotype
eoValueParam<unsigned int> vecSizeParam(8, "vecSize", "Genotype size", 'V');
parser.processParam( vecSizeParam, "Representation" );
unsigned vecSize = vecSizeParam.value();
// the name of the "status" file where all actual parameter values will be saved
string str_status = parser.ProgramName() + ".status"; // default value
eoValueParam<string> statusParam(str_status.c_str(), "status", "Status file");
parser.processParam( statusParam, "Persistence" );
// do the following AFTER ALL PARAMETERS HAVE BEEN PROCESSED
// i.e. in case you need parameters somewhere else, postpone these
if (parser.userNeedsHelp()) {
parser.printHelp(cout);
exit(1);
}
if (statusParam.value() != "") {
ofstream os(statusParam.value().c_str());
os << parser;// and you can use that file as parameter file
}
/* =========================================================
*
* Random seed
*
* ========================================================= */
//reproducible random seed: if you don't change SEED above,
// you'll aways get the same result, NOT a random run
rng.reseed(seed);
/* =========================================================
*
* Initilisation of the solution
*
* ========================================================= */
solution sol(vecSize);
if(vecSize<64)
for(unsigned i=0;i<vecSize;i++) cout<<sol[i]<<" ";
cout<<endl;
/* =========================================================
*
* Eval fitness function
*
* ========================================================= */
EvalOneMax<solution> eval;
/* =========================================================
*
* Evaluation of a solution neighbor's
*
* ========================================================= */
OneMaxIncrEval<Neighbor> incr_eval;
moCudaVectorEval<Neighbor,OneMaxIncrEval<Neighbor> > cueval(vecSize,incr_eval);
/* =========================================================
*
* Comparator of solutions and neighbors
*
* ========================================================= */
moNeighborComparator<Neighbor> comparator;
moSolNeighborComparator<Neighbor> solComparator;
/* =========================================================
*
* a solution neighborhood
*
* ========================================================= */
Neighborhood neighborhood(vecSize,cueval);
/* =========================================================
*
* An explorer of solution neighborhood's
*
* ========================================================= */
moSimpleHCexplorer<Neighbor> explorer(neighborhood, cueval,
comparator, solComparator);
/* =========================================================
*
* The local search algorithm
*
* ========================================================= */
//True continuator <=> Always continue
moTrueContinuator<Neighbor> continuator;
moLocalSearch<Neighbor> localSearch(explorer,continuator, eval);
/* =========================================================
*
* The simple Hill Climbing algorithm
*
* ========================================================= */
moSimpleHC<Neighbor> simpleHC(neighborhood,eval,cueval);
/* =========================================================
*
* Execute the local search from random sollution
*
* ========================================================= */
//Can be eval here, else it will be done at the beginning of the localSearch
eval(sol);
std::cout << "initial: " << sol.fitness()<< std::endl;
// Create timer for timing CUDA calculation
moCudaTimer timer;
timer.start();
localSearch(sol);
timer.stop();
printf("CUDA execution time = %f ms\n",timer.getTime());
timer.deleteTimer();
std::cout << "final: " << sol.fitness() << std::endl;
/* =========================================================
*
* Execute the Simple Hill climbing from random sollution
*
* ========================================================= */
solution sol1(vecSize);
if(vecSize<64)
for(unsigned i=0;i<vecSize;i++) cout<<sol1[i]<<" ";
cout<<endl;
cout<<endl;
eval(sol1);
std::cout << "initial: " << sol1.fitness()<< std::endl;
// Create timer for timing CUDA calculation
moCudaTimer timer1;
timer1.start();
simpleHC(sol1);
timer1.stop();
printf("CUDA execution time = %f ms\n",timer1.getTime());
timer1.deleteTimer();
std::cout << "final: " << sol1.fitness() << std::endl;
}
// A main that catches the exceptions
int main(int argc, char **argv)
{
try{
main_function(argc, argv);
}
catch(exception& e){
cout << "Exception: " << e.what() << '\n';
}
return 1;
}

View file

@ -0,0 +1,282 @@
//Init the number of threads per block
#define BLOCK_SIZE 128
#include <iostream>
#include <stdlib.h>
using namespace std;
// The general include for eo
#include <eo>
#include <ga.h>
// Fitness function
#include <problems/eval/EvalOneMax.h>
// Cuda Fitness function
#include <eval/moCudaVectorEval.h>
#include <problems/eval/OneMaxIncrEval.h>
// One Max solution
#include <cudaType/moCudaBitVector.h>
//To compute execution time
#include <performance/moCudaTimer.h>
// One Max neighbor
#include <neighborhood/moCudaBitNeighbor.h>
// One Max ordered neighborhood
#include <neighborhood/moCudaOrderNeighborhood.h>
// The Solution and neighbor comparator
#include <comparator/moNeighborComparator.h>
#include <comparator/moSolNeighborComparator.h>
// The time continuator
#include <continuator/moTimeContinuator.h>
// Local search algorithm
#include <algo/moLocalSearch.h>
// The Tabou Search algorithm explorer
#include <explorer/moTSexplorer.h>
//Algorithm and its components
#include <algo/moTS.h>
//Tabu list
#include <memory/moNeighborVectorTabuList.h>
//Memories
#include <memory/moDummyIntensification.h>
#include <memory/moDummyDiversification.h>
#include <memory/moBestImprAspiration.h>
// REPRESENTATION
typedef moCudaBitVector<eoMaximizingFitness> solution;
typedef moCudaBitNeighbor <solution,eoMaximizingFitness> Neighbor;
typedef moCudaOrderNeighborhood<Neighbor> Neighborhood;
void main_function(int argc, char **argv)
{
/* =========================================================
*
* Parameters
*
* ========================================================= */
// First define a parser from the command-line arguments
eoParser parser(argc, argv);
// For each parameter, define Parameter, read it through the parser,
// and assign the value to the variable
// seed
eoValueParam<uint32_t> seedParam(time(0), "seed", "Random number seed", 'S');
parser.processParam( seedParam );
unsigned seed = seedParam.value();
// description of genotype
eoValueParam<unsigned int> vecSizeParam(8, "vecSize", "Genotype size", 'V');
parser.processParam( vecSizeParam, "Representation" );
unsigned vecSize = vecSizeParam.value();
// size tabu list
eoValueParam<unsigned int> sizeTabuListParam(7, "sizeTabuList", "size of the tabu list", 'T');
parser.processParam( sizeTabuListParam, "Search Parameters" );
unsigned sizeTabuList = sizeTabuListParam.value();
// time Limit
eoValueParam<unsigned int> timeLimitParam(1, "timeLimit", "time limits", 't');
parser.processParam( timeLimitParam, "Search Parameters" );
unsigned timeLimit = timeLimitParam.value();
// the name of the "status" file where all actual parameter values will be saved
string str_status = parser.ProgramName() + ".status"; // default value
eoValueParam<string> statusParam(str_status.c_str(), "status", "Status file");
parser.processParam( statusParam, "Persistence" );
// do the following AFTER ALL PARAMETERS HAVE BEEN PROCESSED
// i.e. in case you need parameters somewhere else, postpone these
if (parser.userNeedsHelp()) {
parser.printHelp(cout);
exit(1);
}
if (statusParam.value() != "") {
ofstream os(statusParam.value().c_str());
os << parser;// and you can use that file as parameter file
}
/* =========================================================
*
* Random seed
*
* ========================================================= */
//reproducible random seed: if you don't change SEED above,
// you'll aways get the same result, NOT a random run
rng.reseed(seed);
/* =========================================================
*
* Eval fitness function
*
* ========================================================= */
EvalOneMax<solution> eval;
/* =========================================================
*
* Evaluation of a solution neighbor's
*
* ========================================================= */
OneMaxIncrEval<Neighbor> incr_eval;
moCudaVectorEval<Neighbor,OneMaxIncrEval<Neighbor> > cueval(vecSize,incr_eval);
/* =========================================================
*
* Comparator of solutions and neighbors
*
* ========================================================= */
moNeighborComparator<Neighbor> comparator;
moSolNeighborComparator<Neighbor> solComparator;
/* =========================================================
*
* a solution neighborhood
*
* ========================================================= */
Neighborhood neighborhood(vecSize,cueval);
/* =========================================================
*
* continuator
*
* ========================================================= */
moTimeContinuator <Neighbor> continuator(timeLimit);
/* =========================================================
*
* tabu list
*
* ========================================================= */
//moNeighborVectorTabuList<shiftNeighbor> tl(sizeTabuList,0);
// tabu list
moNeighborVectorTabuList<Neighbor> tl(sizeTabuList,0);
/* =========================================================
*
* Memories
*
* ========================================================= */
moDummyIntensification<Neighbor> inten;
moDummyDiversification<Neighbor> div;
moBestImprAspiration<Neighbor> asp;
/* =========================================================
*
* An explorer of solution neighborhood's
*
* ========================================================= */
moTSexplorer<Neighbor> explorer(neighborhood, cueval, comparator, solComparator, tl, inten, div, asp);
/* =========================================================
*
* the local search algorithm
*
* ========================================================= */
moLocalSearch<Neighbor> localSearch1(explorer, continuator, eval);
//Basic Constructor
moTS<Neighbor> localSearch2(neighborhood,eval, cueval, 2, 7);
//Simple Constructor
moTS<Neighbor> localSearch3(neighborhood, eval, cueval, 5, tl);
//General Constructor
moTS<Neighbor> localSearch4(neighborhood, eval, cueval, comparator, solComparator, continuator, tl, inten, div, asp);
/* =========================================================
*
* Execute the local search(TS) from random sollution
*
* ========================================================= */
//Initilisation of the solution
solution sol1(vecSize);
eval(sol1);
std::cout << "Tabu Search 1:" << std::endl;
std::cout << "---------------------" << std::endl;
std::cout << "initial: " << sol1.fitness()<< std::endl;
moCudaTimer timer1;
timer1.start();
localSearch1(sol1);
timer1.stop();
printf("CUDA execution time = %f ms\n",timer1.getTime());
timer1.deleteTimer();
std::cout << "final: " << sol1.fitness() << std::endl<<std::endl;
/* =========================================================
*
* Execute the TS Basic Constructor
*
* ========================================================= */
solution sol2(vecSize);
eval(sol2);
std::cout << "Tabu Search 2:" << std::endl;
std::cout << "---------------------" << std::endl;
std::cout << "initial: " << sol2.fitness()<< std::endl;
moCudaTimer timer2;
timer2.start();
localSearch2(sol2);
timer2.stop();
printf("CUDA execution time = %f ms\n",timer2.getTime());
timer2.deleteTimer();
std::cout << "final: " << sol2.fitness() << std::endl<< std::endl;
/* =========================================================
*
* Execute the TS Simple Constructor
*
* ========================================================= */
solution sol3(vecSize);
eval(sol3);
std::cout << "Tabu Search 3:" << std::endl;
std::cout << "---------------------" << std::endl;
std::cout << "initial: " << sol3.fitness()<< std::endl;
moCudaTimer timer3;
timer3.start();
localSearch3(sol3);
timer3.stop();
printf("CUDA execution time = %f ms\n",timer3.getTime());
timer3.deleteTimer();
std::cout << "final: " << sol3.fitness() << std::endl<< std::endl;
/* =========================================================
*
* Execute the TS General Constructor
*
* ========================================================= */
solution sol4(vecSize);
eval(sol4);
std::cout << "Tabu Search 4:" << std::endl;
std::cout << "---------------------" << std::endl;
std::cout << "initial: " << sol4.fitness()<< std::endl;
moCudaTimer timer4;
timer4.start();
localSearch4(sol4);
timer4.stop();
printf("CUDA execution time = %f ms\n",timer4.getTime());
timer4.deleteTimer();
std::cout << "final: " << sol4.fitness() << std::endl<< std::endl;
}
// A main that catches the exceptions
int main(int argc, char **argv)
{
try{
main_function(argc, argv);
}
catch(exception& e){
cout << "Exception: " << e.what() << '\n';
}
return 1;
}

View file

@ -0,0 +1,230 @@
///Init the number of threads per block
#define BLOCK_SIZE 128
//-----------------------------------------------------------------------------
#include <iostream>
#include <stdlib.h>
using namespace std;
// The general include for eo
#include <eo>
#include <ga.h>
// Fitness function
#include <problems/eval/EvalOneMax.h>
// Cuda Fitness function
#include <eval/moCudaVectorEval.h>
#include <problems/eval/OneMaxIncrEval.h>
// One Max solution
#include <cudaType/moCudaBitVector.h>
//To compute execution time
#include <performance/moCudaTimer.h>
// One Max neighbor
#include <neighborhood/moCudaBitNeighbor.h>
// One Max ordered neighborhood
#include <neighborhood/moCudaRndWithReplNeighborhood.h>
//Algorithm and its components
#include <coolingSchedule/moCoolingSchedule.h>
#include <algo/moSA.h>
// The simulated annealing algorithm explorer
#include <explorer/moSAexplorer.h>
//comparator
#include <comparator/moSolNeighborComparator.h>
//continuators
#include <continuator/moTrueContinuator.h>
#include <continuator/moCheckpoint.h>
#include <continuator/moFitnessStat.h>
#include <utils/eoFileMonitor.h>
#include <continuator/moCounterMonitorSaver.h>
//-----------------------------------------------------------------------------
// Define types of the representation solution, different neighbors and neighborhoods
//-----------------------------------------------------------------------------
// REPRESENTATION
typedef moCudaBitVector<eoMaximizingFitness> solution;
typedef moCudaBitNeighbor <solution,eoMaximizingFitness> Neighbor;
typedef moCudaRndWithReplNeighborhood<Neighbor> Neighborhood;
void main_function(int argc, char **argv)
{
/* =========================================================
*
* Parameters
*
* ========================================================= */
// First define a parser from the command-line arguments
eoParser parser(argc, argv);
// For each parameter, define Parameter, read it through the parser,
// and assign the value to the variable
eoValueParam<uint32_t> seedParam(time(0), "seed", "Random number seed", 'S');
parser.processParam( seedParam );
unsigned seed = seedParam.value();
// description of genotype
eoValueParam<unsigned int> vecSizeParam(8, "vecSize", "Genotype size", 'V');
parser.processParam( vecSizeParam, "Representation" );
unsigned vecSize = vecSizeParam.value();
// the name of the "status" file where all actual parameter values will be saved
string str_status = parser.ProgramName() + ".status"; // default value
eoValueParam<string> statusParam(str_status.c_str(), "status", "Status file");
parser.processParam( statusParam, "Persistence" );
// do the following AFTER ALL PARAMETERS HAVE BEEN PROCESSED
// i.e. in case you need parameters somewhere else, postpone these
if (parser.userNeedsHelp()) {
parser.printHelp(cout);
exit(1);
}
if (statusParam.value() != "") {
ofstream os(statusParam.value().c_str());
os << parser;// and you can use that file as parameter file
}
/* =========================================================
*
* Random seed
*
* ========================================================= */
//reproducible random seed: if you don't change SEED above,
// you'll always get the same result, NOT a random run
rng.reseed(seed);
/* =========================================================
*
* Initilisation of the solution
*
* ========================================================= */
//solution sol(size);
solution sol(vecSize);
for(int i=0;i<vecSize;i++) cout<<sol[i]<<" ";
cout<<endl;
/* =========================================================
*
* Eval fitness function
*
* ========================================================= */
EvalOneMax<solution> eval;
/* =========================================================
*
* Evaluation of a solution neighbor's
*
* ========================================================= */
OneMaxIncrEval<Neighbor> incr_eval;
moCudaVectorEval<Neighbor,OneMaxIncrEval<Neighbor> > cueval(vecSize,incr_eval);
/* =========================================================
*
* Comparator of solutions and neighbors
*
* ========================================================= */
// moNeighborComparator<Neighbor> comparator;
moSolNeighborComparator<Neighbor> solComparator;
/* =========================================================
*
* a solution neighborhood
*
* ========================================================= */
Neighborhood neighborhood(vecSize,cueval);
/* =========================================================
*
* the cooling schedule of the process
*
* ========================================================= */
// initial temp, factor of decrease, number of steps without decrease, final temp.
moSimpleCoolingSchedule<solution> coolingSchedule(500, 0.9, 1000, 0.01);
/* =========================================================
*
* the local search algorithm
*
* ========================================================= */
moSA<Neighbor> localSearch1(neighborhood, eval, cueval,coolingSchedule);
/* =========================================================
*
* execute the local search from random solution
*
* ========================================================= */
//init(solution);
eval(sol);
std::cout << "#########################################" << std::endl;
std::cout << "initial solution1: " << sol.fitness() << std::endl;
localSearch1(sol);
std::cout << "final solution1: " << sol.fitness() << std::endl;
std::cout << "#########################################" << std::endl;
/* =========================================================
*
* Comparator of neighbors
*
* ========================================================= */
// moSolNeighborComparator<Neighbor> solComparator;
/* =========================================================
*
* Example of Checkpointing
*
* ========================================================= */
/*moTrueContinuator<Neighbor> continuator;//always continue
moCheckpoint<Neighbor> checkpoint(continuator);
moFitnessStat<solution> fitStat;
checkpoint.add(fitStat);
eoFileMonitor monitor("fitness.out", "");
moCounterMonitorSaver countMon(100, monitor);
checkpoint.add(countMon);
monitor.add(fitStat);
moSA<Neighbor> localSearch2(neighborhood, eval, cueval, coolingSchedule, solComparator, checkpoint);
eval(sol1);
for(int i=0;i<vecSize;i++) cout<<sol1[i]<<" ";
cout<<endl;
std::cout << "#########################################" << std::endl;
std::cout << "initial solution2: " << sol1.fitness() << std::endl ;
localSearch2(sol);
std::cout << "final solution2: " << sol1.fitness() << std::endl ;
std::cout << "#########################################" << std::endl;*/
}
// A main that catc hes the exceptions
int main(int argc, char **argv)
{
try {
main_function(argc, argv);
}
catch (exception& e) {
cout << "Exception: " << e.what() << '\n';
}
return 1;
}