58 Commits

Author SHA1 Message Date
Clay Moore
141ba3bd73 Fix BFGS gradient-convergence denominator for negative energies (#9298)
In Code/Numerics/Optimizer/BFGSOpt.h, the gradient-convergence check
computed

    double term = std::max(funcVal * gradScale, 1.0);
    ...
    test /= term;
    if (test < gradTol) return 0;

When funcVal (the current energy) is negative, funcVal * gradScale is
negative and std::max clamps the denominator to 1.0. The convergence
test therefore divides the gradient norm by 1 instead of by the
intended |E| * gradScale, which over-tightens the criterion by a factor
of |funcVal * gradScale| whenever |funcVal * gradScale| > 1.

Negative energies are a normal mid-minimization state for force fields
that include stabilizing terms (MMFF94, UFF with charges, AMBER-style
potentials), so this affects realistic workloads: extra BFGS iterations
or, occasionally, hitting MAXITS and returning the "too many iterations"
status when convergence would otherwise have been reached.

The fix is to use |funcVal| in the denominator, matching the pattern
used three lines below ('std::max(fabs(pos[i]), 1.0)') and matching the
intended interpretation as a magnitude.

A new test case 'testBFGSOptimizationNegativeEnergy' in
testOptimizer.cpp minimizes a 2D quadratic whose value is always
negative along the convergence path and verifies the optimizer reaches
the analytic minimum.

git blame attributes the original line to commit e08e0d16d (Nov 2015),
when the optimizer was restructured; the surrounding code does use
absolute values, so this reads as an oversight rather than an
intentional choice.
2026-05-28 13:14:59 +02:00
Ricardo Rodriguez
7b7a8a4e17 Refactor iostreams includes (#8846)
* refactor iostreams includes

* restore ostream to MonomerInfo.cpp
2025-10-08 16:08:01 +02:00
Greg Landrum
ebd7dad122 Switch a bunch of C++ tests to use catch2 (#8625) 2025-07-18 11:50:38 +02:00
Hussein Faara
44364fd982 remove no-op macros and dead code (pt 4) (#8037)
* remove no-op macros and dead code (pt 4)

* review comments
2025-01-26 07:49:50 +01:00
Ricardo Rodriguez
1201f214c4 One final round of mem errors (#7943)
* fix descriptors

* fix filtercatalog wrapping

* fix Chem reaction enumeration

* register shared_ptr

* change order of declarations

* fixleaks in SimDivPickers

* Manage ptr arrays in ForceField/BFGSOpt
2024-10-29 06:46:43 +01:00
Eisuke Kawashima
27f711a658 Run clang-tidy (readability-braces-around-statements) (#4977)
https://github.com/rdkit/rdkit/pull/3024#discussion_r526549843
2022-03-10 08:00:10 +01:00
Greg Landrum
c0a62388a2 switch to using target_compile_definitions instead of add_definitions (#3350)
* switch to using target_compile_definitions instead of add_definitions

* missed one
2020-08-21 04:49:07 +02:00
Eisuke Kawashima
e86e2c1d5d Modernization: use nullptr (#3143) 2020-05-25 09:40:01 +02:00
Eisuke Kawashima
75f03412ef Modernize deprecated header inclusion (#3137) 2020-05-04 10:40:57 +02:00
Greg Landrum
45bf58754a Cleanup some cmake dependencies (#3077)
* change minimal cmake version to a consistent 3.5

* progress towards a cleanup

* get the basic python deps working

* two more libs

* another round of changes
all tests pass at this point

* next round of changes
all tests pass at this point

* close to done
all tests pass

* very close

* almost done

* shift the RDBoost dependencies around a bit

* remove an extraneous python linkage
this is trying to get the mac builds working again

* Only link to python if it was built shared (#3091)

* change in response to review

Co-Authored-By: Ric <ricrogz@users.noreply.github.com>

* move that suppression of the maybe-uninitialized warning to BoostStartInclude.h

Co-authored-by: Brian Kelley <fustigator@gmail.com>
Co-authored-by: Ric <ricrogz@users.noreply.github.com>
2020-04-17 14:34:23 +02:00
Greg Landrum
a75018fe38 Cleanups and additional tests to improve test coverage (#2852)
* disable builds of the StructChecker code by default

* operator"" _smarts() doesn't need to catch sanitization errors

* remove unused function

* turn back on some tests that shouldn't have been disabled

* Remove unused code from SMARTS parser and simplify a bit

SmilesParseOps::AddFragToMol is now used only from the SMARTS parser, so we can simplify the API

* Removes obsolete special case code for SMARTS

This was relevant when organic atoms in SMARTS queries were stored as two-part queries.

* improve SMARTS testing

make sure we can generate SMARTS from all the examples and then parse that again.

* Fixes #2814

* Fixes #2815

* some additional smarts tests to improve coverage

* test copy ctor and getPos

* remove obsolete test_list files

* include tests for the morgan invariant generators

* more cleanups and coverage improvements

* remove files that were mistakenly added
2020-01-09 16:07:55 -05:00
Eisuke Kawashima
5cd27a242f Fix typo (#2862)
* Fix typo

* Reflect the comments

* Fix more typos
2019-12-31 06:43:27 +01:00
Greg Landrum
ec31bea97b clang-tidy-7 pass (#2408) 2019-04-16 12:05:47 -04:00
Paolo Tosco
f7c888844d moved test.h from RDBoost to RDGeneral for consistency with export.h (#2074) 2018-10-11 17:35:23 -04:00
Greg Landrum
2738c35178 Fixes #1903 (#1971)
* Fixes #1903

* update SWIG bindings too
2018-07-25 09:14:17 +02:00
Paolo Tosco
c08ea49bda - enable building DLLs on Windows (#1861)
* - enable building DLLs on Windows

* - export.h and test.h are now auto-generated by CMake
2018-05-16 08:42:41 +02:00
gedeck
e9af48ffd7 Issue1071/yapf (#1078)
* Issue #1071: add yapf configuration file

* yapf formatting of Code directory

* yapf formatting of Contrib directory

* yapf formatting of Data directory

* yapf formatting of Docs directory

* yapf formatting of External directory

* yapf formatting of Projects directory

* yapf formatting of Regress directory

* yapf formatting of Scripts directory

* yapf formatting of Web directory

* yapf formatting of rdkit directory
2016-09-23 04:58:46 +02:00
Paolo Tosco
779ec747ac - put SnapshotVect in the RDKit namespace 2016-05-11 23:41:31 +01:00
Paolo Tosco
2b3a818f84 - removed the dependency on Trajectory from ROMol and ForceField 2016-05-11 19:37:09 +01:00
Paolo Tosco
a2eca41365 - the Trajectory object now holds a vector of Snapshots rather than
a vector of shared_ptr to Snapshots
- The PySnapshot class was removed
- the Trajectory::readAmber and Trajectory::readGromos member functions
  were converted into non-member functions
- tests were modified accordingly
2016-05-04 18:42:23 +01:00
Paolo Tosco
3f4c6ec9ff - switch to boost::shared_array 2016-04-25 21:53:04 +01:00
Paolo Tosco
d16b312ee6 - Completely revised coordinate ownership
- Implemented Python wrappers
- prepared relevant test cases
2016-04-24 23:30:25 +01:00
Paolo Tosco
6f8071f7a5 - Progress on Python wrappers
- Some adjustments to the C++ API
2016-04-19 20:53:39 +01:00
Paolo Tosco
9316a15b38 - fixed docs 2016-04-14 23:59:48 +01:00
Paolo Tosco
584b77ea18 - work in progress on the Trajectory branch 2016-04-14 20:04:58 +01:00
Paolo Tosco
406ea052f5 - work in progress 2016-04-12 23:03:57 +01:00
Paolo Tosco
0c0b0a30be - started adding trajectory storage to minimizer 2016-04-12 21:30:55 +01:00
Greg Landrum
07fb36de44 A bit of minor optimization 2015-12-07 04:25:56 +01:00
Greg Landrum
e08e0d16d8 first pass, using google style 2015-11-14 14:58:11 +01:00
Brian Kelley
b31c2870ce Adds a symbol to fix no-symbol warning.
The real fix is to add rdkit_headeronly_library macro
2015-10-18 16:40:44 -04:00
Brian Kelley
66b1c81a61 Fixes more unused parameters 2015-10-18 16:38:50 -04:00
Brian Kelley
5f59333a56 Silences unused parameters 2015-10-18 14:02:29 -04:00
Greg Landrum
7e5c37e685 update some tests to ensure success on 32bit systems 2015-05-01 16:04:17 +02:00
Paolo Tosco
b7ca51d98c - modified BFGSOpt.h to remove a while(1) {} loop which might result
into an infinite loop in linearSearch() with poor initial geometries
- added a relevant unit test in Code/ForceField/Wrap/testConstraints.py
2015-04-20 23:46:23 +01:00
Paolo Tosco
7fe0024c48 - removed the possibility of an indefinite loop in linearSearch(); now an
exception is thrown in such cases
- added a relevant unit test in testConstraints.py
2015-04-20 23:31:55 +01:00
Greg Landrum
9bf13137cf add explicit import of <algorithm> to resolve build problem on VS2013 2014-06-28 15:11:14 +02:00
Greg Landrum
d00ee0825d another update 2012-02-25 16:27:54 +00:00
Greg Landrum
b993f89afe remove the bjam-based build system 2010-09-27 03:54:07 +00:00
Greg Landrum
f3fbef45c5 update copyright statements 2010-09-26 17:04:37 +00:00
Greg Landrum
cb6cdb99b3 merge in a set of changes from Riccardo V. to install .h files as well;
this needs more testing.
2010-09-04 14:07:22 +00:00
Greg Landrum
ec192d981e changes to robustify (and somewhat speed up) the optimizer. These will change results 2010-02-28 13:11:34 +00:00
Greg Landrum
53485592ca builds on windows with visual studio; need to pass back to linux now 2009-10-01 13:35:48 +00:00
Greg Landrum
6caabd787e move these changes over to the windows side and try again there 2009-10-01 08:24:43 +00:00
Greg Landrum
76297b0fff builds and passes tests on linux 2009-09-28 11:02:18 +00:00
Greg Landrum
8bf7a4c187 now all tests pass here as well 2009-02-03 05:26:10 +00:00
Greg Landrum
2580fbaaa2 this is probably a ways from done, but now at least we can run bjam under mingw without it immediately erroring out 2008-11-15 17:14:13 +00:00
Greg Landrum
89a34d1a39 get this building on Darwin; NOTE: this may not work on win or linux yet 2008-09-03 19:24:35 +00:00
Greg Landrum
59929b1993 minor cleanup 2008-05-18 07:29:50 +00:00
Greg Landrum
8424d36830 get things building on windows. 2008-04-08 18:24:56 +00:00
Greg Landrum
d3aea154ef switch everything over to dynamic linking in order to try and solve
the horrible cross-library exception handling mess on linux. This may well break things on windows, which
might want these things static. Regardless, even as it is, this should be considered experimental
2008-04-08 10:24:57 +00:00