Contrastive learning has arisen as a potent method in self-supervised learning (SSL), seeking to acquire rich and significant representations from unlabeled data by differentiating between positive and negative samples. However, the efficacy of contrastive learning is heavily contingent upon many aspects, including feature representation, hyperparameters, and data augmentation techniques, which are often manually tuned and suboptimal. To address these challenges, this research presents a unique framework named HOCLGA that uses Genetic Algorithms (GAs) to automate and optimize these critical components for contrastive learning. In fact, by combining GA with contrastive learning, we provide a systematic method for optimizing feature representations, improving the quality of learned representations, adjusting hyperparameters, investigating data augmentation techniques, and formulating SSL challenges. This study examines the use of self-supervised learning to enhance the precision of identifying damaged regions in medical imaging using High-Intensity Focused Ultrasound (HIFU). The framework is pretrained on large-scale datasets (ImageNet, DeepLesion, Breast Ultrasound) and fine-tuned for ultrasound image analysis. Experimental findings indicate that the proposed method may improve representation learning efficacy and provide substantial progress in medical picture interpretation. Specifically, it achieves the highest accuracy of 94.3