I am looking to find an optimal boundary line between two geographically separated sets of points (a vector layer with S and N points representing two genetic lineages within a species). I would like to do this by minimizing the difference between the sum of inverse square distances to S points and the sum of inverse square distances to N points at a given latitude. I would then connect these points across latitudes. The polyline would end where the sum of inverse sequence distances fell below some threshold value. I may also like to vary symbology along this boundary based on the summed distances. The calculations and output could be a Raster but I would prefer to convert this to a smoothed polyline.

I can do these calculations manually but it is laborious and not-transferable to other projects. Can anyone help with ideas on how to do this within QGIS?