E-CAM minDist2segments_KKT module

The minDist2segments_KKT module returns the minimal distance between two line segments. It uses the Karush-Kuhn-Tucker conditions (KKT) for the minimization under constraints.

Purpose of Module

To study the long term memory of the initial conformation of a highly entangled polymer we need to preserve the topology. It means that two polymer bonds cannot cross. It is of great importance for the study of post-mitotic chromosome unfolding. To resolve the excluded volume constraints one could use a soft or hard potential between the two points associated to the minimal distance.

  • Polymer simulation.
  • To resolve the excluded volume constraints.
  • It is used in a scientific collaborations.
  • Publications: not currently available.


We would use the present module to avoid topology violation in an entangled polymer system. This module is used by other ongoing work.

Background Information

You can find pdf file with a detailed derivation of the minimal distance between two segments using the Karush-Kuhn-Tucker conditions on the minDist2segments_KKT GitLab repository.

Building and Testing

I provide a simple Makefile you can find at the same location that the source code. You need C++11 in order to use the pseudo-random number generator. The example also has OpenMP acceleration, edit the Makefile to enable it. Before the compilation you can clean the previous build with the make mrproper command.

The purpose of the module is to calculate the minimal distance between two segments. For each distance we compare the result to an “exact enumeration” of all the possible distances and return a warning if the two results differ by more than the enumeration precision.

Source Code

The source code and more information can be find at minDist2segments_KKT GitLab repository.