A significant challenge in high-performance computing is to ensure the even distribution of applications across computational resources, preventing issues such as resource fragmentation and network congestion. While cloud computing offers advantages, it introduces scheduling delays caused by data transmission. To address this issue, edge computing has emerged as an alternative to traditional cloud systems, aiming to minimize latency. While various methods have been proposed to address this challenge, they often prioritize one aspect at the expense of overall system performance. In this paper, we present a novel algorithm utilizing ant colony optimization to compute a fitness function and prioritize multiple objectives in scheduling. The algorithm effectively determines how to distribute applications between edge and cloud servers to enhance computational efficiency. This entails a delicate balance between scheduling delays and energy consumption in two distinct phases. Initially, the algorithm identifies applications sensitive to delays and ensures their execution on local edge servers. Subsequently, it identifies applications that require intensive computation and migrates them to the cloud layer, where cloud servers can process them. The results demonstrate that this approach reduces delay costs by 21.19% and decreases energy consumption by 13.76%.