diff options
Diffstat (limited to 'sci-chemistry/ball')
11 files changed, 2116 insertions, 12 deletions
diff --git a/sci-chemistry/ball/ChangeLog b/sci-chemistry/ball/ChangeLog index 3290edb3a35b..c91f8be9068f 100644 --- a/sci-chemistry/ball/ChangeLog +++ b/sci-chemistry/ball/ChangeLog @@ -1,6 +1,20 @@ # ChangeLog for sci-chemistry/ball -# Copyright 1999-2012 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/sci-chemistry/ball/ChangeLog,v 1.3 2012/12/13 10:58:27 jlec Exp $ +# Copyright 1999-2013 Gentoo Foundation; Distributed under the GPL v2 +# $Header: /var/cvsroot/gentoo-x86/sci-chemistry/ball/ChangeLog,v 1.4 2013/01/27 14:30:47 jlec Exp $ + +*ball-1.4.1-r1 (27 Jan 2013) + + 27 Jan 2013; Justin Lecher <jlec@gentoo.org> ball-1.4.1.ebuild, + +ball-1.4.1-r1.ebuild, + +files/ball-1.4.1-Added-MAX_PENALTY-option-to-bond-order-assignment.patch, + +files/ball-1.4.1-BondOrder.xml.patch, + +files/ball-1.4.1-Fix-compilation-of-FTPBondOrderStrategy-Fixes-451.patch, + +files/ball-1.4.1-Fix-compilation-of-Python-bindings-with-new-sip-vers.patch, + +files/ball-1.4.1-Fixed-a-bug-in-the-AssignBondOrderProcessor.patch, + +files/ball-1.4.1-Fixed-the-FPT-version-of-bond-order-assignment-2.patch, + files/ball-1.4.1-gcc-4.7.patch: + Add fix for tests, #454162; backport patches upstream included in debian + package 13 Dec 2012; Justin Lecher <jlec@gentoo.org> ball-1.4.1.ebuild, +files/ball-1.4.1-gcc-4.7.patch, +files/ball-1.4.1-missing-signed.patch, diff --git a/sci-chemistry/ball/Manifest b/sci-chemistry/ball/Manifest index fa7c8e60c6ee..edb412305e85 100644 --- a/sci-chemistry/ball/Manifest +++ b/sci-chemistry/ball/Manifest @@ -1,20 +1,27 @@ -----BEGIN PGP SIGNED MESSAGE----- -Hash: SHA256 +Hash: SHA512 -AUX ball-1.4.1-gcc-4.7.patch 17956 SHA256 bf2afe1ebb4861a56427dc1c40d3f0e4559dadd2ac73404c6e3a5e2fd69951d8 SHA512 8ca2d7ec4f65cf3f763a0c0085d7afe124b3e2c672ca192e66657651bd20d9ad35744b2021812cd64a174870e81f3d8d5004d3f7969578d196b269b63c985bf2 WHIRLPOOL 9f9966f7c089f4577e3e6431d9c5c0faba26b97898123bb51fbfe8febe59f092509b97f6628bb55a7828a20ea7f06afce9322dd6917740a6a666a430138f99d3 +AUX ball-1.4.1-Added-MAX_PENALTY-option-to-bond-order-assignment.patch 40315 SHA256 b3210eb9bc2356b7ae708d07b87c6132cda327311762475a8e9e476360decf43 SHA512 067b227d926d5ee1232f4c9cfe95aa915373f8a741094d2ce4a41527a1d67f03e82be0522b04471a1e6ac34231cdacc05ad164914eee41fe1b0811e594c61396 WHIRLPOOL 24b223a3ca34d343d180d6612e85ca213091f8ff02a636ae32631f84ecebf1785e3f3c419c029c6e22c5328de208a0d55fc0ae3ece0e9b7c465be613446228d8 +AUX ball-1.4.1-BondOrder.xml.patch 1675 SHA256 8aaecb9dc1bc729a0446c350b423b47779b8d82a3b00f570a55e4b4f0b7b02c3 SHA512 77e04209bebff5057ad549d1c1d7b638391fb063efb8635a72b46287a4c4975c2d0940267bce9002f3c9dc0f6fab7e21a3099506f57a44e0a325149ee134b2e0 WHIRLPOOL db3ecb2587e607f8257348d9e6dc558e2795807fd8c62e3fecf82bb426b54d18efba510c2b8990dd6fd74781b048be1e69373678977f723c11ed6624ad774d78 +AUX ball-1.4.1-Fix-compilation-of-FTPBondOrderStrategy-Fixes-451.patch 6031 SHA256 0e505b31c64d673b5b211c27c36d2ba4cfb3f05e19efc08967a22b015045cea2 SHA512 69e07399db0c1b9890074c5078c130fa8fbb8eb423b311170f431facb5e79b666c4fed8a3b2e2b5dda5fa7c18cb1750f47f0ae2103150bb55be3f2b56b252799 WHIRLPOOL c1ebae17b75d2e785fd2ff300aa09f59d3ce55a786d982bb63a81795528e142c5fc141e9b01332510c858437eefd0a177a8ff4232eaf2750a5e2232d1c5353c7 +AUX ball-1.4.1-Fix-compilation-of-Python-bindings-with-new-sip-vers.patch 911 SHA256 7a315d132f6bd7a12f3f80fc409cd8274abf47baaada87992c48a96b8b86d865 SHA512 6d5c0170c494f96cd588ace5f034f3b129a795e749acb5bf46f6e9e8beb853649b0fc7a8465e19a116d93ab08be4844bddcee9d86d95cb95b1275f92c9d17c9c WHIRLPOOL 50482396fac4f4ed23487187f03ee6d210254e4b29da18fb43045ba1e31275858469272a11f7e6ab7b5450f07c5b51e383ea169ef542726b8463909c842d7656 +AUX ball-1.4.1-Fixed-a-bug-in-the-AssignBondOrderProcessor.patch 12645 SHA256 ff24458d7b441281c1e90777eddcb0947afd6aa5d46b96718f4778607219a3c1 SHA512 8a373bd9727aa96d01fc0fcdbffaa176ee4d3dd8b262981d68d403315994b41fa57eade834e8f4b788a8bedae8d3fbc34d82e615bf4d919ff1bbeecf21893612 WHIRLPOOL 36d4cb4e25adc4cb65c6d99452751b167109fbd3f0004a95e04ea95698bb6b0315a6e7c2b30f46f10fd78c0962a67f60bd6a9e8b7b0e0a7d0d6cf694c096e25b +AUX ball-1.4.1-Fixed-the-FPT-version-of-bond-order-assignment-2.patch 14754 SHA256 42f9765b0ba33dbcc3420c6714fd612af99c2bb9dfb0cf10abdcad1e11a2e6d9 SHA512 86368511396a534f9a8fc180bc3b4bd8502c4396d0bd585fb99f28a597034652a620bb8c933ed86776060cf090942c26d36b2b9004cf9760267584bb6c12a948 WHIRLPOOL 6325e12a46c90bb3f3348c06d2c8fb13491c09d9e6e405b27ad45609bd24eb9759fb91a0b40a743333c4f55987ca803b963a9cbbce99c96b9ad2ee4edfd87390 +AUX ball-1.4.1-gcc-4.7.patch 22402 SHA256 227d6dd84389350514e1d548c385ddfaeebca764295ca2e79112c3f98e193038 SHA512 f0ea5b5b4e6fb0c7d91095fcbb40fa8ba2840a0c5b823a1d9133af25c592acc08f8441457627b88be1ace36243054828050c3c395eb9cab41baefe558a06a56c WHIRLPOOL ba14a25a7727f952e872947e586344a0b99e80ea05edac233988b0011fa4a7d57e5c6d1f13106ae0a0160fd84fc251c6dbb473338eb02ef049e113da91adc8a3 AUX ball-1.4.1-libsvm.patch 814 SHA256 01d3e514d11260ca52a7d180219e62bd371ab48787d048321898d6ddf0eee219 SHA512 949e1aeeab71d7453956a1f37841c5fca72fa711e91eadb9293449bd6408a98b840f93c4c360f7ca26eac1b93c48f034d622e49db16613f9d7447488a4189d08 WHIRLPOOL 24e2885ec040aef85a8b85f6ba36a6c84040c659294e987d823f9ce83f94887852b1b88a78d8def41c60d5c950b8d834f8e5408647ce2a4a8990b60fe7f558f8 AUX ball-1.4.1-missing-signed.patch 985 SHA256 5bdeb4613e775e83bf219661f0e494f7556322aac7af3b4dfab593203c6dea7b SHA512 ea50bbceb38e80416e4f49a247816ccaf1318c45676669388f681eca5be525b5ed6d472c1b20afe37d3d95ae5334d90831269c77bce922207b515e8c5a46f20a WHIRLPOOL d6311ba93396e7b4dceb3cdf39d35d736fc8c87f52309d258673f71244903f860199c0cab55cbda81fadf11b82e60361e82c737871e2632c1c5006bdac929b10 AUX ball-1.4.1-multilib.patch 1585 SHA256 ee246df89ca6f1559df359fb6af93462fda9c93fa8a81977f6a5b92190d6ceb5 SHA512 5eebfdce5fba25967c252d0c83f6187079efc55c9481045d6c9e111930e1bb2bed31666b913eb12f46a723aa875559b54f658460efd7be10bbbe4c7cd2982341 WHIRLPOOL f4240a867e4ae503f49bffb986e8bd8a69e1914d6e770e7ae7cb7c03efd23eec3fa095c837e5874785ec4b6bf326c9fec15e16c746f48b89d9afe173f19eb0df AUX ball-1.4.1-pthread.patch 418 SHA256 be38df8bc184929b0db5c3716113a17ac0033ad53ee631a5881c56c664d23970 SHA512 ce35b9f061534c250789f318a96196d3588d1cf875065a32007c6aeda0815809d42ebea0641c22d074f44125d5236450f887574af3624abc0f7eb6933e38343e WHIRLPOOL ee2152800b79e9f899ba5c194d2e9b7a7fd9503fc45e91d5a5ff75ba478c7694c7f14bca94fda675d04e9e45e7601bd87dfce53c127bf04dd480aa8a994bd0b3 AUX ball-1.4.1-python.patch 2780 SHA256 3abb2f70a4d8ea930da13cb68e8f57dd705fad42014bd2cc3912362cada48665 SHA512 dd80af7e899bec2a2dff5b837f6b3eaca3f92d5b8b7c1e22cde5a8428b4e3036739212ef0fdea77955e4716d27638772b84d4516e5a15d5937f0d41692be1cdb WHIRLPOOL f82b11dcbc39ae4d434fe6425ff52253ba7c36e719cb103b30a8f01aee0f24699c4759e3c5e006ce168a586f1f012dee25a1b0f1ae23bd2454aac65983e71003 DIST ball-1.4.1.tar.gz 23073541 SHA256 752b4487040d318bdcb1760c96c3293fed065fad7e0dd0efb5c927382e2aeb53 SHA512 2ee1e3b4c9a7e84b581dd8566612f528b5337c2ab55ea57b44c06efa49bba9335604b64c3b618e8c5992d5854f3db77e247da31addf8dbcb6b02275ae4b328cf WHIRLPOOL 7a37b23825e6a7ef286995337ee4870192e89d0f42cc48d715f079431ab95db18aaa792c6cf6e0c3aca6c58e8f870058d87dd87b57931392fd27ecbf00b92c99 -EBUILD ball-1.4.1.ebuild 1688 SHA256 d2d6d45deecfefb5a8cd13adc16f5e513338064eb5272929df351d90ddbeeea1 SHA512 926d45bfab06abdc1fe6d487daee4110108c5a8f17f6487eb5c0c45453e53253fb0a98609097d07189a2d3fe1a7a1c6a5c39702c2a97efce2918576d8031ea05 WHIRLPOOL f6ad27b33521273d2df825864ce5b535b9b252e9e9fa98bbf4ecb617d9f24917a1d86732bbedb8f393156b82d9e19387b1dd4a7f8775db4c317030771d771bb4 -MISC ChangeLog 874 SHA256 4d035bf0d7af96f3dbc2feff5ab4ce42494d615a61411e5064d9616003ea840d SHA512 3f041202d2fc87264c1733eed4a8541ae9f949c8d263bda781aa4caec0d9d5d5f6f1c39ac1149b4e1cd541304ec859a7fdc5a711bb6ae3055c721a510061036f WHIRLPOOL 8c92afd4264f70666f1f7d74181b3f4f8030653b56cdda45ddc19aaf46d67176eaa5a5220ad42545264d8180ea0ca6eefe2b096377a19ecc2c5f4b345cae6a5e +EBUILD ball-1.4.1-r1.ebuild 2258 SHA256 5673d00017d294d02351fa73fabed6c6e70ad09b5ab74ba02b8405233d2a244e SHA512 010c30e8c2f8240cb7f22f8d1e3f6082956535aca39b997cd5e94a080af649085d9c282b3b0e9c50ab1328cdefa0ca59c59496f2fbb88f581afc22890680f99a WHIRLPOOL 3c48d50e3865d83dacfdd917e207a18733c1ed4e48cef31d6a36e2478ecf111f100053babb6c70da8e3643635fe8ecc0c60b34b2bb3d0bad0948ae3989ac4904 +EBUILD ball-1.4.1.ebuild 1955 SHA256 3fa6f9c5ebd596ae809f446de6c98139146b43faf96dd747051b4c2aec435137 SHA512 8390590a3d6a1c748b6e71fa5fe9090aa6c8e97cbbe4ba289411bb29cd22aa2659bf31d0fb210eeb81b5c54431bcb300760b3399bd131b52736d80a667a8ff3f WHIRLPOOL 7beef116afb51ed67f6bb3fc62a62483e5013e593f80142e47ef204d0af6228a62aa6c4de1ff742f916455fa38e11c34d454e6cc8e37b78b7946035579837c6a +MISC ChangeLog 1537 SHA256 3bf485cf3627fa9993c24e856487c60491545d7f2c59afffa6d78f2337a72926 SHA512 2565fa53d734a41a4eb1fab59e40c5539d43ca86aeacc3d139a9cc9fea1399e9cb3c944911787d3c7f9176e80c0424a7221490cd20aefdca9926c2c366672bb6 WHIRLPOOL 20660b5ea126515cc078f42294524a166eeb06efc634fe8a6761fe15ba54858bdd1335e88a19b1f45080fd467d14d8df5728fcbbba74227e43ac3542e354123b MISC metadata.xml 1462 SHA256 ec9ebcb879be9631cf8d515807054ea6d558f4e36f0bc70e5e3225fdce56527c SHA512 6085649bbedd886ae64d49a50fe30843989a66aad79e61a9a1037b8ff00abbeb97ec53c709b7d4fca6607ed77379a1901db3a8bdf26c4e8bee925883e516b19d WHIRLPOOL 194cd3bb8c8eecb8b2c3208ee25716b4f0b76692a6efc6ad38e29c3018685b3ad656faefa79b2bf4609a5a045bbc9852151857ea142a1518db533a26adf63aaa -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (GNU/Linux) -iEYEAREIAAYFAlDJtNQACgkQgAnW8HDreRZitgCglapVU8Vio4Es8uQeoZJWLVkx -bdMAnRfdLvVVwA2oJUNZRB5fzTs5uOJi -=FEx4 +iEYEAREKAAYFAlEFOh8ACgkQgAnW8HDreRb9IwCgopqvsbrMKv1fJEXN/YixhiNA +ZwwAnjVsbNCD1hr8p/kqmtnaCY7NZGJM +=maas -----END PGP SIGNATURE----- diff --git a/sci-chemistry/ball/ball-1.4.1-r1.ebuild b/sci-chemistry/ball/ball-1.4.1-r1.ebuild new file mode 100644 index 000000000000..6d923d89e238 --- /dev/null +++ b/sci-chemistry/ball/ball-1.4.1-r1.ebuild @@ -0,0 +1,86 @@ +# Copyright 1999-2013 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/sci-chemistry/ball/ball-1.4.1-r1.ebuild,v 1.1 2013/01/27 14:30:47 jlec Exp $ + +EAPI=4 + +PYTHON_DEPEND="python? 2" + +inherit cmake-utils python + +DESCRIPTION="Biochemical Algorithms Library" +HOMEPAGE="http://www.ball-project.org/" +SRC_URI="http://dev.gentoo.org/~jlec/distfiles/${P}.tar.gz" + +SLOT="0" +LICENSE="LGPL-2 GPL-3" +KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux" +IUSE="cuda mpi +python sql +threads +webkit" + +RDEPEND=" + dev-cpp/eigen:3 + dev-libs/boost + media-libs/glew + sci-libs/fftw:3.0[threads?] + sci-libs/gsl + sci-libs/libsvm + sci-mathematics/lpsolve + virtual/opengl + x11-libs/libX11 + x11-libs/qt-core:4 + x11-libs/qt-gui:4 + x11-libs/qt-opengl:4 + x11-libs/qt-test:4 + x11-libs/qt-webkit:4 + cuda? ( dev-util/nvidia-cuda-toolkit ) + mpi? ( virtual/mpi ) + sql? ( x11-libs/qt-sql:4 ) + webkit? ( x11-libs/qt-webkit:4 )" +DEPEND="${RDEPEND} + dev-python/sip + sys-devel/bison + virtual/yacc" + +S="${WORKDIR}"/BALL + +PATCHES=( + "${FILESDIR}"/${P}-multilib.patch + "${FILESDIR}"/${P}-libsvm.patch + "${FILESDIR}"/${P}-pthread.patch + "${FILESDIR}"/${P}-python.patch + "${FILESDIR}"/${P}-missing-signed.patch + "${FILESDIR}"/${P}-gcc-4.7.patch + "${FILESDIR}"/${P}-BondOrder.xml.patch + "${FILESDIR}"/${P}-Fixed-the-FPT-version-of-bond-order-assignment-2.patch + "${FILESDIR}"/${P}-Added-MAX_PENALTY-option-to-bond-order-assignment.patch + "${FILESDIR}"/${P}-Fixed-a-bug-in-the-AssignBondOrderProcessor.patch + "${FILESDIR}"/${P}-Fix-compilation-of-Python-bindings-with-new-sip-vers.patch + ) + +pkg_setup() { + use python \ + && python_set_active_version 2 \ + && python_pkg_setup +} + +src_configure() { + local mycmakeargs=( + $(cmake-utils_use_use threads FFTW_THREADS) + $(cmake-utils_use cuda MT_ENABLE_CUDA) + $(cmake-utils_use mpi MT_ENABLE_MPI) + $(cmake-utils_use sql BALL_HAS_QTSQL) + $(cmake-utils_use_use webkit USE_QTWEBKIT) + $(cmake-utils_use python BALL_PYTHON_SUPPORT) + ) + cmake-utils_src_configure + local i + for i in "${S}"/data/*; do + ln -sf "${i}" "${BUILD_DIR}"/source/TEST/ || die + ln -sf "${i}" "${S}"/source/TEST/ || die + done +} + +src_compile() { + cmake-utils_src_compile + use test && cmake-utils_src_make build_tests +} diff --git a/sci-chemistry/ball/ball-1.4.1.ebuild b/sci-chemistry/ball/ball-1.4.1.ebuild index 44247530df62..811aa9cd3af0 100644 --- a/sci-chemistry/ball/ball-1.4.1.ebuild +++ b/sci-chemistry/ball/ball-1.4.1.ebuild @@ -1,6 +1,6 @@ -# Copyright 1999-2012 Gentoo Foundation +# Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/sci-chemistry/ball/ball-1.4.1.ebuild,v 1.3 2012/12/13 10:58:27 jlec Exp $ +# $Header: /var/cvsroot/gentoo-x86/sci-chemistry/ball/ball-1.4.1.ebuild,v 1.4 2013/01/27 14:30:47 jlec Exp $ EAPI=4 @@ -50,6 +50,7 @@ PATCHES=( "${FILESDIR}"/${P}-python.patch "${FILESDIR}"/${P}-missing-signed.patch "${FILESDIR}"/${P}-gcc-4.7.patch + "${FILESDIR}"/${P}-BondOrder.xml.patch ) pkg_setup() { @@ -68,4 +69,14 @@ src_configure() { $(cmake-utils_use python BALL_PYTHON_SUPPORT) ) cmake-utils_src_configure + local i + for i in "${S}"/data/*; do + ln -sf "${i}" "${BUILD_DIR}"/source/TEST/ || die + ln -sf "${i}" "${S}"/source/TEST/ || die + done +} + +src_compile() { + cmake-utils_src_compile + use test && cmake-utils_src_make build_tests } diff --git a/sci-chemistry/ball/files/ball-1.4.1-Added-MAX_PENALTY-option-to-bond-order-assignment.patch b/sci-chemistry/ball/files/ball-1.4.1-Added-MAX_PENALTY-option-to-bond-order-assignment.patch new file mode 100644 index 000000000000..4af96b783cdb --- /dev/null +++ b/sci-chemistry/ball/files/ball-1.4.1-Added-MAX_PENALTY-option-to-bond-order-assignment.patch @@ -0,0 +1,975 @@ +From: Anna Dehof <anne@bioinf.uni-sb.de> +Date: Mon, 26 Mar 2012 19:11:39 +0200 +Subject: Added MAX_PENALTY option to bond order assignment + +--- + include/BALL/DATATYPE/GRAPH/treeWidth.h | 28 +-- + .../STRUCTURE/BONDORDERS/FPTBondOrderStrategy.h | 16 +- + include/BALL/STRUCTURE/assignBondOrderProcessor.h | 30 ++- + source/APPLICATIONS/UTILITIES/assign_bond_orders.C | 34 +++- + source/DATATYPE/GRAPH/treeWidth.C | 2 +- + source/STRUCTURE/BONDORDERS/FPTBondOrderStrategy.C | 199 +++++++++----------- + source/STRUCTURE/assignBondOrderProcessor.C | 44 +++-- + 7 files changed, 186 insertions(+), 167 deletions(-) + +diff --git a/include/BALL/DATATYPE/GRAPH/treeWidth.h b/include/BALL/DATATYPE/GRAPH/treeWidth.h +index f7687ef..53ecffc 100644 +--- a/include/BALL/DATATYPE/GRAPH/treeWidth.h ++++ b/include/BALL/DATATYPE/GRAPH/treeWidth.h +@@ -100,14 +100,14 @@ namespace BALL + + typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS, + boost::property<boost::vertex_bag_content_t, std::set<OriginalVertexType>, +- boost::property<boost::vertex_bag_special_t, OriginalVertexType, +- boost::property<boost::vertex_bag_type_t, int> > >, ++ boost::property<boost::vertex_bag_special_t, OriginalVertexType, ++ boost::property<boost::vertex_bag_type_t, int> > >, + boost::no_property> TreeDecompositionGraph; + + typedef typename boost::graph_traits<TreeDecompositionGraph>::vertex_descriptor TreeDecompositionBag; + + typedef boost::iterator_property_map<typename std::vector<TreeDecompositionBag>::iterator, +- typename boost::property_map<TreeDecompositionGraph, boost::vertex_index_t>::type> ++ typename boost::property_map<TreeDecompositionGraph, boost::vertex_index_t>::type> + TreeDecompositionParentMap; + typedef boost::graph_as_tree<TreeDecompositionGraph, TreeDecompositionParentMap> TreeDecomposition; + +@@ -131,7 +131,7 @@ namespace BALL + class ComponentFilter_ + { + public: +- ComponentFilter_(ComponentMap cm, Position i) ++ ComponentFilter_(ComponentMap cm, Position i) + : cm_(cm), + component_(i) + { } +@@ -144,7 +144,7 @@ namespace BALL + + protected: + ComponentMap cm_; +- Position component_; ++ Position component_; + }; + + /** PropertyWriter for graphviz output. +@@ -167,7 +167,7 @@ namespace BALL + // TODO: would UndirectedGraph suffice here? + MolecularGraph const* input_; + +- std::vector<boost::shared_ptr<EditableGraph> > components_; ++ std::vector<boost::shared_ptr<EditableGraph> > components_; + + std::vector<boost::shared_ptr<TreeDecomposition> > nice_tree_decompositions_; + std::vector<boost::shared_ptr<TreeDecompositionGraph> > nice_tree_decomposition_graphs_; +@@ -201,7 +201,7 @@ namespace BALL + * @tparam Reducer the reducer which removes a vertex from the graph to reduce it's size + */ + template<class Criterion, class Reducer> +- class GeneralLowerBoundAlgorithm ++ class GeneralLowerBoundAlgorithm + : public UnaryFunctor<UndirectedGraph, Size> + { + public: +@@ -284,7 +284,7 @@ namespace BALL + * @throw BALL::GRAPH::UnconnectedGraphException if called on unconnected graphs + */ + template<class Criterion> +- class GreedyX ++ class GreedyX + : public UnaryFunctor<UndirectedGraph, typename std::pair< + std::vector<boost::graph_traits<typename UndirectedGraph::vertex_descriptor> >, Size> > + { +@@ -296,7 +296,7 @@ namespace BALL + * A criterium for GreedyFillIn which search for a vertex with + * minimum number of additional edges after eliminating + */ +- struct FillInHeuristic ++ struct FillInHeuristic + { + VertexType& operator() (UndirectedGraph& graph); + +@@ -323,8 +323,8 @@ namespace BALL + */ + enum SIMPLICIAL_TYPE + { +- NOT_SIMPLICIAL, +- ALMOST_SIMPLICIAL, ++ NOT_SIMPLICIAL, ++ ALMOST_SIMPLICIAL, + IS_SIMPLICIAL + }; + +@@ -484,7 +484,7 @@ namespace BALL + TreeDecompositionBag buildJoin_(TreeDecompositionBag node, TreeDecompositionBag left, + TreeDecompositionBag right, bool do_forget); + +- TreeDecompositionBag buildSingle_(TreeDecompositionBag node, int node_type, ++ TreeDecompositionBag buildSingle_(TreeDecompositionBag node, int node_type, + TreeDecompositionBag child); + + TreeDecompositionBag buildLinkage_(TreeDecompositionBag node, TreeDecompositionBag child); +@@ -492,8 +492,8 @@ namespace BALL + TreeDecompositionBag linkWithIntroduceNodes_(TreeDecompositionContent parent_set, TreeDecompositionBag child); + TreeDecompositionBag linkWithForgetNodes_ (TreeDecompositionContent parent_set, TreeDecompositionBag child); + +- TreeDecompositionBag branch_(TreeDecompositionBag node, int node_type, +- typename std::vector<TreeDecompositionBag>::iterator begin, ++ TreeDecompositionBag branch_(TreeDecompositionBag node, int node_type, ++ typename std::vector<TreeDecompositionBag>::iterator begin, + typename std::vector<TreeDecompositionBag>::iterator end); + + boost::shared_ptr<TreeDecomposition> tree_; +diff --git a/include/BALL/STRUCTURE/BONDORDERS/FPTBondOrderStrategy.h b/include/BALL/STRUCTURE/BONDORDERS/FPTBondOrderStrategy.h +index 55cef31..ba129b0 100644 +--- a/include/BALL/STRUCTURE/BONDORDERS/FPTBondOrderStrategy.h ++++ b/include/BALL/STRUCTURE/BONDORDERS/FPTBondOrderStrategy.h +@@ -1117,6 +1117,11 @@ namespace BALL + Size max_heap_size_; + + /** ++ * The number of solutions produced so far. ++ */ ++ Size num_computed_solutions_; ++ ++ /** + * current upperbound. This algorithm will just iterate solutions which are better than this upperbound; + */ + Penalty upper_bound_; +@@ -1248,14 +1253,6 @@ namespace BALL + Size solution_number, Penalty upper_bound = infinite_penalty); + + /** +- * Construct a DPBackTrackingCombiner with the given FPTBondOrder and the number of solutions +- * @param bondAssignments vector with the bond assignments. Call #compute before constructing +- * @param solutionNumber the maximum number of solutions you want to backtrack +- */ +- DPBackTrackingCombiner_(std::vector<FPTBondOrderAssignment_>& bond_assignments, +- Size solution_number, Penalty upper_bound = infinite_penalty); +- +- /** + * Copy constructor + */ + DPBackTrackingCombiner_(DPBackTrackingCombiner_ const& copy); +@@ -1407,9 +1404,6 @@ namespace BALL + */ + std::vector<std::vector<int> > const* atom_to_block_; + +- /// upper bound on the penalty values for which we compute solutions +- Penalty upper_bound_; +- + /** + * A shared pointer to the computing data, so that you can copy this instance without copying + * all the computing data +diff --git a/include/BALL/STRUCTURE/assignBondOrderProcessor.h b/include/BALL/STRUCTURE/assignBondOrderProcessor.h +index f8065d6..0d14af8 100644 +--- a/include/BALL/STRUCTURE/assignBondOrderProcessor.h ++++ b/include/BALL/STRUCTURE/assignBondOrderProcessor.h +@@ -183,17 +183,35 @@ namespace BALL + + /** the maximal number of solutions to compute + * +- * If set to zero all optimal solutions will be computed. ++ * If set to zero all optimal or all up to \link MAX_PENALTY MAX_PENALTY \endlink ++ * solutions will be computed. + * +- * @see Option::COMPUTE_ALSO_NON_OPTIMAL_SOLUTIONS ++ * @see Option::COMPUTE_ALSO_NON_OPTIMAL_SOLUTIONS ++ * @see Option::MAX_PENALTY + */ + static const char* MAX_NUMBER_OF_SOLUTIONS; + +- /** compute also non-optimal solutions but not more than +- * \link MAX_NUMBER_OF_SOLUTIONS MAX_NUMBER_OF_SOLUTIONS \endlink solutions. ++ /** the maximal penalty score allowed ++ * ++ * This option respects option \link MAX_NUMBER_OF_SOLUTIONS MAX_NUMBER_OF_SOLUTIONS \endlink ++ * if specified. + * ++ * If set to -1 this option will be ignored. ++ * ++ * @see Option::COMPUTE_ALSO_NON_OPTIMAL_SOLUTIONS + * @see Option::MAX_NUMBER_OF_SOLUTIONS + */ ++ static const char* MAX_PENALTY; ++ ++ /** compute also sub-optimal solutions but not more than ++ * \link MAX_NUMBER_OF_SOLUTIONS MAX_NUMBER_OF_SOLUTIONS \endlink solutions. ++ * ++ * Alternatively \link Option::MAX_PENALTY Option::MAX_PENALTY \endlink ++ * allows to specify a maximal penalty. ++ * ++ * @see Option::MAX_NUMBER_OF_SOLUTIONS ++ * @see Option::MAX_PENALTY ++ */ + static const char* COMPUTE_ALSO_NON_OPTIMAL_SOLUTIONS; + + /** weighting of bond length penalties wrt valence penalties. +@@ -227,6 +245,7 @@ namespace BALL + static const String INIFile; + static const int MAX_BOND_ORDER; + static const int MAX_NUMBER_OF_SOLUTIONS; ++ static const int MAX_PENALTY; + static const bool COMPUTE_ALSO_NON_OPTIMAL_SOLUTIONS; + static const float BOND_LENGTH_WEIGHTING; + static const bool APPLY_FIRST_SOLUTION; +@@ -716,6 +735,9 @@ namespace BALL + // the max number of solutions to compute + int max_number_of_solutions_; + ++ // the max penalty score ++ int max_penalty_; ++ + // flag to indicate, whether also non-optimal solutions should be computed + bool compute_also_non_optimal_solutions_; + +diff --git a/source/APPLICATIONS/UTILITIES/assign_bond_orders.C b/source/APPLICATIONS/UTILITIES/assign_bond_orders.C +index cefef9b..7053baa 100644 +--- a/source/APPLICATIONS/UTILITIES/assign_bond_orders.C ++++ b/source/APPLICATIONS/UTILITIES/assign_bond_orders.C +@@ -16,10 +16,10 @@ using namespace BALL; + + int main(int argc, char** argv) + { +- if ((argc < 3) || (argc > 4)) ++ if (argc < 3) + // if (argc != 3) + { +- Log << "Usage:" << argv[0] << " <Molecule infile> <Molecule outfile> [num_sol]" << endl; ++ Log << "Usage:" << argv[0] << " <Molecule infile> <Molecule outfile> [--num-sol=n] [--strategy=(fpt|a_star|ilp)] [--max-penalty=m]" << endl; + return 1; + } + +@@ -49,24 +49,40 @@ int main(int argc, char** argv) + // set the options: + // + // the solution strategy (A*, ILP or FPT) +- abop.options.set(AssignBondOrderProcessor::Option::ALGORITHM, AssignBondOrderProcessor::Algorithm::A_STAR); ++ abop.options.set(AssignBondOrderProcessor::Option::ALGORITHM, AssignBondOrderProcessor::Algorithm::FPT); + + // specify the inifile with the atomic valence penalties + abop.options.set(AssignBondOrderProcessor::Option::INIFile, AssignBondOrderProcessor::Default::INIFile); + + // options for considering bond length as well +- abop.options.setReal(AssignBondOrderProcessor::Option::BOND_LENGTH_WEIGHTING, 0); +- abop.options.setReal(AssignBondOrderProcessor::Option::USE_FINE_PENALTY, true); ++// abop.options.setReal(AssignBondOrderProcessor::Option::BOND_LENGTH_WEIGHTING, 0); ++// abop.options.setReal(AssignBondOrderProcessor::Option::USE_FINE_PENALTY, true); + + // the combination of the following two options causes the computation of all optimal solutions + abop.options.setInteger(AssignBondOrderProcessor::Option::MAX_NUMBER_OF_SOLUTIONS, 0); + abop.options.setBool(AssignBondOrderProcessor::Option::COMPUTE_ALSO_NON_OPTIMAL_SOLUTIONS, false); + +- if (argc == 4) ++ if (argc > 3) + { +- Log << " with compute fixed number (" << argv[3] << ") solutions" << endl; +- abop.options.setInteger(AssignBondOrderProcessor::Option::MAX_NUMBER_OF_SOLUTIONS, String(argv[3]).toInt()); +- abop.options.setBool(AssignBondOrderProcessor::Option::COMPUTE_ALSO_NON_OPTIMAL_SOLUTIONS, true); ++ for (Index i=3; i<argc; ++i) ++ { ++ if (String(argv[i]).hasPrefix("--strategy")) ++ { ++ abop.options.set(AssignBondOrderProcessor::Option::ALGORITHM, String(argv[i]).getField(1, "=")); ++ } ++ else if (String(argv[i]).hasPrefix("--num-sol")) ++ { ++ Log << " with compute fixed number (" << argv[i] << ") solutions" << endl; ++ abop.options.setInteger(AssignBondOrderProcessor::Option::MAX_NUMBER_OF_SOLUTIONS, String(argv[i]).getField(1, "=").toInt()); ++ abop.options.setBool(AssignBondOrderProcessor::Option::COMPUTE_ALSO_NON_OPTIMAL_SOLUTIONS, true); ++ } ++ else if (String(argv[i]).hasPrefix("--max-penalty")) ++ { ++ abop.options.setInteger(AssignBondOrderProcessor::Option::MAX_PENALTY, String(argv[i]).getField(1, "=").toInt()); ++ abop.options.setBool(AssignBondOrderProcessor::Option::COMPUTE_ALSO_NON_OPTIMAL_SOLUTIONS, true); ++ Log << " with maximum penalty (" << abop.options.getInteger(AssignBondOrderProcessor::Option::MAX_PENALTY) << ")" << endl; ++ } ++ } + } + + // define input and output properties +diff --git a/source/DATATYPE/GRAPH/treeWidth.C b/source/DATATYPE/GRAPH/treeWidth.C +index 7485305..cd0a879 100644 +--- a/source/DATATYPE/GRAPH/treeWidth.C ++++ b/source/DATATYPE/GRAPH/treeWidth.C +@@ -12,7 +12,7 @@ namespace BALL + // find all vertices in the current bag + TreeDecompositionContent content = boost::get(boost::vertex_bag_content, *td_, v); + +- for (typename TreeDecompositionContent::const_iterator tdc_it = content.begin(); tdc_it != content.end(); ++tdc_it) ++ for (TreeDecompositionContent::const_iterator tdc_it = content.begin(); tdc_it != content.end(); ++tdc_it) + { + TreeWidth<MolecularGraph>::OriginalVertexType ov = *tdc_it; + Atom const* atom = boost::get(boost::vertex_atom_ptr, *original_graph_, ov); +diff --git a/source/STRUCTURE/BONDORDERS/FPTBondOrderStrategy.C b/source/STRUCTURE/BONDORDERS/FPTBondOrderStrategy.C +index 42040e5..107823e 100644 +--- a/source/STRUCTURE/BONDORDERS/FPTBondOrderStrategy.C ++++ b/source/STRUCTURE/BONDORDERS/FPTBondOrderStrategy.C +@@ -12,10 +12,6 @@ namespace BALL + const FPTBondOrderStrategy::Penalty FPTBondOrderStrategy::infinite_penalty = 1e5; + const FPTBondOrderStrategy::Valence FPTBondOrderStrategy::max_valence = 8; + +- String FPTBondOrderStrategy::Option::UPPER_PENALTY_BOUND = "upper_penalty_bound"; +- +- FPTBondOrderStrategy::Penalty FPTBondOrderStrategy::Default::UPPER_PENALTY_BOUND = infinite_penalty; +- + FPTBondOrderStrategy::FPTBondOrderStrategy(AssignBondOrderProcessor* parent) + : BondOrderAssignmentStrategy(parent) + { +@@ -33,15 +29,11 @@ namespace BALL + + bool FPTBondOrderStrategy::readOptions(const Options& options) + { +- upper_bound_ = options.get(Option::UPPER_PENALTY_BOUND).toFloat(); +- + return true; + } + + void FPTBondOrderStrategy::setDefaultOptions() + { +- abop->options.setDefault(FPTBondOrderStrategy::Option::UPPER_PENALTY_BOUND, +- FPTBondOrderStrategy::Default::UPPER_PENALTY_BOUND); + } + + void FPTBondOrderStrategy::init() +@@ -64,16 +56,22 @@ namespace BALL + std::vector<boost::shared_ptr<TreeDecomposition> > & ntds = computing_data_->tw->getNiceTreeDecompositions(); + std::vector<FPTBondOrderAssignment_*>& bond_assignments = computing_data_->bond_assignments; + ++ int max_penalty = abop->max_penalty_; ++ if (max_penalty == -1) ++ max_penalty = infinite_penalty; ++ else ++ max_penalty += 1; ++ + bond_assignments.reserve(ntds.size()); + for (Position i = 0; i < ntds.size(); ++i) + { +- bond_assignments.push_back(new FPTBondOrderAssignment_(*this, ntds[i], upper_bound_)); +- bond_assignments[i]->compute(); ++ bond_assignments.push_back(new FPTBondOrderAssignment_(*this, ntds[i], max_penalty)); ++ Penalty result = bond_assignments[i]->compute(); + } + + // initialize backtracking + combiner_ = boost::shared_ptr<DPBackTrackingCombiner_>( +- new DPBackTrackingCombiner_(bond_assignments, abop->max_number_of_solutions_, upper_bound_)); ++ new DPBackTrackingCombiner_(bond_assignments, abop->max_number_of_solutions_, max_penalty)); + } + + boost::shared_ptr<BondOrderAssignment> FPTBondOrderStrategy::computeNextSolution() +@@ -144,7 +142,7 @@ namespace BALL + int penalty = (*penalties_)[start_index + position]; + + return (penalty < 0) ? infinite_penalty : static_cast<float>(penalty); +- } ++ } + else + { + return infinite_penalty; +@@ -155,20 +153,20 @@ namespace BALL + //* DPConfig_ * + //***************************************************************************************************** + +- FPTBondOrderStrategy::DPConfig_::DPConfig_() +- : consumed_valences(0), ++ FPTBondOrderStrategy::DPConfig_::DPConfig_() ++ : consumed_valences(0), + bond_assignments(0) + { + } + +- FPTBondOrderStrategy::DPConfig_::DPConfig_(Size atoms, Size bonds) +- : consumed_valences(atoms, 0), ++ FPTBondOrderStrategy::DPConfig_::DPConfig_(Size atoms, Size bonds) ++ : consumed_valences(atoms, 0), + bond_assignments(bonds, 0) + { + } + +- FPTBondOrderStrategy::DPConfig_::DPConfig_(std::vector<Valence> const& v, std::vector<BondOrder> const& bo) +- : consumed_valences(v), ++ FPTBondOrderStrategy::DPConfig_::DPConfig_(std::vector<Valence> const& v, std::vector<BondOrder> const& bo) ++ : consumed_valences(v), + bond_assignments(bo) + { + } +@@ -258,12 +256,12 @@ namespace BALL + //* DPTable_ * + //***************************************************************************************************** + +- FPTBondOrderStrategy::DPTable_::DPTable_() ++ FPTBondOrderStrategy::DPTable_::DPTable_() + : table() + { + } + +- FPTBondOrderStrategy::DPTable_::DPTable_(DPTable_ const& dptab) ++ FPTBondOrderStrategy::DPTable_::DPTable_(DPTable_ const& dptab) + : table(dptab.table) + { + } +@@ -345,7 +343,7 @@ namespace BALL + if (insertion.second) + { + return true; +- } ++ } + else + { + if (insertion.first->second > penalty) +@@ -353,7 +351,7 @@ namespace BALL + insertion.first->second = penalty; + + return true; +- } ++ } + else + { + return false; +@@ -365,14 +363,14 @@ namespace BALL + //* AdditionalBagProperties_ * + //***************************************************************************************************** + +- FPTBondOrderStrategy::AdditionalBagProperties_::AdditionalBagProperties_() +- : bonds(), +- table(new DPTable_()) ++ FPTBondOrderStrategy::AdditionalBagProperties_::AdditionalBagProperties_() ++ : bonds(), ++ table(new DPTable_()) + { + } + +- FPTBondOrderStrategy::AdditionalBagProperties_::AdditionalBagProperties_(AdditionalBagProperties_ const& copy) +- : bonds(copy.bonds), ++ FPTBondOrderStrategy::AdditionalBagProperties_::AdditionalBagProperties_(AdditionalBagProperties_ const& copy) ++ : bonds(copy.bonds), + table(new DPTable_(*copy.table)) + { + } +@@ -384,7 +382,7 @@ namespace BALL + + FPTBondOrderStrategy::AdditionalBagProperties_& FPTBondOrderStrategy::AdditionalBagProperties_::operator=(AdditionalBagProperties_ const& copy) + { +- if (© != this) ++ if (© != this) + { + bonds = copy.bonds; + table = new DPTable_(*copy.table); +@@ -447,7 +445,7 @@ namespace BALL + { + throw Exception::NullPointer(__FILE__, __LINE__); + } +- case TreeWidth<MolecularGraph>::LEAF_BAG: ++ case TreeWidth<MolecularGraph>::LEAF_BAG: + break; + case TreeWidth<MolecularGraph>::END_BAG: + if (boost::num_vertices(*molecule_) == 0 && (bag == root(*ntd_))) +@@ -455,7 +453,7 @@ namespace BALL + // empty molecule -> empty table + bag_properties.table->insert(DPConfig_(), 0); + return bag_properties.table; +- } ++ } + else + { + // else nice tree decomposition is damaged +@@ -603,7 +601,7 @@ namespace BALL + return bonds; + } + +- void FPTBondOrderStrategy::FPTBondOrderAssignment_::computeIntroduceBag(TreeDecompositionBag& bag, DPTable_& child, ++ void FPTBondOrderStrategy::FPTBondOrderAssignment_::computeIntroduceBag(TreeDecompositionBag& bag, DPTable_& child, + AdditionalBagProperties_& property) + { + typedef TreeWidth<MolecularGraph>::TreeDecompositionContent TreeDecompositionContent; +@@ -614,7 +612,7 @@ namespace BALL + + TreeDecompositionContent vertices = boost::get(boost::vertex_bag_content, *ntd_, bag); + Size num_valences = vertices.size(); +- ++ + std::vector<MolecularGraphTraits::EdgeType>& bonds = property.bonds; + Size num_bonds = bonds.size(); + +@@ -654,7 +652,7 @@ namespace BALL + { + // remember the indizes of the new introduced bonds + indices.push_back(vindex); +- } ++ } + else + { + conf.bond_assignments[vindex] = child_entry.first.get().bond_assignments[cindex++]; +@@ -662,7 +660,7 @@ namespace BALL + } + + // if there are any introduced bonds we have to fill them with each possible value +- if (indices.size() > 0) ++ if (indices.size() > 0) + { + std::vector<int> bond_values(indices.size()); + +@@ -685,7 +683,7 @@ namespace BALL + ++current_index; + } + } +- } ++ } + else + { + table.insert(conf, child_entry.second); +@@ -768,7 +766,7 @@ namespace BALL + return parent_->getPenaltyFor_(forgotten_vertex, forgotten_valence) + child_row.second; + } + +- void FPTBondOrderStrategy::FPTBondOrderAssignment_::computeForgetBag(TreeDecompositionBag& bag, DPTable_& child, ++ void FPTBondOrderStrategy::FPTBondOrderAssignment_::computeForgetBag(TreeDecompositionBag& bag, DPTable_& child, + AdditionalBagProperties_& property) + { + typedef TreeWidth<MolecularGraph>::TreeDecompositionContent TreeDecompositionContent; +@@ -795,7 +793,7 @@ namespace BALL + } + } + +- void FPTBondOrderStrategy::FPTBondOrderAssignment_::computeRootBag(TreeDecompositionBag& bag, ++ void FPTBondOrderStrategy::FPTBondOrderAssignment_::computeRootBag(TreeDecompositionBag& bag, + DPTable_& child, AdditionalBagProperties_& bag_properties) + { + DPConfig_ empty(0, 0); +@@ -816,7 +814,8 @@ namespace BALL + } + + void FPTBondOrderStrategy::FPTBondOrderAssignment_::computeJoinBag(TreeDecompositionBag& bag, +- DPTable_& left_child, DPTable_& right_child, AdditionalBagProperties_& property) ++ DPTable_& left_child, DPTable_& right_child, ++ AdditionalBagProperties_& property) + { + typedef TreeWidth<MolecularGraph>::TreeDecompositionContent TreeDecompositionContent; + +@@ -1268,22 +1267,23 @@ namespace BALL + //* DPBackTracking_ * + //***************************************************************************************************** + +- FPTBondOrderStrategy::DPBackTracking_::DPBackTracking_(FPTBondOrderAssignment_& bond_assignment, Size max_num_solutions, +- std::vector<MolecularGraphTraits::EdgeType> const& bonds, Penalty upper_bound) +- : bond_assignment_(&bond_assignment), +- current_state_(NULL), +- queue_(), +- max_num_solutions_(max_num_solutions), ++ FPTBondOrderStrategy::DPBackTracking_::DPBackTracking_(FPTBondOrderAssignment_& bond_assignment, Size max_num_solutions, ++ std::vector<MolecularGraphTraits::EdgeType> const& bonds, Penalty upper_bound) ++ : bond_assignment_(&bond_assignment), ++ current_state_(NULL), ++ queue_(), ++ max_num_solutions_(max_num_solutions), + bonds_(&bonds), +- bags_(boost::shared_ptr<std::vector<TreeDecompositionBag> >(new std::vector<TreeDecompositionBag>)), +- max_heap_size_(max_num_solutions), ++ bags_(boost::shared_ptr<std::vector<TreeDecompositionBag> >(new std::vector<TreeDecompositionBag>)), ++ max_heap_size_(1e6), ++ num_computed_solutions_(0), + upper_bound_(upper_bound) + { + // order bags in preorder + if (bond_assignment.ntd_ == NULL) + { + throw Exception::NullPointer(__FILE__, __LINE__); +- } ++ } + else + { + bags_->reserve(boost::num_vertices(bond_assignment.ntd_->_g)); +@@ -1303,14 +1303,15 @@ namespace BALL + } + } + +- FPTBondOrderStrategy::DPBackTracking_::DPBackTracking_(DPBackTracking_ const& copy) +- : bond_assignment_(copy.bond_assignment_), +- current_state_(NULL), ++ FPTBondOrderStrategy::DPBackTracking_::DPBackTracking_(DPBackTracking_ const& copy) ++ : bond_assignment_(copy.bond_assignment_), ++ current_state_(NULL), + queue_(), +- max_num_solutions_(copy.max_num_solutions_), +- bonds_(copy.bonds_), +- bags_(copy.bags_), ++ max_num_solutions_(copy.max_num_solutions_), ++ bonds_(copy.bonds_), ++ bags_(copy.bags_), + max_heap_size_(copy.max_heap_size_), ++ num_computed_solutions_(copy.num_computed_solutions_), + upper_bound_(copy.upper_bound_) + { + if (copy.current_state_ != NULL) +@@ -1345,6 +1346,7 @@ namespace BALL + bonds_ = copy.bonds_; + bags_ = copy.bags_; + max_heap_size_ = copy.max_heap_size_; ++ num_computed_solutions_ = copy.num_computed_solutions_; + upper_bound_ = copy.upper_bound_; + } + +@@ -1365,6 +1367,7 @@ namespace BALL + + std::vector<BackTrackingState_*> copy(queue_.begin(), queue_.end()); + queue_.clear(); ++ num_computed_solutions_ = 0; + + for (std::vector<BackTrackingState_*>::iterator iter = copy.begin(); iter != copy.end(); ++iter) + { +@@ -1372,7 +1375,7 @@ namespace BALL + } + } + +- bool FPTBondOrderStrategy::DPBackTracking_::StateComparator_::operator() (BackTrackingState_ const * left, ++ bool FPTBondOrderStrategy::DPBackTracking_::StateComparator_::operator() (BackTrackingState_ const * left, + BackTrackingState_ const * right) const + { + return *left < *right; +@@ -1397,7 +1400,7 @@ namespace BALL + if (order < properties.size()) + { + return properties[order]; +- } ++ } + else + { + throw Exception::IndexOverflow(__FILE__, __LINE__, static_cast<Index>(order), properties.size()); +@@ -1426,12 +1429,12 @@ namespace BALL + + bool FPTBondOrderStrategy::DPBackTracking_::hasMoreSolutions() const + { +- return (!queue_.empty() && (max_heap_size_ > 0)); ++ return (!queue_.empty() && (!max_num_solutions_ || (num_computed_solutions_ <= max_num_solutions_))); + } + + void FPTBondOrderStrategy::DPBackTracking_::nextSolution() + { +- if (queue_.empty() || max_heap_size_ == 0) ++ if (queue_.empty() || max_heap_size_ == 0 || ((max_num_solutions_ > 0) && (num_computed_solutions_ > max_num_solutions_))) + { + throw Exception::OutOfRange(__FILE__, __LINE__); + } +@@ -1444,7 +1447,7 @@ namespace BALL + std::multiset<BackTrackingState_*, StateComparator_>::iterator first = queue_.begin(); + current_state_ = *first; + queue_.erase(first); +- --max_heap_size_; ++ ++num_computed_solutions_; + + TreeDecomposition& tree = *bond_assignment_->ntd_; + +@@ -1469,7 +1472,7 @@ namespace BALL + { + TreeDecomposition::children_iterator c_2 = c_i; + ++c_2; +- visitJoin(*current_state_, bag, getTable(boost::get(boost::vertex_index, tree, *c_i)), ++ visitJoin(*current_state_, bag, getTable(boost::get(boost::vertex_index, tree, *c_i)), + getTable(boost::get(boost::vertex_index, tree, *c_2))); + break; + } +@@ -1769,7 +1772,7 @@ namespace BALL + if (d < bonds_->size()) + { + return d; +- } ++ } + else + { + throw Exception::IndexOverflow(__FILE__, __LINE__, static_cast<Index>(d), bonds_->size()); +@@ -1795,7 +1798,7 @@ namespace BALL + + bool FPTBondOrderStrategy::DPBackTracking_::isSolutionNeeded(Penalty penalty) + { +- if (max_heap_size_ == 0) {return false;} ++ if (max_heap_size_ == 0 || ((max_num_solutions_ > 0) && (num_computed_solutions_ > max_num_solutions_))) {return false;} + if (queue_.size() >= max_heap_size_) {return Maths::isLess(penalty, upper_bound_);} + return Maths::isLessOrEqual(penalty, upper_bound_); + } +@@ -1846,7 +1849,7 @@ namespace BALL + if (queue_.empty() || max_heap_size_ == 0) + { + return FPTBondOrderStrategy::infinite_penalty; +- } ++ } + else + { + return (*queue_.begin())->assignment.penalty; +@@ -1857,25 +1860,25 @@ namespace BALL + //* DPBackTrackingCombiner_ * + //***************************************************************************************************** + +- FPTBondOrderStrategy::DPBackTrackingCombiner_::DPBackTrackingCombiner_(DPBackTrackingCombiner_ const& copy) +- : backtrackers_(copy.deepCopyOfBacktrackers_()), ++ FPTBondOrderStrategy::DPBackTrackingCombiner_::DPBackTrackingCombiner_(DPBackTrackingCombiner_ const& copy) ++ : backtrackers_(copy.deepCopyOfBacktrackers_()), + priority_queue_(copy.priority_queue_), +- component_solutions_(copy.component_solutions_), ++ component_solutions_(copy.component_solutions_), + assignment_(copy.assignment_), +- solution_number_(copy.solution_number_), +- optimum_(copy.optimum_), ++ solution_number_(copy.solution_number_), ++ optimum_(copy.optimum_), + upper_bound_(copy.upper_bound_) + { + } + +- FPTBondOrderStrategy::DPBackTrackingCombiner_::DPBackTrackingCombiner_(std::vector<FPTBondOrderAssignment_*>& bond_assignments, +- Size solution_number, Penalty upper_bound) +- : backtrackers_(), +- priority_queue_(), ++ FPTBondOrderStrategy::DPBackTrackingCombiner_::DPBackTrackingCombiner_(std::vector<FPTBondOrderAssignment_*>& bond_assignments, ++ Size solution_number, Penalty upper_bound) ++ : backtrackers_(), ++ priority_queue_(), + component_solutions_(bond_assignments.size()), +- assignment_(), +- solution_number_(solution_number), +- optimum_(FPTBondOrderStrategy::infinite_penalty), ++ assignment_(), ++ solution_number_(solution_number), ++ optimum_(FPTBondOrderStrategy::infinite_penalty), + upper_bound_(upper_bound) + { + if (bond_assignments.empty()) +@@ -1897,7 +1900,7 @@ namespace BALL + FPTBondOrderStrategy::EdgeComparator_ ec(&graph); + std::sort(sorted_edges.begin(), sorted_edges.end(), ec); + +- for (std::vector<FPTBondOrderAssignment_*>::const_iterator iter = bond_assignments.begin(); ++ for (std::vector<FPTBondOrderAssignment_*>::const_iterator iter = bond_assignments.begin(); + iter != bond_assignments.end(); ++iter) + { + backtrackers_.push_back(new DPBackTracking_(**iter, solution_number_, sorted_edges, upper_bound_)); +@@ -1906,39 +1909,6 @@ namespace BALL + initialize_(); + } + +- FPTBondOrderStrategy::DPBackTrackingCombiner_::DPBackTrackingCombiner_(std::vector<FPTBondOrderAssignment_>& bond_assignments, +- Size solution_number, Penalty upper_bound) +- : backtrackers_(), +- priority_queue_(), +- component_solutions_(bond_assignments.size()), +- assignment_(), +- solution_number_(solution_number), +- optimum_(FPTBondOrderStrategy::infinite_penalty), +- upper_bound_(upper_bound) +- { +- backtrackers_.reserve(bond_assignments.size()); +- +- MolecularGraph& graph = *bond_assignments[0].molecule_; +- sorted_edges.reserve(boost::num_edges(graph)); +- +- BGL_FORALL_EDGES(edge_it, graph, MolecularGraph) +- { +- sorted_edges.push_back(edge_it); +- } +- +- // sort bonds - the second vertex could be in false order +- FPTBondOrderStrategy::EdgeComparator_ ec(&graph); +- std::sort(sorted_edges.begin(), sorted_edges.end(), ec); +- +- for (std::vector<FPTBondOrderAssignment_>::iterator iter = bond_assignments.begin(); +- iter != bond_assignments.end(); ++iter) +- { +- backtrackers_.push_back(new DPBackTracking_(*iter, solution_number_, sorted_edges, upper_bound_)); +- } +- +- initialize_(); +- } +- + FPTBondOrderStrategy::DPBackTrackingCombiner_::~DPBackTrackingCombiner_() + { + clear(); +@@ -1946,14 +1916,14 @@ namespace BALL + + void FPTBondOrderStrategy::DPBackTrackingCombiner_::clear() + { +- for (std::vector<DPBackTracking_*>::iterator iter = backtrackers_.begin(); ++ for (std::vector<DPBackTracking_*>::iterator iter = backtrackers_.begin(); + iter != backtrackers_.end(); ++iter) + { + delete *iter; + } + } + +- FPTBondOrderStrategy::DPBackTrackingCombiner_& ++ FPTBondOrderStrategy::DPBackTrackingCombiner_& + FPTBondOrderStrategy::DPBackTrackingCombiner_::operator = (DPBackTrackingCombiner_ const& copy) + { + if (this != ©) +@@ -1972,7 +1942,7 @@ namespace BALL + return *this; + } + +- std::pair<Size, FPTBondOrderStrategy::Penalty> ++ std::pair<Size, FPTBondOrderStrategy::Penalty> + FPTBondOrderStrategy::DPBackTrackingCombiner_::getNextMinimumBackTracker_() const + { + if (backtrackers_.size() == 1) +@@ -2034,7 +2004,7 @@ namespace BALL + assignment_ = ass; + + return; +- } ++ } + else + { + throw Exception::OutOfRange(__FILE__, __LINE__); +@@ -2061,7 +2031,7 @@ namespace BALL + assignment_ = priority_queue_.top(); + + priority_queue_.pop(); +- } ++ } + else + { + throw Exception::OutOfRange(__FILE__, __LINE__); +@@ -2151,7 +2121,7 @@ namespace BALL + return assignment_; + } + +- std::vector<FPTBondOrderStrategy::DPBackTracking_*> ++ std::vector<FPTBondOrderStrategy::DPBackTracking_*> + FPTBondOrderStrategy::DPBackTrackingCombiner_::deepCopyOfBacktrackers_() const + { + std::vector<DPBackTracking_*> ts; +@@ -2166,5 +2136,4 @@ namespace BALL + return ts; + } + +- + } +diff --git a/source/STRUCTURE/assignBondOrderProcessor.C b/source/STRUCTURE/assignBondOrderProcessor.C +index f8acc4f..9863a54 100644 +--- a/source/STRUCTURE/assignBondOrderProcessor.C ++++ b/source/STRUCTURE/assignBondOrderProcessor.C +@@ -108,6 +108,9 @@ namespace BALL + const char* AssignBondOrderProcessor::Option::MAX_NUMBER_OF_SOLUTIONS = "max_number_of_solutions"; + const int AssignBondOrderProcessor::Default::MAX_NUMBER_OF_SOLUTIONS = 10; + ++ const char* AssignBondOrderProcessor::Option::MAX_PENALTY = "max_penalty_score"; ++ const int AssignBondOrderProcessor::Default::MAX_PENALTY = -1; ++ + const char* AssignBondOrderProcessor::Option::COMPUTE_ALSO_NON_OPTIMAL_SOLUTIONS = "compute_also_non_optimal_solutions"; + const bool AssignBondOrderProcessor::Default::COMPUTE_ALSO_NON_OPTIMAL_SOLUTIONS = false; + +@@ -148,6 +151,7 @@ namespace BALL + max_bond_order_(), + alpha_(), + max_number_of_solutions_(), ++ max_penalty_(-1), + compute_also_non_optimal_solutions_(), + add_missing_hydrogens_(), + compute_also_connectivity_(), +@@ -237,13 +241,14 @@ namespace BALL + ret &= s_it->second->readOptions(options); + } + +- max_bond_order_ = options.getInteger(Option::MAX_BOND_ORDER); +- alpha_ = options.getReal(Option::BOND_LENGTH_WEIGHTING); +- max_number_of_solutions_ = options.getInteger(Option::MAX_NUMBER_OF_SOLUTIONS); ++ max_bond_order_ = options.getInteger(Option::MAX_BOND_ORDER); ++ alpha_ = options.getReal(Option::BOND_LENGTH_WEIGHTING); ++ max_number_of_solutions_ = options.getInteger(Option::MAX_NUMBER_OF_SOLUTIONS); ++ max_penalty_ = options.getInteger(Option::MAX_PENALTY); + compute_also_non_optimal_solutions_ = options.getBool(Option::COMPUTE_ALSO_NON_OPTIMAL_SOLUTIONS); +- add_missing_hydrogens_ = options.getBool(Option::ADD_HYDROGENS); ++ add_missing_hydrogens_ = options.getBool(Option::ADD_HYDROGENS); + compute_also_connectivity_ = options.getBool(Option::COMPUTE_ALSO_CONNECTIVITY); +- use_fine_penalty_ = options.getBool(Option::USE_FINE_PENALTY); ++ use_fine_penalty_ = options.getBool(Option::USE_FINE_PENALTY); + + if (max_bond_order_ <= 0) + { +@@ -257,6 +262,12 @@ namespace BALL + << " : Error in options! Please check the option Option::MAX_NUMBER_OF_SOLUTIONS." << endl; + ret = false; + } ++ if (max_penalty_ < -1) ++ { ++ Log.error() << __FILE__ << " " << __LINE__ ++ << " : Error in options! Please check the option Option::MAX_PENALTY." << endl; ++ ret = false; ++ } + if ((alpha_ < 0) || ((alpha_ > 1))) + { + Log.error() << __FILE__ << " " << __LINE__ +@@ -280,14 +291,13 @@ namespace BALL + || (options.getBool(Option::OVERWRITE_SELECTED_BONDS) == true) + || (options.getBool(Option::OVERWRITE_SINGLE_BOND_ORDERS) == false) + || (options.getBool(Option::OVERWRITE_DOUBLE_BOND_ORDERS) == false) +- || (options.getBool(Option::OVERWRITE_TRIPLE_BOND_ORDERS) == false) +- || (options.getInteger(Option::MAX_NUMBER_OF_SOLUTIONS) == 0)) ++ || (options.getBool(Option::OVERWRITE_TRIPLE_BOND_ORDERS) == false) ) + ) + { + Log.error() << __FILE__ << " " << __LINE__ + << " : Error in options! FPT cannot be used with these options." << endl +- << " Switch to solution strategy ASTAR by setting Option::ALGORITHM to Algorithm::ASTAR." << endl; +- ++ << " Consider switch to solution strategy ASTAR by setting Option::ALGORITHM to Algorithm::ASTAR." << endl ++ << " Abort." << endl; + ret = false; + } + +@@ -328,6 +338,7 @@ cout << " \t Penalty file " << options[Option::Option::INIFile] << endl; + cout << " \t alpha: " << options[Option::BOND_LENGTH_WEIGHTING] << endl; + cout << " \t max bond order: " << options[Option::MAX_BOND_ORDER] << endl; + cout << " \t max number of solutions " << options[Option::MAX_NUMBER_OF_SOLUTIONS] << endl; ++cout << " \t max penalty " << options[Option::MAX_PENALTY] << endl; + cout << " \t compute also non-optimal solutions: " << options.getBool(Option::COMPUTE_ALSO_NON_OPTIMAL_SOLUTIONS) << endl; + cout << " \t compute also connectivity: " << options.getBool(Option::COMPUTE_ALSO_CONNECTIVITY) << endl; + cout << " \t connectivity cutoff: " << options[Option::CONNECTIVITY_CUTOFF] << endl; +@@ -354,7 +365,7 @@ cout << endl; + // check the options + + // What kind of composite do we have? +- // Do we have a molecule? (Nothingelse is allowed) ++ // Do we have a molecule? (Nothing else is allowed) + if (RTTI::isKindOf<Molecule>(ac)) + { + // Store the AtomContainer +@@ -517,7 +528,7 @@ cout << "preassignPenaltyClasses_:" << preassignPenaltyClasses_() << " precomput + #ifdef BALL_HAS_LPSOLVE + strategy = strategies_["ILP"].get(); + #else +- Log.error() << "Error: BALL was configured without lpsolve support! Try A_STAR instead!" << ++ Log.error() << "Error: BALL was configured without lpsolve support! Try A_STAR or FPT instead!" << + __FILE__ << " " << __LINE__<< std::endl; + + return Processor::ABORT; +@@ -552,16 +563,20 @@ cout << "preassignPenaltyClasses_:" << preassignPenaltyClasses_() << " precomput + solutions_.push_back(*solution); + + // Do we have to find more solutions? +- bool found_another = true; +- bool last_sol_is_optimal = true; ++ bool found_another = true; ++ bool last_sol_is_optimal = true; ++ bool consider_max_penalty = (max_penalty_ > -1); ++ double last_penalty = getTotalPenalty(0); + + while ( found_another + && ((getNumberOfComputedSolutions() < max_number_of_solutions_) || (!max_number_of_solutions_)) + && (last_sol_is_optimal || (compute_also_non_optimal_solutions_)) ++ && ((last_penalty <= max_penalty_) || (!consider_max_penalty)) + ) + { + found_another = computeNextSolution(options.getBool(Option::APPLY_FIRST_SOLUTION)); + last_sol_is_optimal &= (fabs(getTotalPenalty(0) - getTotalPenalty(solutions_.size()-1)) < 1.e-4); ++ last_penalty = getTotalPenalty(solutions_.size()-1); + } + #if defined DEBUG_TIMER + timer_.stop(); +@@ -1206,6 +1221,9 @@ cout << " ~~~~~~~~ added hydrogen dump ~~~~~~~~~~~~~~~~" << endl; + options.setDefaultInteger(AssignBondOrderProcessor::Option::MAX_NUMBER_OF_SOLUTIONS, + AssignBondOrderProcessor::Default::MAX_NUMBER_OF_SOLUTIONS); + ++ options.setDefaultInteger(AssignBondOrderProcessor::Option::MAX_PENALTY, ++ AssignBondOrderProcessor::Default::MAX_PENALTY); ++ + options.setDefaultBool(AssignBondOrderProcessor::Option::COMPUTE_ALSO_NON_OPTIMAL_SOLUTIONS, + AssignBondOrderProcessor::Default::COMPUTE_ALSO_NON_OPTIMAL_SOLUTIONS); + diff --git a/sci-chemistry/ball/files/ball-1.4.1-BondOrder.xml.patch b/sci-chemistry/ball/files/ball-1.4.1-BondOrder.xml.patch new file mode 100644 index 000000000000..51e592806999 --- /dev/null +++ b/sci-chemistry/ball/files/ball-1.4.1-BondOrder.xml.patch @@ -0,0 +1,30 @@ + source/STRUCTURE/assignBondOrderProcessor.C | 2 +- + source/TEST/AssignBondOrderProcessor_test.C | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/source/STRUCTURE/assignBondOrderProcessor.C b/source/STRUCTURE/assignBondOrderProcessor.C +index f8acc4f..035fffc 100644 +--- a/source/STRUCTURE/assignBondOrderProcessor.C ++++ b/source/STRUCTURE/assignBondOrderProcessor.C +@@ -100,7 +100,7 @@ namespace BALL + const bool AssignBondOrderProcessor::Default::KEKULIZE_RINGS = true; + + const char* AssignBondOrderProcessor::Option::INIFile = "iniFile"; +- const String AssignBondOrderProcessor::Default::INIFile = "/bond_lengths/BondOrder.xml"; ++ const String AssignBondOrderProcessor::Default::INIFile = "bond_lengths/BondOrder.xml"; + + const char* AssignBondOrderProcessor::Option::MAX_BOND_ORDER = "max_bond_order"; + const int AssignBondOrderProcessor::Default::MAX_BOND_ORDER = 3; +diff --git a/source/TEST/AssignBondOrderProcessor_test.C b/source/TEST/AssignBondOrderProcessor_test.C +index 6dfafcc..3405ef5 100644 +--- a/source/TEST/AssignBondOrderProcessor_test.C ++++ b/source/TEST/AssignBondOrderProcessor_test.C +@@ -1834,7 +1834,7 @@ CHECK(Option::INIFile) + // There is really not much we can test here, so we just execute the processor + // to have a chance of catching bugs with valgrind if they sneak in + AssignBondOrderProcessor abop; +- abop.options.set(AssignBondOrderProcessor::Option::INIFile, "/bond_lengths/BondOrderGAFF.xml"); ++ abop.options.set(AssignBondOrderProcessor::Option::INIFile, "bond_lengths/BondOrderGAFF.xml"); + + System sys40; + MOL2File mol40(BALL_TEST_DATA_PATH(AssignBondOrderProcessor_test_C4_input.mol2), std::ios::in); diff --git a/sci-chemistry/ball/files/ball-1.4.1-Fix-compilation-of-FTPBondOrderStrategy-Fixes-451.patch b/sci-chemistry/ball/files/ball-1.4.1-Fix-compilation-of-FTPBondOrderStrategy-Fixes-451.patch new file mode 100644 index 000000000000..40b4b252fa48 --- /dev/null +++ b/sci-chemistry/ball/files/ball-1.4.1-Fix-compilation-of-FTPBondOrderStrategy-Fixes-451.patch @@ -0,0 +1,138 @@ +From: Anna Dehof <anne@bioinf.uni-sb.de> +Date: Fri, 8 Jun 2012 19:28:12 +0200 +Subject: Fix compilation of FTPBondOrderStrategy (Fixes #451) + +This patch is due to Daniel Stoeckel. +--- + source/STRUCTURE/BONDORDERS/FPTBondOrderStrategy.C | 33 +++++++++++--------- + 1 file changed, 18 insertions(+), 15 deletions(-) + +diff --git a/source/STRUCTURE/BONDORDERS/FPTBondOrderStrategy.C b/source/STRUCTURE/BONDORDERS/FPTBondOrderStrategy.C +index 6572d96..98adf98 100644 +--- a/source/STRUCTURE/BONDORDERS/FPTBondOrderStrategy.C ++++ b/source/STRUCTURE/BONDORDERS/FPTBondOrderStrategy.C +@@ -322,7 +322,7 @@ namespace BALL + } + } + +- return *best; ++ return DPConstRow_(boost::reference_wrapper<DPConfig_ const>(best->first), best->second); + } + + FPTBondOrderStrategy::Penalty FPTBondOrderStrategy::DPTable_::operator[](FPTBondOrderStrategy::DPConfig_ const& config) const +@@ -601,6 +601,9 @@ namespace BALL + + return bonds; + } ++ ++#define convertToCRow(tmp)\ ++ std::make_pair(boost::reference_wrapper<const DPConfig_>((tmp).first), (tmp).second) + + void FPTBondOrderStrategy::FPTBondOrderAssignment_::computeIntroduceBag(TreeDecompositionBag& bag, DPTable_& child, + AdditionalBagProperties_& property) +@@ -621,7 +624,7 @@ namespace BALL + // copy with n new bondvalue-columns with different values + for (DPTable_::const_iterator iter = child.begin(); iter != child.end(); ++iter) + { +- DPConstRow_ child_entry = *iter; ++ DPConstRow_ child_entry = convertToCRow(*iter); + DPConfig_ conf(num_valences, num_bonds); + + Size vindex = 0; +@@ -786,7 +789,7 @@ namespace BALL + + for (DPTable_::const_iterator entry_iterator = child.begin(); entry_iterator != child.end(); ++entry_iterator) + { +- Penalty entry_penalty(forgetInnerVertexIn(bag, *entry_iterator, new_entry, child_property.bonds, forgotten_index)); ++ Penalty entry_penalty(forgetInnerVertexIn(bag, convertToCRow(*entry_iterator), new_entry, child_property.bonds, forgotten_index)); + if (entry_penalty < upper_bound_) + { + property.table->insert(new_entry, entry_penalty); +@@ -803,7 +806,7 @@ namespace BALL + Penalty min_penalty = FPTBondOrderStrategy::infinite_penalty; + for (DPTable_::const_iterator iter = child.begin(); iter != child.end(); ++iter) + { +- min_penalty = std::min(min_penalty, forgetInnerVertexIn(bag, *iter, empty, empty_list, 0)); ++ min_penalty = std::min(min_penalty, forgetInnerVertexIn(bag, convertToCRow(*iter), empty, empty_list, 0)); + + if (Maths::isEqual(0, min_penalty)) + { +@@ -830,14 +833,14 @@ namespace BALL + // insert each entry of the left child into a DPJoinMap + for (DPTable_::const_iterator left_iter = left_child.begin(); left_iter != left_child.end(); ++left_iter) + { +- DPConstRow_ left_entry = *left_iter; ++ DPConstRow_ left_entry = convertToCRow(*left_iter); + map.insert(std::pair<DPConfig_ const*, Penalty> (left_entry.first.get_pointer(), left_entry.second)); + } + + // find for each entry of the right child's table appropiate entries in the DPJoinMap (which have the same bondvalues) + for (DPTable_::const_iterator r_iter = right_child.begin(); r_iter != right_child.end(); ++r_iter) + { +- DPConstRow_ right_entry = *r_iter; ++ DPConstRow_ right_entry = convertToCRow(*r_iter); + DPConfig_ const* right_conf = right_entry.first.get_pointer(); + + std::pair<DPJoinMap_::const_iterator, DPJoinMap_::const_iterator> matching_range(map.equal_range(right_conf)); +@@ -1602,7 +1605,7 @@ namespace BALL + // insert possible antecessors in vectors + for (DPTable_::const_iterator iter = left_table.begin(); iter != left_table.end(); ++iter) + { +- DPConstRow_ antecessor = *iter; ++ DPConstRow_ antecessor = convertToCRow(*iter); + if (comp.compare(&successor, antecessor.first.get_pointer()) == 0) + { + left_entries.push_back(iter); +@@ -1611,7 +1614,7 @@ namespace BALL + + for (DPTable_::const_iterator iter = right_table.begin(); iter != right_table.end(); ++iter) + { +- DPConstRow_ antecessor = *iter; ++ DPConstRow_ antecessor = convertToCRow(*iter); + if (comp.compare(&successor, antecessor.first.get_pointer()) == 0) + { + right_entries.push_back(iter); +@@ -1623,10 +1626,10 @@ namespace BALL + + for (std::vector<DPTable_::const_iterator>::const_iterator left = left_entries.begin(); left != left_entries.end(); ++left) + { +- DPConstRow_ left_entry = **left; ++ DPConstRow_ left_entry = convertToCRow(**left); + for (std::vector<DPTable_::const_iterator>::const_iterator right = right_entries.begin(); right != right_entries.end(); ++right) + { +- DPConstRow_ right_entry = **right; ++ DPConstRow_ right_entry = convertToCRow(**right); + + // check sum of valences + bool correct_valences = true; +@@ -1657,8 +1660,8 @@ namespace BALL + + Penalty best_penalty = best.first->second + best.second->second; + +- DPConstRow_ left = *best.first; +- DPConstRow_ right = *best.second; ++ DPConstRow_ left = convertToCRow(*best.first); ++ DPConstRow_ right = convertToCRow(*best.second); + + extendState(state, left.first, 0); + ++state.index; +@@ -1668,8 +1671,8 @@ namespace BALL + { + DPPairIt_ entry = *iter; + +- DPConstRow_ left = *entry.first; +- DPConstRow_ right = *entry.second; ++ DPConstRow_ left = convertToCRow(*entry.first); ++ DPConstRow_ right = convertToCRow(*entry.second); + + Penalty add_penalty = (left.second + right.second) - best_penalty; + if (isSolutionNeeded(state.assignment.penalty + add_penalty)) +@@ -1720,7 +1723,7 @@ namespace BALL + // check for each row entry: is it a possible anteccessor? + for (DPTable_::iterator iter = table.begin(); iter != table.end(); ++iter) + { +- Penalty pen = bond_assignment_->forgetInnerVertexIn(bag, *iter, test_entry, child_bonds, forgotten_index); ++ Penalty pen = bond_assignment_->forgetInnerVertexIn(bag, convertToCRow(*iter), test_entry, child_bonds, forgotten_index); + + if (pen < FPTBondOrderStrategy::infinite_penalty && test_entry == successor) + { diff --git a/sci-chemistry/ball/files/ball-1.4.1-Fix-compilation-of-Python-bindings-with-new-sip-vers.patch b/sci-chemistry/ball/files/ball-1.4.1-Fix-compilation-of-Python-bindings-with-new-sip-vers.patch new file mode 100644 index 000000000000..38b3ba0dab1b --- /dev/null +++ b/sci-chemistry/ball/files/ball-1.4.1-Fix-compilation-of-Python-bindings-with-new-sip-vers.patch @@ -0,0 +1,25 @@ +From: Andreas Hildebrandt <andreas.hildebrandt@uni-mainz.de> +Date: Wed, 15 Aug 2012 00:12:49 +0200 +Subject: Fix compilation of Python bindings with new sip versions. + +For some reason, sip does not like static members of the same type as the class. +In this case, a varget_... - method is generated with the wrong arguments +(unnamed parameter which should be called "sipSelf"). This patch works around +it. +--- + source/PYTHON/EXTENSIONS/BALL/PTE_.sip | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/source/PYTHON/EXTENSIONS/BALL/PTE_.sip b/source/PYTHON/EXTENSIONS/BALL/PTE_.sip +index 4589e92..3e5f8ff 100644 +--- a/source/PYTHON/EXTENSIONS/BALL/PTE_.sip ++++ b/source/PYTHON/EXTENSIONS/BALL/PTE_.sip +@@ -61,7 +61,7 @@ class Element + //friend ostream& operator << (ostream& s, const Element&); + bool isUnknown() const; + +- static Element UNKNOWN; ++ Element UNKNOWN; + }; + + class PTE_ diff --git a/sci-chemistry/ball/files/ball-1.4.1-Fixed-a-bug-in-the-AssignBondOrderProcessor.patch b/sci-chemistry/ball/files/ball-1.4.1-Fixed-a-bug-in-the-AssignBondOrderProcessor.patch new file mode 100644 index 000000000000..813c9369bdac --- /dev/null +++ b/sci-chemistry/ball/files/ball-1.4.1-Fixed-a-bug-in-the-AssignBondOrderProcessor.patch @@ -0,0 +1,271 @@ +From: Anna Dehof <anne@bioinf.uni-sb.de> +Date: Fri, 27 Apr 2012 18:41:52 +0200 +Subject: Fixed a bug in the AssignBondOrderProcessor + +--- + .../STRUCTURE/BONDORDERS/bondOrderAssignment.h | 2 +- + source/STRUCTURE/BONDORDERS/FPTBondOrderStrategy.C | 13 +++-- + source/STRUCTURE/assignBondOrderProcessor.C | 27 +++++++---- + source/TEST/AssignBondOrderProcessor_test.C | 50 +++++++++++++++----- + 4 files changed, 67 insertions(+), 25 deletions(-) + +diff --git a/include/BALL/STRUCTURE/BONDORDERS/bondOrderAssignment.h b/include/BALL/STRUCTURE/BONDORDERS/bondOrderAssignment.h +index 57adc41..f8aab75 100644 +--- a/include/BALL/STRUCTURE/BONDORDERS/bondOrderAssignment.h ++++ b/include/BALL/STRUCTURE/BONDORDERS/bondOrderAssignment.h +@@ -68,7 +68,7 @@ namespace BALL + float total_charge; + int node_expansions; + int queue_size; +- ++ + AtomContainer* ac; + }; + } +diff --git a/source/STRUCTURE/BONDORDERS/FPTBondOrderStrategy.C b/source/STRUCTURE/BONDORDERS/FPTBondOrderStrategy.C +index 107823e..6572d96 100644 +--- a/source/STRUCTURE/BONDORDERS/FPTBondOrderStrategy.C ++++ b/source/STRUCTURE/BONDORDERS/FPTBondOrderStrategy.C +@@ -108,7 +108,8 @@ namespace BALL + } + else + { +- /* Log.info() << "AssignBondOrderProcessor: strategy FPT does not support computeNextSolution(). " << endl ++ // since we return a pointer, nothing to do here ++ /* Log.info() << "AssignBondOrderProcessor: strategy FPT does not support computeNextSolution(). " << endl + << "Please use the options Option::MAX_NUMBER_OF_SOLUTIONS or Option::COMPUTE_ALSO_NON_OPTIMAL_SOLUTIONS " << endl + << "to compute additional solutions." << endl; */ + } +@@ -1429,12 +1430,12 @@ namespace BALL + + bool FPTBondOrderStrategy::DPBackTracking_::hasMoreSolutions() const + { +- return (!queue_.empty() && (!max_num_solutions_ || (num_computed_solutions_ <= max_num_solutions_))); ++ return (!queue_.empty() && (!max_num_solutions_ || (num_computed_solutions_ < max_num_solutions_))); + } + + void FPTBondOrderStrategy::DPBackTracking_::nextSolution() + { +- if (queue_.empty() || max_heap_size_ == 0 || ((max_num_solutions_ > 0) && (num_computed_solutions_ > max_num_solutions_))) ++ if (queue_.empty() || (max_heap_size_ == 0) || ((max_num_solutions_ > 0) && (num_computed_solutions_ > max_num_solutions_))) + { + throw Exception::OutOfRange(__FILE__, __LINE__); + } +@@ -1987,7 +1988,9 @@ namespace BALL + + bool FPTBondOrderStrategy::DPBackTrackingCombiner_::hasMoreSolutions() const + { +- return (!priority_queue_.empty() || (getNextMinimumBackTracker_().second) < upper_bound_); ++ std::pair<Size, Penalty> next_min = getNextMinimumBackTracker_(); ++ ++ return (backtrackers_[next_min.first]->hasMoreSolutions() && (!priority_queue_.empty() || (next_min.second) < upper_bound_)); + } + + void FPTBondOrderStrategy::DPBackTrackingCombiner_::nextSolution() +@@ -2014,7 +2017,7 @@ namespace BALL + // compute next minimal Solution + std::pair<Size, Penalty> next_min = getNextMinimumBackTracker_(); + +- if (next_min.second < upper_bound_ && (priority_queue_.empty() || next_min.second < priority_queue_.top().penalty)) ++ if ((next_min.second < upper_bound_) && (priority_queue_.empty() || (next_min.second < priority_queue_.top().penalty))) + { + DPBackTracking_& min_back_tracker = *backtrackers_[next_min.first]; + +diff --git a/source/STRUCTURE/assignBondOrderProcessor.C b/source/STRUCTURE/assignBondOrderProcessor.C +index 9863a54..9443fb8 100644 +--- a/source/STRUCTURE/assignBondOrderProcessor.C ++++ b/source/STRUCTURE/assignBondOrderProcessor.C +@@ -295,8 +295,20 @@ namespace BALL + ) + { + Log.error() << __FILE__ << " " << __LINE__ +- << " : Error in options! FPT cannot be used with these options." << endl +- << " Consider switch to solution strategy ASTAR by setting Option::ALGORITHM to Algorithm::ASTAR." << endl ++ << " : Error in options! FPT cannot be used with these option(s): "; ++ if (options.getReal(Option::BOND_LENGTH_WEIGHTING) > 0.) ++ Log.error() << "BOND_LENGTH_WEIGHTING "; ++ if (options.getBool(Option::ADD_HYDROGENS)) ++ Log.error() << "ADD_HYDROGENS "; ++ if (options.getBool(Option::COMPUTE_ALSO_CONNECTIVITY)) ++ Log.error() << "COMPUTE_ALSO_CONNECTIVITY "; ++ if (options.getBool(Option::OVERWRITE_SELECTED_BONDS)) ++ Log.error() << "OVERWRITE_SELECTED_BONDS "; ++ if (!options.getBool(Option::OVERWRITE_SINGLE_BOND_ORDERS)) ++ Log.error() << "OVERWRITE_SINGLE_BOND_ORDERS "; ++ Log.error() << endl; ++ ++ Log.error() << " Consider switch to solution strategy ASTAR by setting Option::ALGORITHM to Algorithm::ASTAR." << endl + << " Abort." << endl; + ret = false; + } +@@ -321,8 +333,8 @@ namespace BALL + + #ifdef DEBUG + cout << " OPTIONS:" << endl; +-cout << " \t Algorithm: " << options[Option::Option::ALGORITHM] << endl; +-cout << " \t Heuristic: " << options[Option::Option::HEURISTIC] << endl; ++cout << " \t Algorithm: " << options[Option::ALGORITHM] << endl; ++cout << " \t Heuristic: " << options[Option::HEURISTIC] << endl; + + cout << " \t Overwrite bonds (single, double, triple, selected):" + << options.getBool(Option::OVERWRITE_SINGLE_BOND_ORDERS) << " " +@@ -334,7 +346,7 @@ cout << " \t Overwrite bonds (single, double, triple, selected):" + cout << " \t Add hydrogens : " << options.getBool(Option::ADD_HYDROGENS) << endl; + cout << " \t Use fine penalty : " << options.getBool(Option::USE_FINE_PENALTY) << endl; + cout << " \t Kekulizer: " << options.getBool(Option::KEKULIZE_RINGS) << endl; +-cout << " \t Penalty file " << options[Option::Option::INIFile] << endl; ++cout << " \t Penalty file " << options[Option::INIFile] << endl; + cout << " \t alpha: " << options[Option::BOND_LENGTH_WEIGHTING] << endl; + cout << " \t max bond order: " << options[Option::MAX_BOND_ORDER] << endl; + cout << " \t max number of solutions " << options[Option::MAX_NUMBER_OF_SOLUTIONS] << endl; +@@ -549,7 +561,7 @@ cout << "preassignPenaltyClasses_:" << preassignPenaltyClasses_() << " precomput + boost::shared_ptr<BondOrderAssignment> solution = strategy->computeNextSolution(); + + // Do we have a solution? +- if (!solution) ++ if (!solution || !solution->valid) + { + Log.info() << "AssignBondOrderProcessor: No valid bond order assignment found!" << endl; + #if defined DEBUG_TIMER +@@ -1237,7 +1249,6 @@ cout << " ~~~~~~~~ added hydrogen dump ~~~~~~~~~~~~~~~~" << endl; + AssignBondOrderProcessor::Default::APPLY_FIRST_SOLUTION); + } + +- + bool AssignBondOrderProcessor::apply(Position i) + { + bool result = false; +@@ -1370,7 +1381,7 @@ cout << " ~~~~~~~~ added hydrogen dump ~~~~~~~~~~~~~~~~" << endl; + + boost::shared_ptr<BondOrderAssignment> solution = strategy->computeNextSolution(); + +- if (solution) ++ if (solution && solution->valid) + { + solutions_.push_back(*solution); + found_a_sol = true; +diff --git a/source/TEST/AssignBondOrderProcessor_test.C b/source/TEST/AssignBondOrderProcessor_test.C +index 6dfafcc..fdf92d1 100644 +--- a/source/TEST/AssignBondOrderProcessor_test.C ++++ b/source/TEST/AssignBondOrderProcessor_test.C +@@ -201,6 +201,8 @@ RESULT + + + CHECK(check Options for consistency) ++ Log.error().disableOutput(); ++ + AssignBondOrderProcessor testbop; + testbop.setDefaultOptions(); + TEST_EQUAL(testbop.hasValidOptions(), true) +@@ -208,21 +210,17 @@ CHECK(check Options for consistency) + testbop.setDefaultOptions(); + testbop.options.set(AssignBondOrderProcessor::Option::ALGORITHM, AssignBondOrderProcessor::Algorithm::FPT); + testbop.options.set(AssignBondOrderProcessor::Option::ADD_HYDROGENS, true); +- + TEST_EQUAL(testbop.hasValidOptions(), false) + + testbop.setDefaultOptions(); + testbop.options.set(AssignBondOrderProcessor::Option::ALGORITHM, AssignBondOrderProcessor::Algorithm::FPT); + testbop.options.set(AssignBondOrderProcessor::Option::OVERWRITE_SELECTED_BONDS, true); +- + TEST_EQUAL(testbop.hasValidOptions(), false) + + testbop.setDefaultOptions(); + testbop.options.set(AssignBondOrderProcessor::Option::ALGORITHM, AssignBondOrderProcessor::Algorithm::FPT); + testbop.options.set(AssignBondOrderProcessor::Option::MAX_NUMBER_OF_SOLUTIONS, 0); +- +- TEST_EQUAL(testbop.hasValidOptions(), false) +- ++ TEST_EQUAL(testbop.hasValidOptions(), true) + + testbop.setDefaultOptions(); + testbop.options.set(AssignBondOrderProcessor::Option::ALGORITHM, AssignBondOrderProcessor::Algorithm::FPT); +@@ -230,9 +228,8 @@ CHECK(check Options for consistency) + testbop.options.set(AssignBondOrderProcessor::Option::OVERWRITE_SINGLE_BOND_ORDERS, true); + testbop.options.set(AssignBondOrderProcessor::Option::COMPUTE_ALSO_CONNECTIVITY, true); + testbop.options.set(AssignBondOrderProcessor::Option::MAX_NUMBER_OF_SOLUTIONS, 0); +- + TEST_EQUAL(testbop.hasValidOptions(), false) +- ++ Log.error().enableOutput(); + RESULT + + /////////////////////// ALGORITHMS ////////////////////// +@@ -841,10 +838,11 @@ CHECK(getTotalPenalty(Position i) and operator() FPT single solution) + System sys2; + MOL2File mol_in2(BALL_TEST_DATA_PATH(AssignBondOrderProcessor_test_AN06.mol2), std::ios::in); + mol_in2 >> sys2; ++ TEST_EQUAL(testbop.getNumberOfComputedSolutions(), 10) ++ + sys2.apply(testbop); + TEST_REAL_EQUAL(testbop.getTotalPenalty(0), 2.f)//0.00625) + +- + System sys3; + MOL2File mol_in3(BALL_TEST_DATA_PATH(AssignBondOrderProcessor_test_BEWCUB.mol2), std::ios::in); + mol_in3 >> sys3; +@@ -856,6 +854,7 @@ CHECK(getTotalPenalty(Position i) and operator() FPT single solution) + MOL2File mol15(BALL_TEST_DATA_PATH(AssignBondOrderProcessor_test_CUDJAM_sol_5.mol2), std::ios::in); + mol15 >> sys15; + sys15.apply(testbop); ++ + TEST_REAL_EQUAL(testbop.getTotalPenalty(1), 2.f ) //0.0015528 ) + TEST_REAL_EQUAL(testbop.getTotalPenalty(2), 5.f ) //0.00388199) + TEST_REAL_EQUAL(testbop.getTotalPenalty(3), 7.f ) //0.00543478) +@@ -904,6 +903,34 @@ CHECK(getTotalPenalty(Position i) and operator() FPT single solution) + + RESULT + ++CHECK(operator() FPT vs A*) ++ AssignBondOrderProcessor testbop_a; ++ testbop_a.options.set(AssignBondOrderProcessor::Option::ALGORITHM,AssignBondOrderProcessor::Algorithm::A_STAR); ++ testbop_a.options.setBool(AssignBondOrderProcessor::Option::COMPUTE_ALSO_NON_OPTIMAL_SOLUTIONS, true); ++ ++ AssignBondOrderProcessor testbop_fpt; ++ testbop_fpt.options.set(AssignBondOrderProcessor::Option::ALGORITHM,AssignBondOrderProcessor::Algorithm::FPT); ++ testbop_fpt.options.setBool(AssignBondOrderProcessor::Option::COMPUTE_ALSO_NON_OPTIMAL_SOLUTIONS, true); ++ ++ System sys4; ++ MOL2File mol4(BALL_TEST_DATA_PATH(AssignBondOrderProcessor_test_CITSED10_sol_6.mol2), std::ios::in); ++ mol4 >> sys4; ++ sys4.apply(testbop_a); ++ sys4.apply(testbop_fpt); ++ TEST_REAL_EQUAL(testbop_a.getNumberOfComputedSolutions(), testbop_fpt.getNumberOfComputedSolutions()) ++ ++ TEST_REAL_EQUAL(testbop_a.getTotalPenalty(0), testbop_fpt.getTotalPenalty(0)) //1.f ) ++ TEST_REAL_EQUAL(testbop_a.getTotalPenalty(1), testbop_fpt.getTotalPenalty(1)) //1.f ) ++ TEST_REAL_EQUAL(testbop_a.getTotalPenalty(2), testbop_fpt.getTotalPenalty(2)) //32.f) ++ TEST_REAL_EQUAL(testbop_a.getTotalPenalty(3), testbop_fpt.getTotalPenalty(3)) //34.f) ++ TEST_REAL_EQUAL(testbop_a.getTotalPenalty(4), testbop_fpt.getTotalPenalty(4)) //34.f) ++ TEST_REAL_EQUAL(testbop_a.getTotalPenalty(5), testbop_fpt.getTotalPenalty(5)) //34.f) ++ TEST_REAL_EQUAL(testbop_a.getTotalPenalty(6), testbop_fpt.getTotalPenalty(6)) //66.f) ++ TEST_REAL_EQUAL(testbop_a.getTotalPenalty(7), testbop_fpt.getTotalPenalty(7)) //66.f) ++ TEST_REAL_EQUAL(testbop_a.getTotalPenalty(8), testbop_fpt.getTotalPenalty(8)) //67.f) ++ ++RESULT ++ + + CHECK(getTotalCharge(Position i)) + // This feature is experimental!! +@@ -1023,7 +1050,7 @@ CHECK(computeNextSolution() using ILP) + MOL2File mol_in(BALL_TEST_DATA_PATH(AssignBondOrderProcessor_test_AN06.mol2), std::ios::in); + mol_in >> sys; + sys.apply(testbop); +- TEST_EQUAL(testbop.getNumberOfComputedSolutions(),1) ++ TEST_EQUAL(testbop.getNumberOfComputedSolutions(), 1) + TEST_REAL_EQUAL(testbop.getTotalPenalty(0), 2.f)//0.00625)// 2.) + TEST_EQUAL(testbop.computeNextSolution(), true) + TEST_REAL_EQUAL(testbop.getTotalPenalty(1), 32.f)//0.1)//32.) +@@ -1091,9 +1118,10 @@ CHECK(computeNextSolution() using FPT) + MOL2File mol_in(BALL_TEST_DATA_PATH(AssignBondOrderProcessor_test_AN06.mol2), std::ios::in); + mol_in >> sys; + sys.apply(testbop); +- TEST_EQUAL(testbop.getNumberOfComputedSolutions(),1) ++ TEST_EQUAL(testbop.getNumberOfComputedSolutions(), 1) + TEST_REAL_EQUAL(testbop.getTotalPenalty(0), 2.f)//0.00625)// 2.) +- TEST_EQUAL(testbop.computeNextSolution(), false) ++ bool test = testbop.computeNextSolution(); ++ TEST_EQUAL(test, false) + + RESULT + diff --git a/sci-chemistry/ball/files/ball-1.4.1-Fixed-the-FPT-version-of-bond-order-assignment-2.patch b/sci-chemistry/ball/files/ball-1.4.1-Fixed-the-FPT-version-of-bond-order-assignment-2.patch new file mode 100644 index 000000000000..c5d3fddb1b89 --- /dev/null +++ b/sci-chemistry/ball/files/ball-1.4.1-Fixed-the-FPT-version-of-bond-order-assignment-2.patch @@ -0,0 +1,444 @@ + include/BALL/DATATYPE/GRAPH/graphAlgorithms.h | 7 +- + include/BALL/DATATYPE/GRAPH/treeWidth.h | 44 ++++++- + include/BALL/DATATYPE/GRAPH/treeWidth.iC | 145 +++++++++++++-------- + source/DATATYPE/GRAPH/treeWidth.C | 24 ++++ + source/STRUCTURE/BONDORDERS/FPTBondOrderStrategy.C | 12 +- + 5 files changed, 161 insertions(+), 71 deletions(-) + +diff --git a/include/BALL/DATATYPE/GRAPH/graphAlgorithms.h b/include/BALL/DATATYPE/GRAPH/graphAlgorithms.h +index d10de34..5e218ff 100644 +--- a/include/BALL/DATATYPE/GRAPH/graphAlgorithms.h ++++ b/include/BALL/DATATYPE/GRAPH/graphAlgorithms.h +@@ -25,7 +25,7 @@ namespace boost + enum vertex_orig_ptr_t { vertex_orig_ptr }; + + enum edge_bond_ptr_t { edge_bond_ptr }; +- enum edge_orig_ptr_t { edge_orig_ptr }; ++ enum edge_orig_ptr_t { edge_orig_ptr }; + + BOOST_INSTALL_PROPERTY(vertex, atom_ptr); + BOOST_INSTALL_PROPERTY(vertex, orig_ptr); +@@ -150,7 +150,7 @@ namespace BALL + { + bi = ai; ++bi; + for (; bi != ai_end; ++bi) +- if (!boost::edge(*ai, *bi, graph).second) ++ if (*bi != *ai && !boost::edge(*ai, *bi, graph).second) + boost::add_edge(*ai, *bi, graph); + } + +@@ -179,7 +179,6 @@ namespace BALL + + typedef typename boost::property_traits<typename boost::property_map<UndirectedGraph, boost::edge_all_t>::type>::value_type EdgeProperties; + +- EdgeProperties ep = boost::get(boost::edge_all_t(), graph, boost::edge(vertex, *ai, graph).first) ; + result.getEdgeProperties().push_back(boost::get(boost::edge_all_t(), graph, boost::edge(vertex, *ai, graph).first)); + + bi = ai; ++bi; +@@ -189,7 +188,7 @@ namespace BALL + { + boost::add_edge(*ai, *bi, graph); + result.getEdges().push_back(std::make_pair(boost::get(boost::vertex_index, graph, *ai), +- boost::get(boost::vertex_index, graph, *bi))); ++ boost::get(boost::vertex_index, graph, *bi))); + } + } + } +diff --git a/include/BALL/DATATYPE/GRAPH/treeWidth.h b/include/BALL/DATATYPE/GRAPH/treeWidth.h +index dc7cdc5..f7687ef 100644 +--- a/include/BALL/DATATYPE/GRAPH/treeWidth.h ++++ b/include/BALL/DATATYPE/GRAPH/treeWidth.h +@@ -30,10 +30,12 @@ + #include <map> + #include <set> + #include <vector> ++#include <iostream> + + #include <boost/graph/connected_components.hpp> + #include <boost/graph/filtered_graph.hpp> + #include <boost/graph/graph_as_tree.hpp> ++#include <boost/graph/graphviz.hpp> + #include <boost/graph/copy.hpp> + + namespace boost +@@ -91,7 +93,7 @@ namespace BALL + END_BAG + }; + +- typedef typename GRAPH::GraphTraits<UndirectedGraph>::EditableGraph EditableGraph; ++ typedef typename GRAPH::GraphTraits<UndirectedGraph>::EditableGraph EditableGraph; + typedef typename boost::graph_traits<UndirectedGraph>::vertex_descriptor OriginalVertexType; + + typedef std::set<OriginalVertexType> TreeDecompositionContent; +@@ -111,6 +113,16 @@ namespace BALL + + TreeWidth(UndirectedGraph const& input); + ++ /** Compute the tree width of a given tree decomposition. ++ * This function iterates over all nodes in the graph to determine the tree width, ++ * i.e., the (maximum number of vertices over all bags) - 1 ++ */ ++ static Size computeTreeWidth(TreeDecomposition const& td); ++ ++ /** Write a tree decomposition in graphviz format. ++ */ ++ void writeGraphvizFile(std::ostream& out, TreeDecomposition const& td); ++ + std::vector<boost::shared_ptr<EditableGraph> >& getComponents() { return components_; } + std::vector<boost::shared_ptr<TreeDecomposition> >& getNiceTreeDecompositions() { return nice_tree_decompositions_; } + +@@ -120,25 +132,44 @@ namespace BALL + { + public: + ComponentFilter_(ComponentMap cm, Position i) +- : cm_(&cm), ++ : cm_(cm), + component_(i) + { } + + template <typename Vertex> + bool operator() (const Vertex& e) const + { +- return ((*cm_)[e] == component_); ++ return ((cm_)[e] == component_); + } + + protected: +- ComponentMap* cm_; ++ ComponentMap cm_; + Position component_; + }; + ++ /** PropertyWriter for graphviz output. ++ */ ++ class BagContentWriter ++ { ++ public: ++ BagContentWriter(TreeDecomposition const* td, UndirectedGraph const* original_graph) ++ : td_(td), ++ original_graph_(original_graph) ++ { } ++ ++ void operator() (std::ostream& out, const TreeDecompositionBag& v) const; ++ ++ protected: ++ TreeDecomposition const* td_; ++ UndirectedGraph const* original_graph_; ++ }; ++ ++ // TODO: would UndirectedGraph suffice here? + MolecularGraph const* input_; ++ + std::vector<boost::shared_ptr<EditableGraph> > components_; + +- std::vector<boost::shared_ptr<TreeDecomposition> > nice_tree_decompositions_; ++ std::vector<boost::shared_ptr<TreeDecomposition> > nice_tree_decompositions_; + std::vector<boost::shared_ptr<TreeDecompositionGraph> > nice_tree_decomposition_graphs_; + }; + +@@ -397,6 +428,9 @@ namespace BALL + * The bitset remembers the eliminated vertices without an ordering. + */ + BitSet buildBitset() const; ++ ++ protected: ++ std::map<int, VertexType> index_to_vertex_; + }; + + /** +diff --git a/include/BALL/DATATYPE/GRAPH/treeWidth.iC b/include/BALL/DATATYPE/GRAPH/treeWidth.iC +index 633e588..99f14cf 100644 +--- a/include/BALL/DATATYPE/GRAPH/treeWidth.iC ++++ b/include/BALL/DATATYPE/GRAPH/treeWidth.iC +@@ -68,6 +68,34 @@ namespace BALL + } + } + ++ template <class UndirectedGraph> ++ Size TreeWidth<UndirectedGraph>::computeTreeWidth(TreeDecomposition const& td) ++ { ++ Size result = 1; ++ ++ BGL_FORALL_VERTICES_T(current_vertex, td._g, UndirectedGraph) ++ { ++ result = std::max((Size)(boost::get(boost::vertex_bag_content, td, current_vertex).size()), result); ++ } ++ ++ return result - 1; ++ } ++ ++ template <class UndirectedGraph> ++ void TreeWidth<UndirectedGraph>::writeGraphvizFile(std::ostream& out, TreeDecomposition const& td) ++ { ++ boost::write_graphviz(out, td._g, BagContentWriter(&td, input_)); ++ } ++ ++ template <> ++ void TreeWidth<MolecularGraph>::BagContentWriter::operator() (std::ostream& out, const TreeDecompositionBag& v) const; ++ ++ template <class UndirectedGraph> ++ void TreeWidth<UndirectedGraph>::BagContentWriter::operator() (std::ostream& out, const TreeDecompositionBag& v) const ++ { ++ out << "[label=\"" << boost::get(boost::vertex_index, *td_, v) << "\"]"; ++ } ++ + // ***************************************************************************************** + // * TreeWidthImplementation * + // ***************************************************************************************** +@@ -322,8 +350,9 @@ namespace BALL + if (boost::out_degree(vertex, graph_) <= 1) + return IS_SIMPLICIAL; + +- VertexType* n1 = NULL; +- VertexType* n2 = NULL; ++ VertexType n1 = VertexType(); ++ VertexType n2 = VertexType(); ++ bool found_unconnected = false; + + typename boost::graph_traits<UndirectedGraph>::adjacency_iterator a_i, a_j, ai_end; + +@@ -337,20 +366,21 @@ namespace BALL + + if (!boost::edge(i, j, graph_).second) + { +- if (!n1) ++ if (!found_unconnected) + { +- n1 = &i; +- n2 = &j; ++ n1 = i; ++ n2 = j; ++ found_unconnected = true; + } +- else if (i == *n1 || i == *n2) ++ else if (i == n1 || i == n2) + { +- n1 = &i; +- n2 = &i; ++ n1 = i; ++ n2 = i; + } +- else if (j == *n1 || j == *n2) ++ else if (j == n1 || j == n2) + { +- n1 = &j; +- n2 = &j; ++ n1 = j; ++ n2 = j; + } + else + { +@@ -376,11 +406,10 @@ namespace BALL + { + Size nxt = cstate.permutation.size(); + +- std::map<int, VertexType> index_to_vertex; + BGL_FORALL_VERTICES_T(current_vertex, graph_, UndirectedGraph) + { + Size index = boost::get(boost::vertex_index, graph_, current_vertex); +- index_to_vertex[index] = current_vertex; ++ index_to_vertex_[index] = current_vertex; + SIMPLICIAL_TYPE simplicial(isSimplicial(current_vertex)); + if (simplicial == IS_SIMPLICIAL || simplicial == ALMOST_SIMPLICIAL) + { +@@ -388,14 +417,13 @@ namespace BALL + } + } + +- +- for (typename std::vector<Size>::const_iterator st_iter = cstate.permutation.begin() + nxt; +- st_iter != cstate.permutation.end(); ++st_iter) ++ for (typename std::vector<Size>::const_iterator st_iter = cstate.permutation.begin() + nxt; ++ st_iter != cstate.permutation.end(); ++ ++st_iter) + { +- VertexType vertex = index_to_vertex[*st_iter]; ++ VertexType vertex = index_to_vertex_[*st_iter]; + cstate.g = std::max(cstate.g, (Size)boost::out_degree(vertex, graph_)); + cstate.f = std::max(cstate.f, cstate.g); +- + GRAPH::eliminateVertex(vertex, graph_); + } + } +@@ -459,55 +487,62 @@ namespace BALL + { + upper_bound = nstate.f; + state.permutation = nstate.permutation; +- state.permutation.push_back(0); ++ BGL_FORALL_VERTICES_T(v, graph_, UndirectedGraph) // yes, it is only one, but still... ++ { ++ state.permutation.push_back(boost::get(boost::vertex_index, graph_, v)); ++ } + } + } + else + { +- std::map<int, VertexType> index_to_vertex; ++ index_to_vertex_.clear(); + BGL_FORALL_VERTICES_T(v, graph_, UndirectedGraph) + { +- index_to_vertex[boost::get(boost::vertex_index, graph_, v)] = v; ++ index_to_vertex_[boost::get(boost::vertex_index, graph_, v)] = v; + } + + for (typename std::vector<Size>::iterator viter = greedy_solution.first.begin(); + viter != greedy_solution.first.end(); ++viter) + { +- VertexType& vertex = index_to_vertex[*viter]; +- Size degree = boost::out_degree(vertex, graph_); +- +- GRAPH::UndoEliminateOperation<UndirectedGraph> elimination(graph_, vertex); +- +- QuickBBState xstate(nstate); +- xstate.g = std::max(nstate.g, degree); +- xstate.permutation.push_back(boost::get(boost::vertex_index, graph_, vertex)); +- +- BitSet bitset(buildBitset()); +- +- Size lower_bound = L()(graph_); +- xstate.h = lower_bound; +- xstate.f = max(xstate.g, lower_bound); +- +- if (xstate.f >= upper_bound) +- { +- elimination.undo(); +- +- continue; +- } +- +- MapPos entry(visitedSubgraphs.insert(MapEntry(bitset, xstate.f))); +- +- if (entry.second) +- { +- branchAndBound(xstate); +- } +- else if ((entry.first)->second > xstate.f) ++ if (index_to_vertex_.find(*viter) != index_to_vertex_.end()) + { +- entry.first->second = xstate.f; +- branchAndBound(xstate); ++ VertexType& vertex = index_to_vertex_[*viter]; ++ Size degree = boost::out_degree(vertex, graph_); ++ ++ GRAPH::UndoEliminateOperation<UndirectedGraph> elimination = GRAPH::eliminateVertexUndoable(vertex, graph_); ++ ++ QuickBBState xstate(nstate); ++ xstate.g = std::max(nstate.g, degree); ++ xstate.permutation.push_back(*viter); ++ ++ BitSet bitset(buildBitset()); ++ ++ Size lower_bound = L()(graph_); ++ xstate.h = lower_bound; ++ xstate.f = max(xstate.g, lower_bound); ++ ++ if (xstate.f >= upper_bound) ++ { ++ VertexType vertex_replace = elimination.undo(); ++ index_to_vertex_[*viter] = vertex_replace; ++ continue; ++ } ++ ++ MapPos entry(visitedSubgraphs.insert(MapEntry(bitset, xstate.f))); ++ ++ if (entry.second) ++ { ++ branchAndBound(xstate); ++ } ++ else if ((entry.first)->second > xstate.f) ++ { ++ entry.first->second = xstate.f; ++ branchAndBound(xstate); ++ } ++ ++ VertexType vertex_replace = elimination.undo(); ++ index_to_vertex_[*viter] = vertex_replace; + } +- +- elimination.undo(); + } + } + } +@@ -687,7 +722,7 @@ namespace BALL + typename TreeWidth<OriginalGraphType>::TreeDecompositionBag + TreeWidthImplementation<UndirectedGraph>::TreeDecompositionBuilder<OriginalGraphType>::buildRoot_(TreeDecompositionBag child) + { +- TreeDecompositionBag last_vertex; ++ TreeDecompositionBag last_vertex = TreeDecompositionBag(); + + TreeDecompositionContent content = boost::get(boost::vertex_bag_content, *nice_tree_, child); + +diff --git a/source/DATATYPE/GRAPH/treeWidth.C b/source/DATATYPE/GRAPH/treeWidth.C +index 981605d..7485305 100644 +--- a/source/DATATYPE/GRAPH/treeWidth.C ++++ b/source/DATATYPE/GRAPH/treeWidth.C +@@ -1 +1,25 @@ + #include <BALL/DATATYPE/GRAPH/treeWidth.h> ++ ++#include <BALL/KERNEL/atom.h> ++ ++namespace BALL ++{ ++ template <> ++ void TreeWidth<MolecularGraph>::BagContentWriter::operator() (std::ostream& out, const TreeDecompositionBag& v) const ++ { ++ out << "[label=\""; ++ ++ // find all vertices in the current bag ++ TreeDecompositionContent content = boost::get(boost::vertex_bag_content, *td_, v); ++ ++ for (typename TreeDecompositionContent::const_iterator tdc_it = content.begin(); tdc_it != content.end(); ++tdc_it) ++ { ++ TreeWidth<MolecularGraph>::OriginalVertexType ov = *tdc_it; ++ Atom const* atom = boost::get(boost::vertex_atom_ptr, *original_graph_, ov); ++ ++ out << atom->getFullName() << " (" << atom << ") " << "\\n"; ++ } ++ ++ out << "\"]"; ++ } ++} +diff --git a/source/STRUCTURE/BONDORDERS/FPTBondOrderStrategy.C b/source/STRUCTURE/BONDORDERS/FPTBondOrderStrategy.C +index 4f872ae..c708535 100644 +--- a/source/STRUCTURE/BONDORDERS/FPTBondOrderStrategy.C ++++ b/source/STRUCTURE/BONDORDERS/FPTBondOrderStrategy.C +@@ -68,7 +68,7 @@ namespace BALL + for (Position i = 0; i < ntds.size(); ++i) + { + bond_assignments.push_back(new FPTBondOrderAssignment_(*this, ntds[i], upper_bound_)); +- Penalty result = bond_assignments[i]->compute(); ++ bond_assignments[i]->compute(); + } + + // initialize backtracking +@@ -650,8 +650,8 @@ namespace BALL + { + Edge e = *it; + +- MolecularGraphTraits::VertexType source = boost::source(*it, *molecule_); +- MolecularGraphTraits::VertexType target = boost::target(*it, *molecule_); ++ MolecularGraphTraits::VertexType source = boost::source(e, *molecule_); ++ MolecularGraphTraits::VertexType target = boost::target(e, *molecule_); + + if (iv == source || iv == target) + { +@@ -1893,8 +1893,7 @@ namespace BALL + + BGL_FORALL_EDGES(edge_it, graph, MolecularGraph) + { +- if (boost::source(edge_it, graph) < boost::target(edge_it, graph)) +- sorted_edges.push_back(edge_it); ++ sorted_edges.push_back(edge_it); + } + + // sort bonds - the second vertex could be in false order +@@ -1927,8 +1926,7 @@ namespace BALL + + BGL_FORALL_EDGES(edge_it, graph, MolecularGraph) + { +- if (boost::source(edge_it, graph) < boost::target(edge_it, graph)) +- sorted_edges.push_back(edge_it); ++ sorted_edges.push_back(edge_it); + } + + // sort bonds - the second vertex could be in false order diff --git a/sci-chemistry/ball/files/ball-1.4.1-gcc-4.7.patch b/sci-chemistry/ball/files/ball-1.4.1-gcc-4.7.patch index 438d9b3770f7..6ab98729a83e 100644 --- a/sci-chemistry/ball/files/ball-1.4.1-gcc-4.7.patch +++ b/sci-chemistry/ball/files/ball-1.4.1-gcc-4.7.patch @@ -1,4 +1,5 @@ include/BALL/COMMON/global.h | 26 +++++------ + include/BALL/COMMON/hash.h | 36 +++++++-------- include/BALL/DATATYPE/bitVector.h | 2 +- include/BALL/DATATYPE/hashMap.h | 9 +--- include/BALL/DATATYPE/string.h | 11 +++-- @@ -11,7 +12,9 @@ source/COMMON/version.C | 2 +- source/STRUCTURE/BONDORDERS/FPTBondOrderStrategy.C | 41 +++++++++-------- source/STRUCTURE/kekulizer.C | 8 ++-- - 13 files changed, 91 insertions(+), 84 deletions(-) + source/TEST/INIFile_test.C | 8 ++-- + source/TEST/ParameterSection_test.C | 2 +- + 16 files changed, 114 insertions(+), 107 deletions(-) diff --git a/include/BALL/COMMON/global.h b/include/BALL/COMMON/global.h index 11d9246..02c81c6 100644 @@ -67,6 +70,60 @@ index 11d9246..02c81c6 100644 } #endif // BALL_COMMON_GLOBAL_H +diff --git a/include/BALL/COMMON/hash.h b/include/BALL/COMMON/hash.h +index 8d45df3..ebb9a55 100644 +--- a/include/BALL/COMMON/hash.h ++++ b/include/BALL/COMMON/hash.h +@@ -15,24 +15,6 @@ + + namespace BALL + { +- /** General Hash Function Template. +- This template function provides a simple wrapper +- for the specialized hash functions. It facilitates their use +- in STL hash associative containers which expect a <b>Hasher</b> +- class as template parameter. +- \ingroup Common +- */ +- template <typename T> +- class HashFunction +- { +- public: +- +- HashIndex operator () (const T& t) const +- { +- return Hash(t); +- } +- }; +- + /** @name Specialized Hash Functions. + */ + //@{ +@@ -105,6 +87,24 @@ namespace BALL + + //@} + ++ /** General Hash Function Template. ++ This template function provides a simple wrapper ++ for the specialized hash functions. It facilitates their use ++ in STL hash associative containers which expect a <b>Hasher</b> ++ class as template parameter. ++ \ingroup Common ++ */ ++ template <typename T> ++ class HashFunction ++ { ++ public: ++ ++ HashIndex operator () (const T& t) const ++ { ++ return Hash(t); ++ } ++ }; ++ + } // namespace BALL + + #endif // BALL_COMMON_HASH_H diff --git a/include/BALL/DATATYPE/bitVector.h b/include/BALL/DATATYPE/bitVector.h index 991f08e..dc7ead6 100644 --- a/include/BALL/DATATYPE/bitVector.h @@ -487,3 +544,49 @@ index d1f4e78..c277091 100644 Size best_solution = 0; for (Position solp = 0; solp < solutions_.size(); solp++) +diff --git a/source/TEST/INIFile_test.C b/source/TEST/INIFile_test.C +index 1f59d2c..cf37841 100644 +--- a/source/TEST/INIFile_test.C ++++ b/source/TEST/INIFile_test.C +@@ -198,10 +198,10 @@ CHECK(bool appendLine(const String& section_name, const String& line)) + + CAPTURE_OUTPUT_LEVEL(2000) + TEST_EQUAL(ini.appendLine("Section9", "GAU"), false) +- COMPARE_OUTPUT("In INIFile "BALL_TEST_DATA_PATH(INIFile_test.ini)" , error while appending line: GAU . Illegal section-name: Section9\n") ++ COMPARE_OUTPUT("In INIFile " BALL_TEST_DATA_PATH(INIFile_test.ini)" , error while appending line: GAU . Illegal section-name: Section9\n") + CAPTURE_OUTPUT_LEVEL(2000) + TEST_EQUAL(ini.appendLine("Section2", "[AU"), false) +- COMPARE_OUTPUT("In INIFile "BALL_TEST_DATA_PATH(INIFile_test.ini)" , error while appending line: [AU . Illegal section-name: Section2\n") ++ COMPARE_OUTPUT("In INIFile " BALL_TEST_DATA_PATH(INIFile_test.ini)" , error while appending line: [AU . Illegal section-name: Section2\n") + TEST_EQUAL(ini.appendLine("Section3", "test1 = 123"), true) + TEST_EQUAL(*ini.getLine(9), "test1 = 123") + TEST_EQUAL(ini.getNumberOfLines(), 11) +@@ -403,13 +403,13 @@ CHECK(bool appendSection(const String& section)) + TEST_EQUAL(ini.hasSection(ini.HEADER), true) + CAPTURE_OUTPUT_LEVEL(2000) + TEST_EQUAL(ini.appendSection(ini.HEADER), false) +- const char* output = "INIFile::appendSection: "BALL_TEST_DATA_PATH(INIFile_test.ini)" , while adding section: '#HEADER!' already exists.\n"; ++ const char* output = "INIFile::appendSection: " BALL_TEST_DATA_PATH(INIFile_test.ini)" , while adding section: '#HEADER!' already exists.\n"; + COMPARE_OUTPUT(output) + TEST_EQUAL(ini.getNumberOfLines(), 10) + + CAPTURE_OUTPUT_LEVEL(2000) + TEST_EQUAL(ini.appendSection("Section1"), false) +- COMPARE_OUTPUT("INIFile::appendSection: "BALL_TEST_DATA_PATH(INIFile_test.ini)" , while adding section: 'Section1' already exists.\n") ++ COMPARE_OUTPUT("INIFile::appendSection: " BALL_TEST_DATA_PATH(INIFile_test.ini)" , while adding section: 'Section1' already exists.\n") + TEST_EQUAL(ini.getNumberOfLines(), 10) + TEST_EQUAL(ini.hasSection("Section1"), true) + +diff --git a/source/TEST/ParameterSection_test.C b/source/TEST/ParameterSection_test.C +index 16424cd..b934b4a 100644 +--- a/source/TEST/ParameterSection_test.C ++++ b/source/TEST/ParameterSection_test.C +@@ -55,7 +55,7 @@ CHECK(ParameterSection::extractSection(Parameters& parameters, const String& sec + bool result; + CAPTURE_OUTPUT_LEVEL(2000) + result = ps.extractSection(param, "Section1"); +- COMPARE_OUTPUT("ParameterSection::extractSection: error reading section Section1 of file "BALL_TEST_DATA_PATH(ParameterSection_test.ini)":\nWrong number of fields in the format line: 0. FORMAT:\n") ++ COMPARE_OUTPUT("ParameterSection::extractSection: error reading section Section1 of file " BALL_TEST_DATA_PATH(ParameterSection_test.ini)":\nWrong number of fields in the format line: 0. FORMAT:\n") + TEST_EQUAL(result, false) + TEST_EQUAL(ps.getSectionName(), "Section1") + |