diff --git a/metslib-0.5.3-boost.patch b/metslib-0.5.3-boost.patch new file mode 100644 index 0000000..b2be68e --- /dev/null +++ b/metslib-0.5.3-boost.patch @@ -0,0 +1,113 @@ +diff -up ./metslib/mets.hh.boost ./metslib/mets.hh +--- ./metslib/mets.hh.boost 2011-05-05 08:38:51.000000000 -0400 ++++ ./metslib/mets.hh 2016-02-01 19:52:22.848282043 -0500 +@@ -106,7 +106,15 @@ + #include + #include + #include +-#if defined (METSLIB_HAVE_UNORDERED_MAP) ++ ++#if defined (METSLIB_TR1_BOOST) ++# include ++# include ++# include ++# include ++# include ++# include ++#elif defined (METSLIB_HAVE_UNORDERED_MAP) + # include + # include + #elif defined (METSLIB_HAVE_TR1_UNORDERED_MAP) +diff -up ./metslib/metslib_config.hh.boost ./metslib/metslib_config.hh +--- ./metslib/metslib_config.hh.boost 2011-05-05 08:38:51.000000000 -0400 ++++ ./metslib/metslib_config.hh 2016-02-01 19:48:09.724145145 -0500 +@@ -16,4 +16,5 @@ + # define METSLIB_HAVE_TR1_UNORDERED_MAP 1 + # endif + #endif ++#define METSLIB_TR1_BOOST 1 + #endif +diff -up ./metslib/model.hh.boost ./metslib/model.hh +--- ./metslib/model.hh.boost 2011-05-05 08:38:51.000000000 -0400 ++++ ./metslib/model.hh 2016-02-01 19:46:24.481900865 -0500 +@@ -244,7 +244,11 @@ namespace mets { + template + void random_shuffle(permutation_problem& p, random_generator& rng) + { +-#if defined (METSLIB_HAVE_UNORDERED_MAP) && !defined (METSLIB_TR1_MIXED_NAMESPACE) ++#if defined (METSLIB_TR1_BOOST) ++ boost::uniform_int unigen; ++ boost::variate_generator >gen(rng, unigen); ++#elif defined (METSLIB_HAVE_UNORDERED_MAP) && !defined (METSLIB_TR1_MIXED_NAMESPACE) + std::uniform_int unigen; + std::variate_generator >gen(rng, unigen); +@@ -263,7 +267,9 @@ namespace mets { + template + void perturbate(permutation_problem& p, unsigned int n, random_generator& rng) + { +-#if defined (METSLIB_HAVE_UNORDERED_MAP) && !defined (METSLIB_TR1_MIXED_NAMESPACE) ++#if defined (METSLIB_TR1_BOOST) ++ boost::uniform_int<> int_range; ++#elif defined (METSLIB_HAVE_UNORDERED_MAP) && !defined (METSLIB_TR1_MIXED_NAMESPACE) + std::uniform_int<> int_range; + #else + std::tr1::uniform_int<> int_range; +@@ -527,7 +533,9 @@ namespace mets { + + + /// @brief Generates a stochastic subset of the neighborhood. +-#if defined (METSLIB_HAVE_UNORDERED_MAP) && !defined (METSLIB_TR1_MIXED_NAMESPACE) ++#if defined (METSLIB_TR1_BOOST) ++ template ++#elif defined (METSLIB_HAVE_UNORDERED_MAP) && !defined (METSLIB_TR1_MIXED_NAMESPACE) + template + #else + template +@@ -555,7 +563,10 @@ namespace mets { + + protected: + random_generator& rng; +-#if defined (METSLIB_HAVE_UNORDERED_MAP) && !defined (METSLIB_TR1_MIXED_NAMESPACE) ++ ++#if defined (METSLIB_TR1_BOOST) ++ boost::uniform_int<> int_range; ++#elif defined (METSLIB_HAVE_UNORDERED_MAP) && !defined (METSLIB_TR1_MIXED_NAMESPACE) + std::uniform_int<> int_range; + #else + std::tr1::uniform_int<> int_range; +diff -up ./metslib/simulated-annealing.hh.boost ./metslib/simulated-annealing.hh +--- ./metslib/simulated-annealing.hh.boost 2011-05-05 08:38:51.000000000 -0400 ++++ ./metslib/simulated-annealing.hh 2016-02-01 19:46:24.481900865 -0500 +@@ -133,7 +133,11 @@ namespace mets { + double stop_temp_m; + double current_temp_m; + double K_m; +-#if defined (METSLIB_HAVE_UNORDERED_MAP) && !defined (METSLIB_TR1_MIXED_NAMESPACE) ++#if defined (METSLIB_TR1_BOOST) ++ boost::uniform_real ureal; ++ boost::mt19937 rng; ++ boost::variate_generator< boost::mt19937, boost::uniform_real > gen; ++#elif defined (METSLIB_HAVE_UNORDERED_MAP) && !defined (METSLIB_TR1_MIXED_NAMESPACE) + std::uniform_real ureal; + std::mt19937 rng; + std::variate_generator< std::mt19937, std::uniform_real > gen; +diff -up ./metslib/tabu-search.hh.boost ./metslib/tabu-search.hh +--- ./metslib/tabu-search.hh.boost 2011-05-05 08:38:51.000000000 -0400 ++++ ./metslib/tabu-search.hh 2016-02-01 19:46:24.482900905 -0500 +@@ -314,7 +314,13 @@ namespace mets { + + protected: + typedef std::deque move_list_type; +-#if defined (METSLIB_HAVE_UNORDERED_MAP) && !defined (METSLIB_TR1_MIXED_NAMESPACE) ++#if defined (METSLIB_TR1_BOOST) ++ typedef boost::unordered_map< ++ mana_move*, // Key type ++ int, //insert a move and the number of times it's present in the list ++ mana_move_hash, ++ dereferenced_equal_to > move_map_type; ++#elif defined (METSLIB_HAVE_UNORDERED_MAP) && !defined (METSLIB_TR1_MIXED_NAMESPACE) + typedef std::unordered_map< + mana_move*, // Key type + int, //insert a move and the number of times it's present in the list diff --git a/metslib-0.5.3-cpp17.patch b/metslib-0.5.3-cpp17.patch new file mode 100644 index 0000000..ae8e72a --- /dev/null +++ b/metslib-0.5.3-cpp17.patch @@ -0,0 +1,13 @@ +diff -up ./metslib/abstract-search.hh.cpp17 ./metslib/abstract-search.hh +--- ./metslib/abstract-search.hh.cpp17 2022-12-06 18:47:40.335305410 -0500 ++++ ./metslib/abstract-search.hh 2022-12-06 18:48:08.774436936 -0500 +@@ -106,8 +106,7 @@ namespace mets { + /// An exception mets::no_moves_error can be risen when no move is + /// possible. + virtual void +- search() +- throw(no_moves_error) = 0; ++ search() = 0; + + /// @brief The solution recorder instance. + const solution_recorder& diff --git a/metslib-0.5.3-noarch.patch b/metslib-0.5.3-noarch.patch new file mode 100644 index 0000000..22f62fa --- /dev/null +++ b/metslib-0.5.3-noarch.patch @@ -0,0 +1,14 @@ +diff -up ./metslib.pc.in.noarch ./metslib.pc.in +--- ./metslib.pc.in.noarch 2013-08-10 11:03:19.804295046 -0400 ++++ ./metslib.pc.in 2013-08-10 11:03:33.005806016 -0400 +@@ -1,9 +1,8 @@ + prefix=@prefix@ + exec_prefix=@exec_prefix@ +-libdir=@libdir@ + includedir=@includedir@ + + Name: METS tabu search generic library. + Description: METS Tabu Search Metaheuristic C++ generic library. + Version: @VERSION@ +-Cflags: -I${includedir}/@GENERIC_LIBRARY_NAME@-@GENERIC_API_VERSION@ -I${libdir}/@GENERIC_LIBRARY_NAME@-@GENERIC_API_VERSION@/include ++Cflags: -I${includedir}/@GENERIC_LIBRARY_NAME@-@GENERIC_API_VERSION@ diff --git a/metslib-0.5.3.tgz b/metslib-0.5.3.tgz new file mode 100644 index 0000000..80dcacf Binary files /dev/null and b/metslib-0.5.3.tgz differ diff --git a/metslib.spec b/metslib.spec new file mode 100644 index 0000000..5f7941a --- /dev/null +++ b/metslib.spec @@ -0,0 +1,94 @@ +# This is really a noarch package, we're just building on all arches so we +# can run unit tests across all arches. The debuginfo will always be empty +# (no executables or libraries,) so we can disable it +%global debug_package %{nil} + +Name: metslib +Version: 0.5.3 +Release: 1%{?dist} +Summary: Metaheuristic modeling framework and optimization toolkit in modern C++ + +License: GPLv3+ or CPL +URL: https://projects.coin-or.org/metslib +Source0: http://www.coin-or.org/download/source/%{name}/%{name}-%{version}.tgz +# Removes all "libdir" paths from .pc file (which are unneeded). Not upstream +Patch0: %{name}-0.5.3-noarch.patch +# Port metslib to use boost random functionality instead of outdated tr1 +# Based on https://github.com/PointCloudLibrary/pcl/commit/57ace9a92d1667eaa6193262032ff688e222ce0f +# Not upstream +Patch1: %{name}-0.5.3-boost.patch +# Update abstract-search.hpp to remove deprecated exception specification +# Not upstream +Patch2: %{name}-0.5.3-cpp17.patch + +BuildRequires: make +BuildRequires: gcc-c++ +BuildRequires: doxygen +BuildRequires: boost-devel +BuildRequires: graphviz + +%description +%{summary}. + +%package devel +Summary: Metaheuristic modeling framework and optimization toolkit in modern C++ +Provides: %{name}-static = %{version}-%{release} +BuildArch: noarch +Requires: boost-devel + +%description devel +METSlib is a metaheuristic modeling framework and optimization toolkit in +modern C++ released as Free/Libre/Open Source Software. + +Model and algorithms are modular: any search algorithm can be applied to the +same model. On the other hand no assumption is made on the model, you can +work on any problem type: timetabling, assignment problems, vehicle routing, +bin-packing and so on. + +Once you have implemented your model in the problem framework, the library +makes easy testing different Tabu Search strategies or even different +algorithms (Simulated Annealing or other local search based algorithms) with +a few lines of code. + +%package doc +Summary: Documentation for %{name} +BuildArch: noarch + +%description doc +The %{name}-doc package provides documentation for the %{name} library. + +%prep +%setup -q +%patch0 -p0 +%patch1 -p1 -b .boost +%patch2 -p1 -b .cpp17 +# Disable -O3 optimization for unit tests +sed -i 's| -O3||g' configure + +%build +export CXXFLAGS="%{optflags} --std=gnu++14" +%configure +make %{?_smp_mflags} +doxygen doxydoc/doxygen.conf + +%install +%make_install +# Move pkgconfig file to /usr/share/pkgconfig (since package is noarch) +mkdir -p %{buildroot}%{_datadir} +mv %{buildroot}%{_libdir}/pkgconfig %{buildroot}%{_datadir} + +%check +export CXXFLAGS="%{optflags}" +make test + +%files devel +%doc AUTHORS COPYING NEWS README +%{_includedir}/* +%{_datadir}/pkgconfig/*.pc + +%files doc +%doc doxydoc/html COPYING + +%changelog +* Mon May 2 2023 will_niutao - 0.5.3-1 +- Init for openEuler