You need to enable JavaScript to run this app. 铀铅地质年代学:大数据集最优约束多边形求解优化
优惠活动
大模型
产品
解决方案
定价
更多

铀铅地质年代学:大数据集最优约束多边形求解优化

高效识别U-Pb协和图中最优边界多边形的方法需求

我正在处理铀铅(Uranium-Lead)地质年代学数据集,这类数据通常通过Wetherill协和图解释:图的x-y轴分别为对应年龄估计的Pb/U比值,由于两轴年龄估计独立且同位素衰变速率不同,等年龄线(协和线)呈曲线形态。

常规方法针对单一线性数据阵列做回归,提取与协和线的交点并传递不确定性,但复杂数据集的解释难度极大。这类场景下,核心信息可由顶点位于协和线上的多边形表示——密集数据阵列的边界线就是地质年代学信息的载体。

我当前处理的数据量超百万个点,需要识别出**包含最大比例数据、同时最紧凑(面积最小)**的最优多边形(并非单纯面积最大)。


模拟场景与合成数据

以下代码模拟了典型复杂场景:矿物颗粒形成于30亿年(upper.int.age.max)至25亿年(upper.int.age.min)前,之后分别在10亿年(lower.int.age.1)和1亿年(lower.int.age.2)前经历蚀变事件:

## set seed
set.seed( 12 ) 

## now create ages for a model dataset events
lower.int.age.1 <- 1000
lower.int.age.2 <- 100
upper.int.age.min <- 2500
upper.int.age.max <- 3000

## a couple of required equations
ratio735 <- function(age) {   ## Age in years
  exp( 9.8485e-10 * age * 1e6 ) - 1 
}

ratio638 <- function(age) {   ## Age in years
  exp( 1.55125e-10 * age * 1e6 ) - 1 
}

## calculate x and y values from the age information
x.values <- c( ratio735(lower.int.age.1), 
ratio735(lower.int.age.2) ) # calculate 7/35 ratios
y.values <- c( ratio638(lower.int.age.1), 
ratio638(lower.int.age.2) ) # calculate 6/38 ratios


## now make a data frame of example data
data.test <- data.frame( upper.age = runif( 5000, min = 
upper.int.age.min, max = upper.int.age.max ),
                     prop.1 = runif( 5000, min = 0.05, max = 1 ),
                     prop.2 = runif( 5000, min = 0.05, max = 1 ) ) 
data.test$x1 <- ( ( ratio735( data.test$upper.age ) - x.values[1] 
) * ( data.test$prop.1 ) ) + x.values[1]
data.test$y1 <- ( ( ratio638( data.test$upper.age ) - y.values[1] 
) * ( data.test$prop.1 ) ) + y.values[1]

data.test$x2 <- ( ( data.test$x1 - x.values[2] ) * ( 
data.test$prop.2 ) ) + x.values[2]
data.test$y2 <- ( ( data.test$y1 - y.values[2] ) * ( 
data.test$prop.2 ) ) + y.values[2]

协和线生成与可视化

以下是协和线的方程、线上点生成及绘图代码,黑色点代表关键地质事件:

## line equation 
concordia.x <- function(t) {
  x <- exp(9.8485e-10 * t * 1e6) - 1  
  x
}  
concordia.y <- function(t) {
  y <- exp(1.55125e-10 * t * 1e6) - 1  
  y
}


concordia.line <- data.frame( age = seq(0,3000,1) ) 
concordia.line$x <- ratio735( concordia.line$age )
concordia.line$y <- ratio638( concordia.line$age )
concordia.points <- subset( concordia.line, age == lower.int.age.1 
| age == lower.int.age.2 | age == upper.int.age.min | age == upper.int.age.max )
## plot the data and line
ggplot( data.test, aes( x= x2, y = y2 ) ) +
  geom_line( data = concordia.line, aes( x = x, y = y ) ) +
  geom_point( color = "red" ) +
  geom_point( data = concordia.points, aes( x = x, y = y ),
              size = 4 )

理想情况下,模型应返回以四个加粗点为顶点的多边形。


当前暴力法实现(效率极低)

我当前通过暴力枚举所有可能的多边形顶点组合来筛选最优解,步骤如下:

  1. 生成四组协和线上的年龄序列,用expand.grid生成所有组合,筛选符合年龄顺序的顶点组合
  2. 为每个组合生成对应多边形的x-y坐标
  3. 用sp::point.in.polygon计算每个多边形包含的数据比例,同时计算多边形面积
  4. 筛选包含数据比例最高且面积最小的多边形

对应的代码实现:

## create polygons
lower.1 = seq( from = 0, to = 100, by = 50 ) ## corner 1 
lower.2 = seq( from = 900, to = 1100, by = 100 ) ## corner 2 
upper.1 = seq( from = 2400, to = 2800, by = 100 ) ## corner 3
upper.2 = seq( from = 2800, to = 3200, by = 100 ) ## corner 4
# find all combinations
age.values = expand.grid( lower.1, lower.2, upper.1, upper.2 )
colnames( age.values ) <- c( "lower.1", "lower.2", "upper.1", 
"upper.2" )

##filter for polygons with a certain order to them
age.values.used <- subset( age.values, lower.1 < lower.2 & lower.2 < upper.1 & upper.1 < upper.2 ) 


## calculate a list of x,y values for each polygon
polygons <- list(NA)

## Fill the list with a for loop - not a great way, I know
for( i in 1:nrow( age.values.used ) ) {
  data.temp <- age.values.used[ i, ]
  polygons[[ i ]] <- data.frame( age = age.values.used[i,], 
                                 x = concordia.x( as.vector( t( data.temp ) ) ),
                                 y = concordia.y( as.vector( t( data.temp ) ) ) )
}
library(sp, pracma)
## calculate the fraction of data in one polygon
in.poly   <- function( poly.frame, points ) { ##uses two 
dataframes, one with data, one with the x and y coords for the polygon
  ## use sp point.in.polygon function
  in.polygon <- sp::point.in.polygon( point.x = points[,1],
                        point.y = points[,2],
                        pol.x = poly.frame$x,
                        pol.y = poly.frame$y )

  sum( in.polygon == 1 ) / length( in.polygon )
}
## create a blank data frame to fill in a for loop
results.data <- data.frame( upper.1 = rep( NA, times = length( 
    polygons ) ), upper.2 = rep( NA, times = length( 
    polygons ) ), lower.2 = rep( NA, times = length( 
    polygons ) ), lower.1 = rep( NA, times = length( 
    polygons ) ), fraction.data.in = rep( NA, times = 
    length( polygons ) ), area = rep( NA, times = length( polygons 
    ) ) )
for( j in 1:length( polygons ) ) {
  results.data$upper.1[ j ] = polygons[[j]]$age.upper.2[1]
  results.data$upper.2[ j ] = polygons[[j]]$age.upper.2[1]
  results.data$lower.2[ j ] = polygons[[j]]$age.lower.2[1]
  results.data$lower.1[ j ] = polygons[[j]]$age.lower.1[1]
  results.data$fraction.data.in[j] <- in.poly( polygons[[j]], 
         data.test[, c("x2", "y2")] )
  rpoly.def <- sp::Polygon( polygons[[j]][,c("x","y")] )

  results.data$area[ j ] <- slot( poly.def, "area" )
  }

暴力法的枚举逻辑在处理百万级数据时效率极低,恳请提供更优雅、高效的实现方法。


内容的提问来源于stack exchange,提问作者Jesse

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.13 23:00:52