cratepy.clustering.adaptivity.crve_adaptivity.AdaptiveClusterGrouping

class AdaptiveClusterGrouping(adapt_mat_phase, phase_clusters, adapt_trigger_ratio=None, adapt_split_threshold=None, adapt_max_level=None, adapt_min_voxels=None, is_merge_adapt_groups=None, min_adapt_feature_val=None)[source]

Bases: AdaptivityCriterion

Clustering adaptivity cluster grouping criterion.

This adaptivity clustering criterion is not formally documented.

_adapt_groups

Store the cluster labels (item, list[int]) associated with each adaptive cluster group (key, int).

Type:

dict

_groups_adapt_level

Store adaptive level (item, int) of each adaptive cluster group (key, int).

Type:

dict

_target_groups_ids

Target adaptive cluster groups (item, list[int]) whose clusters are to be adapted.

Type:

list

get_parameters()[source]

Get clustering adaptivity criterion parameters.

get_target_clusters(self, adapt_data_matrix, voxels_clusters)[source]

Get clustering adaptivity target clusters.

update_group_clusters(self, adaptive_clustering_map)[source]

Update adaptive cluster groups after adaptive procedures.

get_adapt_groups(self)[source]

Get adaptive cluster groups.

get_groups_adapt_level(self)[source]

Get adaptive cluster groups adaptive level.

get_min_adapt_feature_val(self)[source]

Get minimum significant value of clustering adaptivity feature.

_adaptivity_trigger_condition(self, adapt_data_matrix)[source]

Evaluate adaptive cluster group adaptivity trigger condition.

_adaptivity_selection_criterion(self, adapt_data_matrix)[source]

Select target clusters from adaptive cluster group.

Constructor.

Parameters:
  • adapt_mat_phase (str) – Adaptive material phase label.

  • phase_clusters (dict) – Clusters labels (item, list[int]) associated with each material phase (key, str).

  • adapt_trigger_ratio (float, default=None) – Threshold associated with the adaptivity trigger condition, defining the value of the relative ratio (max - avg)/avg above which the adaptive cluster group is set to be adapted, where max and avg are the maximum and average adaptivity feature values in the adaptive cluster group, respectively.

  • adapt_split_threshold (float, default=None) – Threshold associated with the adaptivity selection criterion, defining the split boundary of each adaptive cluster group according to the associated position in terms of the adaptivity value range within the group. For instance, a adapt_split_threshold of 0.8 means that the split boundary divides the clusters whose adaptivity feature value is above min + 0.8*(max - min) (top 20% of the value range) from the remaining clusters.

  • adapt_max_level (int, default=None) – Maximum adaptive cluster group adaptive level.

  • adapt_min_voxels (int, default=None) – Minimum number of voxels that cluster must contain to be targeted for adaptivity.

  • is_merge_adapt_groups (bool, default=None) – True if the adaptive cluster groups of the same adaptive level are to be merged, False if each adaptive cluster group follows an independent hierarchy.

  • min_adapt_feature_val (float, default=None) – Minimum significant value of clustering adaptivity control feature.

List of Public Methods

get_adapt_groups

Get adaptive cluster groups.

get_groups_adapt_level

Get adaptive cluster groups adaptive level.

get_min_adapt_feature_val

Get minimum significant value of clustering adaptivity feature.

get_parameters

Get clustering adaptivity criterion parameters.

get_target_clusters

Get clustering adaptivity target clusters.

update_group_clusters

Update adaptive cluster groups after adaptive procedures.

Methods

__init__(adapt_mat_phase, phase_clusters, adapt_trigger_ratio=None, adapt_split_threshold=None, adapt_max_level=None, adapt_min_voxels=None, is_merge_adapt_groups=None, min_adapt_feature_val=None)[source]

Constructor.

Parameters:
  • adapt_mat_phase (str) – Adaptive material phase label.

  • phase_clusters (dict) – Clusters labels (item, list[int]) associated with each material phase (key, str).

  • adapt_trigger_ratio (float, default=None) – Threshold associated with the adaptivity trigger condition, defining the value of the relative ratio (max - avg)/avg above which the adaptive cluster group is set to be adapted, where max and avg are the maximum and average adaptivity feature values in the adaptive cluster group, respectively.

  • adapt_split_threshold (float, default=None) – Threshold associated with the adaptivity selection criterion, defining the split boundary of each adaptive cluster group according to the associated position in terms of the adaptivity value range within the group. For instance, a adapt_split_threshold of 0.8 means that the split boundary divides the clusters whose adaptivity feature value is above min + 0.8*(max - min) (top 20% of the value range) from the remaining clusters.

  • adapt_max_level (int, default=None) – Maximum adaptive cluster group adaptive level.

  • adapt_min_voxels (int, default=None) – Minimum number of voxels that cluster must contain to be targeted for adaptivity.

  • is_merge_adapt_groups (bool, default=None) – True if the adaptive cluster groups of the same adaptive level are to be merged, False if each adaptive cluster group follows an independent hierarchy.

  • min_adapt_feature_val (float, default=None) – Minimum significant value of clustering adaptivity control feature.

_adaptivity_selection_criterion(adapt_data_matrix)[source]

Select target clusters from adaptive cluster group.

Parameters:

adapt_data_matrix (numpy.ndarray (2d)) – Adaptivity feature data matrix (numpy.ndarray of shape (adapt_phase_n_clusters, 2)) that, for the i-th cluster of the adaptive material phase, contains the cluster label in adapt_data_matrix[i, 0] and the associated adaptive feature value in adapt_data_matrix[i, 1].

Returns:

target_clusters – List containing the labels (int) of clusters to be adapted.

Return type:

list

_adaptivity_trigger_condition(adapt_data_matrix)[source]

Evaluate adaptive cluster group adaptivity trigger condition.

Parameters:

adapt_data_matrix (numpy.ndarray (2d)) – Adaptivity feature data matrix (numpy.ndarray of shape (adapt_phase_n_clusters, 2)) that, for the i-th cluster of the adaptive material phase, contains the cluster label in adapt_data_matrix[i, 0] and the associated adaptive feature value in adapt_data_matrix[i, 1].

Returns:

True if clustering adaptivity is triggered in the adaptive cluster group, False otherwise.

Return type:

bool

get_adapt_groups()[source]

Get adaptive cluster groups.

Returns:

adapt_groups – Store the cluster labels (item, list[int]) associated with each adaptive cluster group (key, int).

Return type:

dict

get_groups_adapt_level()[source]

Get adaptive cluster groups adaptive level.

Returns:

groups_adapt_level – Store adaptive level (item, int) of each adaptive cluster group (key, int).

Return type:

dict

get_min_adapt_feature_val()[source]

Get minimum significant value of clustering adaptivity feature.

Returns:

min_adapt_feature_val – Minimum significant value of clustering adaptivity control feature.

Return type:

float

static get_parameters()[source]

Get clustering adaptivity criterion parameters.

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

Returns:

  • mandatory_parameters (dict) – Mandatory adaptivity type parameters (str) and associated type (item, type).

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

get_target_clusters(adapt_data_matrix, voxels_clusters)[source]

Get clustering adaptivity target clusters.

Parameters:
  • adapt_data_matrix (numpy.ndarray (2d)) – Adaptivity feature data matrix (numpy.ndarray of shape (adapt_phase_n_clusters, 2)) that, for the i-th cluster of the adaptive material phase, contains the cluster label in adapt_data_matrix[i, 0] and the associated adaptive feature value in adapt_data_matrix[i, 1].

  • voxels_clusters (numpy.ndarray (2d or 3d)) – Regular grid of voxels (spatial discretization of the RVE), where each entry contains the cluster label (int) assigned to the corresponding voxel.

Returns:

  • target_clusters (list[int]) – List containing 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 required for the adaptive procedures.

update_group_clusters(adaptive_clustering_map)[source]

Update adaptive cluster groups after adaptive procedures.

Parameters:

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