cratepy.clustering.clusteringphase.ACRMP

class ACRMP[source]

Bases: CRMP

Adaptive Cluster-Reduced Material Phase interface.

perform_adaptive_clustering(self, target_clusters, target_clusters_data)[source]

abstract: Perform ACRMP adaptive clustering step.

get_adaptive_output(self)[source]

abstract: Get adaptivity metrics for clustering adaptivity output.

_check_adaptivity_lock(self)[source]

abstract: Check ACRMP adaptivity locking conditions.

get_adaptivity_type_parameters()[source]

abstract: Get ACRMP mandatory and optional adaptivity type parameters.

_set_adaptivity_type_parameters(self, adaptivity_type)[source]

abstract: Set clustering adaptivity parameters.

_dynamic_split_factor(ref_split_factor, adapt_trigger_ratio, magnitude, dynamic_amp=0)[source]

Compute dynamic adaptive clustering split factor.

Constructor.

List of Public Methods

get_adaptive_output

Get adaptivity metrics for clustering adaptivity output.

get_adaptivity_type_parameters

Get ACRMP mandatory and optional adaptivity type parameters.

get_clustering_type

Get cluster-reduced material phase adaptivity type.

get_n_clusters

Get current number of clusters.

get_valid_clust_algs

Get valid clustering algorithms to compute the CRMP.

perform_adaptive_clustering

Perform ACRMP adaptive clustering step.

perform_base_clustering

Perform CRMP base clustering.

Methods

abstract __init__()

Constructor.

abstract _check_adaptivity_lock()[source]

Check ACRMP adaptivity locking conditions.

Check conditions that may deactivate the adaptive procedures in the ACRMP. Once the ACRMP adaptivity is locked, it is treated as a SCRMP for the remainder of the problem numerical solution.

static _dynamic_split_factor(ref_split_factor, adapt_trigger_ratio, magnitude, dynamic_amp=0)[source]

Compute dynamic adaptive clustering split factor.

A detailed description of the dynamic adaptive clustering split factor can be found in Ferreira et. al (2022) [1].


Parameters:
  • ref_split_factor (float) – Reference (centered) adaptive clustering split factor. The adaptive clustering split factor must be contained between 0 and 1 (included). The lower bound (0) enforces a single split, while the upper bound (1) performs the maximum number splits of each cluster (leading to single-voxel clusters).

  • adapt_trigger_ratio (float) – Threshold associated with the adaptivity trigger condition.

  • magnitude (float) – Difference between cluster ratio and adaptive trigger ratio. Given that the cluster ratio ranges between 0 and 1 and only clusters with a ratio greater or equal than the adaptive trigger ratio are targeted, the magnitude ranges between 0 and 1 - trigger ratio.

  • dynamic_amp (float, default=0) – Dynamic split factor amplitude centered around the reference adaptive clustering split factor.

Returns:

adapt_split_factor – Adaptive clustering split factor. The adaptive clustering split factor must be contained between 0 and 1 (included). The lower bound (0) enforces a single split, i.e., 2 new clusters, while the upper bound (1) is associated with a maximum defined number of new voxels.

Return type:

float

abstract _set_adaptivity_type_parameters(adaptivity_type)[source]

Set clustering adaptivity parameters.

Parameters:

adaptivity_type (dict) – Clustering adaptivity parameters.

static _update_cluster_labels(labels, min_label=0)

Update cluster labels starting with the provided minimum label.

Parameters:
  • labels (numpy.ndarray (1d)) – Cluster labels (numpy.ndarray[int] of shape (n_items,)).

  • min_label (int, default=0) – Minimum cluster label.

Returns:

  • new_labels (numpy.ndarray (1d)) – Updated cluster labels (numpy.ndarray[int] of shape (n_items,)).

  • max_label (int) – Maximum cluster label.

abstract get_adaptive_output()[source]

Get adaptivity metrics for clustering adaptivity output.

Returns:

adaptivity_output – List containing the adaptivity metrics associated with the clustering adaptivity output file.

Return type:

list[int or float]

abstract static get_adaptivity_type_parameters()[source]

Get ACRMP mandatory and optional adaptivity type parameters.

Besides returning the ACRMP mandatory and optional adaptivity type parameters, this method establishes the default values for the optional parameters.

Returns:

  • adapt_type_man_parameters (list[str]) – Mandatory adaptivity type parameters (str).

  • adapt_type_opt_parameters (dict) – Optional adaptivity type parameters (key, str) and associated default value (item).

abstract get_clustering_type()

Get cluster-reduced material phase adaptivity type.

Returns:

clustering_type – Type of cluster-reduced material phase.

Return type:

str

abstract get_n_clusters()

Get current number of clusters.

Returns:

n_clusters – Number of material phase clusters.

Return type:

int

abstract static get_valid_clust_algs()

Get valid clustering algorithms to compute the CRMP.

Returns:

clust_algs – Clustering algorithms identifiers (str).

Return type:

list[str]

abstract perform_adaptive_clustering(target_clusters, target_clusters_data)[source]

Perform ACRMP adaptive clustering step.

Parameters:
  • target_clusters (list[int]) – List with the labels (int) of clusters to be adapted.

  • target_clusters_data (dict) – For each target cluster (key, str), store dictionary (item, dict) containing cluster associated parameters relevant for the adaptive procedures.

Returns:

adaptive_clustering_map – List of new cluster labels (item, list[int] resulting from the adaptivity of each target cluster (key, str).

Return type:

dict

abstract perform_base_clustering()

Perform CRMP base clustering.