53 use Except_mod,
only: NEGBIG_RK
54 use Kind_mod,
only: IK, LK, RK, SK
55 use Err_mod,
only: Err_type
60 public :: IK, LK, RK, SK
71 integer(IK) ,
allocatable ::
Size(:)
72 integer(IK) ,
allocatable :: CumSumSize(:)
73 integer(IK) ,
allocatable :: Membership(:)
74 integer(IK) ,
allocatable :: EffectiveSize(:)
75 real(RK) ,
allocatable :: LogVolNormed(:)
76 real(RK) ,
allocatable :: ChoLowCovUpp(:,:,:)
77 real(RK) ,
allocatable :: InvCovMat(:,:,:)
78 real(RK) ,
allocatable :: ChoDia(:,:)
79 real(RK) ,
allocatable :: Center(:,:)
86 real(RK) ,
allocatable :: ScaleFactorSq(:)
87 real(RK) ,
allocatable :: ScaleFactor(:)
88 real(RK) ,
allocatable :: LogVolRatio(:)
89 real(RK) ,
allocatable :: MahalSq(:,:)
104 logical(LK) :: deallocated
= .true._LK
105 logical(LK) ,
allocatable :: SubclusteringWarranted(:)
112 real(RK) :: logSumVolNormed
113 logical(LK) :: subclusteringEnabled
123 real(RK) ,
allocatable :: LogLikeFitness(:)
124 real(RK) ,
allocatable :: SumLogLikeFitness(:)
131 real(RK) :: potential
132 real(RK) ,
allocatable :: Center(:,:)
133 integer(IK) ,
allocatable :: Membership(:)
134 integer(IK) ,
allocatable ::
Size(:)
135 type(Err_type) :: Err
142 integer(IK) ,
allocatable :: Final(:,:)
143 real(RK) ,
allocatable :: VolNormedCDF(:)
153 integer(IK) :: minSize
154 integer(IK) :: kmeansNumFailMax
155 integer(IK) :: numRecursiveCall
156 integer(IK) :: kmeansNumRecursionMax
157 integer(IK) :: convergenceFailureCount
158 integer(IK) :: kvolumeNumRecursionMax
159 logical(LK) :: biasCorrectionEnabled
160 logical(LK) :: mahalSqWeightEnabled
161 logical(LK) :: stanEnabled
163 real(RK) :: kmeansRelTol
164 real(RK) :: logExpansion
165 real(RK) :: logShrinkage
166 real(RK) :: pointLogVolNormed
167 real(RK) :: parentLogVolNormed
168 real(RK) :: mahalSqWeightExponent
169 real(RK) ,
allocatable :: BiasCorrectionScaleFactorSq(:)
170 integer(IK) ,
allocatable :: PointIndex(:)
171 type(Err_type) :: Err
181 real(RK) ,
intent(inout) ,
contiguous :: Point(:,:)
182 real(RK) ,
intent(in) ,
optional :: parentLogVolNormed
190 integer(IK) ,
intent(in) :: fileUnit
191 real(RK) ,
intent(in) :: Point(Partition%nd,Partition%np)
202 logical(LK) :: scaleOptimizationEnabled
203 logical(LK) :: shapeOptimizationEnabled
204 logical(LK) :: shapeAdaptationEnabled
205 logical(LK) :: optimizationEnabled
206 real(RK) ,
allocatable :: LogLikeFitness(:)
209 procedure,
pass :: get => getPartitionMaxDen
210 procedure,
pass :: write => writePartitionMaxDen
254 module function constructPartitionMaxDen( Point & ! LCOV_EXCL_LINE
255 , nc,nt & ! LCOV_EXCL_LINE
256 , nemax & ! LCOV_EXCL_LINE
257 , minSize & ! LCOV_EXCL_LINE
258 , stanEnabled & ! LCOV_EXCL_LINE
259 , trimEnabled & ! LCOV_EXCL_LINE
260 , kmeansRelTol & ! LCOV_EXCL_LINE
261 , logExpansion & ! LCOV_EXCL_LINE
262 , logShrinkage & ! LCOV_EXCL_LINE
263 , parentLogVolNormed & ! LCOV_EXCL_LINE
264 , mahalSqWeightExponent & ! LCOV_EXCL_LINE
265 , kmeansNumFailMax & ! LCOV_EXCL_LINE
266 , kmeansNumRecursionMax & ! LCOV_EXCL_LINE
267 , kvolumeNumRecursionMax & ! LCOV_EXCL_LINE
268 , scaleOptimizationEnabled & ! LCOV_EXCL_LINE
269 , shapeOptimizationEnabled & ! LCOV_EXCL_LINE
270 , shapeAdaptationEnabled & ! LCOV_EXCL_LINE
271 , biasCorrectionEnabled & ! LCOV_EXCL_LINE
273#if INTEL_COMPILER_ENABLED && DLL_ENABLED && (WINDOWS_ENABLED || DARWIN_ENABLED)
274 !DEC$ ATTRIBUTES DLLEXPORT :: constructPartitionMaxDen
277 real(RK) ,
intent(inout) ,
contiguous :: Point(:,:)
278 real(RK) ,
intent(in) :: parentLogVolNormed
279 integer(IK) ,
intent(in) ,
optional :: nc,nt
280 integer(IK) ,
intent(in) ,
optional :: nemax
281 integer(IK) ,
intent(in) ,
optional :: minSize
282 integer(IK) ,
intent(in) ,
optional :: kmeansNumFailMax
283 integer(IK) ,
intent(in) ,
optional :: kmeansNumRecursionMax
284 integer(IK) ,
intent(in) ,
optional :: kvolumeNumRecursionMax
285 logical(LK) ,
intent(in) ,
optional :: scaleOptimizationEnabled
286 logical(LK) ,
intent(in) ,
optional :: shapeOptimizationEnabled
287 logical(LK) ,
intent(in) ,
optional :: shapeAdaptationEnabled
288 logical(LK) ,
intent(in) ,
optional :: biasCorrectionEnabled
289 logical(LK) ,
intent(in) ,
optional :: stanEnabled
290 logical(LK) ,
intent(in) ,
optional :: trimEnabled
291 real(RK) ,
intent(in) ,
optional :: kmeansRelTol
292 real(RK) ,
intent(in) ,
optional :: logExpansion
293 real(RK) ,
intent(in) ,
optional :: logShrinkage
294 real(RK) ,
intent(in) ,
optional :: mahalSqWeightExponent
296 end function constructPartitionMaxDen
302 module subroutine getPartitionMaxDen(Partition, Point, parentLogVolNormed)
303#if INTEL_COMPILER_ENABLED && DLL_ENABLED && (WINDOWS_ENABLED || DARWIN_ENABLED)
304 !DEC$ ATTRIBUTES DLLEXPORT :: getPartitionMaxDen
307 real(RK) ,
intent(inout) ,
contiguous :: Point(:,:)
308 real(RK) ,
intent(in) ,
optional :: parentLogVolNormed
309 end subroutine getPartitionMaxDen
315 module subroutine writePartitionMaxDen ( Partition & ! LCOV_EXCL_LINE
316 , fileUnit & ! LCOV_EXCL_LINE
317 , Point & ! LCOV_EXCL_LINE
319#if INTEL_COMPILER_ENABLED && DLL_ENABLED && (WINDOWS_ENABLED || DARWIN_ENABLED)
320 !DEC$ ATTRIBUTES DLLEXPORT :: writePartitionMaxDen
323 integer(IK) ,
intent(in) :: fileUnit
324 real(RK) ,
intent(in) :: Point(Partition%nd,Partition%np)
325 character(
*,SK) ,
parameter :: fileFormat
= "(*(g0,:,','))"
326 integer(IK) :: i, j, ic
327 end subroutine writePartitionMaxDen
333 module procedure :: constructPartitionMaxDen
343 logical(LK) :: isDynesty
= .false._LK
344 logical(LK) :: isMultiNest
= .false._LK
345 logical(LK) :: isParaMonte
= .false._LK
346 character(:, SK),
allocatable :: name
352 logical(LK) :: inclusionFractionEnabled
353 real(RK) :: inclusionFraction
357 procedure,
pass :: get => getPartitionMinVol
358 procedure,
pass :: write => writePartitionMinVol
404 module function constructPartitionMinVol( Point & ! LCOV_EXCL_LINE
405 , nc,nt & ! LCOV_EXCL_LINE
406 , nemax & ! LCOV_EXCL_LINE
407 , minSize & ! LCOV_EXCL_LINE
408 , stanEnabled & ! LCOV_EXCL_LINE
409 , trimEnabled & ! LCOV_EXCL_LINE
410 , kmeansRelTol & ! LCOV_EXCL_LINE
411 , logExpansion & ! LCOV_EXCL_LINE
412 , logShrinkage & ! LCOV_EXCL_LINE
413 , inclusionFraction & ! LCOV_EXCL_LINE
414 , mahalSqWeightExponent & ! LCOV_EXCL_LINE
415 , parentLogVolNormed & ! LCOV_EXCL_LINE
416 , kmeansNumFailMax & ! LCOV_EXCL_LINE
417 , kmeansNumRecursionMax & ! LCOV_EXCL_LINE
418 , kvolumeNumRecursionMax & ! LCOV_EXCL_LINE
419 , scaleOptimizationEnabled & ! LCOV_EXCL_LINE
420 , shapeOptimizationEnabled & ! LCOV_EXCL_LINE
421 , shapeAdaptationEnabled & ! LCOV_EXCL_LINE
422 , biasCorrectionEnabled & ! LCOV_EXCL_LINE
423 , method & ! LCOV_EXCL_LINE
425#if INTEL_COMPILER_ENABLED && DLL_ENABLED && (WINDOWS_ENABLED || DARWIN_ENABLED)
426 !DEC$ ATTRIBUTES DLLEXPORT :: constructPartitionMinVol
429 real(RK) ,
intent(inout) ,
contiguous :: Point(:,:)
430 character(
*, SK),
intent(in) ,
optional :: method
431 integer(IK) ,
intent(in) ,
optional :: nc,nt
432 integer(IK) ,
intent(in) ,
optional :: nemax
433 integer(IK) ,
intent(in) ,
optional :: minSize
434 integer(IK) ,
intent(in) ,
optional :: kmeansNumFailMax
435 integer(IK) ,
intent(in) ,
optional :: kmeansNumRecursionMax
436 integer(IK) ,
intent(in) ,
optional :: kvolumeNumRecursionMax
437 logical(LK) ,
intent(in) ,
optional :: scaleOptimizationEnabled
438 logical(LK) ,
intent(in) ,
optional :: shapeOptimizationEnabled
439 logical(LK) ,
intent(in) ,
optional :: shapeAdaptationEnabled
440 logical(LK) ,
intent(in) ,
optional :: biasCorrectionEnabled
441 logical(LK) ,
intent(in) ,
optional :: stanEnabled
442 logical(LK) ,
intent(in) ,
optional :: trimEnabled
443 real(RK) ,
intent(in) ,
optional :: kmeansRelTol
444 real(RK) ,
intent(in) ,
optional :: logExpansion
445 real(RK) ,
intent(in) ,
optional :: logShrinkage
446 real(RK) ,
intent(in) ,
optional :: inclusionFraction
447 real(RK) ,
intent(in) ,
optional :: mahalSqWeightExponent
448 real(RK) ,
intent(in) ,
optional :: parentLogVolNormed
450 end function constructPartitionMinVol
456 module subroutine getPartitionMinVol(Partition, Point, parentLogVolNormed)
457#if INTEL_COMPILER_ENABLED && DLL_ENABLED && (WINDOWS_ENABLED || DARWIN_ENABLED)
458 !DEC$ ATTRIBUTES DLLEXPORT :: getPartitionMinVol
461 real(RK) ,
intent(inout) ,
contiguous :: Point(:,:)
462 real(RK) ,
intent(in) ,
optional :: parentLogVolNormed
463 end subroutine getPartitionMinVol
469 module subroutine writePartitionMinVol ( Partition & ! LCOV_EXCL_LINE
470 , fileUnit & ! LCOV_EXCL_LINE
471 , Point & ! LCOV_EXCL_LINE
473#if INTEL_COMPILER_ENABLED && DLL_ENABLED && (WINDOWS_ENABLED || DARWIN_ENABLED)
474 !DEC$ ATTRIBUTES DLLEXPORT :: writePartitionMinVol
477 integer(IK) ,
intent(in) :: fileUnit
478 real(RK) ,
intent(in) :: Point(Partition%nd,Partition%np)
479 character(
*,SK) ,
parameter :: fileFormat
= "(*(g0,:,','))"
480 integer(IK) :: i, j, ic
481 end subroutine writePartitionMinVol
487 module procedure :: constructPartitionMinVol
499#if INTEL_COMPILER_ENABLED && DLL_ENABLED && (WINDOWS_ENABLED || DARWIN_ENABLED)
502 use InterpLinear_mod,
only: InterpLinear_type
503 use Kind_mod,
only: IK, RK
506 integer(IK) ,
intent(in) :: nd
507 integer(IK) ,
intent(in) :: npmin
508 integer(IK) ,
intent(in) :: npmax
509 real(RK) :: LogCount(npmin:npmax)
510 real(RK) :: BiasCorrectionScaleFactorSq(npmin:npmax)
511 integer(IK) :: ip, ndim
512 type(InterpLinear_type) :: Interp
515 real(RK),
allocatable :: LogNumPointInSpheroid(:)
516 real(RK),
allocatable :: LogMeanLogScaleFactor(:)
518#include "Partition_mod.inc.scaleFactor.inc.F90"
521 if (npmin
< nd
+ 1_IK)
error stop
522 if (ndim
< lbound(Case,
dim = 1))
error stop
523 if (ndim
> ubound(Case,
dim = 1)) ndim
= ubound(Case,
dim = 1)
525 LogCount(npmin:npmax)
= [(
log(
real(ip,RK)), ip
= npmin, npmax )]
526 Interp
= InterpLinear_type(SortedX
= Case(ndim)
%LogNumPointInSpheroid, SortedY
= Case(ndim)
%LogMeanLogScaleFactor)
527 BiasCorrectionScaleFactorSq(npmin:npmax)
= exp(
2_IK*exp(Interp
%predict(QueryX
= LogCount)))
529#if DEBUG_ENABLED || TESTING_ENABLED || CODECOV_ENABLED
531 if (
any(BiasCorrectionScaleFactorSq
< 1._RK))
error stop
533 where (BiasCorrectionScaleFactorSq
< 1._RK); BiasCorrectionScaleFactorSq
= 1._RK;
end where
542#if INTEL_COMPILER_ENABLED && DLL_ENABLED && (WINDOWS_ENABLED || DARWIN_ENABLED)
545 use Except_mod,
only: NEGBIG_RK
546 use Kind_mod,
only: IK, RK
548 integer(IK) ,
intent(in) :: count
549 real(RK) ,
intent(in) :: logVolRatio
550 real(RK) :: logLikeFitness
551 logLikeFitness
= count
* (
1._RK + logVolRatio
- exp(logVolRatio))
553 if (logLikeFitness
< NEGBIG_RK
.or. logLikeFitness
> 0._RK)
then
554 write(
*,
*)
.or."Internal error occurred: logLikeFitness < NEGBIG_RK logLikeFitness > 0._RK"
555 write(
*,
*)
"count, logVolRatio, logLikeFitness:", count, logVolRatio, logLikeFitness
This module contains procedures and routines for ellipsoidal partitioning of a given set of points by...
PURE real(RK) function getLogLikeFitness(count, logVolRatio)
character(*, SK), parameter MODULE_NAME
real(RK) function, dimension(npmin:npmax) getBiasCorrectionScaleFactorSq(nd, npmin, npmax)
Abstract class containing the basic properties of partitions that are common between the exploration ...
The base class for generating a vector of Kmeans objects that hold the properties of different Kmeans...
The Method_type class for specifying which minimum-volume partitioning method to be used.
The subclass for generating objects that hold partition properties at any given level of partitioning...
The subclass for generating objects that hold partition properties at any given level of partitioning...
The subclass for generating objects that hold partition properties at any given level of partitioning...
The base class for generating objects that hold partition properties at any given level of partitioni...
The class for generating objects that hold the final output partition properties.
The PartitionMaxDen_type class.
The PartitionMinVol_type class.
The Partition_type abstract class for Partition derived types. Partitions an input array Point(nd,...